MCPcopy Create free account
hub / github.com/DHTMLX/scheduler / extend$9

Function extend$9

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

Source from the content-addressed store, hash-verified

6065 } };
6066 }
6067 function extend$9(scheduler2) {
6068 scheduler2.json = scheduler2._parsers.json = { canParse: function(data) {
6069 if (data && typeof data === "object") {
6070 return true;
6071 } else if (typeof data === "string") {
6072 try {
6073 var result = JSON.parse(data);
6074 return Object.prototype.toString.call(result) === "[object Object]" || Object.prototype.toString.call(result) === "[object Array]";
6075 } catch (err) {
6076 return false;
6077 }
6078 }
6079 return false;
6080 }, parse: function(data) {
6081 var events = [];
6082 if (typeof data == "string") {
6083 data = JSON.parse(data);
6084 }
6085 if (Object.prototype.toString.call(data) === "[object Array]") {
6086 events = data;
6087 } else {
6088 if (data) {
6089 if (data.events) {
6090 events = data.events;
6091 } else if (data.data) {
6092 events = data.data;
6093 }
6094 }
6095 }
6096 events = events || [];
6097 if (data.dhx_security) {
6098 if (window.dhtmlx) {
6099 window.dhtmlx.security_key = data.dhx_security;
6100 }
6101 scheduler2.security_key = data.dhx_security;
6102 }
6103 var collections = data && data.collections ? data.collections : {};
6104 var collections_loaded = false;
6105 for (var key in collections) {
6106 if (collections.hasOwnProperty(key)) {
6107 collections_loaded = true;
6108 var collection = collections[key];
6109 var arr = scheduler2.serverList[key];
6110 if (!arr) {
6111 scheduler2.serverList[key] = arr = [];
6112 }
6113 arr.splice(0, arr.length);
6114 for (var j = 0; j < collection.length; j++) {
6115 var option = collection[j];
6116 var obj = { key: option.value, label: option.label };
6117 for (var option_key in option) {
6118 if (option.hasOwnProperty(option_key)) {
6119 if (option_key == "value" || option_key == "label")
6120 continue;
6121 obj[option_key] = option[option_key];
6122 }
6123 }
6124 arr.push(obj);

Callers 1

extend$7Function · 0.70

Calls 2

parseMethod · 0.65
callEventMethod · 0.65

Tested by

no test coverage detected