uncrash everything on pressing all
This commit is contained in:
		
							parent
							
								
									132e49b589
								
							
						
					
					
						commit
						30b3cf0d0a
					
				| @ -1 +1 @@ | |||||||
| Subproject commit 1222e87853bbd79540ca1d8a91602b619131644b | Subproject commit 08c759451d133ea8009ef89a6aec7b0def82a1f5 | ||||||
							
								
								
									
										22
									
								
								main.js
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								main.js
									
									
									
									
									
								
							| @ -216,6 +216,7 @@ function loadDictionary() { | |||||||
|                 //prepare search. maybe async this if we're loading a specific word?
 |                 //prepare search. maybe async this if we're loading a specific word?
 | ||||||
|                 for (let i = 0; i < keys.length; i++) { |                 for (let i = 0; i < keys.length; i++) { | ||||||
|                     try { |                     try { | ||||||
|  |                         if (keys[i] == "") continue; | ||||||
|                         //create array
 |                         //create array
 | ||||||
|                         searchDictionary[keys[i]] = []; |                         searchDictionary[keys[i]] = []; | ||||||
| 
 | 
 | ||||||
| @ -250,13 +251,11 @@ function loadDictionary() { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function search(word, type) { | function search(word, type) { | ||||||
|     console.log(type); |  | ||||||
|     if (type == "all") { word = "" }; |     if (type == "all") { word = "" }; | ||||||
|     if (type == "random") { |     if (type == "random") { | ||||||
|         let random = Math.floor(Math.random() * Object.keys(json).length); |         let random = Math.floor(Math.random() * Object.keys(json).length); | ||||||
|         return [Object.keys(json)[random]]; |         return [Object.keys(json)[random]]; | ||||||
|     } |     } | ||||||
|     console.log(word); |  | ||||||
|     let words = word.split(" "); |     let words = word.split(" "); | ||||||
|     for (let i = 0; i < words.length; i++) { |     for (let i = 0; i < words.length; i++) { | ||||||
|         words[i] = stripWord(words[i]); |         words[i] = stripWord(words[i]); | ||||||
| @ -375,9 +374,11 @@ function doSearch(state = true) { | |||||||
|                 //number, meaning (*required)
 |                 //number, meaning (*required)
 | ||||||
|                 meaning.innerHTML += "<span class='result-number'>" + (o + 1) + "</span><span class='result-big'>" + json[results[i]][o]["meaning"] + "</span>"; |                 meaning.innerHTML += "<span class='result-number'>" + (o + 1) + "</span><span class='result-big'>" + json[results[i]][o]["meaning"] + "</span>"; | ||||||
|                 //longer translation (below are not required, make sure to check for them)
 |                 //longer translation (below are not required, make sure to check for them)
 | ||||||
|                 if (json[results[i]][o]["translation"] != undefined && json[results[i]][o]["translation"].toLowerCase() != json[results[i]][o]["meaning"].toLowerCase()) { |                 if (json[results[i]][o]["translation"] != undefined) { | ||||||
|  |                     if (json[results[i]][o]["meaning"] != undefined && json[results[i]][o]["translation"].toLowerCase() != json[results[i]][o]["meaning"].toLowerCase()) { | ||||||
|                         meaning.innerHTML += "<br><span class='result-translation'>" + json[results[i]][o]["translation"] + "</span>"; |                         meaning.innerHTML += "<br><span class='result-translation'>" + json[results[i]][o]["translation"] + "</span>"; | ||||||
|                     } |                     } | ||||||
|  |                 } | ||||||
|                 //example
 |                 //example
 | ||||||
|                 if (json[results[i]][o]["examples"] != undefined) { |                 if (json[results[i]][o]["examples"] != undefined) { | ||||||
|                     let temp = "" |                     let temp = "" | ||||||
| @ -478,6 +479,11 @@ function goHome(state = true) { | |||||||
| 
 | 
 | ||||||
| async function registerSW() { | async function registerSW() { | ||||||
|     if ('serviceWorker' in navigator) { |     if ('serviceWorker' in navigator) { | ||||||
|  |         if (location.hostname === "localhost" || location.hostname === "127.0.0.1") { | ||||||
|  |             console.log("localhost - not registering sw"); //because spamming removeSW() every time i make a change is annoying;
 | ||||||
|  |             removeSW(); //just in case =w=
 | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|         navigator.serviceWorker.register('./sw.js').then(registration => { |         navigator.serviceWorker.register('./sw.js').then(registration => { | ||||||
|             registration.onupdatefound = () => { |             registration.onupdatefound = () => { | ||||||
|                 const installingWorker = registration.installing; |                 const installingWorker = registration.installing; | ||||||
| @ -491,21 +497,11 @@ async function registerSW() { | |||||||
|                             // but the previous service worker will still serve the older
 |                             // but the previous service worker will still serve the older
 | ||||||
|                             // content until all client tabs are closed.
 |                             // content until all client tabs are closed.
 | ||||||
|                             header.querySelector("#update").style.display = "block"; |                             header.querySelector("#update").style.display = "block"; | ||||||
| 
 |  | ||||||
|                             // Execute callback
 |  | ||||||
|                             if (config && config.onUpdate) { |  | ||||||
|                                 config.onUpdate(registration); |  | ||||||
|                             } |  | ||||||
|                         } else { |                         } else { | ||||||
|                             // At this point, everything has been precached.
 |                             // At this point, everything has been precached.
 | ||||||
|                             // It's the perfect time to display a
 |                             // It's the perfect time to display a
 | ||||||
|                             // "Content is cached for offline use." message.
 |                             // "Content is cached for offline use." message.
 | ||||||
|                             console.log('Content is cached for offline use.'); |                             console.log('Content is cached for offline use.'); | ||||||
| 
 |  | ||||||
|                             // Execute callback
 |  | ||||||
|                             if (config && config.onSuccess) { |  | ||||||
|                                 config.onSuccess(registration); |  | ||||||
|                             } |  | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|                 }; |                 }; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user