console only top window
This commit is contained in:
parent
157ebaef9c
commit
042aa94936
1 changed files with 38 additions and 14 deletions
|
@ -28,8 +28,6 @@ store.subscribe(() => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
consoleFrames.initialize(window.document);
|
|
||||||
|
|
||||||
const reloadSettings = () => {
|
const reloadSettings = () => {
|
||||||
return browser.runtime.sendMessage({
|
return browser.runtime.sendMessage({
|
||||||
type: messages.SETTINGS_QUERY,
|
type: messages.SETTINGS_QUERY,
|
||||||
|
@ -38,17 +36,43 @@ const reloadSettings = () => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
browser.runtime.onMessage.addListener((action) => {
|
// TODO: the followin methods should be implemented in each top component and
|
||||||
switch (action.type) {
|
// frame component
|
||||||
case messages.CONSOLE_HIDE_COMMAND:
|
const initTopComponents = () => {
|
||||||
window.focus();
|
consoleFrames.initialize(window.document);
|
||||||
consoleFrames.blur(window.document);
|
|
||||||
return Promise.resolve();
|
browser.runtime.onMessage.addListener((action) => {
|
||||||
case messages.SETTINGS_CHANGED:
|
switch (action.type) {
|
||||||
return reloadSettings();
|
case messages.CONSOLE_HIDE_COMMAND:
|
||||||
default:
|
window.focus();
|
||||||
return Promise.resolve();
|
consoleFrames.blur(window.document);
|
||||||
}
|
return Promise.resolve();
|
||||||
});
|
case messages.SETTINGS_CHANGED:
|
||||||
|
return reloadSettings();
|
||||||
|
default:
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const initFrameConponents = () => {
|
||||||
|
browser.runtime.onMessage.addListener((action) => {
|
||||||
|
switch (action.type) {
|
||||||
|
case messages.CONSOLE_HIDE_COMMAND:
|
||||||
|
window.focus();
|
||||||
|
return Promise.resolve();
|
||||||
|
case messages.SETTINGS_CHANGED:
|
||||||
|
return reloadSettings();
|
||||||
|
default:
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
if (window.self === window.top) {
|
||||||
|
initTopComponents();
|
||||||
|
} else {
|
||||||
|
initFrameConponents();
|
||||||
|
}
|
||||||
|
|
||||||
reloadSettings();
|
reloadSettings();
|
||||||
|
|
Reference in a new issue