extend the default page
This commit is contained in:
parent
b1cceec7fc
commit
d71e9effd0
3 changed files with 123 additions and 114 deletions
18
scripts/pages/page.js
Normal file
18
scripts/pages/page.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
/* page.js
|
||||
Construct an internal page.
|
||||
*/
|
||||
|
||||
import windowman from "/scripts/GUI/windowman.js";
|
||||
|
||||
export default class Page {
|
||||
constructor () {
|
||||
this.window = window;
|
||||
|
||||
this.window[`manager`] = new windowman();
|
||||
(this.window[`manager`]) ? this.window.manager.sync() : false;
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
M.AutoInit();
|
||||
});
|
||||
}
|
||||
};
|
|
@ -1,22 +1,21 @@
|
|||
/* Popup.js
|
||||
Build the interface for popup
|
||||
Build the interface for popup
|
||||
*/
|
||||
|
||||
// Import modules.
|
||||
import {read, forget} from "/scripts/secretariat.js";
|
||||
import windowman from "/scripts/GUI/windowman.js";
|
||||
let secretariat = await import(chrome.runtime.getURL("scripts/secretariat.js"));
|
||||
import Page from "/scripts/pages/page.js";
|
||||
|
||||
function start() {
|
||||
windowman.prepare();
|
||||
}
|
||||
/* Populate the strings on the page. */
|
||||
function say(element) {
|
||||
// document.title
|
||||
class Page_Popup extends Page {
|
||||
constructor() {
|
||||
super();
|
||||
(this.events) ? this.events() : false;
|
||||
}
|
||||
|
||||
events() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function main() {
|
||||
let tab = start();
|
||||
say(tab);
|
||||
}
|
||||
|
||||
main();
|
||||
new Page_Popup();
|
|
@ -5,109 +5,101 @@
|
|||
// Import modules.
|
||||
//import { windowman } from "../windowman.js";
|
||||
|
||||
import {forget} from "/scripts/secretariat.js";
|
||||
import windowman from "/scripts/GUI/windowman.js";
|
||||
import {read, forget} from "/scripts/secretariat.js";
|
||||
import Page from "/scripts/pages/page.js";
|
||||
|
||||
async function build() {
|
||||
let window = new windowman();
|
||||
window.sync();
|
||||
class Page_Settings extends Page {
|
||||
constructor() {
|
||||
super();
|
||||
(this.events) ? this.events() : false;
|
||||
}
|
||||
|
||||
/*
|
||||
Define the mapping of each button.
|
||||
|
||||
@param {object} window the window
|
||||
*/
|
||||
events() {
|
||||
if (document.querySelector(`[data-action="filters,update"]`)) {
|
||||
document
|
||||
.querySelector(`[data-action="filters,update"]`)
|
||||
.addEventListener(`click`, async () => {
|
||||
let filters = new (
|
||||
await import(chrome.runtime.getURL(`scripts/filters.js`))
|
||||
).default();
|
||||
filters.update();
|
||||
});
|
||||
}
|
||||
|
||||
// Add the window events.
|
||||
events(window);
|
||||
};
|
||||
|
||||
/*
|
||||
Define the mapping of each button.
|
||||
|
||||
@param {object} window the window
|
||||
*/
|
||||
function events(window) {
|
||||
if (document.querySelector(`[data-action="filters,update"]`)) {
|
||||
document
|
||||
.querySelector(`[data-action="filters,update"]`)
|
||||
.addEventListener(`click`, async () => {
|
||||
let filters = new (
|
||||
await import(chrome.runtime.getURL(`scripts/filters.js`))
|
||||
).default();
|
||||
filters.update();
|
||||
});
|
||||
}
|
||||
|
||||
if (document.querySelector(`[data-action="filters,add,one"]`)) {
|
||||
document
|
||||
.querySelector(`[data-action="filters,add,one"]`)
|
||||
.addEventListener(`click`, async () => {
|
||||
// Import the filters module.
|
||||
const texts = (
|
||||
await import(chrome.runtime.getURL(`/scripts/strings/read.js`))
|
||||
).default;
|
||||
let filters = new (
|
||||
await import(chrome.runtime.getURL(`scripts/filters.js`))
|
||||
).default();
|
||||
|
||||
let filter_source = prompt(
|
||||
texts.localized(`settings_filters_add_prompt`),
|
||||
);
|
||||
if (filter_source ? filter_source.trim() : false) {
|
||||
filters.update(filter_source.trim());
|
||||
};
|
||||
});
|
||||
}
|
||||
if (document.querySelector(`[data-action="filters,update,one"]`)) {
|
||||
document
|
||||
.querySelector(`[data-action="filters,update,one"]`)
|
||||
.addEventListener(`click`, async () => {
|
||||
// Import the filters module.
|
||||
const texts = (
|
||||
await import(chrome.runtime.getURL(`/scripts/strings/read.js`))
|
||||
).default;
|
||||
let filters = new (
|
||||
await import(chrome.runtime.getURL(`scripts/filters.js`))
|
||||
).default();
|
||||
|
||||
// Open text input window for adding a filter.
|
||||
let filter_source = (document.querySelector(`[data-result-linked="filters"] [data-result-content="*"]`)) ? document.querySelector(`[data-result-linked="filters"] [data-result-content="*"]`).innerText : prompt(texts.localized(`settings_filters_add_prompt`));
|
||||
if (filter_source ? filter_source.trim() : false) {
|
||||
filters.update(filter_source.trim());
|
||||
};
|
||||
});
|
||||
}
|
||||
if (document.querySelector(`[data-action="filters,add,one"]`)) {
|
||||
document
|
||||
.querySelector(`[data-action="filters,add,one"]`)
|
||||
.addEventListener(`click`, async () => {
|
||||
// Import the filters module.
|
||||
const texts = (
|
||||
await import(chrome.runtime.getURL(`/scripts/strings/read.js`))
|
||||
).default;
|
||||
let filters = new (
|
||||
await import(chrome.runtime.getURL(`scripts/filters.js`))
|
||||
).default();
|
||||
|
||||
let filter_source = prompt(
|
||||
texts.localized(`settings_filters_add_prompt`),
|
||||
);
|
||||
if (filter_source ? filter_source.trim() : false) {
|
||||
filters.update(filter_source.trim());
|
||||
};
|
||||
});
|
||||
}
|
||||
if (document.querySelector(`[data-action="filters,update,one"]`)) {
|
||||
document
|
||||
.querySelector(`[data-action="filters,update,one"]`)
|
||||
.addEventListener(`click`, async () => {
|
||||
// Import the filters module.
|
||||
const texts = (
|
||||
await import(chrome.runtime.getURL(`/scripts/strings/read.js`))
|
||||
).default;
|
||||
let filters = new (
|
||||
await import(chrome.runtime.getURL(`scripts/filters.js`))
|
||||
).default();
|
||||
|
||||
if (document.querySelector(`[data-action="filters,delete,one"]`)) {
|
||||
document
|
||||
.querySelector(`[data-action="filters,delete,one"]`)
|
||||
.addEventListener(`click`, async () => {
|
||||
// Import the filters module.
|
||||
let texts = (
|
||||
await import(chrome.runtime.getURL(`/scripts/strings/read.js`))
|
||||
).default;
|
||||
let filters = new (
|
||||
await import(chrome.runtime.getURL(`scripts/filters.js`))
|
||||
).default();
|
||||
|
||||
// Open text input window for adding a filter.
|
||||
let filter_source = (document.querySelector(`[data-result-linked="filters"] [data-result-content="*"]`)) ? document.querySelector(`[data-result-linked="filters"] [data-result-content="*"]`).innerText : prompt(texts.localized(`settings_filters_remove_prompt`));
|
||||
if (filter_source ? filter_source.trim() : false) {
|
||||
filters.remove(filter_source.trim());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (document.querySelector(`[data-action="storage,clear"]`)) {
|
||||
document
|
||||
.querySelector(`[data-action="storage,clear"]`)
|
||||
.addEventListener(`click`, async () => {
|
||||
forget(`sites`);
|
||||
});
|
||||
// Open text input window for adding a filter.
|
||||
let filter_source = (document.querySelector(`[data-result-linked="filters"] [data-result-content="*"]`)) ? document.querySelector(`[data-result-linked="filters"] [data-result-content="*"]`).innerText : prompt(texts.localized(`settings_filters_add_prompt`));
|
||||
if (filter_source ? filter_source.trim() : false) {
|
||||
filters.update(filter_source.trim());
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
if (document.querySelector(`[data-action="filters,delete,one"]`)) {
|
||||
document
|
||||
.querySelector(`[data-action="filters,delete,one"]`)
|
||||
.addEventListener(`click`, async () => {
|
||||
// Import the filters module.
|
||||
let texts = (
|
||||
await import(chrome.runtime.getURL(`/scripts/strings/read.js`))
|
||||
).default;
|
||||
let filters = new (
|
||||
await import(chrome.runtime.getURL(`scripts/filters.js`))
|
||||
).default();
|
||||
|
||||
// Open text input window for adding a filter.
|
||||
let filter_source = (document.querySelector(`[data-result-linked="filters"] [data-result-content="*"]`)) ? document.querySelector(`[data-result-linked="filters"] [data-result-content="*"]`).innerText : prompt(texts.localized(`settings_filters_remove_prompt`));
|
||||
if (filter_source ? filter_source.trim() : false) {
|
||||
filters.remove(filter_source.trim());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (document.querySelector(`[data-action="storage,clear"]`)) {
|
||||
document
|
||||
.querySelector(`[data-action="storage,clear"]`)
|
||||
.addEventListener(`click`, async () => {
|
||||
await forget(`sites`);
|
||||
console.log(await read(null, 1), await read(null, -1));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function load() {
|
||||
build();
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
M.AutoInit();
|
||||
});
|
||||
}
|
||||
|
||||
load();
|
||||
new Page_Settings();
|
Loading…
Add table
Add a link
Reference in a new issue