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 () => {
|
||||
// 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.
|
||||
user_response = confirm(reader.read(`GUI_alert_confirm_action_text`));
|
||||
|
||||
})();
|
||||
// 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) {
|
||||
(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)]));
|
||||
}
|
||||
})();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,27 @@
|
|||
/* windowman
|
||||
Window management */
|
||||
|
||||
import texts from "./read.JS";
|
||||
import texts from "./read.js";
|
||||
|
||||
class windowman {
|
||||
/* 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(`<link rel="stylesheet" type="text/css" href="${source}">`);
|
||||
})
|
||||
UI.library.forEach((source) => {
|
||||
$(`head`).append(
|
||||
`<link rel="stylesheet" type="text/css" href="${source}">`,
|
||||
);
|
||||
});
|
||||
|
||||
$(`head`).append(`<script type="module" src="${UI.script}"></script>`);
|
||||
} catch (error) {
|
||||
|
@ -19,36 +29,47 @@ class windowman {
|
|||
}
|
||||
|
||||
// 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) {
|
||||
this.window = chrome.windows.create({
|
||||
url: chrome.runtime.getURL(URL),
|
||||
type: "popup",
|
||||
width: (width) ? width: 400,
|
||||
height: (height) ? height: 600,
|
||||
width: width ? width : 400,
|
||||
height: height ? height : 600,
|
||||
});
|
||||
}
|
||||
|
||||
static fill() {
|
||||
|
||||
function text() {
|
||||
let text_elements = document.querySelectorAll("[data-text]");
|
||||
|
||||
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`)));}
|
||||
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`)),
|
||||
);
|
||||
}
|
||||
|
||||
text_element.innerText = text_inserted;
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function storage() {
|
||||
(async () => {
|
||||
// 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]");
|
||||
|
||||
|
@ -67,8 +88,10 @@ class windowman {
|
|||
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};
|
||||
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);
|
||||
|
@ -79,7 +102,6 @@ class windowman {
|
|||
break;
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
})();
|
||||
}
|
||||
|
@ -90,12 +112,13 @@ class windowman {
|
|||
|
||||
/* 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"));
|
||||
const secretariat = await import(
|
||||
chrome.runtime.getURL("scripts/secretariat.js")
|
||||
);
|
||||
|
||||
let input_elements = document.querySelectorAll("[data-store]");
|
||||
|
||||
|
@ -126,12 +149,16 @@ class windowman {
|
|||
input_element.setAttribute(`max`, 1);*/
|
||||
default:
|
||||
element[`event`] = function () {
|
||||
secretariat.write(data[`source`][`root`], data[`source`][`target`], this.value);
|
||||
secretariat.write(
|
||||
data[`source`][`root`],
|
||||
data[`source`][`target`],
|
||||
this.value,
|
||||
);
|
||||
};
|
||||
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. */
|
||||
function changeUI() {
|
||||
function tabs() {
|
||||
let menus = (document.querySelectorAll("menu[role=tablist]"))
|
||||
let menus = document.querySelectorAll("menu[role=tablist]");
|
||||
|
||||
if (menus) {
|
||||
menus.forEach((menu) => {
|
||||
|
@ -155,17 +182,30 @@ class windowman {
|
|||
let BUTTONS = MENU.querySelectorAll("button, a");
|
||||
|
||||
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 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);
|
||||
|
||||
if (!(this.getAttribute(`for`)).includes(SECTION.id)) {
|
||||
SECTION.setAttribute(`hidden`, ((this.getAttribute(`for`)).includes(SECTION.id)));
|
||||
if (!this.getAttribute(`for`).includes(SECTION.id)) {
|
||||
SECTION.setAttribute(
|
||||
`hidden`,
|
||||
this.getAttribute(`for`).includes(SECTION.id),
|
||||
);
|
||||
} else {
|
||||
SECTION.removeAttribute(`hidden`);
|
||||
}
|
||||
|
@ -173,26 +213,32 @@ class windowman {
|
|||
|
||||
// Save.
|
||||
(async () => {
|
||||
const secretariat = await import(chrome.runtime.getURL("scripts/secretariat.js"));
|
||||
const secretariat = await import(
|
||||
chrome.runtime.getURL("scripts/secretariat.js")
|
||||
);
|
||||
|
||||
// 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();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
document.addEventListener('contextmenu', event => event.preventDefault());
|
||||
document.addEventListener("contextmenu", (event) =>
|
||||
event.preventDefault(),
|
||||
);
|
||||
|
||||
changeUI();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue