📄 sscorlib.js
字号:
// Script# Core Runtime// Copyright (c) 2007, Nikhil Kothari. All Rights Reserved.// http://projects.nikhilk.net//function isUndefined(o){return(o===undefined);}function isNull(o){return(o===null);}function isNullOrUndefined(o){return(o===null)||(o===undefined);}function $(id){return document.getElementById(id);}document.getElementsBySelector=function(cssSelector,root){var all=root?root.getElementsByTagName('*'):document.getElementsByTagName('*');var matches=[];var styleSheet=document.getElementsBySelector.styleSheet;if(!styleSheet){var styleSheetNode=document.createElement('style');styleSheetNode.type='text/css';document.getElementsByTagName('head')[0].appendChild(styleSheetNode);styleSheet=styleSheetNode.styleSheet||styleSheetNode.sheet;document.getElementsBySelector.styleSheet=styleSheet;} if(window.navigator.userAgent.indexOf('MSIE')>=0){styleSheet.addRule(cssSelector,'ssCssMatch:true',0);for(var i=all.length-1;i>=0;i--){var element=all[i];if(element.currentStyle.ssCssMatch){matches[matches.length]=element;}} styleSheet.removeRule(0);} else{var matchValue=document.getElementsBySelector.matchValue;if(!matchValue){matchValue=(window.navigator.userAgent.indexOf('Opera')>=0)?'"ssCssMatch"':'ssCssMatch 1';document.getElementsBySelector.matchValue=matchValue;} styleSheet.insertRule(cssSelector+' { counter-increment: ssCssMatch }',0);var docView=document.defaultView;for(var i=all.length-1;i>=0;i--){var element=all[i];if(docView.getComputedStyle(element,null).counterIncrement===matchValue){matches[matches.length]=element;}} styleSheet.deleteRule(0);} if(matches.length>1){matches.reverse();} return matches;}Object.__typeName='Object';Object.__baseType=null;Object.parse=function(s){return eval(s);}Object.getKeyCount=function(d){var count=0;for(var n in d){count++;} return count;}Object.clearKeys=function(d){for(var n in d){delete d[n];}}Object.keyExists=function(d,key){return d[key]!==undefined;}Function.parse=function(s){if(!Function._parseCache){Function._parseCache={};} var fn=Function._parseCache[s];if(!fn){try{eval('fn = '+s);if(typeof(fn)!='function'){fn=null;} else{Function._parseCache[s]=fn;}} catch(ex){}} return fn;}Boolean.__typeName='Boolean';Boolean.parse=function(s){return(s.toLowerCase()=='true');}Number.__typeName='Number';Number.parse=function(s){if(!s||!s.length){return 0;} if((s.indexOf('.')>=0)||(s.indexOf('e')>=0)||s.endsWith('f')||s.endsWith('F')){return parseFloat(s);} return parseInt(s);}Number.prototype.format=function(format,useLocale){if(isNullOrUndefined(format)||(format.length==0)||(format=='i')){if(useLocale){return this.toLocaleString();} else{return this.toString();}} return this._netFormat(format,useLocale);}Number._commaFormat=function(number,groups,decimal,comma){var decimalPart=null;var decimalIndex=number.indexOf(decimal);if(decimalIndex>0){decimalPart=number.substr(decimalIndex);number=number.substr(0,decimalIndex);} var negative=number.startsWith('-');if(negative){number=number.substr(1);} var groupIndex=0;var groupSize=groups[groupIndex];if(number.length<groupSize){return decimalPart?number+decimalPart:number;} var index=number.length;var s='';var done=false;while(!done){var length=groupSize;var startIndex=index-length;if(startIndex<0){groupSize+=startIndex;length+=startIndex;startIndex=0;done=true;} if(!length){break;} var part=number.substr(startIndex,length);if(s.length){s=part+comma+s;} else{s=part;} index-=length;if(groupIndex<groups.length-1){groupIndex++;groupSize=groups[groupIndex];}} if(negative){s='-'+s;} return decimalPart?s+decimalPart:s;}Number.prototype._netFormat=function(format,useLocale){var nf=useLocale?CultureInfo.Current.numberFormat:CultureInfo.Neutral.numberFormat;var s='';var precision=-1;if(format.length>1){precision=parseInt(format.substr(1));} var fs=format.charAt(0);switch(fs){case'd':case'D':s=parseInt(Math.abs(this)).toString();if(precision!=-1){s=s.padLeft(precision,'0');} if(this<0){s='-'+s;} break;case'x':case'X':s=parseInt(Math.abs(this)).toString(16);if(fs=='X'){s=s.toUpperCase();} if(precision!=-1){s=s.padLeft(precision,'0');} break;case'e':case'E':if(precision==-1){s=this.toExponential();} else{s=this.toExponential(precision);} if(fs=='E'){s=s.toUpperCase();} break;case'f':case'F':case'n':case'N':if(precision==-1){precision=nf.numberDecimalDigits;} s=this.toFixed(precision).toString();if(precision&&(nf.numberDecimalSeparator!='.')){var index=s.indexOf('.');s=s.substr(0,index)+nf.numberDecimalSeparator+s.substr(index+1);} if((fs=='n')||(fs=='N')){s=Number._commaFormat(s,nf.numberGroupSizes,nf.numberDecimalSeparator,nf.numberGroupSeparator);} break;case'c':case'C':if(precision==-1){precision=nf.currencyDecimalDigits;} s=Math.abs(this).toFixed(precision).toString();if(precision&&(nf.currencyDecimalSeparator!='.')){var index=s.indexOf('.');s=s.substr(0,index)+nf.currencyDecimalSeparator+s.substr(index+1);} s=Number._commaFormat(s,nf.currencyGroupSizes,nf.currencyDecimalSeparator,nf.currencyGroupSeparator);if(this<0){s=String.format(nf.currencyNegativePattern,s);} else{s=String.format(nf.currencyPositivePattern,s);} break;case'p':case'P':if(precision==-1){precision=nf.percentDecimalDigits;} s=(Math.abs(this)*100.0).toFixed(precision).toString();if(precision&&(nf.percentDecimalSeparator!='.')){var index=s.indexOf('.');s=s.substr(0,index)+nf.percentDecimalSeparator+s.substr(index+1);} s=Number._commaFormat(s,nf.percentGroupSizes,nf.percentDecimalSeparator,nf.percentGroupSeparator);if(this<0){s=String.format(nf.percentNegativePattern,s);} else{s=String.format(nf.percentPositivePattern,s);} break;} return s;}Math.truncate=function(n){return(n>=0)?Math.floor(n):Math.ceil(n);}String.__typeName='String';String.Empty='';String.compare=function(s1,s2,ignoreCase){if(ignoreCase){if(s1){s1=s1.toUpperCase();} if(s2){s2=s2.toUpperCase();}} s1=s1||'';s2=s2||'';if(s1==s2){return 0;} if(s1<s2){return-1;} return 1;}String.prototype.compareTo=function(s,ignoreCase){return String.compare(this,s,ignoreCase);}String.prototype.endsWith=function(suffix){if(!suffix.length){return true;} if(suffix.length>this.length){return false;} return(this.substr(this.length-suffix.length)==suffix);}String.equals=function(s1,s2,ignoreCase){return String.compare(s1,s2,ignoreCase)==0;}String._format=function(format,values,useLocale){if(!String._formatRE){String._formatRE=/(\{[^\}^\{]+\})/g;} return format.replace(String._formatRE,function(str,m){var index=parseInt(m.substr(1));var value=values[index+1];if(isNullOrUndefined(value)){return'';} if(value.format){var formatSpec=null;var formatIndex=m.indexOf(':');if(formatIndex>0){formatSpec=m.substring(formatIndex+1,m.length-1);} return value.format.call(value,formatSpec,useLocale);} else{if(useLocale){return value.toLocaleString();} return value.toString();}});}String.format=function(format){return String._format(format,arguments,false);}String.fromChar=function(ch,count){var s=ch;for(var i=1;i<count;i++){s+=ch;} return s;}String.prototype.htmlDecode=function(){if(!String._htmlDecRE){String._htmlDecMap={'&':'&','<':'<','>':'>','"':'"'};String._htmlDecRE=/(&|<|>|")/gi;} var s=this;s=s.replace(String._htmlDecRE,function(str,m){return String._htmlDecMap[m];});return s;}String.prototype.htmlEncode=function(){if(!String._htmlEncRE){String._htmlEncMap={'&':'&','<':'<','>':'>','"':'"'};String._htmlEncRE=/([&<>"])/g;} var s=this;if(String._htmlEncRE.test(s)){s=s.replace(String._htmlEncRE,function(str,m){return String._htmlEncMap[m];});} return s;}String.prototype.indexOfAny=function(chars,startIndex,count){var length=this.length;if(!length){return-1;} startIndex=startIndex||0;count=count||length;var endIndex=startIndex+count-1;if(endIndex>=length){endIndex=length-1;} for(var i=startIndex;i<=endIndex;i++){if(chars.indexOf(this.charAt(i))>=0){return i;}} return-1;}String.prototype.insert=function(index,value){if(!value){return this;} if(!index){return value+this;} var s1=this.substr(0,index);var s2=this.substr(index);return s1+value+s2;}String.isNullOrEmpty=function(s){return!s||!s.length;}String.prototype.lastIndexOfAny=function(chars,startIndex,count){var length=this.length;if(!length){return-1;} startIndex=startIndex||length-1;count=count||length;var endIndex=startIndex-count+1;if(endIndex<0){endIndex=0;} for(var i=startIndex;i>=endIndex;i--){if(chars.indexOf(this.charAt(i))>=0){return i;}} return-1;}String.localeFormat=function(format){return String._format(format,arguments,true);}String.prototype.padLeft=function(totalWidth,ch){if(this.length<totalWidth){ch=ch||' ';return String.fromChar(ch,totalWidth-this.length)+this;} return this;}String.prototype.padRight=function(totalWidth,ch){if(this.length<totalWidth){ch=ch||' ';return this+String.fromChar(ch,totalWidth-this.length);} return this;}String.prototype.quote=function(){if(!String._quoteMap){String._quoteMap={'\\':'\\\\','\'':'\\\'','"':'\\"','\r':'\\r','\n':'\\n','\t':'\\t','\f':'\\f','\b':'\\b'};String._quoteRE=new RegExp("([\'\"\\\x00-\x1F\x7F-\uFFFF])","g");} var s=this;if(String._quoteRE.test(s)){s=this.replace(String._quoteRE,function(str,m){var c=String._quoteMap[m];if(c){return c;} c=m.charCodeAt(0);return'\\u'+c.toString(16).toUpperCase().padLeft(4,'0');});} return'"'+s+'"';}String.prototype.remove=function(index,count){if(!count||((index+count)>this.length)){return this.substr(0,index);} return this.substr(0,index)+this.substr(index+count);}String.prototype._replace=String.prototype.replace;String.prototype.replace=function(oldValue,newValue){if(oldValue.constructor==String){newValue=newValue||'';return this.split(oldValue).join(newValue);} return String.prototype._replace.call(this,oldValue,newValue);}String.prototype.startsWith=function(prefix){if(!prefix.length){return true;} if(prefix.length>this.length){return false;} return(this.substr(0,prefix.length)==prefix);}String.prototype.trim=function(){return this.trimEnd().trimStart();}String.prototype.trimEnd=function(){return this.replace(/\s*$/,'');}String.prototype.trimStart=function(){return this.replace(/^\s*/,'');}String.prototype.unquote=function(){return eval('('+this+')');}Array.__typeName='Array';Array.prototype.add=function(item){this[this.length]=item;}Array.prototype.addRange=function(items){if(!items){return;} var length=items.length;for(var index=0;index<length;index++){this[this.length]=items[index];}}Array.prototype.aggregate=function(seed,callback){var length=this.length;for(var index=0;index<length;index++){seed=callback(seed,this[index],index,this);} return seed;}Array.prototype.clear=function(){if(this.length>0){this.splice(0,this.length);}}Array.prototype.clone=function(){var length=this.length;var array=new Array(length);for(var index=0;index<length;index++){array[index]=this[index];} return array;}Array.prototype.contains=function(item){var index=this.indexOf(item);return(index>=0);}Array.prototype.dequeue=function(){return this.shift();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -