-
Notifications
You must be signed in to change notification settings - Fork 0
/
tv.console-min.js
12 lines (11 loc) · 2.76 KB
/
tv.console-min.js
1
2
3
4
5
6
7
8
9
10
11
12
/**
* @author Vladimir Reznichenko <kalessil@gmail.com>
* @date 12.05.2012
*
* https://github.com/kalessil/tv.jquery
*
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://www.opensource.org/licenses/mit-license.php
* http://www.opensource.org/licenses/GPL-2.0
*/
(function(e){var d=[];var o=function(u){var v=u[0];var t=u[1];var s="";if(t>1){s=" ["+t+"]"}return"› "+v+s};var l=function(){while(d.length>1){d.pop()}};var h=function(v){var t;var u;for(var s in d){u=d[s];t=(u[0]===v);if(t){return true}}return false};var q=function(t){var s=[t,1];d.push(s)};var m=function(v){var t;var u;for(var s in d){u=d[s];t=(u[0]===v);if(t){var w=d.length-1;if(w!=s){var x=d[w];d[w]=d[s];d[s]=x}return}}};var g=function(){return d.length};var j=function(v){var t;var u;for(var s in d){u=d[s];t=(u[0]===v);if(t){++d[s][1];return}}};var b=function(t){var s=h(t);if(!s){q(t);return}j(t);m(t)};var i=function(){var s={log:function(t){b(t);s.refresh()},debug:function(t){b("Debug: "+t);s.refresh()},error:function(t){b('<span style="color:#F00">'+t+"</span>");s.refresh()},info:function(t){b("Info: "+t);s.refresh()},warn:function(t){b('<span style="color:#FF7000">'+t+"</span>");s.refresh()},refresh:function(){},clear:function(){l();s.refresh()}};return s};var a=function(v,u,w){var x=w.url;var t=u.statusText;var z=w.type;var y=(window.location.protocol.toLowerCase()==="https");if(y){var s=(x.split(":",1))[0];if(s==="http"){x=x.replace("http://",'<span style="color:#F00">http</span>://')}}x='<span style="color:#666;text-decoration:underline">'+x+"</span>";t=(t?(' <span style="color:#a6a6a6">'+t+"</span>"):"");return z+" "+x+t};window.addEventListener("error",function(s){window.console.error(s.message);return true});e(document).ajaxError(function(v,u,w,t){var s=a(v,u,w);window.console.error(s+" "+(t?t:""))});e(document).ajaxSuccess(function(t,s,u){var v=a(t,s,u);window.console.info(v)});var r=function(){var s=g();if(!s){return}c(d)};var c=function(v){f.innerHTML="";var u;var t=e(f);for(var s in v){u=o(v[s]);t.append(u);f.appendChild(k.cloneNode(false))}f.style.display="block"};var f;var n=function(){var s=document.createElement("div");s.setAttribute("id","tv-console");s.style.display="none";s.style.position="absolute";s.style.bottom=0;s.style.left=0;s.style.width="100%";s.style.borderTop="solid 1px #c6c6c6";s.style.paddingTop="7px";s.style.paddingRight="7px";s.style.paddingBottom="7px";s.style.paddingLeft="7px";s.style.color="#a6a6a6";s.style.fontSize="0.9em";document.getElementsByTagName("body")[0].appendChild(s);f=s};var p=function(){k=document.createElement("br");window.console=i();var s="";if(typeof window.console!="undefined"){s=" (native one is overridden)"}b("TV console started"+s);n();window.console.refresh=r;window.console.refresh()};var k;e(document).ready(p)})(jQuery);