extend the default page
This commit is contained in:
		
							parent
							
								
									b1cceec7fc
								
							
						
					
					
						commit
						d71e9effd0
					
				
					 3 changed files with 123 additions and 114 deletions
				
			
		
							
								
								
									
										18
									
								
								scripts/pages/page.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								scripts/pages/page.js
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,18 @@ | ||||||
|  | /* page.js  | ||||||
|  | Construct an internal page.  | ||||||
|  | */ | ||||||
|  | 
 | ||||||
|  | import windowman from "/scripts/GUI/windowman.js"; | ||||||
|  | 
 | ||||||
|  | export default class Page { | ||||||
|  |      constructor () { | ||||||
|  |           this.window = window; | ||||||
|  | 
 | ||||||
|  |           this.window[`manager`] = new windowman(); | ||||||
|  |           (this.window[`manager`]) ? this.window.manager.sync() : false; | ||||||
|  | 
 | ||||||
|  | 		document.addEventListener("DOMContentLoaded", function () { | ||||||
|  | 			M.AutoInit(); | ||||||
|  | 		}); | ||||||
|  |      } | ||||||
|  | }; | ||||||
|  | @ -1,22 +1,21 @@ | ||||||
| /* Popup.js | /* Popup.js | ||||||
|   Build the interface for popup | 	Build the interface for popup | ||||||
| */ | */ | ||||||
| 
 | 
 | ||||||
| // Import modules.
 | // Import modules.
 | ||||||
|  | import {read, forget} from "/scripts/secretariat.js"; | ||||||
| import windowman from "/scripts/GUI/windowman.js"; | import windowman from "/scripts/GUI/windowman.js"; | ||||||
| let secretariat = await import(chrome.runtime.getURL("scripts/secretariat.js")); | import Page from "/scripts/pages/page.js"; | ||||||
| 
 | 
 | ||||||
| function start() { | class Page_Popup extends Page { | ||||||
|   windowman.prepare(); | 	constructor() { | ||||||
| } | 		super(); | ||||||
| /* Populate the strings on the page. */ | 		(this.events) ? this.events() : false; | ||||||
| function say(element) { | 	} | ||||||
|   // document.title
 | 
 | ||||||
|  | 	events() { | ||||||
|  | 
 | ||||||
|  | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function main() { | new Page_Popup(); | ||||||
|   let tab = start(); |  | ||||||
|   say(tab); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| main(); |  | ||||||
|  | @ -5,109 +5,101 @@ | ||||||
| // Import modules.
 | // Import modules.
 | ||||||
| //import { windowman } from "../windowman.js";
 | //import { windowman } from "../windowman.js";
 | ||||||
| 
 | 
 | ||||||
| import {forget} from "/scripts/secretariat.js"; | import {read, forget} from "/scripts/secretariat.js"; | ||||||
| import windowman from "/scripts/GUI/windowman.js"; | import Page from "/scripts/pages/page.js"; | ||||||
| 
 | 
 | ||||||
| async function build() { | class Page_Settings extends Page { | ||||||
| 	let window = new windowman(); | 	constructor() { | ||||||
| 	window.sync(); | 		super(); | ||||||
|  | 		(this.events) ? this.events() : false; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	/* | ||||||
|  | 	Define the mapping of each button. | ||||||
|  | 
 | ||||||
|  | 	@param {object} window the window | ||||||
|  | 	*/ | ||||||
|  | 	events() { | ||||||
|  | 		if (document.querySelector(`[data-action="filters,update"]`)) { | ||||||
|  | 			document | ||||||
|  | 				.querySelector(`[data-action="filters,update"]`) | ||||||
|  | 				.addEventListener(`click`, async () => { | ||||||
|  | 					let filters = new ( | ||||||
|  | 						await import(chrome.runtime.getURL(`scripts/filters.js`)) | ||||||
|  | 					).default(); | ||||||
|  | 					filters.update(); | ||||||
|  | 				}); | ||||||
|  | 		} | ||||||
| 	 | 	 | ||||||
| 	// Add the window events. 
 | 		if (document.querySelector(`[data-action="filters,add,one"]`)) { | ||||||
| 	events(window); | 			document | ||||||
| }; | 				.querySelector(`[data-action="filters,add,one"]`) | ||||||
| 
 | 				.addEventListener(`click`, async () => { | ||||||
| /* | 					// Import the filters module.
 | ||||||
| Define the mapping of each button. | 					const texts = ( | ||||||
| 
 | 						await import(chrome.runtime.getURL(`/scripts/strings/read.js`)) | ||||||
| @param {object} window the window | 					).default; | ||||||
| */ | 					let filters = new ( | ||||||
| function events(window) { | 						await import(chrome.runtime.getURL(`scripts/filters.js`)) | ||||||
| 	if (document.querySelector(`[data-action="filters,update"]`)) { | 					).default(); | ||||||
| 		document | 					 | ||||||
| 			.querySelector(`[data-action="filters,update"]`) | 					let filter_source = prompt( | ||||||
| 			.addEventListener(`click`, async () => { | 						texts.localized(`settings_filters_add_prompt`), | ||||||
| 				let filters = new ( | 					); | ||||||
| 					await import(chrome.runtime.getURL(`scripts/filters.js`)) | 					if (filter_source ? filter_source.trim() : false) { | ||||||
| 				).default(); | 						filters.update(filter_source.trim()); | ||||||
| 				filters.update(); | 					}; | ||||||
| 			}); | 				}); | ||||||
| 	} | 		} | ||||||
| 
 | 		if (document.querySelector(`[data-action="filters,update,one"]`)) { | ||||||
| 	if (document.querySelector(`[data-action="filters,add,one"]`)) { | 			document | ||||||
| 		document | 				.querySelector(`[data-action="filters,update,one"]`) | ||||||
| 			.querySelector(`[data-action="filters,add,one"]`) | 				.addEventListener(`click`, async () => { | ||||||
| 			.addEventListener(`click`, async () => { | 					// Import the filters module.
 | ||||||
| 				// Import the filters module.
 | 					const texts = ( | ||||||
| 				const texts = ( | 						await import(chrome.runtime.getURL(`/scripts/strings/read.js`)) | ||||||
| 					await import(chrome.runtime.getURL(`/scripts/strings/read.js`)) | 					).default; | ||||||
| 				).default; | 					let filters = new ( | ||||||
| 				let filters = new ( | 						await import(chrome.runtime.getURL(`scripts/filters.js`)) | ||||||
| 					await import(chrome.runtime.getURL(`scripts/filters.js`)) | 					).default(); | ||||||
| 				).default(); |  | ||||||
| 				 |  | ||||||
| 				let filter_source = prompt( |  | ||||||
| 					texts.localized(`settings_filters_add_prompt`), |  | ||||||
| 				); |  | ||||||
| 				if (filter_source ? filter_source.trim() : false) { |  | ||||||
| 					filters.update(filter_source.trim()); |  | ||||||
| 				}; |  | ||||||
| 			}); |  | ||||||
| 	} |  | ||||||
| 	if (document.querySelector(`[data-action="filters,update,one"]`)) { |  | ||||||
| 		document |  | ||||||
| 			.querySelector(`[data-action="filters,update,one"]`) |  | ||||||
| 			.addEventListener(`click`, async () => { |  | ||||||
| 				// Import the filters module.
 |  | ||||||
| 				const texts = ( |  | ||||||
| 					await import(chrome.runtime.getURL(`/scripts/strings/read.js`)) |  | ||||||
| 				).default; |  | ||||||
| 				let filters = new ( |  | ||||||
| 					await import(chrome.runtime.getURL(`scripts/filters.js`)) |  | ||||||
| 				).default(); |  | ||||||
| 
 |  | ||||||
| 				// Open text input window for adding a filter.
 |  | ||||||
| 				let filter_source = (document.querySelector(`[data-result-linked="filters"] [data-result-content="*"]`)) ? document.querySelector(`[data-result-linked="filters"] [data-result-content="*"]`).innerText : prompt(texts.localized(`settings_filters_add_prompt`)); |  | ||||||
| 				if (filter_source ? filter_source.trim() : false) { |  | ||||||
| 					filters.update(filter_source.trim()); |  | ||||||
| 				}; |  | ||||||
| 			}); |  | ||||||
| 	} |  | ||||||
| 	 | 	 | ||||||
| 	if (document.querySelector(`[data-action="filters,delete,one"]`)) { | 					// Open text input window for adding a filter.
 | ||||||
| 		document | 					let filter_source = (document.querySelector(`[data-result-linked="filters"] [data-result-content="*"]`)) ? document.querySelector(`[data-result-linked="filters"] [data-result-content="*"]`).innerText : prompt(texts.localized(`settings_filters_add_prompt`)); | ||||||
| 			.querySelector(`[data-action="filters,delete,one"]`) | 					if (filter_source ? filter_source.trim() : false) { | ||||||
| 			.addEventListener(`click`, async () => { | 						filters.update(filter_source.trim()); | ||||||
| 				// Import the filters module.
 | 					}; | ||||||
| 				let texts = ( | 				}); | ||||||
| 					await import(chrome.runtime.getURL(`/scripts/strings/read.js`)) | 		} | ||||||
| 				).default; | 		 | ||||||
| 				let filters = new ( | 		if (document.querySelector(`[data-action="filters,delete,one"]`)) { | ||||||
| 					await import(chrome.runtime.getURL(`scripts/filters.js`)) | 			document | ||||||
| 				).default(); | 				.querySelector(`[data-action="filters,delete,one"]`) | ||||||
| 
 | 				.addEventListener(`click`, async () => { | ||||||
| 				// Open text input window for adding a filter.
 | 					// Import the filters module.
 | ||||||
| 				let filter_source = (document.querySelector(`[data-result-linked="filters"] [data-result-content="*"]`)) ? document.querySelector(`[data-result-linked="filters"] [data-result-content="*"]`).innerText : prompt(texts.localized(`settings_filters_remove_prompt`)); | 					let texts = ( | ||||||
| 				if (filter_source ? filter_source.trim() : false) { | 						await import(chrome.runtime.getURL(`/scripts/strings/read.js`)) | ||||||
| 					filters.remove(filter_source.trim()); | 					).default; | ||||||
| 				} | 					let filters = new ( | ||||||
| 			}); | 						await import(chrome.runtime.getURL(`scripts/filters.js`)) | ||||||
| 	} | 					).default(); | ||||||
| 
 | 	 | ||||||
| 	if (document.querySelector(`[data-action="storage,clear"]`)) { | 					// Open text input window for adding a filter.
 | ||||||
| 		document | 					let filter_source = (document.querySelector(`[data-result-linked="filters"] [data-result-content="*"]`)) ? document.querySelector(`[data-result-linked="filters"] [data-result-content="*"]`).innerText : prompt(texts.localized(`settings_filters_remove_prompt`)); | ||||||
| 			.querySelector(`[data-action="storage,clear"]`) | 					if (filter_source ? filter_source.trim() : false) { | ||||||
| 			.addEventListener(`click`, async () => { | 						filters.remove(filter_source.trim()); | ||||||
| 				forget(`sites`); | 					} | ||||||
| 			}); | 				}); | ||||||
|  | 		} | ||||||
|  | 	 | ||||||
|  | 		if (document.querySelector(`[data-action="storage,clear"]`)) { | ||||||
|  | 			document | ||||||
|  | 				.querySelector(`[data-action="storage,clear"]`) | ||||||
|  | 				.addEventListener(`click`, async () => { | ||||||
|  | 					await forget(`sites`); | ||||||
|  | 					console.log(await read(null, 1), await read(null, -1)); | ||||||
|  | 				}); | ||||||
|  | 		} | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function load() { | new Page_Settings(); | ||||||
| 	build(); |  | ||||||
| 	 |  | ||||||
| 	document.addEventListener("DOMContentLoaded", function () { |  | ||||||
| 		M.AutoInit(); |  | ||||||
| 	}); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| load(); |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue