A compatible JavaScript with almost all versions of web browsers












0












$begingroup$


Would you be kind and possibly review the following script and help me with any possible improvement and correction?



The code has to run on a blog with a goal of being fast, and it has to be compatible with all versions of web browsers (e.g., IE, Chrome, Safari, etc.).



Sorry about my programming style, which looks like a minified code. If the code is not appropriate, please comment and I will delete the question.



Thank you so much for your time!



<script type="text/javascript">
var J={
/*attribute set*/
a:function(z){var e=document.getElementById(z.k);e.setAttribute(z.a,z.v);},

/*attribute remove*/
b:function(z){
var i,e; e=document.getElementById(z.k); /*key element*/
for(i=0;i<z.a.length;i++){e.removeAttribute(z.a[i]);}; /*attribute length*/
},

/*cursor focus*/
c:function(z){
var i,e; e=document.getElementsByTagName(z.k); /*key element*/
if(e.length>0){
for(i in e){
if(e[i].getAttribute(z.a)===z.v){e[i].focus();break;} /*attribute - attribute value*/
}
}
},

d:function(z){var i,e; e=document.querySelectorAll('.'+z.k);for(i=0;i<e.length;i++){e[i].parentNode.removeChild(e[i]);}},

/*style get files*/
e:function(z){
var w,y,e,ar,x=;
Object.keys(z).forEach(function(a,b,c){
window[a]=null;
x[a]=new XMLHttpRequest();
if(a=='m'){
w=window.innerWidth; /*window size*/
switch(true) {
case(w<200):
window.y='a1';window.e=0.8; /*tiny*/
break;
case(w>=200&&w<=360):
window.y='a2';window.e=0.9;/*x small*/
break;
case(w>360&&w<=480):
window.y='a3';window.e=1; /*small*/
break;
case(w>480&&w<=768):
window.y='a4';window.e=1.1; /*medium*/
break;
case(w>768&&w<=1280):
window.y='a5';window.e=1.3; /*large*/
break;
case(w>1280&&w<=1920):
window.y='a6';window.e=1.6; /*x large*/
break;
case(w>1920):
window.y='a7';window.e=1.9; /*xx large*/
break;
default:
window.y='a5';window.e=1.2; /*default size */
break;
}
url=window.location.origin.concat('/',z[a.toString()],window.y,'.txt');

} else {
url=window.location.origin.concat('/',z[a.toString()]);
}
x[a].open("GET",url,true);

x[a].onreadystatechange=function (z){
if(x[a].readyState===4){
if(x[a].status===200 || x[a].status==0){
window[a]=x[a].responseText;
}
}
}
x[a].send();
});
},

/*local storage set*/
l:function(z){return sessionStorage.setItem(z.k,z.v);},

/*get json*/
o:function(z){
var g,h,x=;

Object.keys(z).forEach(function(a,b,c){
window[a]=null;
x[b]=new XMLHttpRequest();
url=window.location.origin.concat('/',z[a.toString()]);
x[b].open("GET",url,true);
x[b].onreadystatechange=function (z){
if(x[b].readyState===4){
if(x[b].status===200 || x[b].status==0){
window[a]=x[b].responseText;
}
}
}
x[b].send();
});
},

/*click*/
q:function(z){document.getElementById(z.e).click();},

/*switch display*/
s:function(z){
var x,a;
x=/(di-0)/i;
if(x.test(z.d.nextElementSibling.attributes.getNamedItem('class').nodeValue)){a=1}else{a=0}
switch (a){
case 1:
z.d.nextElementSibling.attributes.getNamedItem('class').nodeValue='di-2';
break;
case 0:
z.d.nextElementSibling.attributes.getNamedItem('class').nodeValue='di-0';
break;
}
},

/*put page*/
t:function(z,g){
if(z==null){return;}
z=z.trim();
z=JSON.parse(z);
var a,c,d,e,p,i,j,t,p=;a=document.getElementById(g.t);
for(i in z){
if(a==null){break;};
if(i==1){continue;}
c=null; /*current element class name*/
d=z[i].d; /*current element depth*/
e=null; /*current element*/
if(z[i].a!=undefined){if(z[i].a.class!=undefined){c=z[i].a.class+" i".concat(i,"-d",d);}else{c="i".concat(i,"-d",d);}}else{c="i".concat(i,"-d",d);}
p[d]=c;e=document.createElement(z[i].t); /*create the new element*/
if(z[i].x!=undefined){t=document.createTextNode(z[i].x);e.appendChild(t);} /*element text*/
if(z[i].a!=undefined){for(j in z[i].a){if(j!='class'){e.setAttribute(j,z[i].a[j]);}}} /*non-class attributes*/
e.setAttribute("class",c); /*class attribute*/
if(i==0){a.appendChild(e);}
if(i>0){a.getElementsByClassName(p[(d-1)])[0].appendChild(e);}
}
},

/*style*/
u:function(z){
var d,e,t,w,f,s,i,q,n,k,j,h,x,y;
x=window.innerWidth; /*window size*/
if(z.c==null||z.m==null||z.g==null){
return;
}
c=JSON.parse(z.c);

d='';s='';t='';w='';i=99;f=51; /*font count*/ q=20; /*columns size*/
for(n in c){
for(k in c[n]){i++;d=d.concat('.r',i,',r',i,' a{color:#',c[n][k],'}.b',i,',.b',i,' a{background-color:#',c[n][k],'}');}
}
for(j=1;j<f;j++){s=s+'.s'.concat(j,'{font-size:',(j*window.e),'px}');} /*font-size*/
for(i=1;i<=q;i++){
t=t+'.'+window.y+i+','; /*width calc*/
w=w+'.'+window.y+i+'{width:'+(100/(q+1-i))+'%}';
if(i==q){
t=t.substr(0,t.length-1);
h='.ro{margin:0;padding:0;width:100%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;display:inline-block;}'.concat(t,'{float:left;position:relative;min-height:1px}',w,s,z.g,z.m,d); /*assembled css*/
break;
}
}
s=document.createElement('style'); /*create style tag*/
t=document.createTextNode(h); /*create style text*/
s.appendChild(t); /*append text to tag*/
document.body.appendChild(s); /*append style to body*/
},

/*window reload*/
w:function(){window.location.reload();},

/*regex prep*/
x:function(z){var v=;v.push(z.v.split(","));return v;},

/*generate random between min and max*/
y:function(z){return Number(Math.random()*(z.x-z.n)+z.n).toFixed(8);},

/*update bar*/
z:function(z){
var a,b,c,d,i,u,n,x,e1,e2,x1,x2;
if(window['d']==null){return;}
d=window['d'].trim();
u=document.getElementsByClassName('u1');
c=3;
e1=Number(62.5839781125).toFixed(c*2);
x1=Number(76.1834054875).toFixed(c*2);
e2=Number(122.2642650928).toFixed(c*2);
x2=Number(141.8925133056).toFixed(c*2);
n=Number((c+((e2/(c*2))+(e1/2))/100).toFixed(c*2));
x=Number((c+((x2/(c*2))+(x1/2))/100).toFixed(c*2));
for(i=0;i<u.length;i++){
a=(Number(JSON.parse(d)[u[i].attributes["data"].value])*J.y({n:n,x:x})).toFixed(c);
b=(Number(a*c*5/2)+50).toFixed(c/2);
if(b<=100&&b>=-100){
u[i].attributes["style"].value="padding-left:".concat(b,'%;');
u[i].children[0].textContent=a;
}
};
}
};
</script>


<script type="text/javascript">
window.rt=1000;r=0;
var m=setInterval(function(){
if(r>84600 || window['d']==null){clearInterval(m);}
r++; J.z({});

document.getElementById('t-2').textContent=new Date().toLocaleTimeString(); // clock

J.o({d:'blog/data/s-1.txt'});

}, window.rt);

function op(z) {document.getElementById(z.d).style.width="325px";}
function cl(z) {document.getElementById(z.d).style.width="0";}

(function() {
var cx = '!!!!!!!!!!!!!!!!!!!';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = 'https://cse.google.com/cse.js?cx='+ cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();

window.onload = function(){
document.getElementById('gsc-i-id1').placeholder = 'e.g., United Stocks AMD';
};

</script>








share







New contributor




Emma is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$

















    0












    $begingroup$


    Would you be kind and possibly review the following script and help me with any possible improvement and correction?



    The code has to run on a blog with a goal of being fast, and it has to be compatible with all versions of web browsers (e.g., IE, Chrome, Safari, etc.).



    Sorry about my programming style, which looks like a minified code. If the code is not appropriate, please comment and I will delete the question.



    Thank you so much for your time!



    <script type="text/javascript">
    var J={
    /*attribute set*/
    a:function(z){var e=document.getElementById(z.k);e.setAttribute(z.a,z.v);},

    /*attribute remove*/
    b:function(z){
    var i,e; e=document.getElementById(z.k); /*key element*/
    for(i=0;i<z.a.length;i++){e.removeAttribute(z.a[i]);}; /*attribute length*/
    },

    /*cursor focus*/
    c:function(z){
    var i,e; e=document.getElementsByTagName(z.k); /*key element*/
    if(e.length>0){
    for(i in e){
    if(e[i].getAttribute(z.a)===z.v){e[i].focus();break;} /*attribute - attribute value*/
    }
    }
    },

    d:function(z){var i,e; e=document.querySelectorAll('.'+z.k);for(i=0;i<e.length;i++){e[i].parentNode.removeChild(e[i]);}},

    /*style get files*/
    e:function(z){
    var w,y,e,ar,x=;
    Object.keys(z).forEach(function(a,b,c){
    window[a]=null;
    x[a]=new XMLHttpRequest();
    if(a=='m'){
    w=window.innerWidth; /*window size*/
    switch(true) {
    case(w<200):
    window.y='a1';window.e=0.8; /*tiny*/
    break;
    case(w>=200&&w<=360):
    window.y='a2';window.e=0.9;/*x small*/
    break;
    case(w>360&&w<=480):
    window.y='a3';window.e=1; /*small*/
    break;
    case(w>480&&w<=768):
    window.y='a4';window.e=1.1; /*medium*/
    break;
    case(w>768&&w<=1280):
    window.y='a5';window.e=1.3; /*large*/
    break;
    case(w>1280&&w<=1920):
    window.y='a6';window.e=1.6; /*x large*/
    break;
    case(w>1920):
    window.y='a7';window.e=1.9; /*xx large*/
    break;
    default:
    window.y='a5';window.e=1.2; /*default size */
    break;
    }
    url=window.location.origin.concat('/',z[a.toString()],window.y,'.txt');

    } else {
    url=window.location.origin.concat('/',z[a.toString()]);
    }
    x[a].open("GET",url,true);

    x[a].onreadystatechange=function (z){
    if(x[a].readyState===4){
    if(x[a].status===200 || x[a].status==0){
    window[a]=x[a].responseText;
    }
    }
    }
    x[a].send();
    });
    },

    /*local storage set*/
    l:function(z){return sessionStorage.setItem(z.k,z.v);},

    /*get json*/
    o:function(z){
    var g,h,x=;

    Object.keys(z).forEach(function(a,b,c){
    window[a]=null;
    x[b]=new XMLHttpRequest();
    url=window.location.origin.concat('/',z[a.toString()]);
    x[b].open("GET",url,true);
    x[b].onreadystatechange=function (z){
    if(x[b].readyState===4){
    if(x[b].status===200 || x[b].status==0){
    window[a]=x[b].responseText;
    }
    }
    }
    x[b].send();
    });
    },

    /*click*/
    q:function(z){document.getElementById(z.e).click();},

    /*switch display*/
    s:function(z){
    var x,a;
    x=/(di-0)/i;
    if(x.test(z.d.nextElementSibling.attributes.getNamedItem('class').nodeValue)){a=1}else{a=0}
    switch (a){
    case 1:
    z.d.nextElementSibling.attributes.getNamedItem('class').nodeValue='di-2';
    break;
    case 0:
    z.d.nextElementSibling.attributes.getNamedItem('class').nodeValue='di-0';
    break;
    }
    },

    /*put page*/
    t:function(z,g){
    if(z==null){return;}
    z=z.trim();
    z=JSON.parse(z);
    var a,c,d,e,p,i,j,t,p=;a=document.getElementById(g.t);
    for(i in z){
    if(a==null){break;};
    if(i==1){continue;}
    c=null; /*current element class name*/
    d=z[i].d; /*current element depth*/
    e=null; /*current element*/
    if(z[i].a!=undefined){if(z[i].a.class!=undefined){c=z[i].a.class+" i".concat(i,"-d",d);}else{c="i".concat(i,"-d",d);}}else{c="i".concat(i,"-d",d);}
    p[d]=c;e=document.createElement(z[i].t); /*create the new element*/
    if(z[i].x!=undefined){t=document.createTextNode(z[i].x);e.appendChild(t);} /*element text*/
    if(z[i].a!=undefined){for(j in z[i].a){if(j!='class'){e.setAttribute(j,z[i].a[j]);}}} /*non-class attributes*/
    e.setAttribute("class",c); /*class attribute*/
    if(i==0){a.appendChild(e);}
    if(i>0){a.getElementsByClassName(p[(d-1)])[0].appendChild(e);}
    }
    },

    /*style*/
    u:function(z){
    var d,e,t,w,f,s,i,q,n,k,j,h,x,y;
    x=window.innerWidth; /*window size*/
    if(z.c==null||z.m==null||z.g==null){
    return;
    }
    c=JSON.parse(z.c);

    d='';s='';t='';w='';i=99;f=51; /*font count*/ q=20; /*columns size*/
    for(n in c){
    for(k in c[n]){i++;d=d.concat('.r',i,',r',i,' a{color:#',c[n][k],'}.b',i,',.b',i,' a{background-color:#',c[n][k],'}');}
    }
    for(j=1;j<f;j++){s=s+'.s'.concat(j,'{font-size:',(j*window.e),'px}');} /*font-size*/
    for(i=1;i<=q;i++){
    t=t+'.'+window.y+i+','; /*width calc*/
    w=w+'.'+window.y+i+'{width:'+(100/(q+1-i))+'%}';
    if(i==q){
    t=t.substr(0,t.length-1);
    h='.ro{margin:0;padding:0;width:100%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;display:inline-block;}'.concat(t,'{float:left;position:relative;min-height:1px}',w,s,z.g,z.m,d); /*assembled css*/
    break;
    }
    }
    s=document.createElement('style'); /*create style tag*/
    t=document.createTextNode(h); /*create style text*/
    s.appendChild(t); /*append text to tag*/
    document.body.appendChild(s); /*append style to body*/
    },

    /*window reload*/
    w:function(){window.location.reload();},

    /*regex prep*/
    x:function(z){var v=;v.push(z.v.split(","));return v;},

    /*generate random between min and max*/
    y:function(z){return Number(Math.random()*(z.x-z.n)+z.n).toFixed(8);},

    /*update bar*/
    z:function(z){
    var a,b,c,d,i,u,n,x,e1,e2,x1,x2;
    if(window['d']==null){return;}
    d=window['d'].trim();
    u=document.getElementsByClassName('u1');
    c=3;
    e1=Number(62.5839781125).toFixed(c*2);
    x1=Number(76.1834054875).toFixed(c*2);
    e2=Number(122.2642650928).toFixed(c*2);
    x2=Number(141.8925133056).toFixed(c*2);
    n=Number((c+((e2/(c*2))+(e1/2))/100).toFixed(c*2));
    x=Number((c+((x2/(c*2))+(x1/2))/100).toFixed(c*2));
    for(i=0;i<u.length;i++){
    a=(Number(JSON.parse(d)[u[i].attributes["data"].value])*J.y({n:n,x:x})).toFixed(c);
    b=(Number(a*c*5/2)+50).toFixed(c/2);
    if(b<=100&&b>=-100){
    u[i].attributes["style"].value="padding-left:".concat(b,'%;');
    u[i].children[0].textContent=a;
    }
    };
    }
    };
    </script>


    <script type="text/javascript">
    window.rt=1000;r=0;
    var m=setInterval(function(){
    if(r>84600 || window['d']==null){clearInterval(m);}
    r++; J.z({});

    document.getElementById('t-2').textContent=new Date().toLocaleTimeString(); // clock

    J.o({d:'blog/data/s-1.txt'});

    }, window.rt);

    function op(z) {document.getElementById(z.d).style.width="325px";}
    function cl(z) {document.getElementById(z.d).style.width="0";}

    (function() {
    var cx = '!!!!!!!!!!!!!!!!!!!';
    var gcse = document.createElement('script');
    gcse.type = 'text/javascript';
    gcse.async = true;
    gcse.src = 'https://cse.google.com/cse.js?cx='+ cx;
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(gcse, s);
    })();

    window.onload = function(){
    document.getElementById('gsc-i-id1').placeholder = 'e.g., United Stocks AMD';
    };

    </script>








    share







    New contributor




    Emma is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.







    $endgroup$















      0












      0








      0





      $begingroup$


      Would you be kind and possibly review the following script and help me with any possible improvement and correction?



      The code has to run on a blog with a goal of being fast, and it has to be compatible with all versions of web browsers (e.g., IE, Chrome, Safari, etc.).



      Sorry about my programming style, which looks like a minified code. If the code is not appropriate, please comment and I will delete the question.



      Thank you so much for your time!



      <script type="text/javascript">
      var J={
      /*attribute set*/
      a:function(z){var e=document.getElementById(z.k);e.setAttribute(z.a,z.v);},

      /*attribute remove*/
      b:function(z){
      var i,e; e=document.getElementById(z.k); /*key element*/
      for(i=0;i<z.a.length;i++){e.removeAttribute(z.a[i]);}; /*attribute length*/
      },

      /*cursor focus*/
      c:function(z){
      var i,e; e=document.getElementsByTagName(z.k); /*key element*/
      if(e.length>0){
      for(i in e){
      if(e[i].getAttribute(z.a)===z.v){e[i].focus();break;} /*attribute - attribute value*/
      }
      }
      },

      d:function(z){var i,e; e=document.querySelectorAll('.'+z.k);for(i=0;i<e.length;i++){e[i].parentNode.removeChild(e[i]);}},

      /*style get files*/
      e:function(z){
      var w,y,e,ar,x=;
      Object.keys(z).forEach(function(a,b,c){
      window[a]=null;
      x[a]=new XMLHttpRequest();
      if(a=='m'){
      w=window.innerWidth; /*window size*/
      switch(true) {
      case(w<200):
      window.y='a1';window.e=0.8; /*tiny*/
      break;
      case(w>=200&&w<=360):
      window.y='a2';window.e=0.9;/*x small*/
      break;
      case(w>360&&w<=480):
      window.y='a3';window.e=1; /*small*/
      break;
      case(w>480&&w<=768):
      window.y='a4';window.e=1.1; /*medium*/
      break;
      case(w>768&&w<=1280):
      window.y='a5';window.e=1.3; /*large*/
      break;
      case(w>1280&&w<=1920):
      window.y='a6';window.e=1.6; /*x large*/
      break;
      case(w>1920):
      window.y='a7';window.e=1.9; /*xx large*/
      break;
      default:
      window.y='a5';window.e=1.2; /*default size */
      break;
      }
      url=window.location.origin.concat('/',z[a.toString()],window.y,'.txt');

      } else {
      url=window.location.origin.concat('/',z[a.toString()]);
      }
      x[a].open("GET",url,true);

      x[a].onreadystatechange=function (z){
      if(x[a].readyState===4){
      if(x[a].status===200 || x[a].status==0){
      window[a]=x[a].responseText;
      }
      }
      }
      x[a].send();
      });
      },

      /*local storage set*/
      l:function(z){return sessionStorage.setItem(z.k,z.v);},

      /*get json*/
      o:function(z){
      var g,h,x=;

      Object.keys(z).forEach(function(a,b,c){
      window[a]=null;
      x[b]=new XMLHttpRequest();
      url=window.location.origin.concat('/',z[a.toString()]);
      x[b].open("GET",url,true);
      x[b].onreadystatechange=function (z){
      if(x[b].readyState===4){
      if(x[b].status===200 || x[b].status==0){
      window[a]=x[b].responseText;
      }
      }
      }
      x[b].send();
      });
      },

      /*click*/
      q:function(z){document.getElementById(z.e).click();},

      /*switch display*/
      s:function(z){
      var x,a;
      x=/(di-0)/i;
      if(x.test(z.d.nextElementSibling.attributes.getNamedItem('class').nodeValue)){a=1}else{a=0}
      switch (a){
      case 1:
      z.d.nextElementSibling.attributes.getNamedItem('class').nodeValue='di-2';
      break;
      case 0:
      z.d.nextElementSibling.attributes.getNamedItem('class').nodeValue='di-0';
      break;
      }
      },

      /*put page*/
      t:function(z,g){
      if(z==null){return;}
      z=z.trim();
      z=JSON.parse(z);
      var a,c,d,e,p,i,j,t,p=;a=document.getElementById(g.t);
      for(i in z){
      if(a==null){break;};
      if(i==1){continue;}
      c=null; /*current element class name*/
      d=z[i].d; /*current element depth*/
      e=null; /*current element*/
      if(z[i].a!=undefined){if(z[i].a.class!=undefined){c=z[i].a.class+" i".concat(i,"-d",d);}else{c="i".concat(i,"-d",d);}}else{c="i".concat(i,"-d",d);}
      p[d]=c;e=document.createElement(z[i].t); /*create the new element*/
      if(z[i].x!=undefined){t=document.createTextNode(z[i].x);e.appendChild(t);} /*element text*/
      if(z[i].a!=undefined){for(j in z[i].a){if(j!='class'){e.setAttribute(j,z[i].a[j]);}}} /*non-class attributes*/
      e.setAttribute("class",c); /*class attribute*/
      if(i==0){a.appendChild(e);}
      if(i>0){a.getElementsByClassName(p[(d-1)])[0].appendChild(e);}
      }
      },

      /*style*/
      u:function(z){
      var d,e,t,w,f,s,i,q,n,k,j,h,x,y;
      x=window.innerWidth; /*window size*/
      if(z.c==null||z.m==null||z.g==null){
      return;
      }
      c=JSON.parse(z.c);

      d='';s='';t='';w='';i=99;f=51; /*font count*/ q=20; /*columns size*/
      for(n in c){
      for(k in c[n]){i++;d=d.concat('.r',i,',r',i,' a{color:#',c[n][k],'}.b',i,',.b',i,' a{background-color:#',c[n][k],'}');}
      }
      for(j=1;j<f;j++){s=s+'.s'.concat(j,'{font-size:',(j*window.e),'px}');} /*font-size*/
      for(i=1;i<=q;i++){
      t=t+'.'+window.y+i+','; /*width calc*/
      w=w+'.'+window.y+i+'{width:'+(100/(q+1-i))+'%}';
      if(i==q){
      t=t.substr(0,t.length-1);
      h='.ro{margin:0;padding:0;width:100%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;display:inline-block;}'.concat(t,'{float:left;position:relative;min-height:1px}',w,s,z.g,z.m,d); /*assembled css*/
      break;
      }
      }
      s=document.createElement('style'); /*create style tag*/
      t=document.createTextNode(h); /*create style text*/
      s.appendChild(t); /*append text to tag*/
      document.body.appendChild(s); /*append style to body*/
      },

      /*window reload*/
      w:function(){window.location.reload();},

      /*regex prep*/
      x:function(z){var v=;v.push(z.v.split(","));return v;},

      /*generate random between min and max*/
      y:function(z){return Number(Math.random()*(z.x-z.n)+z.n).toFixed(8);},

      /*update bar*/
      z:function(z){
      var a,b,c,d,i,u,n,x,e1,e2,x1,x2;
      if(window['d']==null){return;}
      d=window['d'].trim();
      u=document.getElementsByClassName('u1');
      c=3;
      e1=Number(62.5839781125).toFixed(c*2);
      x1=Number(76.1834054875).toFixed(c*2);
      e2=Number(122.2642650928).toFixed(c*2);
      x2=Number(141.8925133056).toFixed(c*2);
      n=Number((c+((e2/(c*2))+(e1/2))/100).toFixed(c*2));
      x=Number((c+((x2/(c*2))+(x1/2))/100).toFixed(c*2));
      for(i=0;i<u.length;i++){
      a=(Number(JSON.parse(d)[u[i].attributes["data"].value])*J.y({n:n,x:x})).toFixed(c);
      b=(Number(a*c*5/2)+50).toFixed(c/2);
      if(b<=100&&b>=-100){
      u[i].attributes["style"].value="padding-left:".concat(b,'%;');
      u[i].children[0].textContent=a;
      }
      };
      }
      };
      </script>


      <script type="text/javascript">
      window.rt=1000;r=0;
      var m=setInterval(function(){
      if(r>84600 || window['d']==null){clearInterval(m);}
      r++; J.z({});

      document.getElementById('t-2').textContent=new Date().toLocaleTimeString(); // clock

      J.o({d:'blog/data/s-1.txt'});

      }, window.rt);

      function op(z) {document.getElementById(z.d).style.width="325px";}
      function cl(z) {document.getElementById(z.d).style.width="0";}

      (function() {
      var cx = '!!!!!!!!!!!!!!!!!!!';
      var gcse = document.createElement('script');
      gcse.type = 'text/javascript';
      gcse.async = true;
      gcse.src = 'https://cse.google.com/cse.js?cx='+ cx;
      var s = document.getElementsByTagName('script')[0];
      s.parentNode.insertBefore(gcse, s);
      })();

      window.onload = function(){
      document.getElementById('gsc-i-id1').placeholder = 'e.g., United Stocks AMD';
      };

      </script>








      share







      New contributor




      Emma is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.







      $endgroup$




      Would you be kind and possibly review the following script and help me with any possible improvement and correction?



      The code has to run on a blog with a goal of being fast, and it has to be compatible with all versions of web browsers (e.g., IE, Chrome, Safari, etc.).



      Sorry about my programming style, which looks like a minified code. If the code is not appropriate, please comment and I will delete the question.



      Thank you so much for your time!



      <script type="text/javascript">
      var J={
      /*attribute set*/
      a:function(z){var e=document.getElementById(z.k);e.setAttribute(z.a,z.v);},

      /*attribute remove*/
      b:function(z){
      var i,e; e=document.getElementById(z.k); /*key element*/
      for(i=0;i<z.a.length;i++){e.removeAttribute(z.a[i]);}; /*attribute length*/
      },

      /*cursor focus*/
      c:function(z){
      var i,e; e=document.getElementsByTagName(z.k); /*key element*/
      if(e.length>0){
      for(i in e){
      if(e[i].getAttribute(z.a)===z.v){e[i].focus();break;} /*attribute - attribute value*/
      }
      }
      },

      d:function(z){var i,e; e=document.querySelectorAll('.'+z.k);for(i=0;i<e.length;i++){e[i].parentNode.removeChild(e[i]);}},

      /*style get files*/
      e:function(z){
      var w,y,e,ar,x=;
      Object.keys(z).forEach(function(a,b,c){
      window[a]=null;
      x[a]=new XMLHttpRequest();
      if(a=='m'){
      w=window.innerWidth; /*window size*/
      switch(true) {
      case(w<200):
      window.y='a1';window.e=0.8; /*tiny*/
      break;
      case(w>=200&&w<=360):
      window.y='a2';window.e=0.9;/*x small*/
      break;
      case(w>360&&w<=480):
      window.y='a3';window.e=1; /*small*/
      break;
      case(w>480&&w<=768):
      window.y='a4';window.e=1.1; /*medium*/
      break;
      case(w>768&&w<=1280):
      window.y='a5';window.e=1.3; /*large*/
      break;
      case(w>1280&&w<=1920):
      window.y='a6';window.e=1.6; /*x large*/
      break;
      case(w>1920):
      window.y='a7';window.e=1.9; /*xx large*/
      break;
      default:
      window.y='a5';window.e=1.2; /*default size */
      break;
      }
      url=window.location.origin.concat('/',z[a.toString()],window.y,'.txt');

      } else {
      url=window.location.origin.concat('/',z[a.toString()]);
      }
      x[a].open("GET",url,true);

      x[a].onreadystatechange=function (z){
      if(x[a].readyState===4){
      if(x[a].status===200 || x[a].status==0){
      window[a]=x[a].responseText;
      }
      }
      }
      x[a].send();
      });
      },

      /*local storage set*/
      l:function(z){return sessionStorage.setItem(z.k,z.v);},

      /*get json*/
      o:function(z){
      var g,h,x=;

      Object.keys(z).forEach(function(a,b,c){
      window[a]=null;
      x[b]=new XMLHttpRequest();
      url=window.location.origin.concat('/',z[a.toString()]);
      x[b].open("GET",url,true);
      x[b].onreadystatechange=function (z){
      if(x[b].readyState===4){
      if(x[b].status===200 || x[b].status==0){
      window[a]=x[b].responseText;
      }
      }
      }
      x[b].send();
      });
      },

      /*click*/
      q:function(z){document.getElementById(z.e).click();},

      /*switch display*/
      s:function(z){
      var x,a;
      x=/(di-0)/i;
      if(x.test(z.d.nextElementSibling.attributes.getNamedItem('class').nodeValue)){a=1}else{a=0}
      switch (a){
      case 1:
      z.d.nextElementSibling.attributes.getNamedItem('class').nodeValue='di-2';
      break;
      case 0:
      z.d.nextElementSibling.attributes.getNamedItem('class').nodeValue='di-0';
      break;
      }
      },

      /*put page*/
      t:function(z,g){
      if(z==null){return;}
      z=z.trim();
      z=JSON.parse(z);
      var a,c,d,e,p,i,j,t,p=;a=document.getElementById(g.t);
      for(i in z){
      if(a==null){break;};
      if(i==1){continue;}
      c=null; /*current element class name*/
      d=z[i].d; /*current element depth*/
      e=null; /*current element*/
      if(z[i].a!=undefined){if(z[i].a.class!=undefined){c=z[i].a.class+" i".concat(i,"-d",d);}else{c="i".concat(i,"-d",d);}}else{c="i".concat(i,"-d",d);}
      p[d]=c;e=document.createElement(z[i].t); /*create the new element*/
      if(z[i].x!=undefined){t=document.createTextNode(z[i].x);e.appendChild(t);} /*element text*/
      if(z[i].a!=undefined){for(j in z[i].a){if(j!='class'){e.setAttribute(j,z[i].a[j]);}}} /*non-class attributes*/
      e.setAttribute("class",c); /*class attribute*/
      if(i==0){a.appendChild(e);}
      if(i>0){a.getElementsByClassName(p[(d-1)])[0].appendChild(e);}
      }
      },

      /*style*/
      u:function(z){
      var d,e,t,w,f,s,i,q,n,k,j,h,x,y;
      x=window.innerWidth; /*window size*/
      if(z.c==null||z.m==null||z.g==null){
      return;
      }
      c=JSON.parse(z.c);

      d='';s='';t='';w='';i=99;f=51; /*font count*/ q=20; /*columns size*/
      for(n in c){
      for(k in c[n]){i++;d=d.concat('.r',i,',r',i,' a{color:#',c[n][k],'}.b',i,',.b',i,' a{background-color:#',c[n][k],'}');}
      }
      for(j=1;j<f;j++){s=s+'.s'.concat(j,'{font-size:',(j*window.e),'px}');} /*font-size*/
      for(i=1;i<=q;i++){
      t=t+'.'+window.y+i+','; /*width calc*/
      w=w+'.'+window.y+i+'{width:'+(100/(q+1-i))+'%}';
      if(i==q){
      t=t.substr(0,t.length-1);
      h='.ro{margin:0;padding:0;width:100%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;display:inline-block;}'.concat(t,'{float:left;position:relative;min-height:1px}',w,s,z.g,z.m,d); /*assembled css*/
      break;
      }
      }
      s=document.createElement('style'); /*create style tag*/
      t=document.createTextNode(h); /*create style text*/
      s.appendChild(t); /*append text to tag*/
      document.body.appendChild(s); /*append style to body*/
      },

      /*window reload*/
      w:function(){window.location.reload();},

      /*regex prep*/
      x:function(z){var v=;v.push(z.v.split(","));return v;},

      /*generate random between min and max*/
      y:function(z){return Number(Math.random()*(z.x-z.n)+z.n).toFixed(8);},

      /*update bar*/
      z:function(z){
      var a,b,c,d,i,u,n,x,e1,e2,x1,x2;
      if(window['d']==null){return;}
      d=window['d'].trim();
      u=document.getElementsByClassName('u1');
      c=3;
      e1=Number(62.5839781125).toFixed(c*2);
      x1=Number(76.1834054875).toFixed(c*2);
      e2=Number(122.2642650928).toFixed(c*2);
      x2=Number(141.8925133056).toFixed(c*2);
      n=Number((c+((e2/(c*2))+(e1/2))/100).toFixed(c*2));
      x=Number((c+((x2/(c*2))+(x1/2))/100).toFixed(c*2));
      for(i=0;i<u.length;i++){
      a=(Number(JSON.parse(d)[u[i].attributes["data"].value])*J.y({n:n,x:x})).toFixed(c);
      b=(Number(a*c*5/2)+50).toFixed(c/2);
      if(b<=100&&b>=-100){
      u[i].attributes["style"].value="padding-left:".concat(b,'%;');
      u[i].children[0].textContent=a;
      }
      };
      }
      };
      </script>


      <script type="text/javascript">
      window.rt=1000;r=0;
      var m=setInterval(function(){
      if(r>84600 || window['d']==null){clearInterval(m);}
      r++; J.z({});

      document.getElementById('t-2').textContent=new Date().toLocaleTimeString(); // clock

      J.o({d:'blog/data/s-1.txt'});

      }, window.rt);

      function op(z) {document.getElementById(z.d).style.width="325px";}
      function cl(z) {document.getElementById(z.d).style.width="0";}

      (function() {
      var cx = '!!!!!!!!!!!!!!!!!!!';
      var gcse = document.createElement('script');
      gcse.type = 'text/javascript';
      gcse.async = true;
      gcse.src = 'https://cse.google.com/cse.js?cx='+ cx;
      var s = document.getElementsByTagName('script')[0];
      s.parentNode.insertBefore(gcse, s);
      })();

      window.onload = function(){
      document.getElementById('gsc-i-id1').placeholder = 'e.g., United Stocks AMD';
      };

      </script>






      javascript cross-browser





      share







      New contributor




      Emma is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share







      New contributor




      Emma is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share



      share






      New contributor




      Emma is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 5 mins ago









      EmmaEmma

      1063




      1063




      New contributor




      Emma is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Emma is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Emma is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          0






          active

          oldest

          votes











          Your Answer





          StackExchange.ifUsing("editor", function () {
          return StackExchange.using("mathjaxEditing", function () {
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
          });
          });
          }, "mathjax-editing");

          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "196"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          Emma is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f214149%2fa-compatible-javascript-with-almost-all-versions-of-web-browsers%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          Emma is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          Emma is a new contributor. Be nice, and check out our Code of Conduct.













          Emma is a new contributor. Be nice, and check out our Code of Conduct.












          Emma is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Code Review Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f214149%2fa-compatible-javascript-with-almost-all-versions-of-web-browsers%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to make a Squid Proxy server?

          Is this a new Fibonacci Identity?

          19世紀