Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var arrMap=function(obj){
- this[0]=[];
- this[1]=[];
- if(typeof obj=="object"){
- this.fromObj(obj);
- }
- };
- function addProto(_proto,_class){
- for(let i in _proto){_class.prototype[i]=_proto[i];}
- }
- addProto(
- {
- i:-1,
- Get:function(_prop){
- this.i=this[0].indexOf(_prop);
- if(this.i>-1){
- return this[1][this.i];
- }
- return null;
- },
- Set:function(_prop,_val){
- this.i=this[0].indexOf(_prop);
- if(this.i>-1){
- this[1][this.i]=_val;
- return _val;
- }
- else{
- this.i=this[0].length;
- this[0].push(_prop);
- this[1].push(_val);
- return _val;
- }
- },
- forEach:function(callBack){
- for(let i=0,ii=true;ii && i<this[0].length;i++){
- ii=!callBack(this[1][i],this[0][i],this[1]);
- }
- },
- setForEach:function(callBack){
- for(let i=0;i<this[0].length;i++){
- this[1][i]=callBack(this[1][i],this[0][i],this[1]);
- }
- return this;
- },
- getForEach:function(callback){
- let arr=new arrMap();
- arr[0]=this[0];
- arr[1]=this[1];
- for(let i=0;i<this[0].length;i++){
- arr[1][i]=callBack(arr[1][i],arr[0][i],arr[1]);
- }
- return arr;
- },
- getObj:function(){
- let obj={};
- for(let i=0,s;i<this[0].length;i++){
- s=this[0][i];
- obj[s.replace(/\W/g,"")]=this[1][i];
- }
- return obj;
- },
- fromObj:function(obj){
- for(let i in obj){this[0].push(i);this[1].push(obj[i]);}
- },
- clearDuplicates:function(){
- for(let i=this[0].length-1;i>-1;i--){
- if(this[0].indexOf(this[0][i])<i){
- this[0].splice(i,1);
- this[1].splice(i,1);
- }
- }
- },
- Remove:function(name){
- this.i=this[0].indexOf(name);
- if(this.i>-1){
- this[0].splice(this.i,1);
- this[1].splice(this.i,1);
- }
- },
- class:"arrMap"
- },
- arrMap
- );
- var o={el:document.body};
- var sssc=function(tagName,id,className,parent){
- let dddel;
- if(typeof parent==="object" ? (!parent.el) :true){
- parent=o;
- }
- dddel=document.createElement(tagName);
- id=(id===undefined) ? ("") : (id+"");
- dddel.id=id;
- className=(className===undefined) ? ("") : (className+"");
- dddel.className=className;
- parent.el.appendChild(dddel);
- if(!parent.els){parent.els={};}
- parent.els[id]={el:dddel};
- return parent.els[id];
- };
- var sssTemplate=function(dddtemplate,obj){
- dddtemplate=dddtemplate;
- let ftext="function(){let text=\""+dddtemplate.replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n")+"\";return text";
- for(let ii in obj){
- ftext+=".replace(/\\[="+ii+"=\\]/g,\""+obj[ii].replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n")+"\")";
- }
- let dddf;
- eval("dddf="+ftext+";};");
- return dddf();
- };
- var sssHide=function(obj){
- obj.el.remove();
- obj.hidden=true;
- };
- var sssShow=function(obj,parent){
- parent.el.appendChild(obj.el);
- obj.hidden=false;
- };
- /*616-286-8687*/
- var incorpHTML=function(obj,html){
- obj.el=html;
- obj.els=new arrMap();
- let dddels=html.children;
- if(dddels.length>0){
- for(let i=0,ii;i<dddels.length;i++){
- ii = dddels[i].id || i;
- obj.els.Set(ii,{});
- incorpHTML(obj.els.Get(ii),dddels[i]);
- }
- }
- }
- incorpHTML(o,document.body);
- / The functions are amazing! /;
- /* limits on size of arrays and strings */
- var ArrLimit=10000,StringLimit=80000, SStringLimit=100;
- /* nice functions { */
- const
- setSeed=function(n){r1=n;r2=n*77+3028493;},
- IF=function(n1,n2,n3){
- if(n1){
- if(typeof n2==="function"){
- n2=n2();
- }
- v.ELSE=false;
- return n2;
- }
- else{
- if(typeof n3==="function"){
- n3=n3();
- }
- v.ELSE=true;
- return n3;
- }
- },
- ELSEIF=function(n1,n2,n3){
- if(v.ELSE){
- if(n1){
- if(typeof n2==="function"){
- n2=n2();
- }
- v.ELSE=false;
- return n2;
- }
- else{
- if(typeof n2==="function"){
- n2=n2();
- }
- v.ELSE=true;
- return n2;
- }
- }
- else{
- if(typeof n2==="function"){
- n3=n3();
- }
- return n3;
- }
- },
- ELSE=function(n1,n2){
- if(v.ELSE){
- if(typeof n1==="function"){
- n1=n1();
- }
- v.ELSE=false;
- return n1;
- }
- else{
- if(typeof n2==="function"){
- n2=n2();
- }
- return n2;
- }
- },
- FOR=function(n1,n2,n3){
- if(typeof n3==="function"){
- for(
- let i=n1,ii=1;
- i<n2 && t2<500;
- t2=((new Date()).getTime())-t1
- ){
- while(i<ii){n3();i++;}
- ii*=2;
- }
- }
- else{
- return n3;
- }
- },
- /*while and for loops are only allowed to run for (at most) 2 seconds*/
- WHILE=function(n1,n2){
- if(typeof n2==="function"){
- if(typeof n1==="function"){
- for(
- let i=0,ii=1;
- t2<500;
- t2=((new Date()).getTime())-t1
- ){
- while(i<ii && n1()){n2();i++;}
- ii*=2;
- }
- }
- else{
- for(
- let i=0,ii=1;
- i<n1 && t2<500;
- t2=((new Date()).getTime())-t1
- ){
- while(i<ii){n2();i++;}
- ii*=2;
- }
- }
- }
- else{
- return n2;
- }
- },
- ABS=function(n){return (n<0) ? -n : n ;},
- FLOOR=function(n){return Math.floor(n);},
- CEIL=function(n){return Math.ceil(n);},
- ROUND=function(n){return Math.round(n);},
- STRING=function(n){
- n=""+n;
- return n.slice(0,Math.min(n.length,StringLimit));
- },
- SSTRING=function(n){
- n=""+n;
- return n.slice(0,Math.min(n.length,SStringLimit));
- },
- NUMBER=function(n){
- if(n===null || n===undefined || typeof n==="function"){return 0;}
- else if(typeof n==="string"){return Number(n);}
- else if(typeof n==="object"){
- if(length in n){return n.length;}
- return NaN;
- }
- else{return n+0;}
- },
- SVAR=function(n1,n2){
- v[STRING(n1)]=n2;
- return n2;
- },
- GVAR=function(n1){return v[STRING(n1)];},
- TYPEOF=function(n){return typeof n;},
- NOT=function(n){return !n;},
- ARRAY=function(){
- let n=arguments,arr=[];
- for(let i=0;i<n;i++){
- arr[i]=n[i];
- }
- return arr;
- },
- CONCAT=function(){
- let arr=[];
- for(let i=0;i<arguments.length;i++){
- if(Array.isArray(arguments[i])){
- arr=arr.concat(arguments[i]);
- }
- }
- },
- CALL=function(n1){
- if(typeof n1!="function"){return n1;}
- let arr=[];
- for(let i=1;i<ArrLimit && i<arguments.length;i++){
- arr[i-1]=arguments[i];
- }
- n1(...arr);
- },
- ELABLE=function(n){
- return ( typeof n === "object" && n !== null ) ? ( typeof n.el === "object" && n !== null && ( ( typeof n.els === "object" && n !== null ) ? ( n.els.class === "arrMap" ) : false ) ) : false;
- },
- PROPABLE=function(n){
- return !( n===undefined || n===null || n===true || n===false );
- },
- GETEL=function( obj ){
- let arg = arguments, i = 1;
- if( Array.isArray( arg[1] ) ){
- arg = arg[1];
- i = 0;
- }
- let currentObj = obj, currentProp = obj;
- if( ELABLE( currentObj ) ){
- while( i<arg.length ){
- currentProp = currentObj?.els?.Get( arg[i] );
- if( ELABLE( currentProp ) ){
- currentObj = currentProp;
- }
- else{
- i=arg.length;
- }
- i++;
- }
- return currentProp;
- }
- },
- SETEL=function( obj ){
- let arg = arguments, i = 1;
- if( Array.isArray( arg[1] ) ){
- arg = arg[1];
- i = 0;
- }
- let currentObj = obj, currentProp = obj;
- if( ELABLE( currentObj ) && arg.length>1 ){
- while( i<arg.length-2 ){
- currentProp = currentObj?.els?.Get( arg[i] );
- if( ELABLE( currentProp ) ){
- currentObj = currentProp;
- }
- else{
- i=arg.length;
- }
- i++;
- }
- currentObj?.els?.Set( arg[i] , arg[i+1] );
- return arg[ i+1 ];
- }
- },
- HASEL=function( obj ){
- let arg = arguments, i = 1, hasProp = true;
- if( Array.isArray( arg[1] ) ){
- arg = arg[1];
- i = 0;
- }
- let currentObj = obj, currentProp = obj;
- if( ELABLE( currentObj ) ){
- while( i<arg.length ){
- currentProp = currentObj?.els?.Get( arg[i] );
- if( ELABLE( currentProp ) ){
- currentObj = currentProp;
- }
- else{
- hasProp = false;
- i = arg.length;
- }
- i++;
- }
- return hasProp;
- }
- },
- GETELS=function( obj ){
- let arg = arguments, i = 1;
- if( Array.isArray( arg[1] ) ){
- arg = arg[1];
- i = 0;
- }
- let currentObj = obj, currentProp = obj;
- if( ELABLE( currentObj ) ){
- while( i<arg.length ){
- currentProp = currentObj?.els?.Get( arg[i] );
- if( ELABLE( currentProp ) ){
- currentObj = currentProp;
- }
- else{
- currentProp = currentObj;
- i=arg.length;
- }
- i++;
- }
- return currentProp;
- }
- },
- SETELS=function( obj ){
- let arg = arguments, i = 1, setmode = false;
- if( Array.isArray( arg[1] ) ){
- arg = arg[1];
- i = 0;
- }
- let currentObj = obj, currentProp = obj;
- if( ELABLE( currentObj ) && arg.length>1 ){
- while( i<arg.length-2 ){
- if( setmode ){
- currentProp = { el:document.createElement("div") , els:new arrMap() };
- currentObj.els.Set( arg[i] , currentProp);
- currentObj = currentProp;
- }
- else{
- currentProp = currentObj?.els?.Get( arg[i] );
- if( ELABLE( currentProp ) ){
- currentObj = currentProp;
- }
- else{
- setmode = true;
- i--;
- }
- }
- i++;
- }
- currentProp?.els?.Set( arg[i] , arg[ i+1 ] );
- return arg[ i+1 ];
- }
- },
- GETPROP=function( obj ){
- let arg = arguments, i = 1;
- if( Array.isArray( arg[1] ) ){
- arg = arg[1];
- i = 0;
- }
- let currentObj = obj, currentProp = obj;
- if( PROPABLE( currentObj ) ){
- while( i<arg.length ){
- currentProp = currentObj[arg[i]];
- if( PROPABLE( currentProp ) ){
- currentObj = currentProp;
- }
- else{
- i=arg.length;
- }
- i++;
- }
- return currentProp;
- }
- },
- SETPROP=function( obj ){
- let arg = arguments, i = 1;
- if( Array.isArray( arg[1] ) ){
- arg = arg[1];
- i = 0;
- }
- let currentObj = obj, currentProp = obj;
- if( PROPABLE( currentObj ) && arg.length>1 ){
- while( i<arg.length-2 ){
- currentProp = currentObj[arg[i]];
- if( PROPABLE( currentProp ) ){
- currentObj = currentProp;
- }
- else{
- i=arg.length;
- }
- i++;
- }
- currentProp[ arg[i] ] = arg[ i+1 ];
- return arg[ i+1 ];
- }
- },
- HASPROP=function( obj ){
- let arg = arguments, i = 1, hasProp = true;
- if( Array.isArray( arg[1] ) ){
- arg = arg[1];
- i = 0;
- }
- let currentObj = obj, currentProp = obj;
- if( PROPABLE( currentObj ) ){
- while( i<arg.length ){
- currentProp = currentObj[arg[i]];
- if( PROPABLE( currentProp ) ){
- currentObj = currentProp;
- }
- else{
- if( i<arg.length-1 || currentProp === undefined ){
- hasProp = false;
- }
- i = arg.length;
- }
- i++;
- }
- return hasProp;
- }
- },
- GETPROPS=function( obj ){
- let arg = arguments, i = 1;
- if( Array.isArray( arg[1] ) ){
- arg = arg[1];
- i = 0;
- }
- let currentObj = obj, currentProp = obj;
- if( PROPABLE( currentObj ) ){
- while( i<arg.length ){
- currentProp = currentObj[arg[i]];
- if( PROPABLE( currentProp ) ){
- currentObj = currentProp;
- }
- else{
- currentProp = currentObj;
- i=arg.length;
- }
- i++;
- }
- return currentProp;
- }
- },
- SETPROPS=function( obj ){
- let arg = arguments, i = 1, setmode = false;
- if( Array.isArray( arg[1] ) ){
- arg = arg[1];
- i = 0;
- }
- let currentObj = obj, currentProp = obj;
- if( PROPABLE( currentObj ) && arg.length>1 ){
- while( i<arg.length-2 ){
- if( setmode ){
- currentProp = {};
- currentObj[ arg[i] ] = currentProp;
- currentObj = currentProp;
- }
- else{
- currentProp = currentObj[arg[i]];
- if( PROPABLE( currentProp ) ){
- currentObj = currentProp;
- }
- else{
- setmode = true;
- i--;
- }
- }
- i++;
- }
- currentProp[ arg[i] ] = arg[ i+1 ];
- return arg[ i+1 ];
- }
- }
- ;
- /* converts text into a valid HTML id */
- var text2id=function(text){
- text=text.split("-").join("--");
- for(let i=0;i<id2js.length;i++){
- text=text.split(id2js[i][0]).join("-"+id2js[i][1]);
- }
- /*every other weird unicode character*/
- let m=text.match(/[\u0000-\u001f\u007f-\uffff]/g);
- for(let i=0;i<m.length;i++){
- text=text.replace(m[i],"-"+padText(getCharCode(m[i]).toString(16).toUpperCase(),"0",4));
- }
- return text;
- };
- /* converts text into a valid JavaScript property value */
- var text2js=function(){
- text=text.split("$").join("$$");
- for(let i=0;i<id2js.length;i++){
- text=text.split(id2js[i][0]).join("$"+id2js[i][1]);
- }
- /*every other weird unicode character*/
- let m=text.match(/[\u0000-\u001f\u007f-\uffff]/g);
- for(let i=0;i<m.length;i++){
- text=text.replace(m[i],"$"+padText(getCharCode(m[i]).toString(16).toUpperCase(),"0",4));
- }
- return text;
- };
- /* converts speically formatted js prop name to text */
- var js2text=function(text){
- for(let i=0;i<id2js.length;i++){
- text=text.split("$"+id2js[i][1]).join(id2js[i][0]);
- }
- /*every other weird unicode character*/
- let m = text.match(/\$[0-9A-F]{4}/g) || [];
- for(let i=0;i<m.length;i++){
- text=text.replace(m[i],String.fromCharCode(Number(m[i].slice(1))));
- }
- return text;
- };
- /* converts specially formatted HTML id to text */
- var id2text=function(text){
- for(let i=0;i<id2js.length;i++){
- text=text.split("-"+id2js[i][1]).join(id2js[i][0]);
- }
- /*every other weird unicode character*/
- let m = text.match(/-[0-9A-F]{4}/g) || [];
- for(let i=0;i<m.length;i++){console.log(fromHex(m[i].slice(1)));
- text=text.replace(m[i],String.fromCharCode(fromHex(m[i].slice(1))));
- }
- return text;
- };
- formatNumber=function(n,sDigits,format){
- if(n===Infinity||n===0||n===-Infinity){return ""+n;}
- const formats=[
- [/comma/i,-1],
- [/sho?a?rt/i,0],
- [/l+o+n+g+/i,1],
- 2
- ];
- let pow10 = Math.floor(Math.log(n)/Math.LN10)+1;
- format=IF(typeof format==="number",format,WHICH_TOKEN(format,formats));
- if(format===-1){
- let text="";let digits=0;
- if(n<0){n=-n;text+="-";}
- if(n<1){
- text+="0.";
- while(n>0){
- n*=10;
- text+=Math.floor(n%10);
- n%=1;
- }
- }
- else{
- while(n>0){
- digits++;
- text=(n%10)+((digits%3===0 && n>10)?",":"")+text;
- n=Math.floor(n/10);
- }
- }
- return text;
- }
- const arrs=(format===0) ? [
- ["", "U" ,"Du","T" ,"Qa","Qi","Sx","Sp","Oc","N" ],
- ["", "D" ,"Vg","Tg","Qg","Qq","Sx","Sp","Og","Ng","C" ],
- ["","K","M" ,"B" ,"T" ,"Qa","Qi","Sx","Sp","Oc","N" ]
- ] : [
- ["","Uno","Duo","Tre","Quatorro","Quinqua","Sexe","Septe","Octo","Nona"],
- ["","Dec","Vigint","Trigint","Quadragint","Quinquagint","Sexagint","Septagint","Octogint","Nonagint","Cent"],
- ["","Thousand","M","B","Tr","Quadr","Quint","Sext","Sept","Oct","Non"]
- ];
- let roundN = Math.round(n/Math.pow(10,(pow10-sDigits))) * Math.pow(10,(pow10-sDigits));
- n=(format<2) ? (
- String(
- roundN/(
- Math.pow(1000,Math.floor(
- (pow10-1)/3
- ))
- ) + " " +
- (
- pow10>33 ?
- (
- (
- ((pow10-4)%30) < 3 ?
- "" :
- arrs[0][Math.floor(((pow10-4)%30)/3)]
- ) +
- arrs[1][Math.floor((pow10-4)/30)]
- ) :
- IF(
- pow10>3,
- arrs[2][Math.floor((pow10-1)/3)],
- ""
- )
- )
- ).replace(/(\d+)\.\D/g,"$1 ") +
- (
- format===1 && pow10>6 ?
- "illion" :
- ""
- )
- ) : (
- roundN/Math.pow(10,pow10-1)+
- (
- pow10<2 && pow10>=1 ?
- "" :
- "E"+(pow10-1)
- )
- );
- return n;
- };
- const onMobile=(
- /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(navigator.userAgent||navigator.vendor||window.opera)
- );
Add Comment
Please, Sign In to add comment