mirror of
https://github.com/wahyd4/cdnjs.git
synced 2026-08-11 05:46:04 +10:00
1 line
9.4 KiB
JavaScript
1 line
9.4 KiB
JavaScript
Array.prototype.shift||(Array.prototype.shift=function(){if(this.length>0){for(var e=this[0],t=0,i=this.length-1;i>t;t++)this[t]=this[t+1];return this.length--,e}});var log4javascript;(function(){function e(){}function t(e){return e.message?e.message:e.description?e.description:e+""}function i(e){var t=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));return e.substr(t+1)}function n(e){if(e){var n="Exception: "+t(e);try{e.lineNumber&&(n+=" on line number "+e.lineNumber),e.fileName&&(n+=" in file "+i(e.fileName))}catch(r){}return h&&e.stack&&(n+=l+"Stack trace:"+l+e.stack),n}return null}function r(e){return e instanceof Error}function o(e){return Boolean(e)}function s(){function e(e){try{return o(e.loaded)}catch(t){return!1}}function t(){g=!0,h()}function i(e){var t=u();e.open();for(var i=0,n=t.length;n>i;i++)e.writeln(t[i]);e.close()}function n(){function i(){g?clearInterval(n):o(d)&&e(d)&&(clearInterval(n),t())}var n=setInterval(i,100)}function r(){var r="width="+y+",height="+x+",status,resizable",o="log4javascriptLitePopUp"+location.host.replace(/[^a-z0-9]/gi,"_");d=window.open("",o,r),f=!1,d?e(d)?(d.mainPageReloaded(),t()):(i(d.document),e(d)?t():n()):(b=!1,m&&alert("log4javascript: pop-up windows appear to be blocked. Please unblock them to use pop-up logging.")),v=!0}function s(){if(!p&&!f){if(d.closed)return f=!0,!1;!g&&d.loaded&&(g=!0)}return!p&&g&&!f}function a(e,t){for(var i=""+e;t>i.length;)i="0"+i;return i}function c(e,t){for(;t>e.length;)e+=" ";return e}function h(){if(s()){for(;C.length>0;){var e=C.shift(),t=e.timeStamp,i=a(t.getHours(),2)+":"+a(t.getMinutes(),2)+":"+a(t.getSeconds(),2),n=i+" "+c(e.level.name,5)+" - "+e.getCombinedMessages(),r=e.getThrowableStrRep();r&&(n+=l+r),d.log(e.level,n)}_&&d.focus()}}var u=function(){return['<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">','<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">'," <head>"," <title>log4javascript</title>",' <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'," <!-- Make IE8 behave like IE7, having gone to all the trouble of making IE work -->",' <meta http-equiv="X-UA-Compatible" content="IE=7" />',' <script type="text/javascript">'," //<![CDATA["," var loggingEnabled = true;"," var messagesBeforeDocLoaded = [];",""," function toggleLoggingEnabled() {",' setLoggingEnabled($("enableLogging").checked);'," }",""," function setLoggingEnabled(enable) {"," loggingEnabled = enable;"," }",""," function scrollToLatestEntry() {"," var l = getLogContainer();",' if (typeof l.scrollTop != "undefined") {'," var latestLogEntry = l.lastChild;"," if (latestLogEntry) {"," l.scrollTop = l.scrollHeight;"," }"," }"," }",""," function log(logLevel, formattedMessage) {"," if (loggingEnabled) {"," if (loaded) {"," doLog(logLevel, formattedMessage);"," } else {"," messagesBeforeDocLoaded.push([logLevel, formattedMessage]);"," }"," }"," }",""," function doLog(logLevel, formattedMessage) {",' var logEntry = document.createElement("div");'," logEntry.appendChild(document.createTextNode(formattedMessage));",' logEntry.className = "logentry " + logLevel.name;'," getLogContainer().appendChild(logEntry);"," scrollToLatestEntry();"," }",""," function mainPageReloaded() {",' var separator = document.createElement("div");',' separator.className = "separator";',' separator.innerHTML = " ";'," getLogContainer().appendChild(separator);"," }",""," var loaded = false;",' var logLevels = ["DEBUG", "INFO", "WARN", "ERROR", "FATAL"];',""," window.onload = function() {"," setLogContainerHeight();"," toggleLoggingEnabled();"," for (var i = 0; i < messagesBeforeDocLoaded.length; i++) {"," doLog(messagesBeforeDocLoaded[i][0], messagesBeforeDocLoaded[i][1]);"," }"," messagesBeforeDocLoaded = [];"," loaded = true;",""," // Workaround to make sure log div starts at the correct size"," setTimeout(setLogContainerHeight, 20);"," };",""," function getLogContainer() {",' return $("log");'," }",""," function clearLog() {",' getLogContainer().innerHTML = "";'," }",""," /* ------------------------------------------------------------------------- */",""," // Other utility functions",""," // Syntax borrowed from Prototype library"," function $(id) {"," return document.getElementById(id);"," }",""," function getWindowHeight() {"," if (window.innerHeight) {"," return window.innerHeight;"," } else if (document.documentElement && document.documentElement.clientHeight) {"," return document.documentElement.clientHeight;"," } else if (document.body) {"," return document.body.clientHeight;"," }"," return 0;"," }",""," function getChromeHeight() {",' return $("toolbar").offsetHeight;'," }",""," function setLogContainerHeight() {"," var windowHeight = getWindowHeight();",' $("body").style.height = getWindowHeight() + "px";',' getLogContainer().style.height = "" +',' Math.max(0, windowHeight - getChromeHeight()) + "px";'," }",""," window.onresize = function() {"," setLogContainerHeight();"," };",""," //]]>"," </script>",' <style type="text/css">'," body {"," background-color: white;"," color: black;"," padding: 0;"," margin: 0;"," font-family: tahoma, verdana, arial, helvetica, sans-serif;"," overflow: hidden;"," }"," "," div#toolbar {"," border-top: solid #ffffff 1px;"," border-bottom: solid #aca899 1px;"," background-color: #f1efe7;"," padding: 3px 5px;"," font-size: 68.75%;"," }",""," div#toolbar input.button {"," padding: 0 5px;"," font-size: 100%;"," }",""," div#log {"," font-family: Courier New, Courier;"," font-size: 75%;"," width: 100%;"," overflow: auto;"," clear: both;"," }",""," *.logentry {"," overflow: visible;"," white-space: pre;"," }",""," *.TRACE {"," color: #666666;"," }",""," *.DEBUG {"," color: green;"," }",""," *.INFO {"," color: #000099;"," }",""," *.WARN {"," color: #999900;"," }",""," *.ERROR {"," color: red;"," }",""," *.FATAL {"," color: #660066;"," }",""," div#log div.separator {"," background-color: #cccccc;"," margin: 5px 0;"," line-height: 1px;"," }"," </style>"," </head>","",' <body id="body">',' <div id="toolbar">'," Options:",' <input type="checkbox" id="enableLogging" onclick="toggleLoggingEnabled()" class="stateful" checked="checked" title="Enable/disable logging" /><label for="enableLogging" id="enableLoggingLabel">Enable logging</label>',' <input type="button" id="clearButton" value="Clear" onclick="clearLog()" class="stateful button" title="Clear all log messages" />',' <input type="button" id="closeButton" value="Close" onclick="window.close()" class="stateful button" title="Close the window" />'," </div>",' <div id="log" class="TRACE DEBUG INFO WARN ERROR FATAL"></div>'," </body>","</html>"]},d=null,p=!1,f=!1,g=!1,m=!0,v=!1,b=!0,y=600,x=400,_=!1,C=[];this.append=function(e){v||r(),C.push(e),s()&&h()}}function a(){var e=new s,t=u.ALL;this.log=function(t,i){if(c&&t.isGreaterOrEqual(this.getLevel())){var n,o=i.length-1,s=i[i.length-1];i.length>1&&r(s)&&(n=s,o--);for(var a=[],l=0;o>=l;l++)a[l]=i[l];var h=new f(this,new Date,t,a,n);e.append(h)}},this.setLevel=function(e){t=e},this.getLevel=function(){return t}}var l="\r\n";log4javascript=new e,log4javascript.version="1.4.3",log4javascript.edition="log4javascript_lite";var c="undefined"!=typeof log4javascript_disabled&&log4javascript_disabled?!1:!0;log4javascript.setEnabled=function(e){c=o(e)},log4javascript.isEnabled=function(){return c};var h=!1;log4javascript.setShowStackTraces=function(e){h=o(e)};var u=function(e,t){this.level=e,this.name=t};u.prototype={toString:function(){return this.name},equals:function(e){return this.level==e.level},isGreaterOrEqual:function(e){return this.level>=e.level}},u.ALL=new u(Number.MIN_VALUE,"ALL"),u.TRACE=new u(1e4,"TRACE"),u.DEBUG=new u(2e4,"DEBUG"),u.INFO=new u(3e4,"INFO"),u.WARN=new u(4e4,"WARN"),u.ERROR=new u(5e4,"ERROR"),u.FATAL=new u(6e4,"FATAL"),u.OFF=new u(Number.MAX_VALUE,"OFF"),log4javascript.Level=u,log4javascript.Appender=s,a.prototype={trace:function(){this.log(u.TRACE,arguments)},debug:function(){this.log(u.DEBUG,arguments)},info:function(){this.log(u.INFO,arguments)},warn:function(){this.log(u.WARN,arguments)},error:function(){this.log(u.ERROR,arguments)},fatal:function(){this.log(u.FATAL,arguments)},isEnabledFor:function(e){return e.isGreaterOrEqual(this.getLevel())},isTraceEnabled:function(){return this.isEnabledFor(u.TRACE)},isDebugEnabled:function(){return this.isEnabledFor(u.DEBUG)},isInfoEnabled:function(){return this.isEnabledFor(u.INFO)},isWarnEnabled:function(){return this.isEnabledFor(u.WARN)},isErrorEnabled:function(){return this.isEnabledFor(u.ERROR)},isFatalEnabled:function(){return this.isEnabledFor(u.FATAL)}};var d=null;log4javascript.getDefaultLogger=function(){return d||(d=new a),d},log4javascript.getLogger=log4javascript.getDefaultLogger;var p=null;log4javascript.getNullLogger=function(){return p||(p=new a,p.setLevel(u.OFF)),p};var f=function(e,t,i,n,r){this.logger=e,this.timeStamp=t,this.level=i,this.messages=n,this.exception=r};f.prototype={getThrowableStrRep:function(){return this.exception?n(this.exception):""},getCombinedMessages:function(){return 1===this.messages.length?this.messages[0]:this.messages.join(l)}},log4javascript.LoggingEvent=f,window.log4javascript=log4javascript})(); |