PS3_Toolset/js/logger.min.js
2022-10-16 19:13:28 +02:00

1 line
7.3 KiB
JavaScript

!function(e){"use strict";function p(e){return"function"==typeof e||"[object Function]"===t.call(e)}function f(e){var t,n=(t=Number(e),isNaN(t)?0:0!==t&&isFinite(t)?(0<t?1:-1)*Math.floor(Math.abs(t)):t);return Math.min(Math.max(n,0),r)}var t,r,o,i,l,a;Array.from||(Array.from=(t=Object.prototype.toString,r=Math.pow(2,53)-1,function(e,t,n){var r=Object(e);if(null==e)throw new TypeError("Array.from requires an array-like object - not null or undefined");var o,i=1<arguments.length?t:void 0;if(void 0!==i){if(!p(i))throw new TypeError("Array.from: when provided, the second argument must be a function");2<arguments.length&&(o=n)}for(var l,a=f(r.length),s=p(this)?Object(new this(a)):new Array(a),c=0;c<a;)l=r[c],s[c]=i?void 0===o?i(l,c):i.call(o,l,c):l,c+=1;return s.length=a,s})),Object.keys||(Object.keys=Object.keys||(o=Object.prototype.hasOwnProperty,i=!{toString:null}.propertyIsEnumerable("toString"),a=(l=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"]).length,function(e){if("object"!=typeof e&&"function"!=typeof e||null===e)throw new TypeError("Object.keys called on a non-object");var t=[];for(var n in e)o.call(e,n)&&t.push(n);if(i)for(var r=0;r<a;r++)o.call(e,l[r])&&t.push(l[r]);return t}));function s(e){var t=Object.keys(e);t.sort(function(e,t){return e===t?0:t<e?1:-1});for(var n='<span class="dropdown" ><span class="ui-icon icon-triangle"></span><span>'+e+'</span><span class="dropdown-content">',r=0;r<t.length;r++){var o=e[t[r]];"number"==typeof o&&(o="0x"+o.toString(16)),n+='<span><span class="dd-left">'+t[r]+'</span><span class="dd-centre">=</span><span class="dd-right">'+o+"</span></span><br>"}return n+="</span></span>"}function n(e){var t=document.createEvent("Event");t.initEvent("addLog",!1,!1),t.message=e,window.jQuery&&(t.immediate=4===window.jQuery("#tabs").tabs("option","active")),frames.ifrlog.window.document.dispatchEvent(t)}function c(e){if(document.getElementById("inet").checked&&0<e.length)for(var t=0;t<e.length;t++){var n=null;e[t]&&"string"==typeof e[t]&&0<e[t].length?n=e[t]:"number"==typeof e[t]?n="0x"+e[t].toString(16):"boolean"==typeof e[t]?n=e[t].toString():"object"==typeof e[t]?s(e[t]):"function"==typeof e[t]&&e[t],n&&("<br>"===n.substr(0,4)&&(n=n.substr(4,n.length-4)),r="<br>",o="\n ",n=n.replace(new RegExp(function(e){return e.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")}(r),"g"),o),helper&&helper.bc&&helper.bc.send(n))}var r,o}function u(e,t){return function(){return t.apply(e,arguments)}}function g(){for(var e,t=arguments,n=t[0],r=1;r<t.length;r++)for(e in t[r])e in n||!t[r].hasOwnProperty(e)||(n[e]=t[r][e]);return n}var d,h={VERSION:"1.7.1-bg"},b={};function v(e,t){return{value:e,name:t}}h.TRACE=v(1,"TRACE"),h.DEBUG=v(2,"DEBUG"),h.INFO=v(3,"INFO"),h.TIME=v(4,"TIME"),h.WARN=v(5,"WARN"),h.ERROR=v(8,"ERROR"),h.OFF=v(99,"OFF");function y(e){this.context=e,this.setLevel(e.filterLevel),this.log=this.info}y.prototype={_iptlog:"ilog",_iptwrn:"iwarn",_ipterr:"ierror",_iptdbg:"idbg",_iptnet:"inet",_tbip:"ip_txtbox",_tbport:"port_txtbox",iptlog:function(){return this._iptlog},iptwrn:function(){return this._iptwrn},ipterr:function(){return this._ipterr},iptdbg:function(){return this._iptdbg},iptnet:function(){return this._iptnet},tbip:function(){return this._tbip},tbport:function(){return this._tbport},setGUI:function(e){window.jQuery&&(0<window.jQuery("#"+e.info).length&&(this._iptlog=e.info),0<window.jQuery("#"+e.warn).length&&(this._iptwrn=e.warn),0<window.jQuery("#"+e.error).length&&(this._ipterr=e.error),0<window.jQuery("#"+e.dbg).length&&(this._iptdbg=e.dbg),0<window.jQuery("#"+e.net).length&&(this._iptnet=e.net),0<window.jQuery("#"+e.ip).length&&(this._tbip=e.ip),0<window.jQuery("#"+e.port).length&&(this._tbport=e.port))},setLevel:function(e){e&&"value"in e&&(this.context.filterLevel=e)},getLevel:function(){return this.context.filterLevel},enabledFor:function(e){var t=this.context.filterLevel;return e.value>=t.value},trace:function(){this.invoke(h.TRACE,arguments),c(arguments)},debug:function(){this.invoke(h.DEBUG,arguments);for(var e="<p class='logs "+(document.getElementById(this._iptdbg).checked?"log-debug":"log-debug ui-helper-hidden")+'\'><span class="fa fa-question-circle fa-fw"></span> ',t=0;t<arguments.length;t++)0<t&&(e+="<span>, </span>"),"string"==typeof arguments[t]?e+=arguments[t]:"number"==typeof arguments[t]?e+="0x"+arguments[t].toString(16):"boolean"==typeof arguments[t]?e+=arguments[t]:"object"==typeof arguments[t]?e+=s(arguments[t]):"function"==typeof arguments[t]&&(e+=arguments[t]);n(e+"</p>")},info:function(){this.invoke(h.INFO,arguments);var e=document.getElementById(this._iptlog).checked?"log-info":"log-info ui-helper-hidden";0<arguments.length&&"string"==typeof arguments[0]&&"<br>"===arguments[0].substr(0,4)&&(arguments[0]=arguments[0].substr(4)),n("<p class='logs "+e+'\'><span class="fa fa-info-circle fa-fw"></span> '+Array.from(arguments)+"</p>"),c(arguments)},warn:function(){this.invoke(h.WARN,arguments);var e=document.getElementById(this._iptwrn).checked?"log-warning":"log-warning ui-helper-hidden";n("<p class='logs "+e+'\'><span class="fa fa-exclamation-circle fa-fw"></span> '+Array.from(arguments)+"</p>"),c(arguments)},error:function(){this.invoke(h.ERROR,arguments);var e=document.getElementById(this._ipterr).checked?"log-error":"log-error ui-helper-hidden";n("<p class='logs "+e+'\'><span class="fa fa-times-circle fa-fw"></span> '+Array.from(arguments)+"</p>"),c(arguments)},time:function(e){"string"==typeof e&&0<e.length&&this.invoke(h.TIME,[e,"start"])},timeEnd:function(e){"string"==typeof e&&0<e.length&&this.invoke(h.TIME,[e,"end"])},invoke:function(e,t){d&&this.enabledFor(e)&&d(t,g({level:e},this.context))}};var w,m=new y({filterLevel:h.OFF});(w=h).enabledFor=u(m,m.enabledFor),w.trace=u(m,m.trace),w.debug=u(m,m.debug),w.time=u(m,m.time),w.timeEnd=u(m,m.timeEnd),w.info=u(m,m.info),w.warn=u(m,m.warn),w.error=u(m,m.error),w.setGUI=u(m,m.setGUI),w.iptlog=u(m,m.iptlog),w.iptwrn=u(m,m.iptwrn),w.ipterr=u(m,m.ipterr),w.iptdbg=u(m,m.iptdbg),w.iptnet=u(m,m.iptnet),w.tbip=u(m,m.tbip),w.tbport=u(m,m.tbport),w.log=w.info,h.setHandler=function(e){d=e},h.setLevel=function(e){for(var t in m.setLevel(e),b)b.hasOwnProperty(t)&&b[t].setLevel(e)},h.getLevel=function(){return m.getLevel()},h.get=function(e){return b[e]||(b[e]=new y(g({name:e},m.context)))},h.createDefaultHandler=function(o){(o=o||{}).formatter=o.formatter||function(e,t){t.name&&e.unshift("["+t.name+"]")};function i(e,t){Function.prototype.apply.call(e,console,t)}var l={};return"undefined"==typeof console?function(){}:function(e,t){e=Array.prototype.slice.call(e);var n,r=console.log;t.level===h.TIME?(n=(t.name?"["+t.name+"] ":"")+e[0],"start"===e[1]?console.time?console.time(n):l[n]=(new Date).getTime():console.timeEnd?console.timeEnd(n):i(r,[n+": "+((new Date).getTime()-l[n])+"ms"])):(t.level===h.WARN&&console.warn?r=console.warn:t.level===h.ERROR&&console.error?r=console.error:t.level===h.INFO&&console.info?r=console.info:t.level===h.DEBUG&&console.debug?r=console.debug:t.level===h.TRACE&&console.trace&&(r=console.trace),o.formatter(e,t),i(r,e))}},h.useDefaults=function(e){h.setLevel(e&&e.defaultLevel||h.DEBUG),h.setHandler(h.createDefaultHandler(e))},"function"==typeof define&&define.amd?define(h):"undefined"!=typeof module&&module.exports?module.exports=h:(h._prevLogger=e.Logger,h.noConflict=function(){return e.Logger=h._prevLogger,h},e.Logger=h)}(this);