crash the window when the building is wrong
This commit is contained in:
		
							parent
							
								
									42d2278e6c
								
							
						
					
					
						commit
						493abd746a
					
				
					 1 changed files with 299 additions and 273 deletions
				
			
		|  | @ -3,6 +3,9 @@ Window and window content management */ | |||
| 
 | ||||
| import texts from "./read.js"; | ||||
| 
 | ||||
| // MAKE SURE TO TURN THIS OFF DURING BUILD.
 | ||||
| let DEBUG = false; | ||||
| 
 | ||||
| class windowman { | ||||
| 	static new(URL, height, width) { | ||||
| 		this.window = chrome.windows.create({ | ||||
|  | @ -16,10 +19,11 @@ class windowman { | |||
| 	// Prepare the window with its metadata.
 | ||||
| 	constructor() { | ||||
| 		function headers() { | ||||
| 		let LOAD_STATE = true; | ||||
| 			let UI = { | ||||
|         library: [ | ||||
| 				"CSS": [ | ||||
| 					chrome.runtime.getURL( | ||||
|             "gui/styles/external/mdi/materialdesignicons.min.css", | ||||
| 						"gui/styles/external/fonts/materialdesignicons.min.css", | ||||
| 					), | ||||
| 					chrome.runtime.getURL( | ||||
| 						"gui/styles/external/materialize/css/materialize.css", | ||||
|  | @ -28,13 +32,35 @@ class windowman { | |||
| 				], | ||||
| 			}; | ||||
| 
 | ||||
|       UI.library.forEach((source) => { | ||||
| 
 | ||||
| 			for (let index = 0; index < UI[`CSS`].length; index++) { | ||||
| 				const source = UI.CSS[index]; | ||||
| 				 | ||||
| 				(async () => { | ||||
| 					const net = await import(chrome.runtime.getURL(`/scripts/net.js`)); | ||||
| 			 | ||||
| 					let resource = false; | ||||
| 					try { | ||||
| 						resource = await net.download(source, `text`, true); | ||||
| 					} catch(err) {}; | ||||
| 	 | ||||
| 					if (resource) { | ||||
| 						let metadata_element = document.createElement(`link`); | ||||
| 						metadata_element.setAttribute(`rel`, `stylesheet`); | ||||
| 						metadata_element.setAttribute(`type`, `text/css`); | ||||
| 						metadata_element.setAttribute(`href`, source); | ||||
| 						document.querySelector(`head`).appendChild(metadata_element); | ||||
|       }); | ||||
| 					} else { | ||||
| 						const alerts = (await import(chrome.runtime.getURL(`/gui/scripts/alerts.js`))).default; | ||||
| 						const reader = (await import(chrome.runtime.getURL(`/gui/scripts/read.js`))).default; | ||||
| 	 | ||||
| 						alerts.error(-1, reader.localized(`error_msg_fileNotFound`), true, [source]); | ||||
| 
 | ||||
| 						// Stop loading the page when an error has occured; it's not going to work! 
 | ||||
| 						if (!DEBUG) {window.close()}; | ||||
| 					} | ||||
| 				})(); | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		// Get the window.
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue