From 89b22bccba0c35b1264ac0288a9be810a446f031 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:51:04 +0800
Subject: [PATCH] move files to locations describing their function
---
gui/pages/open/popup.htm | 6 +-
gui/pages/open/settings.htm | 9 +-
gui/pages/settings.htm | 137 ++++++++++++-----------
gui/scripts/{ => pages}/popup.js | 12 +-
gui/scripts/pages/settings.js | 61 ++++++++++
gui/scripts/settings.JS | 184 -------------------------------
6 files changed, 148 insertions(+), 261 deletions(-)
rename gui/scripts/{ => pages}/popup.js (64%)
create mode 100644 gui/scripts/pages/settings.js
delete mode 100644 gui/scripts/settings.JS
diff --git a/gui/pages/open/popup.htm b/gui/pages/open/popup.htm
index 87f4450..3122b25 100644
--- a/gui/pages/open/popup.htm
+++ b/gui/pages/open/popup.htm
@@ -1,5 +1,5 @@
-
-
-
+
+
+
diff --git a/gui/pages/open/settings.htm b/gui/pages/open/settings.htm
index ae7db14..20f6411 100644
--- a/gui/pages/open/settings.htm
+++ b/gui/pages/open/settings.htm
@@ -1,5 +1,8 @@
-
-
-
+
+
+
diff --git a/gui/pages/settings.htm b/gui/pages/settings.htm
index 7fd747f..075dcfa 100644
--- a/gui/pages/settings.htm
+++ b/gui/pages/settings.htm
@@ -1,66 +1,75 @@
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/gui/scripts/popup.js b/gui/scripts/pages/popup.js
similarity index 64%
rename from gui/scripts/popup.js
rename to gui/scripts/pages/popup.js
index bd24577..884589e 100644
--- a/gui/scripts/popup.js
+++ b/gui/scripts/pages/popup.js
@@ -3,22 +3,20 @@
*/
// Import modules.
-import texts from './read.JS';
-import windowman from './windowman.JS';
+import windowman from "../windowman.js";
let secretariat = await import(chrome.runtime.getURL("scripts/secretariat.js"));
-
function start() {
- windowman.prepare();
+ windowman.prepare();
}
/* Populate the strings on the page. */
function say(element) {
- // document.title
+ // document.title
}
function main() {
- let tab = start();
- say(tab);
+ let tab = start();
+ say(tab);
}
main();
diff --git a/gui/scripts/pages/settings.js b/gui/scripts/pages/settings.js
new file mode 100644
index 0000000..fca129b
--- /dev/null
+++ b/gui/scripts/pages/settings.js
@@ -0,0 +1,61 @@
+/* Settings.js
+ Build the interface for the settings
+*/
+
+// Import modules.
+import { windowman } from "../windowman.js";
+let secretariat = await import(chrome.runtime.getURL("scripts/secretariat.js"));
+
+// Import configuration file.
+// const config = chrome.runtime.getURL('gui/layouts/settings.json');
+
+let pref_pane = 0;
+
+function start() {
+ windowman.prepare();
+}
+
+/* Generate the appropriate strings. */
+function say() {
+ windowman.fill();
+}
+
+/*
+ Arrange the interface.
+ */
+function arrange() {
+ async function click() {
+ let last_opened = (
+ await Promise.all([secretariat.read([`view`, window.location.href], 1)])
+ )[0];
+ if (!last_opened) {
+ last_opened = "settings";
+ }
+
+ document.querySelector(`[role="tab"][for="${last_opened}"]`).click();
+ }
+
+ // click!
+ // document.querySelector(`menu button[role="tab"][aria-controls="${last_opened}"]`).click();
+ click();
+}
+
+/*
+ Define the mapping of each button.
+ */
+function events() {
+ windowman.events();
+}
+
+function main() {
+ let tab = start();
+ say();
+ events();
+
+ arrange();
+
+ /*arrange();
+ events();*/
+}
+
+main();
diff --git a/gui/scripts/settings.JS b/gui/scripts/settings.JS
deleted file mode 100644
index 5cbc17f..0000000
--- a/gui/scripts/settings.JS
+++ /dev/null
@@ -1,184 +0,0 @@
-/* Settings.js
- Build the interface for the settings
-*/
-
-// Import modules.
-import texts from './read.JS';
-import {windowman} from './windowman.JS';
-let secretariat = await import(chrome.runtime.getURL("scripts/secretariat.js"));
-
-// Import configuration file.
-// const config = chrome.runtime.getURL('gui/layouts/settings.json');
-
-let pref_pane = 0;
-
-
-function start() {
- windowman.prepare();
-}
-
-/* Generate the appropriate strings. */
-function say() {
- windowman.fill();
-}
-
- /* Add the UI design. */
- //function design(element) {
- // Set the event of the window.
- /*function controls() {
- document.getElementById(element[`titlebar`][`controls`][`Close`][`ID`]).onclick = function(){element.terminate(false)};
- }
-
- function menu() {
- element.inject(null, 'navbar', element[`content`], `menu`, null, null, {'role': 'tablist'})
- }
-
- /* Add the content. */
- /*function content() {
- let page_layout = jsonData;
-
- windowman_builder.tabs(Object.keys(page_layout));
-
- function tabs(tab_names, parent_element) {
- (tab_names).forEach((tab_name) => {
- // Create the elements for each tab content.
- let inserted_element = element.inject(texts.localized(`term_`.concat(tab_name)), texts.localized(`term_`.concat(tab_name)), element[`content`], `section`, null, null, {'role': `tabpanel`});
-
- // Create the menu elements.
- element.inject(texts.localized(`term_`.concat(tab_name)), texts.localized(`term_`.concat(tab_name)), element[`content`][`navbar`], `button`, null, null, {'aria-controls': inserted_element});
-
- });
- }
-
- /*
- Add each item for each preference page, but do not fill in their default preferences.
-
- @param {dictionary} layout the layout
- *//*
- function eachItem(layout) {
- (layout).forEach((tab) => {
- // let inserted_element = element.inject(texts.localized(`term_`.concat(tab_name)), texts.localized(`term_`.concat(tab_name)), element[`content`], `section`, null, null, {'role': `tabpanel`});
- let current_tab = element[`content`][`navbar`][texts.localized(`term_`.concat(tab_name))];
-
- (Object.keys(current_tab)).forEach((element_item) => {
-
- })
-
- // element.update(element[`content`][`navbar`][texts.localized(`term_`.concat(tab_name))], texts.localized(`term_`.concat(tab_name)));
- // Create the elements for each tab content.
- element.inject(texts.localized(`term_`.concat(tab)), texts.localized(`term_`.concat(tab_name)), element[`content`], `section`, null, null, {'role': `tabpanel`});
-
- // Create the menu elements.
- element.inject(texts.localized(`term_`.concat(tab_name)), texts.localized(`term_`.concat(tab_name)), element[`content`][`navbar`], `button`, null, null, {'aria-controls': inserted_element});
-
- });
- }
-
-
- tabs(Object.keys(page_layout));
- }
-
- function action_buttons() {
- element.inject(`action_buttons`, `footer`, element[`content`], `footer`, [`field-row`], null, {'style': 'justify-content: flex-end'});
-
- let button_names = ['apply', 'cancel'];
-
- (button_names).forEach((button_name) => {
- // Create the elements for each tab content.
- element.inject(null, texts.localized(`term_`.concat(button_name)), element[`content`][`footer`], `button`);
- });
- }
-
- controls();
- menu();
- content();
- action_buttons();
- }
-
- /* Populate the strings on the page. */
- /*function say(element) {
- document.title = texts.localized(`GUI_title_preferences`);
- element.update(element[`titlebar`][`title`], texts.localized(`GUI_title_preferences`));
-
-
- function content() {
- fetch(config)
- .then((response) => response.json())
- .then((jsonData) => {
- let page_layout = jsonData;
-
- function tabs(tab_names) {
- (tab_names).forEach((tab_name) => {
- // Create the elements for each tab content.
- element.update(element[`content`][`navbar`][texts.localized(`term_`.concat(tab_name))], texts.localized(`term_`.concat(tab_name)));
- });
- }
-
- tabs(Object.keys(page_layout));
- })
- .catch((error) => {
- console.error(error);
- });
- }
-
- // Controls
- /*
- let tab_names = ['preferences', 'filters', 'about'];
- (tab_names).forEach((tab_name) => {
- element.update(element[`content`][`navbar`][texts.localized(`term_`.concat(tab_name))], texts.localized(`term_`.concat(tab_name)));
- });
-
- function action_buttons() {
- let button_names = ['apply', 'cancel'];
-
- (button_names).forEach((button_name) => {
- // Create the elements for each tab content.
- element.update(element[`content`][`footer`][texts.localized(`term_`.concat(button_name))], texts.localized(`term_`.concat(button_name)));
- });
- }
-
- content();
- action_buttons();
-
- }
-
- */
-
- /*
- Arrange the interface.
- */
- function arrange() {
- async function click() {
- let last_opened = (await Promise.all([secretariat.read([`view`, window.location.href], 1)]))[0];
- if (!last_opened) {last_opened = 'settings'};
-
- document.querySelector(`[role="tab"][for="${last_opened}"]`).click();
- }
-
-
-
- // click!
- // document.querySelector(`menu button[role="tab"][aria-controls="${last_opened}"]`).click();
- click();
- }
-
- /*
- Define the mapping of each button.
- */
- function events() {
- windowman.events();
- };
-
- function main() {
- let tab = start();
- say();
- events();
-
- arrange();
-
-
- /*arrange();
- events();*/
- }
-
- main();