📄 prototype.js
字号:
//Prototype 1.5.0//(c) 2005-2007 Sam Stephensonif(!window.z_prot_js){z_prot_js=true;var Prototype={Version:"1.5.0",ScriptFragment:"(?:<script.*?>)((\n|\r|.)*?)(?:</script>)",emptyFunction:function(){},K:function(x){return x;}};var Class={create:function(){return function(){this.initialize.apply(this,arguments);};}};Object.extend=function(_2,_3){for(var _4 in _3){_2[_4]=_3[_4];}return _2;};Object.extend(Object,{inspect:function(_5){try{if(_5===undefined){return "undefined";}if(_5===null){return "null";}return _5.inspect?_5.inspect():_5.toString();}catch(e){if(e instanceof RangeError){return "...";}throw e;}},keys:function(_6){var _7=[];for(var _8 in _6){_7.push(_8);}return _7;},values:function(_9){var _a=[];for(var _b in _9){_a.push(_9[_b]);}return _a;},clone:function(_c){return Object.extend({},_c);}});Function.prototype.bind=function(){var _d=this,_e=$A(arguments),_f=_e.shift();return function(){return _d.apply(_f,_e.concat($A(arguments)));};};Function.prototype.bindAsEventListener=function(_10){var _11=this,_12=$A(arguments),_10=_12.shift();return function(_13){return _11.apply(_10,[(_13||window.event)].concat(_12).concat($A(arguments)));};};Object.extend(Number.prototype,{toColorPart:function(){var _14=this.toString(16);if(this<16){return "0"+_14;}return _14;},succ:function(){return this+1;},times:function(_15){$R(0,this,true).each(_15);return this;}});String.interpret=function(_16){return _16==null?"":String(_16);};Object.extend(String.prototype,{gsub:function(_17,_18){var _19="",_1a=this,_1b;_18=arguments.callee.prepareReplacement(_18);while(_1a.length>0){if(_1b=_1a.match(_17)){_19+=_1a.slice(0,_1b.index);_19+=String.interpret(_18(_1b));_1a=_1a.slice(_1b.index+_1b[0].length);}else{_19+=_1a,_1a="";}}return _19;},sub:function(_1c,_1d,_1e){_1d=this.gsub.prepareReplacement(_1d);_1e=_1e===undefined?1:_1e;return this.gsub(_1c,function(_1f){if(--_1e<0){return _1f[0];}return _1d(_1f);});},strip:function(){return this.replace(/^\s+/,"").replace(/\s+$/,"");},toArray:function(){return this.split("");},succ:function(){return this.slice(0,this.length-1)+String.fromCharCode(this.charCodeAt(this.length-1)+1);},camelize:function(){var _20=this.split("-"),len=_20.length;if(len==1){return _20[0];}var _22=this.charAt(0)=="-"?_20[0].charAt(0).toUpperCase()+_20[0].substring(1):_20[0];for(var i=1;i<len;i++){_22+=_20[i].charAt(0).toUpperCase()+_20[i].substring(1);}return _22;},capitalize:function(){return this.charAt(0).toUpperCase()+this.substring(1).toLowerCase();},underscore:function(){return this.gsub(/::/,"/").gsub(/([A-Z]+)([A-Z][a-z])/,"#{1}_#{2}").gsub(/([a-z\d])([A-Z])/,"#{1}_#{2}").gsub(/-/,"_").toLowerCase();},dasherize:function(){return this.gsub(/_/,"-");},inspect:function(_24){var _25=this.replace(/\\/g,"\\\\");if(_24){return "\""+_25.replace(/"/g,"\\\"")+"\"";}else{return "'"+_25.replace(/'/g,"\\'")+"'";}}});String.prototype.gsub.prepareReplacement=function(_26){if(typeof _26=="function"){return _26;}var _27=new Template(_26);return function(_28){return _27.evaluate(_28);};};var Template=Class.create();Template.Pattern=/(^|.|\r|\n)(#\{(.*?)\})/;Template.prototype={initialize:function(_29,_2a){this.template=_29.toString();this.pattern=_2a||Template.Pattern;},evaluate:function(_2b){return this.template.gsub(this.pattern,function(_2c){var _2d=_2c[1];if(_2d=="\\"){return _2c[2];}return _2d+String.interpret(_2b[_2c[3]]);});}};var $break=new Object();var $continue=new Object();var Enumerable={each:function(_2e){var _2f=0;try{this._each(function(_30){try{_2e(_30,_2f++);}catch(e){if(e!=$continue){throw e;}}});}catch(e){if(e!=$break){throw e;}}return this;},collect:function(_31){var _32=[];this.each(function(_33,_34){_32.push((_31||Prototype.K)(_33,_34));});return _32;},detect:function(_35){var _36;this.each(function(_37,_38){if(_35(_37,_38)){_36=_37;throw $break;}});return _36;},findAll:function(_39){var _3a=[];this.each(function(_3b,_3c){if(_39(_3b,_3c)){_3a.push(_3b);}});return _3a;},include:function(_3d){var _3e=false;this.each(function(_3f){if(_3f==_3d){_3e=true;throw $break;}});return _3e;},inject:function(_40,_41){this.each(function(_42,_43){_40=_41(_40,_42,_43);});return _40;},invoke:function(_44){var _45=$A(arguments).slice(1);return this.map(function(_46){return _46[_44].apply(_46,_45);});},max:function(_47){var _48;this.each(function(_49,_4a){_49=(_47||Prototype.K)(_49,_4a);if(_48==undefined||_49>=_48){_48=_49;}});return _48;},pluck:function(_4b){var _4c=[];this.each(function(_4d,_4e){_4c.push(_4d[_4b]);});return _4c;},reject:function(_4f){var _50=[];this.each(function(_51,_52){if(!_4f(_51,_52)){_50.push(_51);}});return _50;},toArray:function(){return this.map();}};Object.extend(Enumerable,{map:Enumerable.collect,find:Enumerable.detect,select:Enumerable.findAll,member:Enumerable.include,entries:Enumerable.toArray});var $A=Array.from=function(_53){if(!_53){return [];}if(_53.toArray){return _53.toArray();}else{var _54=[];for(var i=0,_56=_53.length;i<_56;i++){_54.push(_53[i]);}return _54;}};Object.extend(Array.prototype,Enumerable);if(!Array.prototype._reverse){Array.prototype._reverse=Array.prototype.reverse;}Object.extend(Array.prototype,{_each:function(_57){for(var i=0,_59=this.length;i<_59;i++){_57(this[i]);}},first:function(){return this[0];},flatten:function(){return this.inject([],function(_5a,_5b){return _5a.concat(_5b&&_5b.constructor==Array?_5b.flatten():[_5b]);});},without:function(){var _5c=$A(arguments);return this.select(function(_5d){return !_5c.include(_5d);});},reverse:function(_5e){return (_5e!==false?this:this.toArray())._reverse();},clone:function(){return [].concat(this);},inspect:function(){return "["+this.map(Object.inspect).join(", ")+"]";}});Array.prototype.toArray=Array.prototype.clone;function $w(_5f){_5f=_5f.strip();return _5f?_5f.split(/\s+/):[];}if(window.opera){Array.prototype.concat=function(){var _60=[];for(var i=0,_62=this.length;i<_62;i++){_60.push(this[i]);}for(var i=0,_62=arguments.length;i<_62;i++){if(arguments[i].constructor==Array){for(var j=0,_64=arguments[i].length;j<_64;j++){_60.push(arguments[i][j]);}}else{_60.push(arguments[i]);}}return _60;};}var Hash=function(obj){Object.extend(this,obj||{});};Object.extend(Hash.prototype,Enumerable);Object.extend(Hash.prototype,{_each:function(_66){for(var key in this){var _68=this[key];if(_68&&_68==Hash.prototype[key]){continue;}var _69=[key,_68];_69.key=key;_69.value=_68;_66(_69);}},keys:function(){return this.pluck("key");},values:function(){return this.pluck("value");},remove:function(){var _6a;for(var i=0,_6c=arguments.length;i<_6c;i++){var _6d=this[arguments[i]];if(_6d!==undefined){if(_6a===undefined){_6a=_6d;}else{if(_6a.constructor!=Array){_6a=[_6a];}_6a.push(_6d);}}delete this[arguments[i]];}return _6a;}});function $H(_6e){if(_6e&&_6e.constructor==Hash){return _6e;}return new Hash(_6e);}ObjectRange=Class.create();Object.extend(ObjectRange.prototype,Enumerable);Object.extend(ObjectRange.prototype,{initialize:function(_6f,end,_71){this.start=_6f;this.end=end;this.exclusive=_71;},_each:function(_72){var _73=this.start;while(this.include(_73)){_72(_73);_73=_73.succ();}},include:function(_74){if(_74<this.start){return false;}if(this.exclusive){return _74<this.end;}return _74<=this.end;}});var $R=function(_75,end,_77){return new ObjectRange(_75,end,_77);};function $(_78){if(arguments.length>1){for(var i=0,_7a=[],_7b=arguments.length;i<_7b;i++){_7a.push($(arguments[i]));}return _7a;}if(typeof _78=="string"){_78=document.getElementById(_78);}return Element.extend(_78);}if(!window.Element){var Element=new Object();}Element.extend=function(_7c){if(!_7c||_nativeExtensions||_7c.nodeType==3){return _7c;}if(!_7c._extended&&_7c.tagName&&_7c!=window){var _7d=Object.clone(Element.Methods),_7e=Element.extend.cache;for(var _7f in _7d){var _80=_7d[_7f];if(typeof _80=="function"&&!(_7f in _7c)){_7c[_7f]=_7e.findOrStore(_80);}}}_7c._extended=true;return _7c;};Element.extend.cache={findOrStore:function(_81){return this[_81]=this[_81]||function(){return _81.apply(null,[this].concat($A(arguments)));};}};Element.Methods={visible:function(_82){return $(_82).style.display!="none";},toggle:function(_83){_83=$(_83);Element[Element.visible(_83)?"hide":"show"](_83);return _83;},hide:function(_84){$(_84).style.display="none";return _84;},show:function(_85){$(_85).style.display="";return _85;},remove:function(_86){_86=$(_86);_86.parentNode.removeChild(_86);return _86;},descendants:function(_87){return $A($(_87).getElementsByTagName("*"));},match:function(_88,_89){if(typeof _89=="string"){_89=new Selector(_89);}return _89.match($(_88));},down:function(_8a,_8b,_8c){return Selector.findElement($(_8a).descendants(),_8b,_8c);},readAttribute:function(_8d,_8e){_8d=$(_8d);if(document.all&&!window.opera){var t=Element._attributeTranslations;if(t.values[_8e]){return t.values[_8e](_8d,_8e);}if(t.names[_8e]){_8e=t.names[_8e];}var _90=_8d.attributes[_8e];if(_90){return _90.nodeValue;}}return _8d.getAttribute(_8e);},classNames:function(_91){return new Element.ClassNames(_91);},hasClassName:function(_92,_93){if(!(_92=$(_92))){return;}var _94=_92.className;if(_94.length==0){return false;}if(_94==_93||_94.match(new RegExp("(^|\\s)"+_93+"(\\s|$)"))){return true;}return false;},addClassName:function(_95,_96){if(!(_95=$(_95))){return;}Element.classNames(_95).add(_96);return _95;},removeClassName:function(_97,_98){if(!(_97=$(_97))){return;}Element.classNames(_97).remove(_98);return _97;},observe:function(){Event.observe.apply(Event,arguments);return $A(arguments).first();},stopObserving:function(){Event.stopObserving.apply(Event,arguments);return $A(arguments).first();},cleanWhitespace:function(_99){_99=$(_99);var _9a=_99.firstChild;while(_9a){var _9b=_9a.nextSibling;if(_9a.nodeType==3&&!/\S/.test(_9a.nodeValue)){_99.removeChild(_9a);}_9a=_9b;}return _99;},descendantOf:function(_9c,_9d){_9c=$(_9c),_9d=$(_9d);while(_9c=_9c.parentNode){if(_9c==_9d){return true;}}return false;},scrollTo:function(_9e){_9e=$(_9e);var pos=Position.cumulativeOffset(_9e);window.scrollTo(pos[0],pos[1]);return _9e;},getStyle:function(_a0,_a1){_a0=$(_a0);if(["float","cssFloat"].include(_a1)){_a1=(typeof _a0.style.styleFloat!="undefined"?"styleFloat":"cssFloat");}_a1=_a1.camelize();var _a2=_a0.style[_a1];if(!_a2){if(document.defaultView&&document.defaultView.getComputedStyle){var css=document.defaultView.getComputedStyle(_a0,null);_a2=css?css[_a1]:null;}else{if(_a0.currentStyle){_a2=_a0.currentStyle[_a1];}}}if((_a2=="auto")&&["width","height"].include(_a1)&&(_a0.getStyle("display")!="none")){_a2=_a0["offset"+_a1.capitalize()]+"px";}if(window.opera&&["left","top","right","bottom"].include(_a1)){if(Element.getStyle(_a0,"position")=="static"){_a2="auto";}}if(_a1=="opacity"){if(_a2){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -