📄 sscorlib.js
字号:
Array.prototype.enqueue=function(item){this.push(item);}if(!Array.prototype.every){Array.prototype.every=function(callback){for(var i=this.length-1;i>=0;i--){if(!callback(this[i],i,this)){return false;}} return true;}}Array.prototype.extract=function(index,count){if(!count){return this.slice(index);} return this.slice(index,index+count);}if(!Array.prototype.filter){Array.prototype.filter=function(callback){var filtered=[];for(var i=0;i<this.length;i++){if(callback(this[i],i,this)){filtered.add(this[i]);}} return filtered;}}if(!Array.prototype.forEach){Array.prototype.forEach=function(callback){for(var i=0;i<this.length;i++){callback(this[i],i,this);}}}Array.prototype.groupBy=function(callback){var length=this.length;var groups=[];var keys={};for(var index=0;index<length;index++){var key=callback(this[index],index);if(String.isNullOrEmpty(key)){continue;} var items=keys[key];if(!items){items=[];items.key=key;keys[key]=items;groups.add(items);} items.add(this[index]);} return groups;}Array.prototype.index=function(callback){var length=this.length;var items={};for(var index=0;index<length;index++){var key=callback(this[index],index);if(String.isNullOrEmpty(key)){continue;} items[key]=this[index];} return items;}Array.prototype.indexOf=function(item){var length=this.length;if(length){for(var index=0;index<length;index++){if(this[index]===item){return index;}}} return-1;}Array.prototype.insert=function(index,item){this.splice(index,0,item);}Array.prototype.insertRange=function(index,items){this.splice(index,0,items);}if(!Array.prototype.map){Array.prototype.map=function(callback){var mapped=new Array(this.length);for(var i=this.length-1;i>=0;i--){mapped[i]=callback(this[i],i,this);} return mapped;}}Array.parse=function(s){return eval('('+s+')');}Array.prototype.remove=function(item){var index=this.indexOf(item);if(index>=0){this.splice(index,1);return true;} return false;}Array.prototype.removeAt=function(index){return this.splice(index,1)[0];}Array.prototype.removeRange=function(index,count){return this.splice(index,count);}if(!Array.prototype.some){Array.prototype.some=function(callback){for(var i=this.length-1;i>=0;i--){if(callback(this[i],i,this)){return true;}} return false;}}RegExp.__typeName='RegExp';RegExp.parse=function(s){if(s.startsWith('/')){var endSlashIndex=s.lastIndexOf('/');if(endSlashIndex>1){var expression=s.substring(1,endSlashIndex);var flags=s.substr(endSlashIndex+1);return new RegExp(expression,flags);}} return null;}Date.__typeName='Date';Date.get_now=function(){return new Date();}Date.get_today=function(){var d=new Date();return new Date(d.getFullYear(),d.getMonth(),d.getDate());}Date.prototype.format=function(format,useLocale){if(isNullOrUndefined(format)||(format.length==0)||(format=='i')){if(useLocale){return this.toLocaleString();} else{return this.toString();}} if(format=='id'){if(useLocale){return this.toLocaleDateString();} else{return this.toDateString();}} if(format=='it'){if(useLocale){return this.toLocaleTimeString();} else{return this.toTimeString();}} return this._netFormat(format,useLocale);}Date.prototype._netFormat=function(format,useLocale){var dtf=useLocale?CultureInfo.Current.dateFormat:CultureInfo.Neutral.dateFormat;var useUTC=false;if(format.length==1){switch(format){case'f':format=dtf.longDatePattern+' '+dtf.shortTimePattern;case'F':format=dtf.dateTimePattern;break;case'd':format=dtf.shortDatePattern;break;case'D':format=dtf.longDatePattern;break;case't':format=dtf.shortTimePattern;break;case'T':format=dtf.longTimePattern;break;case'g':format=dtf.shortDatePattern+' '+dtf.shortTimePattern;break;case'G':format=dtf.shortDatePattern+' '+dtf.longTimePattern;break;case'R':case'r':format=dtf.gmtDateTimePattern;useUTC=true;break;case'u':format=dtf.universalDateTimePattern;useUTC=true;break;case'U':format=dtf.dateTimePattern;useUTC=true;break;case's':format=dtf.sortableDateTimePattern;break;}} if(format.charAt(0)=='%'){format=format.substr(1);} if(!Date._formatRE){Date._formatRE=/dddd|ddd|dd|d|MMMM|MMM|MM|M|yyyy|yy|y|hh|h|HH|H|mm|m|ss|s|tt|t|fff|ff|f|zzz|zz|z/g;} var re=Date._formatRE;var sb=new StringBuilder();var dt=this;if(useUTC){dt=new Date(Date.UTC(dt.getUTCFullYear(),dt.getUTCMonth(),dt.getUTCDate(),dt.getUTCHours(),dt.getUTCMinutes(),dt.getUTCSeconds(),dt.getUTCMilliseconds()));} re.lastIndex=0;while(true){var index=re.lastIndex;var match=re.exec(format);sb.append(format.slice(index,match?match.index:format.length));if(!match){break;} var fs=match[0];var part=fs;switch(fs){case'dddd':part=dtf.dayNames[dt.getDay()];break;case'ddd':part=dtf.shortDayNames[dt.getDay()];break;case'dd':part=dt.getDay().toString().padLeft(2,'0');break;case'd':part=dt.getDay();break;case'MMMM':part=dtf.monthNames[dt.getMonth()];break;case'MMM':part=dtf.shortMonthNames[dt.getMonth()];break;case'MM':part=(dt.getMonth()+1).toString().padLeft(2,'0');break;case'M':part=(dt.getMonth()+1);break;case'yyyy':part=dt.getFullYear();break;case'yy':part=(dt.getFullYear()%100).toString().padLeft(2,'0');break;case'y':part=(dt.getFullYear()%100);break;case'h':case'hh':part=dt.getHours()%12;if(!part){part='12';} else if(fs=='hh'){part=part.toString().padLeft(2,'0');} break;case'HH':part=dt.getHours().toString().padLeft(2,'0');break;case'H':part=dt.getHours();break;case'mm':part=dt.getMinutes().toString().padLeft(2,'0');break;case'm':part=dt.getMinutes();break;case'ss':part=dt.getSeconds().toString().padLeft(2,'0');break;case's':part=dt.getSeconds();break;case't':case'tt':part=(dt.getHours()<12)?dtf.amDesignator:dtf.pmDesignator;if(fs=='t'){part=part.charAt(0);} break;case'fff':part=dt.getMilliseconds().toString().padLeft(3,'0');break;case'ff':part=dt.getMilliseconds().toString().padLeft(3).substr(0,2);break;case'f':part=dt.getMilliseconds().toString().padLeft(3).charAt(0);break;case'z':part=dt.getTimezoneOffset()/60;part=((part>=0)?'-':'+')+Math.floor(Math.abs(part));break;case'zz':case'zzz':part=dt.getTimezoneOffset()/60;part=((part>=0)?'-':'+')+Math.floor(Math.abs(part)).toString().padLeft(2,'0');if(fs=='zzz'){part+=dtf.timeSeparator+Math.abs(dt.getTimezoneOffset()%60).toString().padLeft(2,'0');} break;} sb.append(part);} return sb.toString();}Error.__typeName='Error';Error.create=function(message,userData,innerException){var e=new Error(message);if(userData){e.userData=userData;} if(innerException){e.innerException=innerException;} return e;}if(!Debug._fail){Debug._fail=function(message){Debug.writeln(message);eval('debugger;');}}Debug.assert=function(condition,message){if(!condition){message='Assert failed: '+message;if(confirm(message+'\r\n\r\nBreak into debugger?')){Debug._fail(message);}}}Debug._dumpCore=function(sb,object,name,indentation,dumpedObjects){if(object===null){sb.appendLine(indentation+name+': null');return;} switch(typeof(object)){case'undefined':sb.appendLine(indentation+name+': undefined');break;case'number':case'string':case'boolean':sb.appendLine(indentation+name+': '+object);break;default:if(Date.isInstance(object)||RegExp.isInstance(object)){sb.appendLine(indentation+name+': '+object);break;} if(dumpedObjects.contains(object)){sb.appendLine(indentation+name+': ...');break;} dumpedObjects.add(object);var type=Type.getInstanceType(object);var typeName=type.get_fullName();var recursiveIndentation=indentation+' ';if(IArray.isInstance(object)){sb.appendLine(indentation+name+': {'+typeName+'}');var length=object.getLength();for(var i=0;i<length;i++){Debug._dumpCore(sb,object.getItem(i),'['+i+']',recursiveIndentation,dumpedObjects);}} else{var td=TypeDescriptor._getObjectDescriptor(object);if(!td){if(object.tagName){sb.appendLine(indentation+name+': <'+object.tagName+'>');var attributes=object.attributes;for(var i=0;i<attributes.length;i++){var attrValue=attributes[i].nodeValue;if(attrValue){Debug._dumpCore(sb,attrValue,attributes[i].nodeName,recursiveIndentation,dumpedObjects);}}} else{sb.appendLine(indentation+name+': {'+typeName+'}');for(var field in object){var v=object[field];if(!Function.isInstance(v)){Debug._dumpCore(sb,v,field,recursiveIndentation,dumpedObjects);}}}} else{sb.appendLine(indentation+name+': {'+typeName+'}');var properties=td._properties;if(properties){for(var prop in properties){var propValue=TypeDescriptor.getProperty(object,prop);Debug._dumpCore(sb,propValue,prop,recursiveIndentation,dumpedObjects);}}}} dumpedObjects.remove(object);break;}}Debug.dump=function(object,name){if((!name||!name.length)&&(object!==null)){name=Type.getInstanceType(object).get_fullName();} if(!name||!name.length){return;} var sb=new StringBuilder();Debug._dumpCore(sb,object,name,'',[]);Debug.writeLine(sb.toString());}Debug.fail=function(message){Debug._fail(message);}Debug.inspect=function(object,name){var dumped=false;if(window.debugService){dumped=window.debugService.inspect(name,object);} if(!dumped){Debug.dump(object,name);}}Debug.writeLine=function(message){if(window.debugService){window.debugService.trace(message);return;} Debug.writeln(message);var traceTextBox=$('_traceTextBox');if(traceTextBox){traceTextBox.value=traceTextBox.value+'\r\n'+message;}}Debug.__typeName='Debug';var Type=Function;Type.__typeName='Type';var __Namespace=function(name){this.__typeName=name;}__Namespace.prototype={__namespace:true,getName:function(){return this.__typeName;}}Type.createNamespace=function(name){if(!window.__namespaces){window.__namespaces={};} if(!window.__rootNamespaces){window.__rootNamespaces=[];} if(window.__namespaces[name]){return;} var ns=window;var nameParts=name.split('.');for(var i=0;i<nameParts.length;i++){var part=nameParts[i];var nso=ns[part];if(!nso){ns[part]=nso=new __Namespace(nameParts.slice(0,i+1).join('.'));if(i==0){window.__rootNamespaces.add(nso);}} ns=nso;} window.__namespaces[name]=ns;}Type.prototype.createClass=function(name,baseType,interfaceType){this.prototype.constructor=this;this.__typeName=name;this.__class=true;this.__baseType=baseType||Object;if(baseType){this.__basePrototypePending=true;} if(interfaceType){this.__interfaces=[];for(var i=2;i<arguments.length;i++){interfaceType=arguments[i];this.__interfaces.add(interfaceType);}}}Type.prototype.createInterface=function(name){this.__typeName=name;this.__interface=true;}Type.prototype.createEnum=function(name,flags){for(var field in this.prototype){this[field]=this.prototype[field];} this.__typeName=name;this.__enum=true;if(flags){this.__flags=true;}}Type.prototype.setupBase=function(){if(this.__basePrototypePending){var baseType=this.__baseType;if(baseType.__basePrototypePending){baseType.setupBase();} for(var memberName in baseType.prototype){var memberValue=baseType.prototype[memberName];if(!this.prototype[memberName]){this.prototype[memberName]=memberValue;}} delete this.__basePrototypePending;}}Type.prototype.constructBase=function(instance,args){if(this.__basePrototypePending){this.setupBase();} if(!args){this.__baseType.apply(instance);} else{this.__baseType.apply(instance,args);}}Type.prototype.callBase=function(instance,name,args){var baseMethod=this.__baseType.prototype[name];if(!args){return baseMethod.apply(instance);} else{return baseMethod.apply(instance,args);}}Type.prototype.get_baseType=function(){return this.__baseType||null;}Type.prototype.get_fullName=function(){return this.__typeName;}Type.prototype.get_name=function(){var fullName=this.__typeName;var nsIndex=fullName.lastIndexOf('.');if(nsIndex>0){return fullName.substr(nsIndex+1);} return fullName;}Type.prototype.isInstance=function(instance){if(isNullOrUndefined(instance)){return false;} if((this==Object)||(instance instanceof this)){return true;} var type=Type.getInstanceType(instance);return this.isAssignableFrom(type);}Type.prototype.isAssignableFrom=function(type){if((this==Object)||(this==type)){return true;} if(this.__class){var baseType=type.__baseType;while(baseType){if(this==baseType){return true;} baseType=baseType.__baseType;}} else if(this.__interface){var interfaces=type.__interfaces;if(interfaces&&interfaces.contains(this)){return true;} var baseType=type.__baseType;while(baseType){interfaces=baseType.__interfaces;if(interfaces&&interfaces.contains(this)){return true;} baseType=baseType.__baseType;}} return false;}Type.isClass=function(type){return(type.__class==true);}Type.isEnum=function(type){return(type.__enum==true);}Type.isFlagsEnum=function(type){return((type.__enum==true)&&(type.__flags==true));}Type.isInterface=function(type){return(type.__interface==true);}Type.canCast=function(instance,type){return type.isInstance(instance);}Type.safeCast=function(instance,type){if(type.isInstance(instance)){return instance;} return null;}Type.getInstanceType=function(instance){var ctor=null;try{ctor=instance.constructor;} catch(ex){} if(!ctor||!ctor.__typeName){ctor=Object;} return ctor;}Type.getType=function(typeName){if(!typeName){return null;} if(!Type.__typeCache){Type.__typeCache={};} var type=Type.__typeCache[typeName];if(!type){type=eval(typeName);Type.__typeCache[typeName]=type;} return type;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -