From 0059314655e481747d94b288bcc829746385f919 Mon Sep 17 00:00:00 2001 From: buzz-lightsnack-2007 <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Mon, 15 Apr 2024 15:49:22 +0800 Subject: [PATCH] And the fate of /gui is sealed Make sure that the proper files that are not in `/gui` are loaded. --- gui/scripts/external/ReadMe.md | 5 ----- gui/scripts/icons.js | 3 --- gui/scripts/logging.JS | 27 ------------------------ gui/scripts/read.JS | 38 ---------------------------------- {gui => pages}/popup.htm | 0 scripts/GUI/windowman.js | 2 +- scripts/filters.js | 4 ++-- scripts/logging.js | 2 +- scripts/net.js | 4 ++-- scripts/pages/settings.js | 6 +++--- 10 files changed, 9 insertions(+), 82 deletions(-) delete mode 100644 gui/scripts/external/ReadMe.md delete mode 100644 gui/scripts/icons.js delete mode 100644 gui/scripts/logging.JS delete mode 100644 gui/scripts/read.JS rename {gui => pages}/popup.htm (100%) diff --git a/gui/scripts/external/ReadMe.md b/gui/scripts/external/ReadMe.md deleted file mode 100644 index aff43f9..0000000 --- a/gui/scripts/external/ReadMe.md +++ /dev/null @@ -1,5 +0,0 @@ -# External GUI Libraries -are not included in this repository for the sake of providing authors' credit. Moreover, it's recommended to get the latest versions for as long as they do not break. - -## Dependencies -- [ ] [JQuery](https://jquery.com/) diff --git a/gui/scripts/icons.js b/gui/scripts/icons.js deleted file mode 100644 index 9db457d..0000000 --- a/gui/scripts/icons.js +++ /dev/null @@ -1,3 +0,0 @@ -/* icons.js -Manage icons. -*/ diff --git a/gui/scripts/logging.JS b/gui/scripts/logging.JS deleted file mode 100644 index 2e30fb0..0000000 --- a/gui/scripts/logging.JS +++ /dev/null @@ -1,27 +0,0 @@ -/* -logging.JS -Send messages for logging. -*/ - -export default class logging { - /* - Raise an error message. - - @param {number} ERROR_CODE the error code - @param {number} ERROR_MESSAGE the custom error message - */ - static error(ERROR_CODE, ERROR_MESSAGE, critical = true) { - (async () => { - // Import the templating. - const texts = ( - await import(chrome.runtime.getURL("gui/scripts/read.js")) - )[`texts`]; - - // Display the error message. - console.error(texts.read(`error_msg`, [ERROR_CODE, ERROR_MESSAGE])); - if (critical) { - alert(texts.read(`error_msg_GUI`, [String(ERROR_CODE)])); - } - })(); - } -} diff --git a/gui/scripts/read.JS b/gui/scripts/read.JS deleted file mode 100644 index 54df3ec..0000000 --- a/gui/scripts/read.JS +++ /dev/null @@ -1,38 +0,0 @@ -/* read_universal - Read a file stored in the universal strings. */ - -let messages = {}; -let message = ""; - -export default class texts { - /* This reads the message from its source. This is a fallback for the content scripts, who doesn't appear to read classes. - - @param {string} message the message name - @param {boolean} autofill fill in the message with the template name when not found - @param {list} params the parameters - @return {string} the message - */ - - static localized(message_name, autofill = false, params = []) { - if (params && (params ? params.length > 0 : false)) { - message = chrome.i18n.getMessage(message_name, params); - } else { - message = chrome.i18n.getMessage(message_name); - } - - // When the message is not found, return the temporary text. - if (!message && autofill) { - message = message_name; - } - - return message; - } -} - -export function read(message_name, autofill, params) { - let message; - - message = texts.localized(message_name, autofill, params); - - return message; -} diff --git a/gui/popup.htm b/pages/popup.htm similarity index 100% rename from gui/popup.htm rename to pages/popup.htm diff --git a/scripts/GUI/windowman.js b/scripts/GUI/windowman.js index 5a2d601..142efa5 100644 --- a/scripts/GUI/windowman.js +++ b/scripts/GUI/windowman.js @@ -5,7 +5,7 @@ import texts from "../strings/read.js"; import net from "../net.js"; // MAKE SURE TO TURN THIS OFF DURING BUILD. -let DEBUG = false; +let DEBUG = true; export default class windowman { static new(URL, height, width) { diff --git a/scripts/filters.js b/scripts/filters.js index e658000..fc3c9a4 100644 --- a/scripts/filters.js +++ b/scripts/filters.js @@ -6,8 +6,8 @@ import {read, write, forget, search} from "./secretariat.js"; import net from "./net.js"; import texts from "/scripts/strings/read.js"; import {Queue} from "./common.js"; -import logging from "/gui/scripts/logging.js" -// const logging = (await import(chrome.runtime.getURL("gui/scripts/logging.js"))).default; +import logging from "/scripts/logging.js" +// const logging = (await import(chrome.runtime.getURL("/scripts/logging.js"))).default; export default class filters { constructor() { diff --git a/scripts/logging.js b/scripts/logging.js index 522aa08..4dacc8d 100644 --- a/scripts/logging.js +++ b/scripts/logging.js @@ -64,7 +64,7 @@ export default class logging { */ static async error(ERROR_CODE, ERROR_MESSAGE, ERROR_STACK, critical = true) { // Import the templating. - const texts = (await import(chrome.runtime.getURL("gui/scripts/read.js"))).default; + const texts = (await import(chrome.runtime.getURL("/scripts/strings/read.js"))).default; // Display the error message. console.error(texts.localized(`error_msg`, false, [ERROR_CODE, ERROR_MESSAGE, ERROR_STACK])); diff --git a/scripts/net.js b/scripts/net.js index 2a21249..6e8f33a 100644 --- a/scripts/net.js +++ b/scripts/net.js @@ -13,9 +13,9 @@ Download a file from the network or locally. */ export default class net { static async download(URL, TYPE, VERIFY_ONLY = false, STRICT = false) { - const texts = (await import(chrome.runtime.getURL(`gui/scripts/read.js`))) + const texts = (await import(chrome.runtime.getURL(`/scripts/strings/read.js`))) .default; - const logging = (await import(chrome.runtime.getURL(`gui/scripts/logging.js`))).default; + const logging = (await import(chrome.runtime.getURL(`/scripts/logging.js`))).default; let CONNECT, DATA; diff --git a/scripts/pages/settings.js b/scripts/pages/settings.js index 9d1a5cc..f072c9f 100644 --- a/scripts/pages/settings.js +++ b/scripts/pages/settings.js @@ -39,7 +39,7 @@ function events(window) { .addEventListener(`click`, async () => { // Import the filters module. const texts = ( - await import(chrome.runtime.getURL(`gui/scripts/read.js`)) + await import(chrome.runtime.getURL(`/scripts/strings/read.js`)) ).default; let filters = new ( await import(chrome.runtime.getURL(`scripts/filters.js`)) @@ -59,7 +59,7 @@ function events(window) { .addEventListener(`click`, async () => { // Import the filters module. const texts = ( - await import(chrome.runtime.getURL(`gui/scripts/read.js`)) + await import(chrome.runtime.getURL(`/scripts/strings/read.js`)) ).default; let filters = new ( await import(chrome.runtime.getURL(`scripts/filters.js`)) @@ -79,7 +79,7 @@ function events(window) { .addEventListener(`click`, async () => { // Import the filters module. let texts = ( - await import(chrome.runtime.getURL(`gui/scripts/read.js`)) + await import(chrome.runtime.getURL(`/scripts/strings/read.js`)) ).default; let filters = new ( await import(chrome.runtime.getURL(`scripts/filters.js`))