mirror of
https://github.com/chinchang/web-maker.git
synced 2025-08-04 20:37:29 +02:00
Fix call to clearCOnsole in case of detached window. fixes #222
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
var mainWindow = window.parent.onMessageFromConsole
|
||||||
|
? window.parent
|
||||||
|
: window.parent.opener;
|
||||||
(function() {
|
(function() {
|
||||||
var logEl,
|
var logEl,
|
||||||
isInitialized = false,
|
isInitialized = false,
|
||||||
@@ -37,11 +40,20 @@
|
|||||||
if (_options.proxyCallback) {
|
if (_options.proxyCallback) {
|
||||||
_options.proxyCallback.apply(null, arguments);
|
_options.proxyCallback.apply(null, arguments);
|
||||||
}
|
}
|
||||||
if (_options.noUi) { return; }
|
if (_options.noUi) {
|
||||||
var el = createElement('div', 'line-height:18px;min-height:18px;background:' +
|
return;
|
||||||
(logEl.children.length % 2 ? 'rgba(255,255,255,0.1)' : '') + ';color:' + color); // zebra lines
|
}
|
||||||
|
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) {
|
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;
|
el.textContent = val;
|
||||||
|
|
||||||
@@ -56,7 +68,7 @@
|
|||||||
|
|
||||||
function clear() {
|
function clear() {
|
||||||
if (_options.noUi) {
|
if (_options.noUi) {
|
||||||
window.parent.clearConsole();
|
mainWindow.clearConsole();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
logEl.innerHTML = '';
|
logEl.innerHTML = '';
|
||||||
@@ -86,7 +98,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function init(options) {
|
function init(options) {
|
||||||
if (isInitialized) { return; }
|
if (isInitialized) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
isInitialized = true;
|
isInitialized = true;
|
||||||
|
|
||||||
@@ -175,7 +189,6 @@
|
|||||||
destroy: checkInitDecorator(destroy)
|
destroy: checkInitDecorator(destroy)
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
var mainWindow = window.parent.onMessageFromConsole ? window.parent : window.parent.opener;
|
|
||||||
screenLog.init({
|
screenLog.init({
|
||||||
noUi: true,
|
noUi: true,
|
||||||
proxyCallback: function() {
|
proxyCallback: function() {
|
||||||
@@ -190,4 +203,4 @@ window._wmEvaluate = function _wmEvaluate(expr) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mainWindow.onMessageFromConsole.call(null, result);
|
mainWindow.onMessageFromConsole.call(null, result);
|
||||||
}
|
};
|
||||||
|
Reference in New Issue
Block a user