MCPcopy Create free account
hub / github.com/DHTMLX/scheduler / cookie

Function cookie

codebase/sources/dhtmlxscheduler.es.js:10321–10411  ·  view source on GitHub ↗
(scheduler2)

Source from the content-addressed store, hash-verified

10319 }
10320}
10321function cookie(scheduler2) {
10322 function getStorageKey() {
10323 return (scheduler2._obj.id || "scheduler") + "_settings";
10324 }
10325 const dateToString = scheduler2.date.date_to_str("%Y-%m-%d %H:%i");
10326 const stringToDate = scheduler2.date.str_to_date("%Y-%m-%d %H:%i");
10327 function safeLocalStorageGet(key) {
10328 try {
10329 return window.localStorage.getItem(key);
10330 } catch (e) {
10331 return null;
10332 }
10333 }
10334 function safeLocalStorageSet(key, value) {
10335 try {
10336 window.localStorage.setItem(key, value);
10337 return true;
10338 } catch (e) {
10339 return false;
10340 }
10341 }
10342 function readStoredState() {
10343 const storageKey = getStorageKey();
10344 const raw = safeLocalStorageGet(storageKey);
10345 if (!raw) {
10346 return { date: null, mode: null };
10347 }
10348 let parsed;
10349 try {
10350 parsed = JSON.parse(raw);
10351 } catch (e) {
10352 return { date: null, mode: null };
10353 }
10354 if (!parsed || typeof parsed !== "object") {
10355 return { date: null, mode: null };
10356 }
10357 let parsedDate = null;
10358 if (typeof parsed.date === "string" && parsed.date.length > 0) {
10359 try {
10360 parsedDate = stringToDate(parsed.date);
10361 if (isNaN(+parsedDate)) {
10362 parsedDate = null;
10363 }
10364 } catch (e) {
10365 parsedDate = null;
10366 }
10367 }
10368 const parsedMode = typeof parsed.mode === "string" ? parsed.mode : null;
10369 return { date: parsedDate, mode: parsedMode };
10370 }
10371 function urlHasExplicitNavigation() {
10372 if (!scheduler2._get_url_nav) {
10373 return false;
10374 }
10375 const urlState = scheduler2._get_url_nav();
10376 if (!urlState) {
10377 return false;
10378 }

Callers

nothing calls this directly

Calls 8

urlHasExplicitNavigationFunction · 0.70
readStoredStateFunction · 0.70
getStorageKeyFunction · 0.70
safeLocalStorageSetFunction · 0.70
date_to_strMethod · 0.65
str_to_dateMethod · 0.65
isViewExistsMethod · 0.65
attachEventMethod · 0.65

Tested by

no test coverage detected