JAVASCRIPT   13

utils.js

Guest on 4th August 2021 02:27:04 PM

  1. // Created 5/28/2013 1:19:44 PM
  2. var el={canvas:{},cTest:!1,id:function(a){return document.getElementById(a)},tag:function(a){return document.getElementsByTagName(a)[0]},tags:function(a){return document.getElementsByTagName(a)},add:function(a){return document.createElement(a)},del:function(a){browser.publisher.isOn?null!=document.getElementById(a)&&el.id(a).parentNode.removeChild(el.id(a)):el.id(a)&&el.id(a).parentNode.removeChild(el.id(a))},Class:function(){return document.getElementsByClassName(tag)},createElement:function(a,c,
  3. b){var b=b||-1,a=document.createElement(a),d;for(d in c)if("styles"!=d)a.setAttribute(d,c[d]);else{var e=void 0;for(e in c.styles)a.style[e]=c.styles[e]}-1!=b&&(fbUtils.isString(b)?document.getElementById(b).appendChild(a):b.appendChild(a));return a}},fbUtils={SPLITTERS:[",",";","."," ","?","!","'",'"',"",String.fromCharCode(10),String.fromCharCode(13),String.fromCharCode(8211),String.fromCharCode(8212),String.fromCharCode(8722),String.fromCharCode(8209),String.fromCharCode(8208)],split:function(a,
  4. c){for(var b=a.split(" "),d=[],e=0;e<b.length;e++)b[e].length>=c&&d.push(b[e]);return d},isSplitter:function(a){for(var c=0;c<this.SPLITTERS.length;c++)if(a==this.SPLITTERS[c])return!0;return!1},getNum:function(a){var c="000"+a;9<a&&(c="00"+a);99<a&&(c="0"+a);999<a&&(c=""+a);return c},hexToRGB:function(a){function c(a){return"#"==a.charAt(0)?a.substring(1,7):a}var b=parseInt(c(a).substring(0,2),16),d=parseInt(c(a).substring(2,4),16),a=parseInt(c(a).substring(4,6),16);return b+","+d+","+a},findArr:function(a,
  5. c){for(i in a)if(1*a[i]===1*c)return i},getMaxZoom:function(a,c){return Math.sqrt(52E5/(a*c))},isFunction:function(a){return"[object Function]"===Object.prototype.toString.call(a)},isArray:function(a){return"[object Array]"===Object.prototype.toString.call(a)},isString:function(a){return"[object String]"===Object.prototype.toString.call(a)},screening:function(a){return a.replace(/</ig,function(){return"&lt;"})}},generatePreloader=function(){var a=el.createElement("div",{id:"mainPreloaderDiv",styles:{width:"100%",
  6. height:"100%","z-index":"1000000","background-color":"#"+BG_COLOR,opacity:"1",position:"absolute","-webkit-transition-duration":"300ms","-webkit-transition-delay":"500ms"}},"body"),c=el.createElement("div",{styles:{position:"absolute","text-align":"center",width:"200px",height:"200px",top:"50%",left:"50%",opacity:"1",margin:"-100px 0 0 -100px","line-height":"100px"}},a),b=el.createElement("image",{id:"preloaderIMG",styles:{"box-shadow":"0 0 3px rgba(0,0,0,0.5)","-webkit-transform-origin":"50% 50%",
  7. "-webkit-transform":"scale("+window.devicePixelRatio+","+window.devicePixelRatio+")"}});b.onload=function(){c.appendChild(this)};b.src=ASSETS_FOLDER+"/thumb.jpg";changeUrlWhenPubl(ASSETS_FOLDER+"/thumb.jpg",function(a){b.src=a},-1==ASSETS_FOLDER.indexOf("static"));var d=document.getElementById("mainPreloaderDiv").style.backgroundColor.match(/\d{1,3}/ig),e="",f;for(f in d)e=2==f?e+Math.abs(155-1*d[f]):e+(155-1*d[f])+",";el.createElement("p",{styles:{position:"absolute",top:"50%",left:"50%",width:"300px",
  8. color:"rgb("+e+")","font-family":"Helvetica Neue","font-size":18*window.devicePixelRatio+"px","line-height":18*window.devicePixelRatio+"px",margin:20*window.devicePixelRatio*window.devicePixelRatio+"px 0px 0px -150px","text-align":"center","text-shadow":"0 0 2px rgba("+e+",0.5)"}},a).appendChild(document.createTextNode(PUBLICATION_NAME))};
  9. function FBRequire(a){var c;this.basePath=a;this.numMods=this.numLoads=0;this.head=document.getElementsByTagName("head")[0];this.load=function(a,d,e){function f(){function h(a){var b;if(!(b=!l)){b=!1;for(var d=c.documentElement.getElementsByTagName("Unit"),e=0;e<d.length;e++){var j=d[e];if(j.getAttribute("FileName")==a.substr(a.lastIndexOf("/")+1)){if(b)throw"module has already loaded";b=!0;j=j.getElementsByTagName("Source");g.numMods+=j.length-1;for(var k=0;k<j.length;k++)f(JAVASCRIPT_FOLDER+"/"+
  10. j[k].getAttribute("FileName"))}}b=!b}b&&f(a)}g.numLoads=0;var f=function(a){var b=document.createElement("script");b.type="text/javascript";b.charset="utf-8";b.async=!0;b.addEventListener("load",function(){g.numLoads++;g.numLoads==g.numMods&&(fbUtils.isFunction(d)?d.call():console.log("FBRequire error: callback function is not a function. Callback:"+d))});b.addEventListener("error",function(){fbUtils.isFunction(e)?e.call():console.log("FBRequire error: errorback function is not a function. Errorback:"+
  11. d)});changeUrlWhenPubl(a,function(a){b.src=a},-1==a.indexOf("static"));g.head.appendChild(b)};if(fbUtils.isArray(a)){g.numMods=a.length;for(var m in a)h(g.basePath+a[m]+".js")}else g.numMods=1,h(g.basePath+a+".js")}var g=this,l="undefined"!=typeof window.DEBUG_MODE&&window.DEBUG_MODE,d=d||function(){},e=e||function(){};if(l)if(c)f();else{var h=new XMLHttpRequest;h.open("GET",JAVASCRIPT_FOLDER+"/!units.xml",!1);h.onreadystatechange=function(){if(4==h.readyState)if(200==h.status)c=h.responseXML,f();
  12. else throw"Status is "+h.status;};h.send(null)}else f()};this.loadCSS=function(a,c){var e=this;this.endOfLoads=document.styleSheets.length+a.length;var c=c||function(){},f=function(a){var b=document.createElement("link");b.type="text/css";b.rel="stylesheet";changeUrlWhenPubl(a,function(a){b.href=a},-1==a.indexOf("static"));e.head.appendChild(b)};if(fbUtils.isArray(a))for(var g in a)f(a[g]+".css");else f(a+".css");(function(){var a=setInterval(function(){e.endOfLoads==document.styleSheets.length&&
  13. (c.call(),clearInterval(a))},20)})()}}
  14. var load=function(){if("undefined"===typeof window.PUBL)window.PUBL=!0;el.id("body").innerText="";generatePreloader();var a=new FBRequire("");a.load([JAVASCRIPT_FOLDER+"/detect",ASSETS_FOLDER+"/properties"],function(){system=new Detect;if("undefined"==typeof publicationData.downloads)publicationData.downloads={pageDownlaod:!1,publicationDownload:!1};PUBL&&""!=publicationData.GA?a.load([JAVASCRIPT_FOLDER+"/../../default/ga"],function(){}):PUBL&&a.load([JAVASCRIPT_FOLDER+"/../../default/noga"],function(){});
  15. if(system.platform.ios)for(var c="user-scalable=no, initial-scale="+1/(window.devicePixelRatio||1)+", maximum-scale="+1/(window.devicePixelRatio||1)+", user-scalable=no",b=document.getElementsByTagName("meta"),d=0;d<b.length;d++)"viewport"==b[d].name&&(b[d].removeAttribute("content"),b[d].setAttribute("content",c));c=function(){DEV="mobile"===system.device.type?"mobile":"tablet";a.load(JAVASCRIPT_FOLDER+("mobile"===DEV?"/mobiledom":system.platform.ios?"/iostdom":"/androidtdom"),function(){if(PUBL&&
  16. system.platform.ios&&"tablet"==DEV&&6<=system.platform.version[0])publicationData.visibility.downloads=!0;generateDOM();a.load([JAVASCRIPT_FOLDER+"/workspace",JAVASCRIPT_FOLDER+"/common",JAVASCRIPT_FOLDER+"/android",JAVASCRIPT_FOLDER+"/ios"],function(){main();var a=el.id("mainPreloaderDiv");a.style["-webkit-transform"]="translateY(-"+window.innerHeight+"px)";a.addEventListener("webkitTransitionEnd",function(){el.del("mainPreloaderDiv")});a=null})})};system.platform.ios?PUBL?a.loadCSS([STYLES_FOLDER+
  17. "/style",STYLES_FOLDER+"/indexios",ASSETS_FOLDER+"/textures/iosskin_pbl"],c):a.loadCSS([STYLES_FOLDER+"/style",STYLES_FOLDER+"/indexios",ASSETS_FOLDER+"/textures/iosskin"],c):a.loadCSS([STYLES_FOLDER+"/styleandroid",STYLES_FOLDER+"/indexandroid",ASSETS_FOLDER+"/skin"],c)})};document.addEventListener("DOMContentLoaded",load);function changeUrlWhenPubl(a,c,b){PUBL&&("undefined"==typeof b||b)?publ.getFile(a,function(a){c(a.target.responseText)}):c(a)}
  18. var publ={getFile:function(a,c){""!=PS&&void 0!=PS&&(a=a+"?password="+PS);""!=USERID&&void 0!=USERID&&(a=a+"?loginTicket="+USERID);var b=new XMLHttpRequest;b.open("GET",a);b.onload=c;b.onerror=function(){};b.send();delete b},getData:function(a,c){publ.getFile(a,function(){var a=new XMLHttpRequest;a.open("GET",this.responseText);a.onload=c;a.onerror=function(){};a.send();delete a})}};

Raw Paste


Login or Register to edit or fork this paste. It's free.