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

Function url

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

Source from the content-addressed store, hash-verified

21095 notImplemented.alert("Units", scheduler2.assert);
21096 }
21097 function url(scheduler2) {
21098 function parseHashParameters() {
21099 const parameters = /* @__PURE__ */ Object.create(null);
21100 const raw = (document.location.hash || "").replace("#", "");
21101 if (!raw) {
21102 return parameters;
21103 }
21104 const pairs = raw.split(",");
21105 const forbiddenKeys = ["__proto__", "constructor", "prototype"];
21106 for (let i = 0; i < pairs.length; i++) {
21107 const parts = pairs[i].split("=");
21108 if (parts.length === 2 && !forbiddenKeys.includes(parts[0])) {
21109 parameters[parts[0]] = parts[1];
21110 }
21111 }
21112 return parameters;
21113 }
21114 scheduler2._get_url_nav = function() {
21115 return parseHashParameters();
21116 };
21117 const dateToString = scheduler2.date.date_to_str("%Y-%m-%d");
21118 const originalGetInitialState = scheduler2._getInitialState;
21119 scheduler2._getInitialState = function(provided) {
21120 const baseState = originalGetInitialState.call(this, provided);
21121 const url2 = scheduler2._get_url_nav ? scheduler2._get_url_nav() : null;
21122 if (!url2) {
21123 return baseState;
21124 }
21125 const nextState = { date: baseState.date, mode: baseState.mode };
21126 if (url2.date) {
21127 const stringToDate = scheduler2.date.str_to_date("%Y-%m-%d");
21128 try {
21129 const parsed = stringToDate(url2.date);
21130 if (!isNaN(+parsed)) {
21131 nextState.date = parsed;
21132 }
21133 } catch (e) {
21134 }
21135 }
21136 if (url2.mode) {
21137 try {
21138 if (this.isViewExists(url2.mode)) {
21139 nextState.mode = url2.mode;
21140 }
21141 } catch (e) {
21142 }
21143 }
21144 return nextState;
21145 };
21146 function updateHashFromState(optionalSelectedEventId) {
21147 const currentDate = scheduler2._date || scheduler2.getState().date;
21148 const currentMode = scheduler2.getState().mode;
21149 const values = ["date=" + dateToString(currentDate), "mode=" + currentMode];
21150 if (optionalSelectedEventId) {
21151 values.push("event=" + optionalSelectedEventId);
21152 }
21153 document.location.hash = "#" + values.join(",");
21154 }

Callers 1

runPostCssFunction · 0.50

Calls 7

parseHashParametersFunction · 0.70
showEventWhenPossibleFunction · 0.70
updateHashFromStateFunction · 0.70
date_to_strMethod · 0.65
str_to_dateMethod · 0.65
isViewExistsMethod · 0.65
attachEventMethod · 0.65

Tested by

no test coverage detected