Skip to content

Commit

Permalink
console polyfill for the weak
Browse files Browse the repository at this point in the history
  • Loading branch information
SlexAxton committed Jan 19, 2011
1 parent 8860e17 commit 3e201f6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
<link rel="stylesheet" href="css/main.css" media="all" />
</head>
<body>
Nothing to see here yet.
Nothing to see here yet.
<script src="js/console.js"></script>
<script src="js/jquery.min.js"></script>
<script src="js/uglifyjs/lib/parse-js.js"></script>
<script src="js/uglifyjs/lib/process.js"></script>
Expand Down
16 changes: 16 additions & 0 deletions js/console.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* JavaScript Debug - v0.4 - 6/22/2010
* http://benalman.com/projects/javascript-debug-console-log/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*
* With lots of help from Paul Irish!
* http://paulirish.com/
*/
window.debug=(function(){var i=this,b=Array.prototype.slice,d=i.console,h={},f,g,m=9,c=["error","warn","info","debug","log"],l="assert clear count dir dirxml exception group groupCollapsed groupEnd profile profileEnd table time timeEnd trace".split(" "),j=l.length,a=[];while(--j>=0){(function(n){h[n]=function(){m!==0&&d&&d[n]&&d[n].apply(d,arguments)}})(l[j])}j=c.length;while(--j>=0){(function(n,o){h[o]=function(){var q=b.call(arguments),p=[o].concat(q);a.push(p);e(p);if(!d||!k(n)){return}d.firebug?d[o].apply(i,q):d[o]?d[o](q):d.log(q)}})(j,c[j])}function e(n){if(f&&(g||!d||!d.log)){f.apply(i,n)}}h.setLevel=function(n){m=typeof n==="number"?n:9};function k(n){return m>0?m>n:c.length+m<=n}h.setCallback=function(){var o=b.call(arguments),n=a.length,p=n;f=o.shift()||null;g=typeof o[0]==="boolean"?o.shift():false;p-=typeof o[0]==="number"?o.shift():n;while(p<n){e(a[p++])}};return h})();

if ( !window.console ) {
window.console = window.debug;
}

0 comments on commit 3e201f6

Please sign in to comment.