From 908433d80d1916c42e80168f32bbb97829c1823f Mon Sep 17 00:00:00 2001
From: buzz-lightsnack-2007
<73412182+buzz-lightsnack-2007@users.noreply.github.com>
Date: Thu, 28 Mar 2024 08:53:29 +0800
Subject: [PATCH] locally renamed files as lowercase file extensions
because not all IDEs seem to support uppercase file name extensions
---
gui/scripts/alerts.js | 35 ++--
gui/scripts/logging.JS | 6 +-
gui/scripts/windowman.JS | 360 ++++++++++++++++++++++-----------------
3 files changed, 223 insertions(+), 178 deletions(-)
diff --git a/gui/scripts/alerts.js b/gui/scripts/alerts.js
index 8e9825d..ba0473d 100644
--- a/gui/scripts/alerts.js
+++ b/gui/scripts/alerts.js
@@ -1,18 +1,17 @@
-/* alerts.js
-Alert management system.
-*/
-
-export function confirm_action() {
- let user_response = false;
-
- (async () => {
- // Import the module.
- let reader = await import(chrome.runtime.getURL("gui/scripts/read.JS"));
-
- // Get the user response.
- user_response = confirm(reader.read(`GUI_alert_confirm_action_text`));
-
- })();
- // Return the user response.
- return (user_response);
-};
+/* alerts.js
+Alert management system.
+*/
+
+export function confirm_action() {
+ let user_response = false;
+
+ (async () => {
+ // Import the module.
+ let reader = await import(chrome.runtime.getURL("gui/scripts/read.js"));
+
+ // Get the user response.
+ user_response = confirm(reader.read(`GUI_alert_confirm_action_text`));
+ })();
+ // Return the user response.
+ return user_response;
+}
diff --git a/gui/scripts/logging.JS b/gui/scripts/logging.JS
index a9c4665..f544d76 100644
--- a/gui/scripts/logging.JS
+++ b/gui/scripts/logging.JS
@@ -13,13 +13,13 @@ export default class logging {
static error(ERROR_CODE, ERROR_MESSAGE, critical = true) {
(async () => {
// Import the templating.
- const texts = await import(chrome.runtime.getURL("gui/scripts/read.JS"));
+ const texts = await import(chrome.runtime.getURL("gui/scripts/read.js"));
// 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)]))
- };
+ alert(texts.read(`error_msg_GUI`, [String(ERROR_CODE)]));
+ }
})();
}
}
diff --git a/gui/scripts/windowman.JS b/gui/scripts/windowman.JS
index 8ff6ba2..54cc6d7 100644
--- a/gui/scripts/windowman.JS
+++ b/gui/scripts/windowman.JS
@@ -1,205 +1,251 @@
/* windowman
Window management */
-import texts from "./read.JS";
+import texts from "./read.js";
class windowman {
- /* Initialize the window frame. */
- static prepare() {
+ /* Initialize the window frame. */
+ static prepare() {
try {
- let UI = {'library': [chrome.runtime.getURL('gui/styles/interface.external.css'), chrome.runtime.getURL('gui/styles/ui.css')], 'script': chrome.runtime.getURL('gui/scripts/external/interface.external.js')};
+ let UI = {
+ library: [
+ chrome.runtime.getURL("gui/styles/interface.external.css"),
+ chrome.runtime.getURL("gui/styles/ui.css"),
+ ],
+ script: chrome.runtime.getURL(
+ "gui/scripts/external/interface.external.js",
+ ),
+ };
- (UI.library).forEach((source) => {
- $(`head`).append(``);
- })
+ UI.library.forEach((source) => {
+ $(`head`).append(
+ ``,
+ );
+ });
- $(`head`).append(``);
- } catch(error) {
- console.error(texts.localized(`error_fileNotFound`, [error]));
+ $(`head`).append(``);
+ } catch (error) {
+ console.error(texts.localized(`error_fileNotFound`, [error]));
}
- // Prevent scaling, similar to a real window.
- $(`head`).append(``);
- }
+ // Prevent scaling, similar to a real window.
+ $(`head`).append(
+ ``,
+ );
+ }
+ constructor(URL, height, width) {
+ this.window = chrome.windows.create({
+ url: chrome.runtime.getURL(URL),
+ type: "popup",
+ width: width ? width : 400,
+ height: height ? height : 600,
+ });
+ }
- constructor(URL, height, width) {
- this.window = chrome.windows.create({
- url: chrome.runtime.getURL(URL),
- type: "popup",
- width: (width) ? width: 400,
- height: (height) ? height: 600,
- });
- }
+ static fill() {
+ function text() {
+ let text_elements = document.querySelectorAll("[data-text]");
- static fill() {
+ text_elements.forEach((text_element) => {
+ let text_inserted = texts.localized(
+ text_element.getAttribute(`data-text`),
+ text_element.hasAttribute(`data-text-parameter`)
+ ? eval(text_element.getAttribute(`data-text-parameter`))
+ : null,
+ );
+ if (!text_inserted) {
+ text_inserted = texts.localized(
+ `term_`.concat(text_element.getAttribute(`data-text`)),
+ );
+ }
- function text() {
- let text_elements = document.querySelectorAll("[data-text]");
+ text_element.innerText = text_inserted;
+ });
+ }
- text_elements.forEach((text_element) => {
- let text_inserted = texts.localized(text_element.getAttribute(`data-text`), (text_element.hasAttribute(`data-text-parameter`)) ? eval(text_element.getAttribute(`data-text-parameter`)) : null );
- if (!text_inserted) {text_inserted = texts.localized(`term_`.concat(text_element.getAttribute(`data-text`)));}
+ function storage() {
+ (async () => {
+ // Import the module.
+ const secretariat = await import(
+ chrome.runtime.getURL("scripts/secretariat.js")
+ );
- text_element.innerText = text_inserted;
- })
- }
+ let input_elements = document.querySelectorAll("[data-store]");
- function storage() {
- (async () => {
- // Import the module.
- const secretariat = await import(chrome.runtime.getURL("scripts/secretariat.js"));
+ input_elements.forEach((input_element) => {
+ // Gather data about the element.
+ // Get the corresponding storage data.
+ let data = {};
+ data[`source`] = input_element.getAttribute(`data-store`);
+ data[`value`] = secretariat.read(data[`source`], -1);
- let input_elements = document.querySelectorAll("[data-store]");
+ data[`value`].then((value) => {
+ switch (input_element.getAttribute(`type`).toLowerCase()) {
+ case `checkbox`:
+ input_element.checked = value;
+ break;
+ case `progress`:
+ case `range`:
+ // Ensure that it is a positive floating-point number.
+ value = !value ? 0 : Math.abs(parseFloat(value));
+ if (value > 100) {
+ value = value / 100;
+ }
- input_elements.forEach((input_element) => {
- // Gather data about the element.
- // Get the corresponding storage data.
- let data = {};
- data[`source`] = input_element.getAttribute(`data-store`);
- data[`value`] = secretariat.read(data[`source`], -1);
+ // Set the attribute of the progress bar.
+ input_element.setAttribute(`value`, value);
+ input_element.setAttribute(`max`, 1);
+ break;
+ default:
+ input_element.value = value;
+ break;
+ }
+ });
+ });
+ })();
+ }
- data[`value`].then((value) => {
- switch (input_element.getAttribute(`type`).toLowerCase()) {
- case `checkbox`:
- input_element.checked = value;
- break;
- case `progress`:
- case `range`:
- // Ensure that it is a positive floating-point number.
- value = (!value) ? 0 : Math.abs(parseFloat(value));
- if (value > 100) {value = value / 100};
+ text();
+ storage();
+ }
- // Set the attribute of the progress bar.
- input_element.setAttribute(`value`, value);
- input_element.setAttribute(`max`, 1);
- break;
- default:
- input_element.value = value;
- break;
- }
- });
+ /* Add click events. */
+ static events() {
+ /* Add events related to storage. */
+ function storage() {
+ (async () => {
+ // Import the module.
+ const secretariat = await import(
+ chrome.runtime.getURL("scripts/secretariat.js")
+ );
- });
- })();
- }
+ let input_elements = document.querySelectorAll("[data-store]");
- text();
- storage();
- }
+ input_elements.forEach((input_element) => {
+ // Gather data about the element.
+ // Get the corresponding storage data.
- /* Add click events. */
- static events() {
+ let element = {};
+ element[`type`] = input_element.getAttribute(`type`).toLowerCase();
+ element[`event`] = function () {};
- /* Add events related to storage. */
- function storage() {
- (async () => {
- // Import the module.
- const secretariat = await import(chrome.runtime.getURL("scripts/secretariat.js"));
-
- let input_elements = document.querySelectorAll("[data-store]");
-
- input_elements.forEach((input_element) => {
- // Gather data about the element.
- // Get the corresponding storage data.
-
- let element = {};
- element[`type`] = input_element.getAttribute(`type`).toLowerCase();
- element[`event`] = function() {};
-
- switch (element[`type`]) {
- case `checkbox`:
- element[`event`] = function() {
- let UI_item = {};
- UI_item[`source`] = this.getAttribute(`data-store`);
- UI_item[`value`] = this.checked;
- secretariat.write(UI_item[`source`], UI_item[`value`]);
- };
- break;
- case `range`:
- /*// Ensure that it is a positive floating-point number.
+ switch (element[`type`]) {
+ case `checkbox`:
+ element[`event`] = function () {
+ let UI_item = {};
+ UI_item[`source`] = this.getAttribute(`data-store`);
+ UI_item[`value`] = this.checked;
+ secretariat.write(UI_item[`source`], UI_item[`value`]);
+ };
+ break;
+ case `range`:
+ /*// Ensure that it is a positive floating-point number.
value = (!value) ? 0 : Math.abs(parseFloat(value));
if (value > 100) {value = value / 100};
// Set the attribute of the progress bar.
input_element.setAttribute(`value`, value);
input_element.setAttribute(`max`, 1);*/
- default:
- element[`event`] = function() {
- secretariat.write(data[`source`][`root`], data[`source`][`target`], this.value);
- };
- break;
- }
+ default:
+ element[`event`] = function () {
+ secretariat.write(
+ data[`source`][`root`],
+ data[`source`][`target`],
+ this.value,
+ );
+ };
+ break;
+ }
- input_element.addEventListener('change', element[`event`]);
- });
- })();
- }
+ input_element.addEventListener("change", element[`event`]);
+ });
+ })();
+ }
- /* Make it feel more like a native window. */
- function functionality() {
- /* Adjust the interface based on events. */
- function changeUI() {
- function tabs() {
- let menus = (document.querySelectorAll("menu[role=tablist]"))
+ /* Make it feel more like a native window. */
+ function functionality() {
+ /* Adjust the interface based on events. */
+ function changeUI() {
+ function tabs() {
+ let menus = document.querySelectorAll("menu[role=tablist]");
- if (menus) {
- menus.forEach((menu) => {
- let buttons = menu.querySelectorAll("button, a");
+ if (menus) {
+ menus.forEach((menu) => {
+ let buttons = menu.querySelectorAll("button, a");
- if (buttons) {
- buttons.forEach((button) => {
- let event = function() {
- // Prevent selection.
- let MENU = this.parentElement;
- let BUTTONS = MENU.querySelectorAll("button, a");
+ if (buttons) {
+ buttons.forEach((button) => {
+ let event = function () {
+ // Prevent selection.
+ let MENU = this.parentElement;
+ let BUTTONS = MENU.querySelectorAll("button, a");
- BUTTONS.forEach((BUTTON) => {
- BUTTON.setAttribute(`aria-selected`, String(BUTTON.getAttribute(`for`) == this.getAttribute(`for`)));
- });
+ BUTTONS.forEach((BUTTON) => {
+ BUTTON.setAttribute(
+ `aria-selected`,
+ String(
+ BUTTON.getAttribute(`for`) ==
+ this.getAttribute(`for`),
+ ),
+ );
+ });
- let CONTAINER = document.getElementById(MENU.getAttribute(`for`));
- let SECTIONS = CONTAINER.querySelectorAll(`#${CONTAINER.id} > section`);
+ let CONTAINER = document.getElementById(
+ MENU.getAttribute(`for`),
+ );
+ let SECTIONS = CONTAINER.querySelectorAll(
+ `#${CONTAINER.id} > section`,
+ );
- SECTIONS.forEach((SECTION) => {
- // SECTION.setAttribute(`hidden`, true);
+ SECTIONS.forEach((SECTION) => {
+ // SECTION.setAttribute(`hidden`, true);
- if (!(this.getAttribute(`for`)).includes(SECTION.id)) {
- SECTION.setAttribute(`hidden`, ((this.getAttribute(`for`)).includes(SECTION.id)));
- } else {
- SECTION.removeAttribute(`hidden`);
- }
- });
+ if (!this.getAttribute(`for`).includes(SECTION.id)) {
+ SECTION.setAttribute(
+ `hidden`,
+ this.getAttribute(`for`).includes(SECTION.id),
+ );
+ } else {
+ SECTION.removeAttribute(`hidden`);
+ }
+ });
- // Save.
- (async () => {
- const secretariat = await import(chrome.runtime.getURL("scripts/secretariat.js"));
+ // Save.
+ (async () => {
+ const secretariat = await import(
+ chrome.runtime.getURL("scripts/secretariat.js")
+ );
- // Write the data.
- secretariat.write([`view`, window.location.href], this.getAttribute(`for`), 1);
- })();
- };
+ // Write the data.
+ secretariat.write(
+ [`view`, window.location.href],
+ this.getAttribute(`for`),
+ 1,
+ );
+ })();
+ };
- button.addEventListener('click', event);
- })
- }
- })
- }
- }
+ button.addEventListener("click", event);
+ });
+ }
+ });
+ }
+ }
- tabs();
- };
+ tabs();
+ }
+ document.addEventListener("contextmenu", (event) =>
+ event.preventDefault(),
+ );
+ changeUI();
+ }
- document.addEventListener('contextmenu', event => event.preventDefault());
-
- changeUI();
- }
-
- storage();
- functionality();
- }
+ storage();
+ functionality();
+ }
}
-export {windowman};
+export { windowman };