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

Function cookie

codebase/sources/dhtmlxscheduler.js:10325–10415  ·  view source on GitHub ↗
(scheduler2)

Source from the content-addressed store, hash-verified

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

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