reinforce ES6 import for secretariat
This commit is contained in:
		
							parent
							
								
									c8fe102fa6
								
							
						
					
					
						commit
						983f0c3af9
					
				
					 1 changed files with 20 additions and 24 deletions
				
			
		|  | @ -4,7 +4,8 @@ Window and window content management */ | |||
| import texts from "../../mapping/read.js"; | ||||
| import net from "/scripts/utils/net.js"; | ||||
| import Window from "../window.js"; | ||||
| import {global} from "/scripts/secretariat.js"; | ||||
| import logging from '/scripts/logging.js'; | ||||
| import {global, observe} from "/scripts/secretariat.js"; | ||||
| 
 | ||||
| export default class windowman { | ||||
| 	static new(URL, height, width) { | ||||
|  | @ -40,14 +41,11 @@ export default class windowman { | |||
| 						throw new ReferenceError((new texts(`error_msg_fileNotFound`, [source])).localized); | ||||
| 					} | ||||
| 				} catch(err) { | ||||
| 					const secretariat = (await import(chrome.runtime.getURL(`/scripts/secretariat.js`))); | ||||
| 					const logging = (await import(chrome.runtime.getURL(`/scripts/logging.js`))).default; | ||||
| 					 | ||||
| 					// Raise an alert. 
 | ||||
| 					logging.error(err.name, err.message, err.stack, true, [source]); | ||||
| 
 | ||||
| 					// Stop loading the page when an error has occured; it's not going to work!
 | ||||
| 					if ((await secretariat.global.read(`debug`, -1) != null) ? await secretariat.global.read(`debug`, -1) : true) { | ||||
| 					if ((await global.read(`debug`, -1) != null) ? await global.read(`debug`, -1) : true) { | ||||
| 						window.close(); | ||||
| 					}; | ||||
| 				}; | ||||
|  | @ -200,15 +198,17 @@ export default class windowman { | |||
| 							: null; | ||||
| 							target[`dimensions`][`width`] = (button.getAttribute(`tab-width`)) ? parseInt(button.getAttribute(`tab-width`)) | ||||
| 							: null; | ||||
| 							 | ||||
| 							const event = function () { | ||||
| 								// Get the correct path.
 | ||||
| 							target[`path`] = ( | ||||
| 								!target[`source`].includes(`://`) | ||||
| 								? window.location.pathname.split(`/`).slice(0, -1).join(`/`).concat(`/`) | ||||
| 								: `` | ||||
| 							).concat(target[`source`]); | ||||
| 							 | ||||
| 							const event = () => { | ||||
| 								// Get the correct path.
 | ||||
| 								 | ||||
| 								new logging((new texts(`page_opening`)).localized, target[`path`]); | ||||
| 
 | ||||
| 								// Open the window as a popup. 
 | ||||
| 								new Window(target[`path`], Object.assign(target[`dimensions`], {"type": "popup"})); | ||||
| 							}; | ||||
|  | @ -258,10 +258,6 @@ export default class windowman { | |||
| 
 | ||||
| 	/* Run this function if you would like to synchronize with data. */ | ||||
| 	async sync() { | ||||
| 		// Import the module.
 | ||||
| 		const secretariat = await import(chrome.runtime.getURL("scripts/secretariat.js")); | ||||
| 		const logging = (await import(chrome.runtime.getURL(`/scripts/logging.js`))).default; | ||||
| 		 | ||||
| 		async function fill() { | ||||
| 			let input_elements = document.querySelectorAll("[data-store]"); | ||||
| 
 | ||||
|  | @ -271,7 +267,7 @@ export default class windowman { | |||
| 				let data = {}; | ||||
| 				data[`source`] = input_element.getAttribute(`data-store`); | ||||
| 				// data[`origin`] = (input_element.hasAttribute(`data-store-location`)) ? parseInt(input_element.getAttribute(`data-store-location`)) : -1
 | ||||
| 				data[`value`] = secretariat.global.read(data[`source`]); | ||||
| 				data[`value`] = global.read(data[`source`]); | ||||
| 
 | ||||
| 				data[`value`].then(async function(value) { | ||||
| 					switch (input_element.getAttribute(`type`).toLowerCase()) { | ||||
|  | @ -316,7 +312,7 @@ export default class windowman { | |||
| 							UI_item[`source`] = this.getAttribute(`data-store`); | ||||
| 							UI_item[`value`] = this.checked; | ||||
| 							UI_item[`store`] = (this.hasAttribute(`data-store-location`)) ? parseInt(this.getAttribute(`data-store-location`)) : -1; | ||||
| 							secretariat.global.write(UI_item[`source`], UI_item[`value`], UI_item[`store`]); | ||||
| 							global.write(UI_item[`source`], UI_item[`value`], UI_item[`store`]); | ||||
| 						}; | ||||
| 						break; | ||||
| 					default: | ||||
|  | @ -338,7 +334,7 @@ export default class windowman { | |||
| 									: parseInt(this.value) | ||||
| 								: this.value; | ||||
| 							UI_item[`store`] = (this.hasAttribute(`data-store-location`)) ? parseInt(this.getAttribute(`data-store-location`)) : -1; | ||||
| 							secretariat.global.write(UI_item[`source`], UI_item[`value`], UI_item[`store`]); | ||||
| 							global.write(UI_item[`source`], UI_item[`value`], UI_item[`store`]); | ||||
| 						}; | ||||
| 						break; | ||||
| 				} | ||||
|  | @ -352,7 +348,7 @@ export default class windowman { | |||
| 		*/ | ||||
| 		async function updates() { | ||||
| 			// Get the storage data.
 | ||||
| 			let storage_data = await secretariat.global.read(); | ||||
| 			let storage_data = await global.read(); | ||||
| 
 | ||||
| 			async function enable() { | ||||
| 				let input_elements = document.querySelectorAll("[data-enable]"); | ||||
|  | @ -361,10 +357,10 @@ export default class windowman { | |||
| 					input_elements.forEach(async (input_element) => { | ||||
| 						if (input_element.getAttribute("data-enable")) { | ||||
| 							// Enable the element.
 | ||||
| 							input_element.disabled = ((await secretariat.global.read(input_element.getAttribute("data-enable"))) != null | ||||
| 								? (typeof (await secretariat.global.read(input_element.getAttribute("data-enable")))).includes(`obj`) | ||||
| 									? (Object.keys(await secretariat.global.read(input_element.getAttribute("data-enable")))).length <= 0 | ||||
| 									: !(!!(await secretariat.global.read(input_element.getAttribute("data-enable")))) | ||||
| 							input_element.disabled = ((await global.read(input_element.getAttribute("data-enable"))) != null | ||||
| 								? (typeof (await global.read(input_element.getAttribute("data-enable")))).includes(`obj`) | ||||
| 									? (Object.keys(await global.read(input_element.getAttribute("data-enable")))).length <= 0 | ||||
| 									: !(!!(await global.read(input_element.getAttribute("data-enable")))) | ||||
| 								: true); | ||||
| 							(input_element.disabled) ? input_element.classList.add(`disabled`) : input_element.classList.remove(`disabled`); | ||||
| 
 | ||||
|  | @ -379,7 +375,7 @@ export default class windowman { | |||
| 			} | ||||
| 
 | ||||
| 			// Update the input elements.
 | ||||
| 			secretariat.observe((what) => { | ||||
| 			observe((what) => { | ||||
| 				enable(); | ||||
| 			}); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue