includes/clientside/static/enano-lib-basic.js
changeset 57 b354deeaa4c4
parent 40 723bb7acf914
child 59 7c4a851fb5c5
equal deleted inserted replaced
56:eb8eacb056d1 57:b354deeaa4c4
    23 
    23 
    24 var detect = navigator.userAgent.toLowerCase();
    24 var detect = navigator.userAgent.toLowerCase();
    25 var IE;
    25 var IE;
    26 var is_Safari;
    26 var is_Safari;
    27 
    27 
    28 // dummy tinyMCE object
       
    29 var tinyMCE = new Object();
       
    30 
       
    31 // Detect whether the user is running the Evil One or not...
    28 // Detect whether the user is running the Evil One or not...
    32 
    29 
    33 function checkIt(string) {
    30 function checkIt(string) {
    34   place = detect.indexOf(string) + 1;
    31   place = detect.indexOf(string) + 1;
    35   thestring = string;
    32   thestring = string;
    36   return place;
    33   return place;
    37 }
    34 }
    38 if (checkIt('msie')) IE = true;
    35 if (checkIt('msie')) IE = true;
    39 else IE = false;
    36 else IE = false;
       
    37 
       
    38 var KILL_SWITCH = false;
       
    39 
       
    40 if ( IE )
       
    41 {
       
    42   var version = window.navigator.appVersion;
       
    43   version = version.substr( ( version.indexOf('MSIE') + 5 ) );
       
    44   var rawversion = '';
       
    45   for ( var i = 0; i < version.length; i++ )
       
    46   {
       
    47     var chr = version.substr(i, 1);
       
    48     if ( !chr.match(/[0-9\.]/) )
       
    49     {
       
    50       break;
       
    51     }
       
    52     rawversion += chr;
       
    53   }
       
    54   rawversion = parseInt(rawversion);
       
    55   if ( rawversion < 6 )
       
    56   {
       
    57     KILL_SWITCH = true;
       
    58   }
       
    59 }
       
    60 
       
    61 // dummy tinyMCE object
       
    62 var tinyMCE = new Object();
       
    63 
       
    64 // Obsolete JSON kill switch
       
    65 function disableJSONExts() { };
    40 
    66 
    41 is_Safari = checkIt('safari') ? true : false;
    67 is_Safari = checkIt('safari') ? true : false;
    42 
    68 
    43 var cmt_open;
    69 var cmt_open;
    44 var list;
    70 var list;
   171   return url;
   197   return url;
   172 }
   198 }
   173 
   199 
   174 var stdAjaxPrefix = append_sid(scriptPath+'/ajax.php?title='+title);
   200 var stdAjaxPrefix = append_sid(scriptPath+'/ajax.php?title='+title);
   175 
   201 
   176 // Code for parsing JSON strings - full source code in json.js
       
   177 if(!Object.prototype.toJSONString){Array.prototype.toJSONString=function(){var a=['['],b,i,l=this.length,v;function p(s){if(b){a.push(',');}
       
   178 a.push(s);b=true;}
       
   179 for(i=0;i<l;i+=1){v=this[i];switch(typeof v){case'undefined':case'function':case'unknown':break;case'object':if(v){if(typeof v.toJSONString==='function'){p(v.toJSONString());}}else{p("null");}
       
   180 break;default:p(v.toJSONString());}}
       
   181 a.push(']');return a.join('');};Boolean.prototype.toJSONString=function(){return String(this);};Date.prototype.toJSONString=function(){function f(n){return n<10?'0'+n:n;}
       
   182 return'"'+this.getFullYear()+'-'+
       
   183 f(this.getMonth()+1)+'-'+
       
   184 f(this.getDate())+'T'+
       
   185 f(this.getHours())+':'+
       
   186 f(this.getMinutes())+':'+
       
   187 f(this.getSeconds())+'"';};Number.prototype.toJSONString=function(){return isFinite(this)?String(this):"null";};Object.prototype.toJSONString=function(){var a=['{'],b,i,v;function p(s){if(b){a.push(',');}
       
   188 a.push(i.toJSONString(),':',s);b=true;}
       
   189 for(i in this){if(this.hasOwnProperty(i)){v=this[i];switch(typeof v){case'undefined':case'function':case'unknown':break;case'object':if(v){if(typeof v.toJSONString==='function'){p(v.toJSONString());}}else{p("null");}
       
   190 break;default:p(v.toJSONString());}}}
       
   191 a.push('}');return a.join('');};(function(s){var m={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'};s.parseJSON=function(filter){try{if(/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test(this)){var j=eval('('+this+')');if(typeof filter==='function'){function walk(k,v){if(v&&typeof v==='object'){for(var i in v){if(v.hasOwnProperty(i)){v[i]=walk(i,v[i]);}}}
       
   192 return filter(k,v);}
       
   193 return walk('',j);}
       
   194 return j;}}catch(e){}
       
   195 throw new SyntaxError("parseJSON");};s.toJSONString=function(){if(/["\\\x00-\x1f]/.test(this)){return'"'+this.replace(/([\x00-\x1f\\"])/g,function(a,b){var c=m[b];if(c){return c;}
       
   196 c=b.charCodeAt();return'\\u00'+
       
   197 Math.floor(c/16).toString(16)+
       
   198 (c%16).toString(16);})+'"';}
       
   199 return'"'+this+'"';};})(String.prototype);}
       
   200 
       
   201 function disableJSONExts()
       
   202 {
       
   203   delete(Object.prototype.toJSONString);
       
   204   delete(Array.prototype.toJSONString);
       
   205   delete(Boolean.prototype.toJSONString);
       
   206   delete(Date.prototype.toJSONString);
       
   207   delete(Number.prototype.toJSONString);
       
   208   delete(String.prototype.toJSONString);
       
   209 }
       
   210 
       
   211 // JSON extensions are deprecated now - use the toJSONString **function**
       
   212 disableJSONExts();
       
   213 
       
   214 var $_REQUEST = new Object();
   202 var $_REQUEST = new Object();
   215 if ( window.location.hash )
   203 if ( window.location.hash )
   216 {
   204 {
   217   var hash = String(window.location.hash);
   205   var hash = String(window.location.hash);
   218   hash = hash.substr(1);
   206   hash = hash.substr(1);
   225     $_REQUEST[a] = b;
   213     $_REQUEST[a] = b;
   226   }
   214   }
   227 }
   215 }
   228 
   216 
   229 var head = document.getElementsByTagName('head')[0];
   217 var head = document.getElementsByTagName('head')[0];
   230 var script = document.createElement('script');
   218 if ( !KILL_SWITCH )
   231 script.type="text/javascript";
   219 {
   232 script.src=scriptPath+"/includes/clientside/tinymce/tiny_mce_src.js";
   220   var script = document.createElement('script');
   233 head.appendChild(script);
   221   script.type="text/javascript";
       
   222   script.src=scriptPath+"/includes/clientside/tinymce/tiny_mce_src.js";
       
   223   head.appendChild(script);
       
   224 }
   234 
   225 
   235 // Start loading files
   226 // Start loading files
   236 var thefiles = [
   227 var thefiles = [
   237   'misc.js',
   228   'misc.js',
   238   'admin-menu.js',
   229   'admin-menu.js',
   257   'flyin.js',
   248   'flyin.js',
   258   'loader.js'
   249   'loader.js'
   259 ];
   250 ];
   260 
   251 
   261 var problem_scripts = {
   252 var problem_scripts = {
   262   'faders.js' : true,
   253   'json.js' : true,
   263   'acl.js' : true,
   254   'template-compiler.js' : true
   264   'admin-menu.js' : true,
       
   265   'loader.js' : true
       
   266 };
   255 };
   267 
   256 
   268 for(var f in thefiles)
   257 for(var f in thefiles)
   269 {
   258 {
   270   if ( typeof(thefiles[f]) != 'string' )
   259   if ( typeof(thefiles[f]) != 'string' )
   271     continue;
   260     continue;
   272   var script = document.createElement('script');
   261   var script = document.createElement('script');
   273   script.type="text/javascript";
   262   script.type="text/javascript";
   274   //if ( problem_scripts[thefiles[f]] )
   263   if ( problem_scripts[thefiles[f]] && KILL_SWITCH )
   275     script.src=scriptPath+"/includes/clientside/static/"+thefiles[f];
   264   {
   276   //else
   265     // alert('kill switch and problem script');
   277   //  script.src=scriptPath+"/includes/clientside/jsres.php?file="+thefiles[f];
   266     continue;
       
   267   }
       
   268   script.src=scriptPath+"/includes/clientside/static/"+thefiles[f];
   278   head.appendChild(script);
   269   head.appendChild(script);
   279 }
   270 }
   280 
   271 
   281 var onload_hooks = new Array();
   272 var onload_hooks = new Array();
   282 
   273