mirror of
https://github.com/wahyd4/cdnjs.git
synced 2026-08-09 21:06:39 +10:00
1 line
8.3 KiB
JavaScript
1 line
8.3 KiB
JavaScript
if(!Array.prototype.shift){Array.prototype.shift=function(){if(this.length>0){var c=this[0];for(var b=0,a=this.length-1;b<a;b++){this[b]=this[b+1]}this.length--;return c}}}var log4javascript;(function(){var h="\r\n";function f(){}log4javascript=new f();log4javascript.version="1.4.9";log4javascript.edition="log4javascript_lite";function n(p){if(p.message){return p.message}else{if(p.description){return p.description}else{return String(p)}}}function d(q){var p=Math.max(q.lastIndexOf("/"),q.lastIndexOf("\\"));return q.substr(p+1)}function b(p){if(p){var r="Exception: "+n(p);try{if(p.lineNumber){r+=" on line number "+p.lineNumber}if(p.fileName){r+=" in file "+d(p.fileName)}}catch(q){}if(l&&p.stack){r+=h+"Stack trace:"+h+p.stack}return r}return null}function j(p){return(p instanceof Error)}function e(p){return Boolean(p)}var k=(typeof log4javascript_disabled!="undefined")&&log4javascript_disabled?false:true;log4javascript.setEnabled=function(p){k=e(p)};log4javascript.isEnabled=function(){return k};var l=false;log4javascript.setShowStackTraces=function(p){l=e(p)};var m=function(q,p){this.level=q;this.name=p};m.prototype={toString:function(){return this.name},equals:function(p){return this.level==p.level},isGreaterOrEqual:function(p){return this.level>=p.level}};m.ALL=new m(Number.MIN_VALUE,"ALL");m.TRACE=new m(10000,"TRACE");m.DEBUG=new m(20000,"DEBUG");m.INFO=new m(30000,"INFO");m.WARN=new m(40000,"WARN");m.ERROR=new m(50000,"ERROR");m.FATAL=new m(60000,"FATAL");m.OFF=new m(Number.MAX_VALUE,"OFF");log4javascript.Level=m;function i(){var z=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;setTimeout(setLogContainerHeight,20);};function getLogContainer(){return $("log");}','function clearLog(){getLogContainer().innerHTML="";}',"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>"]};var t=null;var r=false;var p=false;var B=false;var q=true;var u=false;var J=true;var C=600;var A=400;var y=false;var D=new Array();function v(L){try{return e(L.loaded)}catch(K){return false}}function H(){B=true;G()}function s(N){var L=z();N.open();for(var M=0,K=L.length;M<K;M++){N.writeln(L[M])}N.close()}function F(){function K(){if(B){clearInterval(L)}else{if(e(t)&&v(t)){clearInterval(L);H()}}}var L=setInterval(K,100)}function E(){var L="width="+C+",height="+A+",status,resizable";var K="log4javascriptLitePopUp"+location.host.replace(/[^a-z0-9]/gi,"_");t=window.open("",K,L);p=false;if(t){if(v(t)){t.mainPageReloaded();H()}else{s(t.document);if(v(t)){H()}else{F()}}}else{J=false;if(q){alert("log4javascript: pop-up windows appear to be blocked. Please unblock them to use pop-up logging.")}}u=true}function x(){if(!r&&!p){if(t.closed){p=true;return false}if(!B&&t.loaded){B=true}}return !r&&B&&!p}function w(L,K){var M=""+L;while(M.length<K){M="0"+M}return M}function I(L,K){while(L.length<K){L+=" "}return L}this.append=function(K){if(!u){E()}D.push(K);if(x()){G()}};function G(){if(x()){while(D.length>0){var K=D.shift();var L=K.timeStamp;var O=w(L.getHours(),2)+":"+w(L.getMinutes(),2)+":"+w(L.getSeconds(),2);var N=O+" "+I(K.level.name,5)+" - "+K.getCombinedMessages();var M=K.getThrowableStrRep();if(M){N+=h+M}t.log(K.level,N)}if(y){t.focus()}}}}log4javascript.Appender=i;function c(){var p=new i();var q=m.ALL;this.log=function(y,x){if(k&&y.isGreaterOrEqual(this.getLevel())){var s;var u=x.length-1;var t=x[x.length-1];if(x.length>1&&j(t)){s=t;u--}var v=[];for(var r=0;r<=u;r++){v[r]=x[r]}var w=new g(this,new Date(),y,v,s);p.append(w)}};this.setLevel=function(r){q=r};this.getLevel=function(){return q}}c.prototype={trace:function(){this.log(m.TRACE,arguments)},debug:function(){this.log(m.DEBUG,arguments)},info:function(){this.log(m.INFO,arguments)},warn:function(){this.log(m.WARN,arguments)},error:function(){this.log(m.ERROR,arguments)},fatal:function(){this.log(m.FATAL,arguments)},isEnabledFor:function(p){return p.isGreaterOrEqual(this.getLevel())},isTraceEnabled:function(){return this.isEnabledFor(m.TRACE)},isDebugEnabled:function(){return this.isEnabledFor(m.DEBUG)},isInfoEnabled:function(){return this.isEnabledFor(m.INFO)},isWarnEnabled:function(){return this.isEnabledFor(m.WARN)},isErrorEnabled:function(){return this.isEnabledFor(m.ERROR)},isFatalEnabled:function(){return this.isEnabledFor(m.FATAL)}};var a=null;log4javascript.getDefaultLogger=function(){if(!a){a=new c()}return a};log4javascript.getLogger=log4javascript.getDefaultLogger;var o=null;log4javascript.getNullLogger=function(){if(!o){o=new c();o.setLevel(m.OFF)}return o};var g=function(q,p,t,s,r){this.logger=q;this.timeStamp=p;this.level=t;this.messages=s;this.exception=r};g.prototype={getThrowableStrRep:function(){return this.exception?b(this.exception):""},getCombinedMessages:function(){return(this.messages.length===1)?this.messages[0]:this.messages.join(h)}};log4javascript.LoggingEvent=g;window.log4javascript=log4javascript})(); |