From f60380de8e4cab4eabd96127b5f16026cfd635ae Mon Sep 17 00:00:00 2001
From: buzzcode2007 <73412182+buzz_lightsnack_2007@users.noreply.github.com>
Date: Sat, 23 Mar 2024 22:36:49 +0800
Subject: [PATCH] added the main window management
---
gui/scripts/windowman.JS | 110 +++++++++++++++++++++++++++++++++++++++
gui/settings.htm | 8 ++-
2 files changed, 117 insertions(+), 1 deletion(-)
create mode 100644 gui/scripts/windowman.JS
diff --git a/gui/scripts/windowman.JS b/gui/scripts/windowman.JS
new file mode 100644
index 0000000..5590012
--- /dev/null
+++ b/gui/scripts/windowman.JS
@@ -0,0 +1,110 @@
+/* windowman
+Window management */
+
+let UI = {'library': chrome.runtime.getURL('gui/styles/interface.external.css')};
+
+export default class windowman {
+ /* Initialize the window frame. */
+ static prepare() {
+ $(`head`).append(``);
+ }
+
+ /*
+ Creates a window frame within the specified element.
+
+ @param {string} element_target the element name to build into
+ @param {string} element_ID the target element ID; otherwise, a random ID is generated
+ @param {string} window_title the window's title
+ @param {dictionary} window_buttons the window buttons
+ @return {string} the element IDs
+ */
+ constructor(element_target, element_ID, window_title = document.title, window_buttons = {'Close': false, 'Minimize': false, 'Maximize': false}) {
+ if (!element_ID) {
+ // Make a random element ID.
+ element_ID = (Math.floor((Math.random())**(-3))).toString();
+ };
+
+ let element_data = {
+ 'ID': element_ID,
+ 'titlebar': `${element_ID}_titlebar`,
+ 'title': `${element_ID}_title`,
+ 'controls': `${element_ID}_btns`,
+ 'controls Close': `${element_ID}_btn_close`,
+ 'controls Minimize': `${element_ID}_btn_min`,
+ 'controls Maximize': `${element_ID}_btn_max`,
+ 'content': `${element_ID}_content`
+ }
+
+ function frame() {
+ $(element_target).append(``);
+ $(`#${element_data.ID}`).addClass(`window active`);
+ }
+
+ function titlebar() {
+ $(`#${element_data.ID}`).append(`