⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mochikit.js

📁 Ajax下日志框架
💻 JS
📖 第 1 页 / 共 5 页
字号:
if(m.isArrayLike(_161)){return m.concat(_161);}}var self=MochiKit.Iter;_161=self.iter(_161);var rval=[];try{while(true){rval.push(_161.next());}}catch(e){if(e!=self.StopIteration){throw e;}return rval;}return undefined;},reduce:function(fn,_162,_163){var i=0;var x=_163;var self=MochiKit.Iter;_162=self.iter(_162);if(arguments.length<3){try{x=_162.next();}catch(e){if(e==self.StopIteration){e=new TypeError("reduce() of empty sequence with no initial value");}throw e;}i++;}try{while(true){x=fn(x,_162.next());}}catch(e){if(e!=self.StopIteration){throw e;}}return x;},range:function(){var _165=0;var stop=0;var step=1;if(arguments.length==1){stop=arguments[0];}else{if(arguments.length==2){_165=arguments[0];stop=arguments[1];}else{if(arguments.length==3){_165=arguments[0];stop=arguments[1];step=arguments[2];}else{throw new TypeError("range() takes 1, 2, or 3 arguments!");}}}if(step===0){throw new TypeError("range() step must not be 0");}return {next:function(){if((step>0&&_165>=stop)||(step<0&&_165<=stop)){throw MochiKit.Iter.StopIteration;}var rval=_165;_165+=step;return rval;},repr:function(){return "range("+[_165,stop,step].join(", ")+")";},toString:MochiKit.Base.forwardCall("repr")};},sum:function(_166,_167){var x=_167||0;var self=MochiKit.Iter;_166=self.iter(_166);try{while(true){x+=_166.next();}}catch(e){if(e!=self.StopIteration){throw e;}}return x;},exhaust:function(_168){var self=MochiKit.Iter;_168=self.iter(_168);try{while(true){_168.next();}}catch(e){if(e!=self.StopIteration){throw e;}}},forEach:function(_169,func,self){var m=MochiKit.Base;if(arguments.length>2){func=m.bind(func,self);}if(m.isArrayLike(_169)){try{for(var i=0;i<_169.length;i++){func(_169[i]);}}catch(e){if(e!=MochiKit.Iter.StopIteration){throw e;}}}else{self=MochiKit.Iter;self.exhaust(self.imap(func,_169));}},every:function(_171,func){var self=MochiKit.Iter;try{self.ifilterfalse(func,_171).next();return false;}catch(e){if(e!=self.StopIteration){throw e;}return true;}},sorted:function(_172,cmp){var rval=MochiKit.Iter.list(_172);if(arguments.length==1){cmp=MochiKit.Base.compare;}rval.sort(cmp);return rval;},reversed:function(_173){var rval=MochiKit.Iter.list(_173);rval.reverse();return rval;},some:function(_174,func){var self=MochiKit.Iter;try{self.ifilter(func,_174).next();return true;}catch(e){if(e!=self.StopIteration){throw e;}return false;}},iextend:function(lst,_175){if(MochiKit.Base.isArrayLike(_175)){for(var i=0;i<_175.length;i++){lst.push(_175[i]);}}else{var self=MochiKit.Iter;_175=self.iter(_175);try{while(true){lst.push(_175.next());}}catch(e){if(e!=self.StopIteration){throw e;}}}return lst;},groupby:function(_176,_177){var m=MochiKit.Base;var self=MochiKit.Iter;if(arguments.length<2){_177=m.operator.identity;}_176=self.iter(_176);var pk=undefined;var k=undefined;var v;function fetch(){v=_176.next();k=_177(v);}function eat(){var ret=v;v=undefined;return ret;}var _180=true;return {repr:function(){return "groupby(...)";},next:function(){while(k==pk){fetch();if(_180){_180=false;break;}}pk=k;return [k,{next:function(){if(v==undefined){fetch();}if(k!=pk){throw self.StopIteration;}return eat();}}];}};},groupby_as_array:function(_181,_182){var m=MochiKit.Base;var self=MochiKit.Iter;if(arguments.length<2){_182=m.operator.identity;}_181=self.iter(_181);var _183=[];var _184=true;var _185;while(true){try{var _186=_181.next();var key=_182(_186);}catch(e){if(e==self.StopIteration){break;}throw e;}if(_184||key!=_185){var _187=[];_183.push([key,_187]);}_187.push(_186);_184=false;_185=key;}return _183;},arrayLikeIter:function(_188){var i=0;return {repr:function(){return "arrayLikeIter(...)";},toString:MochiKit.Base.forwardCall("repr"),next:function(){if(i>=_188.length){throw MochiKit.Iter.StopIteration;}return _188[i++];}};},hasIterateNext:function(_189){return (_189&&typeof (_189.iterateNext)=="function");},iterateNextIter:function(_190){return {repr:function(){return "iterateNextIter(...)";},toString:MochiKit.Base.forwardCall("repr"),next:function(){var rval=_190.iterateNext();if(rval===null||rval===undefined){throw MochiKit.Iter.StopIteration;}return rval;}};}});MochiKit.Iter.EXPORT_OK=["iteratorRegistry","arrayLikeIter","hasIterateNext","iterateNextIter",];MochiKit.Iter.EXPORT=["StopIteration","registerIteratorFactory","iter","count","cycle","repeat","next","izip","ifilter","ifilterfalse","islice","imap","applymap","chain","takewhile","dropwhile","tee","list","reduce","range","sum","exhaust","forEach","every","sorted","reversed","some","iextend","groupby","groupby_as_array"];MochiKit.Iter.__new__=function(){var m=MochiKit.Base;this.StopIteration=new m.NamedError("StopIteration");this.iteratorRegistry=new m.AdapterRegistry();this.registerIteratorFactory("arrayLike",m.isArrayLike,this.arrayLikeIter);this.registerIteratorFactory("iterateNext",this.hasIterateNext,this.iterateNextIter);this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};m.nameFunctions(this);};MochiKit.Iter.__new__();if(!MochiKit.__compat__){reduce=MochiKit.Iter.reduce;}MochiKit.Base._exportSymbols(this,MochiKit.Iter);if(typeof (dojo)!="undefined"){dojo.provide("MochiKit.Logging");dojo.require("MochiKit.Base");}if(typeof (JSAN)!="undefined"){JSAN.use("MochiKit.Base",[]);}try{if(typeof (MochiKit.Base)=="undefined"){throw "";}}catch(e){throw "MochiKit.Logging depends on MochiKit.Base!";}if(typeof (MochiKit.Logging)=="undefined"){MochiKit.Logging={};}MochiKit.Logging.NAME="MochiKit.Logging";MochiKit.Logging.VERSION="1.3.1";MochiKit.Logging.__repr__=function(){return "["+this.NAME+" "+this.VERSION+"]";};MochiKit.Logging.toString=function(){return this.__repr__();};MochiKit.Logging.EXPORT=["LogLevel","LogMessage","Logger","alertListener","logger","log","logError","logDebug","logFatal","logWarning"];MochiKit.Logging.EXPORT_OK=["logLevelAtLeast","isLogMessage","compareLogMessage"];MochiKit.Logging.LogMessage=function(num,_192,info){this.num=num;this.level=_192;this.info=info;this.timestamp=new Date();};MochiKit.Logging.LogMessage.prototype={repr:function(){var m=MochiKit.Base;return "LogMessage("+m.map(m.repr,[this.num,this.level,this.info]).join(", ")+")";},toString:MochiKit.Base.forwardCall("repr")};MochiKit.Base.update(MochiKit.Logging,{logLevelAtLeast:function(_194){var self=MochiKit.Logging;if(typeof (_194)=="string"){_194=self.LogLevel[_194];}return function(msg){var _196=msg.level;if(typeof (_196)=="string"){_196=self.LogLevel[_196];}return _196>=_194;};},isLogMessage:function(){var _197=MochiKit.Logging.LogMessage;for(var i=0;i<arguments.length;i++){if(!(arguments[i] instanceof _197)){return false;}}return true;},compareLogMessage:function(a,b){return MochiKit.Base.compare([a.level,a.info],[b.level,b.info]);},alertListener:function(msg){alert("num: "+msg.num+"\nlevel: "+msg.level+"\ninfo: "+msg.info.join(" "));}});MochiKit.Logging.Logger=function(_198){this.counter=0;if(typeof (_198)=="undefined"||_198===null){_198=-1;}this.maxSize=_198;this._messages=[];this.listeners={};this.useNativeConsole=false;};MochiKit.Logging.Logger.prototype={clear:function(){this._messages.splice(0,this._messages.length);},logToConsole:function(msg){if(typeof (window)!="undefined"&&window.console&&window.console.log){window.console.log(msg);}else{if(typeof (opera)!="undefined"&&opera.postError){opera.postError(msg);}else{if(typeof (printfire)=="function"){printfire(msg);}}}},dispatchListeners:function(msg){for(var k in this.listeners){var pair=this.listeners[k];if(pair.ident!=k||(pair[0]&&!pair[0](msg))){continue;}pair[1](msg);}},addListener:function(_199,_200,_201){if(typeof (_200)=="string"){_200=MochiKit.Logging.logLevelAtLeast(_200);}var _202=[_200,_201];_202.ident=_199;this.listeners[_199]=_202;},removeListener:function(_203){delete this.listeners[_203];},baseLog:function(_204,_205){var msg=new MochiKit.Logging.LogMessage(this.counter,_204,MochiKit.Base.extend(null,arguments,1));this._messages.push(msg);this.dispatchListeners(msg);if(this.useNativeConsole){this.logToConsole(msg.level+": "+msg.info.join(" "));}this.counter+=1;while(this.maxSize>=0&&this._messages.length>this.maxSize){this._messages.shift();}},getMessages:function(_206){var _207=0;if(!(typeof (_206)=="undefined"||_206===null)){_207=Math.max(0,this._messages.length-_206);}return this._messages.slice(_207);},getMessageText:function(_208){if(typeof (_208)=="undefined"||_208===null){_208=30;}var _209=this.getMessages(_208);if(_209.length){var lst=map(function(m){return "\n  ["+m.num+"] "+m.level+": "+m.info.join(" ");},_209);lst.unshift("LAST "+_209.length+" MESSAGES:");return lst.join("");}return "";},debuggingBookmarklet:function(_210){if(typeof (MochiKit.LoggingPane)=="undefined"){alert(this.getMessageText());}else{MochiKit.LoggingPane.createLoggingPane(_210||false);}}};MochiKit.Logging.__new__=function(){this.LogLevel={ERROR:40,FATAL:50,WARNING:30,INFO:20,DEBUG:10};var m=MochiKit.Base;m.registerComparator("LogMessage",this.isLogMessage,this.compareLogMessage);var _211=m.partial;var _212=this.Logger;var _213=_212.prototype.baseLog;m.update(this.Logger.prototype,{debug:_211(_213,"DEBUG"),log:_211(_213,"INFO"),error:_211(_213,"ERROR"),fatal:_211(_213,"FATAL"),warning:_211(_213,"WARNING")});var self=this;var _214=function(name){return function(){self.logger[name].apply(self.logger,arguments);};};this.log=_214("log");this.logError=_214("error");this.logDebug=_214("debug");this.logFatal=_214("fatal");this.logWarning=_214("warning");this.logger=new _212();this.logger.useNativeConsole=true;this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};m.nameFunctions(this);};if(typeof (printfire)=="undefined"&&typeof (document)!="undefined"&&document.createEvent&&typeof (dispatchEvent)!="undefined"){printfire=function(){printfire.args=arguments;var ev=document.createEvent("Events");ev.initEvent("printfire",false,true);dispatchEvent(ev);};}MochiKit.Logging.__new__();MochiKit.Base._exportSymbols(this,MochiKit.Logging);if(typeof (dojo)!="undefined"){dojo.provide("MochiKit.DateTime");}if(typeof (MochiKit)=="undefined"){MochiKit={};}if(typeof (MochiKit.DateTime)=="undefined"){MochiKit.DateTime={};}MochiKit.DateTime.NAME="MochiKit.DateTime";MochiKit.DateTime.VERSION="1.3.1";MochiKit.DateTime.__repr__=function(){return "["+this.NAME+" "+this.VERSION+"]";};MochiKit.DateTime.toString=function(){return this.__repr__();};MochiKit.DateTime.isoDate=function(str){str=str+"";if(typeof (str)!="string"||str.length===0){return null;}var iso=str.split("-");if(iso.length===0){return null;}return new Date(iso[0],iso[1]-1,iso[2]);};MochiKit.DateTime._isoRegexp=/(\d{4,})(?:-(\d{1,2})(?:-(\d{1,2})(?:[T ](\d{1,2}):(\d{1,2})(?::(\d{1,2})(?:\.(\d+))?)?(?:(Z)|([+-])(\d{1,2})(?::(\d{1,2}))?)?)?)?)?/;MochiKit.DateTime.isoTimestamp=function(str){str=str+"";if(typeof (str)!="string"||str.length===0){return null;}var res=str.match(MochiKit.DateTime._isoRegexp);if(typeof (res)=="undefined"||res===null){return null;}var year,month,day,hour,min,sec,msec;year=parseInt(res[1],10);if(typeof (res[2])=="undefined"||res[2]===""){return new Date(year);}month=parseInt(res[2],10)-1;day=parseInt(res[3],10);if(typeof (res[4])=="undefined"||res[4]===""){return new Date(year,month,day);}hour=parseInt(res[4],10);min=parseInt(res[5],10);sec=(typeof (res[6])!="undefined"&&res[6]!=="")?parseInt(res[6],10):0;if(typeof (res[7])!="undefined"&&res[7]!==""){msec=Math.round(1000*parseFloat("0."+res[7]));}else{msec=0;}if((typeof (res[8])=="undefined"||res[8]==="")&&(typeof (res[9])=="undefined"||res[9]==="")){return new Date(year,month,day,hour,min,sec,msec);}var ofs;if(typeof (res[9])!="undefined"&&res[9]!==""){ofs=parseInt(res[10],10)*3600000;if(typeof (res[11])!="undefined"&&res[11]!==""){ofs+=parseInt(res[11],10)*60000;}if(res[9]=="-"){ofs=-ofs;}}else{ofs=0;}return new Date(Date.UTC(year,month,day,hour,min,sec,msec)-ofs);};MochiKit.DateTime.toISOTime=function(date,_221){if(typeof (date)=="undefined"||date===null){return null;}var hh=date.getHours();var mm=date.getMinutes();var ss=date.getSeconds();var lst=[((_221&&(hh<10))?"0"+hh:hh),((mm<10)?"0"+mm:mm),((ss<10)?"0"+ss:ss)];return lst.join(":");};MochiKit.DateTime.toISOTimestamp=function(date,_225){if(typeof (date)=="undefined"||date===null){return null;}var sep=_225?"T":" ";var foot=_225?"Z":"";if(_225){date=new Date(date.getTime()+(date.getTimezoneOffset()*60000));}return MochiKit.DateTime.toISODate(date)+sep+MochiKit.DateTime.toISOTime(date,_225)+foot;};MochiKit.DateTime.toISODate=function(date){if(typeof (date)=="undefined"||date===null){return null;}var _228=MochiKit.DateTime._padTwo;return [date.getFullYear(),_228(date.getMonth()+1),_228(date.getDate())].join("-");};MochiKit.DateTime.americanDate=function(d){d=d+"";if(typeof (d)!="string"||d.length===0){return null;}var a=d.split("/");return new Date(a[2],a[0]-1,a[1]);};MochiKit.DateTime._padTwo=function(n){return (n>9)?n:"0"+n;};MochiKit.DateTime.toPaddedAmericanDate=function(d){if(typeof (d)=="undefined"||d===null){return null;}var _230=MochiKit.DateTime._padTwo;return [_230(d.getMonth()+1),_230(d.getDate()),d.getFullYear()].join("/");};MochiKit.DateTime.toAmericanDate=function(d){if(typeof (d)=="undefined"||d===null){return null;}return [d.getMonth()+1,d.getDate(),d.getFullYear()].join("/");};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -