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
				
			
		|  | @ -1,18 +1,17 @@ | ||||||
| /* alerts.js | /* alerts.js | ||||||
| Alert management system. | Alert management system. | ||||||
| */ | */ | ||||||
| 
 | 
 | ||||||
| export function confirm_action() { | export function confirm_action() { | ||||||
|     let user_response = false;  |   let user_response = false; | ||||||
| 
 | 
 | ||||||
|     (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,205 +1,251 @@ | ||||||
| /* 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) { | ||||||
|  |     this.window = chrome.windows.create({ | ||||||
|  |       url: chrome.runtime.getURL(URL), | ||||||
|  |       type: "popup", | ||||||
|  |       width: width ? width : 400, | ||||||
|  |       height: height ? height : 600, | ||||||
|  |     }); | ||||||
|  |   } | ||||||
| 
 | 
 | ||||||
| 	constructor(URL, height, width) { |   static fill() { | ||||||
| 		this.window = chrome.windows.create({ |     function text() { | ||||||
| 	    url: chrome.runtime.getURL(URL), |       let text_elements = document.querySelectorAll("[data-text]"); | ||||||
| 	    type: "popup", |  | ||||||
| 	    width: (width) ? width: 400, |  | ||||||
| 	    height: (height) ? height: 600, |  | ||||||
| 	  }); |  | ||||||
| 	} |  | ||||||
| 
 | 
 | ||||||
| 	static fill() { |       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`)), | ||||||
|  |           ); | ||||||
|  |         } | ||||||
| 
 | 
 | ||||||
| 		function text() { |         text_element.innerText = text_inserted; | ||||||
| 			let text_elements = document.querySelectorAll("[data-text]"); |       }); | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
| 			text_elements.forEach((text_element) => { |     function storage() { | ||||||
| 				let text_inserted = texts.localized(text_element.getAttribute(`data-text`), (text_element.hasAttribute(`data-text-parameter`)) ? eval(text_element.getAttribute(`data-text-parameter`)) : null ); |       (async () => { | ||||||
| 				if (!text_inserted) {text_inserted = texts.localized(`term_`.concat(text_element.getAttribute(`data-text`)));} |         // Import the module.
 | ||||||
|  |         const secretariat = await import( | ||||||
|  |           chrome.runtime.getURL("scripts/secretariat.js") | ||||||
|  |         ); | ||||||
| 
 | 
 | ||||||
| 				text_element.innerText = text_inserted; |         let input_elements = document.querySelectorAll("[data-store]"); | ||||||
| 			}) |  | ||||||
| 		} |  | ||||||
| 
 | 
 | ||||||
| 		function storage() { |         input_elements.forEach((input_element) => { | ||||||
| 			(async () => { |           // Gather data about the element.
 | ||||||
| 				// Import the module.
 |           // Get the corresponding storage data.
 | ||||||
| 				const secretariat = await import(chrome.runtime.getURL("scripts/secretariat.js")); |           let data = {}; | ||||||
|  |           data[`source`] = input_element.getAttribute(`data-store`); | ||||||
|  |           data[`value`] = secretariat.read(data[`source`], -1); | ||||||
| 
 | 
 | ||||||
| 				let input_elements = document.querySelectorAll("[data-store]"); |           data[`value`].then((value) => { | ||||||
|  |             switch (input_element.getAttribute(`type`).toLowerCase()) { | ||||||
|  |               case `checkbox`: | ||||||
|  |                 input_element.checked = value; | ||||||
|  |                 break; | ||||||
|  |               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; | ||||||
|  |                 } | ||||||
| 
 | 
 | ||||||
| 				input_elements.forEach((input_element) => { |                 // Set the attribute of the progress bar.
 | ||||||
| 					// Gather data about the element.
 |                 input_element.setAttribute(`value`, value); | ||||||
| 					// Get the corresponding storage data.
 |                 input_element.setAttribute(`max`, 1); | ||||||
| 					let data = {}; |                 break; | ||||||
| 					data[`source`] = input_element.getAttribute(`data-store`); |               default: | ||||||
| 					data[`value`] = secretariat.read(data[`source`], -1); |                 input_element.value = value; | ||||||
|  |                 break; | ||||||
|  |             } | ||||||
|  |           }); | ||||||
|  |         }); | ||||||
|  |       })(); | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
| 					data[`value`].then((value) => { |     text(); | ||||||
| 						switch (input_element.getAttribute(`type`).toLowerCase()) { |     storage(); | ||||||
| 							case `checkbox`: |   } | ||||||
| 								input_element.checked = value; |  | ||||||
| 								break; |  | ||||||
| 							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}; |  | ||||||
| 
 | 
 | ||||||
| 								// Set the attribute of the progress bar.
 |   /* Add click events. */ | ||||||
| 								input_element.setAttribute(`value`, value); |   static events() { | ||||||
| 								input_element.setAttribute(`max`, 1); |     /* Add events related to storage. */ | ||||||
| 								break; |     function storage() { | ||||||
| 							default: |       (async () => { | ||||||
| 								input_element.value = value; |         // Import the module.
 | ||||||
| 								break; |         const secretariat = await import( | ||||||
| 				    } |           chrome.runtime.getURL("scripts/secretariat.js") | ||||||
| 				  }); |         ); | ||||||
| 
 | 
 | ||||||
| 				}); |         let input_elements = document.querySelectorAll("[data-store]"); | ||||||
| 			})(); |  | ||||||
| 		} |  | ||||||
| 
 | 
 | ||||||
| 		text(); |         input_elements.forEach((input_element) => { | ||||||
| 		storage(); |           // Gather data about the element.
 | ||||||
| 	} |           // Get the corresponding storage data.
 | ||||||
| 
 | 
 | ||||||
| 	/* Add click events. */ |           let element = {}; | ||||||
| 	static events() { |           element[`type`] = input_element.getAttribute(`type`).toLowerCase(); | ||||||
|  |           element[`event`] = function () {}; | ||||||
| 
 | 
 | ||||||
| 		/* Add events related to storage. */ |           switch (element[`type`]) { | ||||||
| 		function storage() { |             case `checkbox`: | ||||||
| 			(async () => { |               element[`event`] = function () { | ||||||
| 				// Import the module.
 |                 let UI_item = {}; | ||||||
| 				const secretariat = await import(chrome.runtime.getURL("scripts/secretariat.js")); |                 UI_item[`source`] = this.getAttribute(`data-store`); | ||||||
| 
 |                 UI_item[`value`] = this.checked; | ||||||
| 				let input_elements = document.querySelectorAll("[data-store]"); |                 secretariat.write(UI_item[`source`], UI_item[`value`]); | ||||||
| 
 |               }; | ||||||
| 				input_elements.forEach((input_element) => { |               break; | ||||||
| 					// Gather data about the element.
 |             case `range`: | ||||||
| 					// Get the corresponding storage data.
 |             /*// Ensure that it is a positive floating-point number. | ||||||
| 
 |  | ||||||
| 					let element = {}; |  | ||||||
| 					element[`type`] = input_element.getAttribute(`type`).toLowerCase(); |  | ||||||
| 					element[`event`] = function() {}; |  | ||||||
| 
 |  | ||||||
| 					switch (element[`type`]) { |  | ||||||
| 						case `checkbox`: |  | ||||||
| 							element[`event`] = function() { |  | ||||||
| 								let UI_item = {}; |  | ||||||
| 								UI_item[`source`] = this.getAttribute(`data-store`); |  | ||||||
| 								UI_item[`value`] = this.checked; |  | ||||||
| 								secretariat.write(UI_item[`source`], UI_item[`value`]); |  | ||||||
| 							}; |  | ||||||
| 							break; |  | ||||||
| 						case `range`: |  | ||||||
| 							/*// 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); | ||||||
| 							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`], | ||||||
| 							break; |                   data[`source`][`target`], | ||||||
| 					} |                   this.value, | ||||||
|  |                 ); | ||||||
|  |               }; | ||||||
|  |               break; | ||||||
|  |           } | ||||||
| 
 | 
 | ||||||
| 					input_element.addEventListener('change', element[`event`]); |           input_element.addEventListener("change", element[`event`]); | ||||||
| 				}); |         }); | ||||||
| 			})(); |       })(); | ||||||
| 		} |     } | ||||||
| 
 | 
 | ||||||
| 		/* Make it feel more like a native window. */ |     /* Make it feel more like a native window. */ | ||||||
| 		function functionality() { |     function functionality() { | ||||||
| 			/* 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) => { | ||||||
| 							let buttons = menu.querySelectorAll("button, a"); |               let buttons = menu.querySelectorAll("button, a"); | ||||||
| 
 | 
 | ||||||
| 							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( | ||||||
| 											} else { |                           `hidden`, | ||||||
| 												SECTION.removeAttribute(`hidden`); |                           this.getAttribute(`for`).includes(SECTION.id), | ||||||
| 											} |                         ); | ||||||
| 										}); |                       } else { | ||||||
|  |                         SECTION.removeAttribute(`hidden`); | ||||||
|  |                       } | ||||||
|  |                     }); | ||||||
| 
 | 
 | ||||||
| 										// 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(), | ||||||
|  |       ); | ||||||
| 
 | 
 | ||||||
|  |       changeUI(); | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
| 			document.addEventListener('contextmenu', event => event.preventDefault()); |     storage(); | ||||||
| 
 |     functionality(); | ||||||
| 			changeUI(); |   } | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		storage(); |  | ||||||
| 		functionality(); |  | ||||||
| 	} |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export {windowman}; | export { windowman }; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue