-
Notifications
You must be signed in to change notification settings - Fork 2
/
Cr-json_min.js
2 lines (2 loc) · 1.94 KB
/
Cr-json_min.js
1
2
if("undefined"==typeof Cr)var Cr={};Cr.fromJsonString=function(r){return this.fromJson(JSON.parse(r))},Cr.fromArray=function(r){var t=r[0];return t.txt||t.elm?this.fromArrayOfJsonObject(r):this.fromArryOfSimpleJson(r)},Cr.fromJson=function(r){return r.txt||r.elm?this.fromJsonObject(r):this.fromSimpleJson(r)},Cr.fromJsonMixedFormat=function(){},Cr.fromArrayOfJsonMixedFormat=function(){},Cr.fromSimpleJson=function(r){for(var t in r){var n,o=r[t];return"txt"==t||"text"==t?this.txt(o.replace(/\\n/g,"\n").replace(/\\t/g," ")):((n=o.event||o.events)&&this.__extractEvents(n),o.childNodes&&(o.childNodes=this.fromArryOfSimpleJson(o.childNodes)),this.elm(t,o))}},Cr.fromArryOfSimpleJson=function(r){var t=[];if(r)for(var n=0,o=r.length;o>n;n++)t.push(this.fromSimpleJson(r[n]));return t},Cr.fromJsonObject=function(r){for(var t in r){if("elm"==t){for(var n in r[t][1])"event"==n.substr(0,5)?this.__extractEvents(r[t][1][n]):"childNodes"==n&&(r[t][1][n]=this.fromArrayOfJsonObject(r[t][1][n]),r[t][2]=!1);return this.elm(r[t][0],r[t][1],r[t][2]?this.fromArrayOfJsonObject(r[t][2]):!1)}if("txt"==t)return this.txt(r[t][0].replace(/\\n/g,"\n").replace(/\\t/g," "))}},Cr.fromArrayOfJsonObject=function(r){var t=[];if(r)for(var n=0,o=r.length;o>n;n++)t.push(this.fromJsonObject(r[n]));return t},Cr.__extractEvents=function(r){if("string"==typeof r[0]&&(r=[r]),r.length)for(var t in r){var n=r[t][1];"string"==typeof n&&(r[t][1]=this.functionForString(n))}else for(var t in r)"string"==typeof t&&"string"==typeof r[t]&&(r[t]=this.functionForString(r[t]))},Cr.functionForString=function(r){return this.__functionForString(r)},Cr.__functionForString=function(r){var t=function(){},n=r.split(".");if(n.length>0&&(window[n[0]]&&(t=window[n[0]]),n.length>1))for(var o=1,i=n.length;i>o;o++)t[n[o]]&&(t=window[n[o]]);return"function"!=typeof t&&(t=function(){}),t},"undefined"!=typeof module&&(module.exports=function(r){for(var t in Cr)r[t]=Cr[t];return r});
//# sourceMappingURL=Cr-json_min.js.map