2787 |
rexy |
1 |
/* https://github.com/liamnewmarch/console-shim 2014 CC-BY @liamnewmarch */
|
|
|
2 |
if (!('console' in window)) {
|
|
|
3 |
(function() {
|
|
|
4 |
var Console, __console;
|
|
|
5 |
Console = function() {
|
|
|
6 |
var check, key, log, methods, _i, _len, _ref;
|
|
|
7 |
this.__buffer = [];
|
|
|
8 |
log = function() {
|
|
|
9 |
return this.__buffer.push(arguments);
|
|
|
10 |
};
|
|
|
11 |
methods = 'assert count debug dir dirxml error exception info log trace warn';
|
|
|
12 |
_ref = methods.split(' ');
|
|
|
13 |
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
|
14 |
key = _ref[_i];
|
|
|
15 |
this[key] = log;
|
|
|
16 |
}
|
|
|
17 |
check = setInterval(function() {
|
|
|
18 |
var data, func, _j, _len1, _ref1, _ref2;
|
|
|
19 |
if ((((_ref1 = window.console) != null ? _ref1.log : void 0) != null) && !console.__buffer) {
|
|
|
20 |
clearInterval(check);
|
|
|
21 |
func = Function.prototype.bind ? Function.prototype.bind.call(console.log, console) : console.log;
|
|
|
22 |
_ref2 = __console.__buffer;
|
|
|
23 |
for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
|
|
|
24 |
data = _ref2[_j];
|
|
|
25 |
func.apply(console, data);
|
|
|
26 |
}
|
|
|
27 |
}
|
|
|
28 |
}, 1000);
|
|
|
29 |
};
|
|
|
30 |
return __console = window.console = new Console();
|
|
|
31 |
})();
|
|
|
32 |
}
|