Permalink
Browse files

console polyfill for the weak

  • Loading branch information...
1 parent 8860e17 commit 3e201f65bcfd559cd3b2c632434e579df023ca31 @SlexAxton committed Jan 19, 2011
Showing with 18 additions and 1 deletion.
  1. +2 −1 index.html
  2. +16 −0 js/console.js
View
@@ -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>
View
@@ -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.