relocate windowman to be in /scripts/GUI

This commit is contained in:
buzz-lightsnack-2007 2024-04-15 15:16:40 +08:00
parent 9e164cabcc
commit b5bcb59de2
7 changed files with 39 additions and 63 deletions

View file

@ -1,7 +1,7 @@
import { windowman } from "../../windowman.JS"; import windowman from "/scripts/GUI/windowman.JS";
function redirect() { function redirect() {
windowman.new(`gui/pages/settings.htm`); windowman.new(`/gui/pages/settings.htm`);
window.close(); window.close();
} }

View file

@ -1,6 +1,6 @@
// Open the settings in a pop-up window. // Open the settings in a pop-up window.
import { windowman } from "../../windowman.JS"; import windowman from "/scripts/GUI/windowman.JS";
function redirect() { function redirect() {
windowman.new(`gui/pages/settings.htm`); windowman.new(`gui/pages/settings.htm`);

View file

@ -3,7 +3,7 @@
*/ */
// Import modules. // Import modules.
import windowman from "../windowman.js"; import windowman from "/scripts/GUI/windowman.js";
let secretariat = await import(chrome.runtime.getURL("scripts/secretariat.js")); let secretariat = await import(chrome.runtime.getURL("scripts/secretariat.js"));
function start() { function start() {

View file

@ -6,12 +6,8 @@
//import { windowman } from "../windowman.js"; //import { windowman } from "../windowman.js";
async function build() { async function build() {
let secretariat = await import( let secretariat = await import(chrome.runtime.getURL("scripts/secretariat.js"));
chrome.runtime.getURL("scripts/secretariat.js") let windowman = (await import(chrome.runtime.getURL("/scripts/GUI/windowman.js"))).default;
);
let windowman = (
await import(chrome.runtime.getURL("gui/scripts/windowman.js"))
).default;
let window = new windowman(); let window = new windowman();
window.sync(); window.sync();

View file

@ -1,7 +1,8 @@
/* windowman /* windowman
Window and window content management */ Window and window content management */
import texts from "./read.js"; import texts from "../strings/read.js";
import net from "../net.js";
// MAKE SURE TO TURN THIS OFF DURING BUILD. // MAKE SURE TO TURN THIS OFF DURING BUILD.
let DEBUG = false; let DEBUG = false;
@ -18,13 +19,13 @@ export default class windowman {
// Prepare the window with its metadata. // Prepare the window with its metadata.
constructor() { constructor() {
function headers() { async function headers() {
let LOAD_STATE = true; let LOAD_STATE = true;
let UI = { let UI = {
CSS: [ CSS: [
chrome.runtime.getURL("gui/styles/external/fonts/materialdesignicons.min.css"), chrome.runtime.getURL("/gui/styles/external/fonts/materialdesignicons.min.css"),
chrome.runtime.getURL("gui/styles/external/materialize/css/materialize.css"), chrome.runtime.getURL("/gui/styles/external/materialize/css/materialize.css"),
chrome.runtime.getURL("gui/styles/ui.css"), chrome.runtime.getURL("/gui/styles/ui.css"),
] ]
}; };
@ -32,13 +33,8 @@ export default class windowman {
const source = UI.CSS[index]; const source = UI.CSS[index];
try { try {
(async () => {
// Import source reading for later.
const reader = (await import(chrome.runtime.getURL(`/gui/scripts/read.js`))).default;
const net = await import(chrome.runtime.getURL(`/scripts/net.js`));
let resource = false; let resource = false;
try { try {
resource = await net.download(source, `text`, true); resource = await net.download(source, `text`, true);
} catch (err) {} } catch (err) {}
@ -50,12 +46,9 @@ export default class windowman {
metadata_element.setAttribute(`href`, source); metadata_element.setAttribute(`href`, source);
document.querySelector(`head`).appendChild(metadata_element); document.querySelector(`head`).appendChild(metadata_element);
} else { } else {
throw new ReferenceError(reader.localized(`error_msg_fileNotFound`)); throw new ReferenceError(new texts(`error_msg_fileNotFound`, [UI.CSS[index]]));
} }
})();
} catch(err) { } catch(err) {
(async() => {
const alerts = (await import(chrome.runtime.getURL(`/gui/scripts/alerts.js`))).default; const alerts = (await import(chrome.runtime.getURL(`/gui/scripts/alerts.js`))).default;
// Raise an alert. // Raise an alert.
@ -65,7 +58,6 @@ export default class windowman {
if (!DEBUG) { if (!DEBUG) {
window.close(); window.close();
} }
})();
// Stop loading immediately during the error. // Stop loading immediately during the error.
break; break;
@ -76,16 +68,6 @@ export default class windowman {
// Get the window. // Get the window.
this[`metadata`] = chrome.windows.getCurrent(); this[`metadata`] = chrome.windows.getCurrent();
/*
window_metadata[`id`] = window.id;
window_metadata[`focused`] = window.focused;
window_metadata[`state`] = window.state;
window_metadata[`type`] = window.type;
window_metadata[`incognito`] = window.incognito;
window_metadata[`alwaysOnTop`] = window.alwaysOnTop;
window_metadata[`sessionId`] = window.sessionId;
window_metadata[`tabs`] = window.tabs;*/
/* Fill in data and events. */ /* Fill in data and events. */
function appearance() { function appearance() {
// Add missing classes to all elements. // Add missing classes to all elements.
@ -417,9 +399,9 @@ export default class windowman {
/* Enable the searching interface. */ /* Enable the searching interface. */
async function search() { async function search() {
const search_GUI_manager = (await import(chrome.runtime.getURL(`gui/scripts/windowman.search.js`))); const search_GUI_manager = (await import(chrome.runtime.getURL(`scripts/gui/windowman.search.js`)));
return (search_GUI_manager.search()); return (search_GUI_manager.search());
} };
fill(); fill();
update(); update();
@ -427,5 +409,3 @@ export default class windowman {
this[`search`] = search(); this[`search`] = search();
} }
} }
export { windowman };

View file

@ -1,6 +1,6 @@
import {read, write, observe} from "/scripts/secretariat.js"; import {read, write, observe} from "/scripts/secretariat.js";
import alerts from "/gui/scripts/alerts.js" import alerts from "/gui/scripts/alerts.js"
import texts from "/gui/scripts/read.js"; import texts from "/scripts/strings/read.js";
export function search() { export function search() {
if (document.querySelectorAll(`[data-result]`)) { if (document.querySelectorAll(`[data-result]`)) {

View file

@ -3,7 +3,7 @@ Manage filters.
*/ */
import {read, write, forget, search} from "./secretariat.js"; import {read, write, forget, search} from "./secretariat.js";
import {download} from "./net.js"; import net from "./net.js";
import texts from "/gui/scripts/read.js"; import texts from "/gui/scripts/read.js";
import {Queue} from "./common.js"; import {Queue} from "./common.js";
import alerts from "/gui/scripts/alerts.js" import alerts from "/gui/scripts/alerts.js"
@ -73,7 +73,7 @@ export default class filters {
new alerts (texts.localized(`settings_filters_update_status`, null, [filter_URL])); new alerts (texts.localized(`settings_filters_update_status`, null, [filter_URL]));
// Create promise of downloading. // Create promise of downloading.
let filter_download = download(filter_URL, `JSON`, false, true); let filter_download = net.download(filter_URL, `JSON`, false, true);
filter_download filter_download
.then(async function (result) { .then(async function (result) {
// Only work when the filter is valid. // Only work when the filter is valid.