1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-08-03 11:57:34 +02:00

Fix call to clearCOnsole in case of detached window. fixes #222

This commit is contained in:
Kushagra Gour
2017-10-25 00:36:36 +05:30
parent 4bb296761c
commit 214f0d89b4

View File

@@ -1,3 +1,6 @@
var mainWindow = window.parent.onMessageFromConsole
? window.parent
: window.parent.opener;
(function() {
var logEl,
isInitialized = false,
@@ -37,11 +40,20 @@
if (_options.proxyCallback) {
_options.proxyCallback.apply(null, arguments);
}
if (_options.noUi) { return; }
var el = createElement('div', 'line-height:18px;min-height:18px;background:' +
(logEl.children.length % 2 ? 'rgba(255,255,255,0.1)' : '') + ';color:' + color); // zebra lines
if (_options.noUi) {
return;
}
var el = createElement(
'div',
'line-height:18px;min-height:18px;background:' +
(logEl.children.length % 2 ? 'rgba(255,255,255,0.1)' : '') +
';color:' +
color
); // zebra lines
var val = [].slice.call(arguments).reduce(function(prev, arg) {
return prev + ' ' + (typeof arg === "object" ? JSON.stringify(arg) : arg);
return (
prev + ' ' + (typeof arg === 'object' ? JSON.stringify(arg) : arg)
);
}, '');
el.textContent = val;
@@ -56,7 +68,7 @@
function clear() {
if (_options.noUi) {
window.parent.clearConsole();
mainWindow.clearConsole();
return;
}
logEl.innerHTML = '';
@@ -86,7 +98,9 @@
}
function init(options) {
if (isInitialized) { return; }
if (isInitialized) {
return;
}
isInitialized = true;
@@ -175,7 +189,6 @@
destroy: checkInitDecorator(destroy)
};
})();
var mainWindow = window.parent.onMessageFromConsole ? window.parent : window.parent.opener;
screenLog.init({
noUi: true,
proxyCallback: function() {
@@ -190,4 +203,4 @@ window._wmEvaluate = function _wmEvaluate(expr) {
return;
}
mainWindow.onMessageFromConsole.call(null, result);
}
};