Provide a complete window.console dummy implementation
authorTim Düsterhus <duesterhus@woltlab.com>
Sat, 13 Apr 2013 16:55:32 +0000 (18:55 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Sat, 13 Apr 2013 16:59:07 +0000 (18:59 +0200)
wcfsetup/install/files/js/WCF.js

index 7b31b9941e90d0ca01157752d57a3fa390b9fbaa..d95feee8c8d4240b47df7ed636160ff913a4268d 100755 (executable)
                return $data;
        };
        
-       // provide a sane console.debug implementation
-       if (!window.console) {
-               window.console = {
-                       debug: function() { /* discard log */ }
-               };
+       // provide a sane window.console implementation
+       if (!window.console) window.console = { };
+       var consoleProperties = [ "log",/* "debug",*/ "info", "warn", "exception", "assert", "dir", "dirxml", "trace", "group", "groupEnd", "groupCollapsed", "profile", "profileEnd", "count", "clear", "time", "timeEnd", "timeStamp", "table", "error" ];
+       for (var i = 0; i < consoleProperties.length; i++) {
+               if (typeof (console[consoleProperties[i]]) === 'undefined') {
+                       console[consoleProperties[i]] = function () { }
+               }
        }
-       else if (typeof(console.debug) === 'undefined') {
+       
+       if (typeof(console.debug) === 'undefined') {
                // forward console.debug to console.log (IE9)
                console.debug = function(string) { console.log(string); };
        }