locally renamed files as lowercase file extensions
because not all IDEs seem to support uppercase file name extensions
This commit is contained in:
parent
89b22bccba
commit
908433d80d
3 changed files with 223 additions and 178 deletions
|
@ -7,12 +7,11 @@ export function confirm_action() {
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
// Import the module.
|
// Import the module.
|
||||||
let reader = await import(chrome.runtime.getURL("gui/scripts/read.JS"));
|
let reader = await import(chrome.runtime.getURL("gui/scripts/read.js"));
|
||||||
|
|
||||||
// Get the user response.
|
// Get the user response.
|
||||||
user_response = confirm(reader.read(`GUI_alert_confirm_action_text`));
|
user_response = confirm(reader.read(`GUI_alert_confirm_action_text`));
|
||||||
|
|
||||||
})();
|
})();
|
||||||
// Return the user response.
|
// Return the user response.
|
||||||
return (user_response);
|
return user_response;
|
||||||
};
|
}
|
||||||
|
|
|
@ -13,13 +13,13 @@ export default class logging {
|
||||||
static error(ERROR_CODE, ERROR_MESSAGE, critical = true) {
|
static error(ERROR_CODE, ERROR_MESSAGE, critical = true) {
|
||||||
(async () => {
|
(async () => {
|
||||||
// Import the templating.
|
// 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.
|
// Display the error message.
|
||||||
console.error(texts.read(`error_msg`, [ERROR_CODE, ERROR_MESSAGE]));
|
console.error(texts.read(`error_msg`, [ERROR_CODE, ERROR_MESSAGE]));
|
||||||
if (critical) {
|
if (critical) {
|
||||||
alert(texts.read(`error_msg_GUI`, [String(ERROR_CODE)]))
|
alert(texts.read(`error_msg_GUI`, [String(ERROR_CODE)]));
|
||||||
};
|
}
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,54 +1,75 @@
|
||||||
/* windowman
|
/* windowman
|
||||||
Window management */
|
Window management */
|
||||||
|
|
||||||
import texts from "./read.JS";
|
import texts from "./read.js";
|
||||||
|
|
||||||
class windowman {
|
class windowman {
|
||||||
/* Initialize the window frame. */
|
/* Initialize the window frame. */
|
||||||
static prepare() {
|
static prepare() {
|
||||||
try {
|
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) => {
|
UI.library.forEach((source) => {
|
||||||
$(`head`).append(`<link rel="stylesheet" type="text/css" href="${source}">`);
|
$(`head`).append(
|
||||||
})
|
`<link rel="stylesheet" type="text/css" href="${source}">`,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
$(`head`).append(`<script type="module" src="${UI.script}"></script>`);
|
$(`head`).append(`<script type="module" src="${UI.script}"></script>`);
|
||||||
} catch(error) {
|
} catch (error) {
|
||||||
console.error(texts.localized(`error_fileNotFound`, [error]));
|
console.error(texts.localized(`error_fileNotFound`, [error]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prevent scaling, similar to a real window.
|
// Prevent scaling, similar to a real window.
|
||||||
$(`head`).append(`<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />`);
|
$(`head`).append(
|
||||||
|
`<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
constructor(URL, height, width) {
|
constructor(URL, height, width) {
|
||||||
this.window = chrome.windows.create({
|
this.window = chrome.windows.create({
|
||||||
url: chrome.runtime.getURL(URL),
|
url: chrome.runtime.getURL(URL),
|
||||||
type: "popup",
|
type: "popup",
|
||||||
width: (width) ? width: 400,
|
width: width ? width : 400,
|
||||||
height: (height) ? height: 600,
|
height: height ? height : 600,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static fill() {
|
static fill() {
|
||||||
|
|
||||||
function text() {
|
function text() {
|
||||||
let text_elements = document.querySelectorAll("[data-text]");
|
let text_elements = document.querySelectorAll("[data-text]");
|
||||||
|
|
||||||
text_elements.forEach((text_element) => {
|
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 );
|
let text_inserted = texts.localized(
|
||||||
if (!text_inserted) {text_inserted = texts.localized(`term_`.concat(text_element.getAttribute(`data-text`)));}
|
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`)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
text_element.innerText = text_inserted;
|
text_element.innerText = text_inserted;
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function storage() {
|
function storage() {
|
||||||
(async () => {
|
(async () => {
|
||||||
// Import the module.
|
// Import the module.
|
||||||
const secretariat = await import(chrome.runtime.getURL("scripts/secretariat.js"));
|
const secretariat = await import(
|
||||||
|
chrome.runtime.getURL("scripts/secretariat.js")
|
||||||
|
);
|
||||||
|
|
||||||
let input_elements = document.querySelectorAll("[data-store]");
|
let input_elements = document.querySelectorAll("[data-store]");
|
||||||
|
|
||||||
|
@ -67,8 +88,10 @@ class windowman {
|
||||||
case `progress`:
|
case `progress`:
|
||||||
case `range`:
|
case `range`:
|
||||||
// Ensure that it is a positive floating-point number.
|
// Ensure that it is a positive floating-point number.
|
||||||
value = (!value) ? 0 : Math.abs(parseFloat(value));
|
value = !value ? 0 : Math.abs(parseFloat(value));
|
||||||
if (value > 100) {value = value / 100};
|
if (value > 100) {
|
||||||
|
value = value / 100;
|
||||||
|
}
|
||||||
|
|
||||||
// Set the attribute of the progress bar.
|
// Set the attribute of the progress bar.
|
||||||
input_element.setAttribute(`value`, value);
|
input_element.setAttribute(`value`, value);
|
||||||
|
@ -79,7 +102,6 @@ class windowman {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
@ -90,12 +112,13 @@ class windowman {
|
||||||
|
|
||||||
/* Add click events. */
|
/* Add click events. */
|
||||||
static events() {
|
static events() {
|
||||||
|
|
||||||
/* Add events related to storage. */
|
/* Add events related to storage. */
|
||||||
function storage() {
|
function storage() {
|
||||||
(async () => {
|
(async () => {
|
||||||
// Import the module.
|
// Import the module.
|
||||||
const secretariat = await import(chrome.runtime.getURL("scripts/secretariat.js"));
|
const secretariat = await import(
|
||||||
|
chrome.runtime.getURL("scripts/secretariat.js")
|
||||||
|
);
|
||||||
|
|
||||||
let input_elements = document.querySelectorAll("[data-store]");
|
let input_elements = document.querySelectorAll("[data-store]");
|
||||||
|
|
||||||
|
@ -105,11 +128,11 @@ class windowman {
|
||||||
|
|
||||||
let element = {};
|
let element = {};
|
||||||
element[`type`] = input_element.getAttribute(`type`).toLowerCase();
|
element[`type`] = input_element.getAttribute(`type`).toLowerCase();
|
||||||
element[`event`] = function() {};
|
element[`event`] = function () {};
|
||||||
|
|
||||||
switch (element[`type`]) {
|
switch (element[`type`]) {
|
||||||
case `checkbox`:
|
case `checkbox`:
|
||||||
element[`event`] = function() {
|
element[`event`] = function () {
|
||||||
let UI_item = {};
|
let UI_item = {};
|
||||||
UI_item[`source`] = this.getAttribute(`data-store`);
|
UI_item[`source`] = this.getAttribute(`data-store`);
|
||||||
UI_item[`value`] = this.checked;
|
UI_item[`value`] = this.checked;
|
||||||
|
@ -125,13 +148,17 @@ class windowman {
|
||||||
input_element.setAttribute(`value`, value);
|
input_element.setAttribute(`value`, value);
|
||||||
input_element.setAttribute(`max`, 1);*/
|
input_element.setAttribute(`max`, 1);*/
|
||||||
default:
|
default:
|
||||||
element[`event`] = function() {
|
element[`event`] = function () {
|
||||||
secretariat.write(data[`source`][`root`], data[`source`][`target`], this.value);
|
secretariat.write(
|
||||||
|
data[`source`][`root`],
|
||||||
|
data[`source`][`target`],
|
||||||
|
this.value,
|
||||||
|
);
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
input_element.addEventListener('change', element[`event`]);
|
input_element.addEventListener("change", element[`event`]);
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
@ -141,7 +168,7 @@ class windowman {
|
||||||
/* Adjust the interface based on events. */
|
/* Adjust the interface based on events. */
|
||||||
function changeUI() {
|
function changeUI() {
|
||||||
function tabs() {
|
function tabs() {
|
||||||
let menus = (document.querySelectorAll("menu[role=tablist]"))
|
let menus = document.querySelectorAll("menu[role=tablist]");
|
||||||
|
|
||||||
if (menus) {
|
if (menus) {
|
||||||
menus.forEach((menu) => {
|
menus.forEach((menu) => {
|
||||||
|
@ -149,23 +176,36 @@ class windowman {
|
||||||
|
|
||||||
if (buttons) {
|
if (buttons) {
|
||||||
buttons.forEach((button) => {
|
buttons.forEach((button) => {
|
||||||
let event = function() {
|
let event = function () {
|
||||||
// Prevent selection.
|
// Prevent selection.
|
||||||
let MENU = this.parentElement;
|
let MENU = this.parentElement;
|
||||||
let BUTTONS = MENU.querySelectorAll("button, a");
|
let BUTTONS = MENU.querySelectorAll("button, a");
|
||||||
|
|
||||||
BUTTONS.forEach((BUTTON) => {
|
BUTTONS.forEach((BUTTON) => {
|
||||||
BUTTON.setAttribute(`aria-selected`, String(BUTTON.getAttribute(`for`) == this.getAttribute(`for`)));
|
BUTTON.setAttribute(
|
||||||
|
`aria-selected`,
|
||||||
|
String(
|
||||||
|
BUTTON.getAttribute(`for`) ==
|
||||||
|
this.getAttribute(`for`),
|
||||||
|
),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
let CONTAINER = document.getElementById(MENU.getAttribute(`for`));
|
let CONTAINER = document.getElementById(
|
||||||
let SECTIONS = CONTAINER.querySelectorAll(`#${CONTAINER.id} > section`);
|
MENU.getAttribute(`for`),
|
||||||
|
);
|
||||||
|
let SECTIONS = CONTAINER.querySelectorAll(
|
||||||
|
`#${CONTAINER.id} > section`,
|
||||||
|
);
|
||||||
|
|
||||||
SECTIONS.forEach((SECTION) => {
|
SECTIONS.forEach((SECTION) => {
|
||||||
// SECTION.setAttribute(`hidden`, true);
|
// SECTION.setAttribute(`hidden`, true);
|
||||||
|
|
||||||
if (!(this.getAttribute(`for`)).includes(SECTION.id)) {
|
if (!this.getAttribute(`for`).includes(SECTION.id)) {
|
||||||
SECTION.setAttribute(`hidden`, ((this.getAttribute(`for`)).includes(SECTION.id)));
|
SECTION.setAttribute(
|
||||||
|
`hidden`,
|
||||||
|
this.getAttribute(`for`).includes(SECTION.id),
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
SECTION.removeAttribute(`hidden`);
|
SECTION.removeAttribute(`hidden`);
|
||||||
}
|
}
|
||||||
|
@ -173,26 +213,32 @@ class windowman {
|
||||||
|
|
||||||
// Save.
|
// Save.
|
||||||
(async () => {
|
(async () => {
|
||||||
const secretariat = await import(chrome.runtime.getURL("scripts/secretariat.js"));
|
const secretariat = await import(
|
||||||
|
chrome.runtime.getURL("scripts/secretariat.js")
|
||||||
|
);
|
||||||
|
|
||||||
// Write the data.
|
// Write the data.
|
||||||
secretariat.write([`view`, window.location.href], this.getAttribute(`for`), 1);
|
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(),
|
||||||
document.addEventListener('contextmenu', event => event.preventDefault());
|
);
|
||||||
|
|
||||||
changeUI();
|
changeUI();
|
||||||
}
|
}
|
||||||
|
@ -202,4 +248,4 @@ class windowman {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export {windowman};
|
export { windowman };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue