attempt: rewrite events and trashed data
This commit is contained in:
parent
c7a262bd1d
commit
2a4e60420d
1 changed files with 29 additions and 18 deletions
|
@ -13,9 +13,9 @@ import logging from "/scripts/logging.js";
|
||||||
class Page_Popup extends Page {
|
class Page_Popup extends Page {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
(this.events) ? this.events() : false;
|
|
||||||
this.content();
|
this.content();
|
||||||
this.background();
|
this.background();
|
||||||
|
this.events();
|
||||||
};
|
};
|
||||||
|
|
||||||
async background() {
|
async background() {
|
||||||
|
@ -83,25 +83,21 @@ class Page_Popup extends Page {
|
||||||
: `loading`)];
|
: `loading`)];
|
||||||
|
|
||||||
// Replace the iframe src with the new page.
|
// Replace the iframe src with the new page.
|
||||||
this.elements[`frame`].forEach((frame) => {
|
this.elements[`frame`].src = PAGE;
|
||||||
frame.src = PAGE;
|
|
||||||
})
|
|
||||||
|
|
||||||
// The results page has its own container.
|
// The results page has its own container.
|
||||||
this.elements[`container`].forEach((CONTAINER) => {
|
this.elements[`container`].classList[(PAGE.includes(`results`)) ? `remove` : `add`](`container`);
|
||||||
CONTAINER.classList[(PAGE.includes(`results`)) ? `remove` : `add`](`container`);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
async content() {
|
async content() {
|
||||||
this.elements = {};
|
this.elements = {};
|
||||||
this.elements[`container`] = document.querySelectorAll(`main`);
|
this.elements[`container`] = document.querySelector(`main`);
|
||||||
this.elements[`frame`] = document.querySelectorAll(`main > iframe.viewer`);
|
this.elements[`frame`] = document.querySelector(`main > iframe.viewer`);
|
||||||
|
this.elements[`nav`] = document.querySelector(`nav`);
|
||||||
|
|
||||||
// Check if the frame is available.
|
// Check if the frame is available.
|
||||||
if (this.elements[`frame`].length) {
|
if (this.elements[`frame`]) {
|
||||||
await this.switch();
|
await this.switch();
|
||||||
this.background();
|
this.background();
|
||||||
} else {
|
} else {
|
||||||
|
@ -119,18 +115,33 @@ class Page_Popup extends Page {
|
||||||
logging.error(err.name, err.message, err.stack);
|
logging.error(err.name, err.message, err.stack);
|
||||||
throw (err);
|
throw (err);
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
events() {
|
events() {
|
||||||
(document.querySelector(`[data-action="open,settings"]`)) ? document.querySelector(`[data-action="open,settings"]`).addEventListener("click", () => {
|
this[`elements`] = (this[`elements`]) ? this[`elements`] : {};
|
||||||
|
this[`elements`][`button`] = {};
|
||||||
|
|
||||||
|
document.querySelectorAll(`[data-action]`).forEach((ELEMENT) => {
|
||||||
|
let ACTION = ELEMENT.getAttribute(`data-action`).trim();
|
||||||
|
this[`elements`][`button`][ACTION] = ELEMENT;
|
||||||
|
|
||||||
|
// Remove the data-action attribute.
|
||||||
|
ELEMENT.removeAttribute(`data-action`);
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(this[`elements`]);
|
||||||
|
|
||||||
|
this[`elements`][`button`][`open,settings`].addEventListener("click", () => {
|
||||||
chrome.runtime.openOptionsPage();
|
chrome.runtime.openOptionsPage();
|
||||||
}) : false;
|
});
|
||||||
(document.querySelector(`[data-action="open,help"]`)) ? document.querySelector(`[data-action="open,help"]`).addEventListener("click", () => {
|
|
||||||
|
this[`elements`][`button`][`open,help`].addEventListener("click", () => {
|
||||||
new Window(`help.htm`);
|
new Window(`help.htm`);
|
||||||
}) : false;
|
});
|
||||||
(document.querySelector(`[data-action="analysis,reload"]`)) ? document.querySelector(`[data-action="analysis,reload"]`).addEventListener("click", () => {
|
|
||||||
|
this[`elements`][`button`][`analysis,reload`].addEventListener("click", () => {
|
||||||
this.send();
|
this.send();
|
||||||
}) : false;
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue