fix onhashchange
This commit is contained in:
		
							
								
								
									
										14
									
								
								js/sudoku.js
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								js/sudoku.js
									
									
									
									
									
								
							| @ -57,14 +57,12 @@ window.onload = function() { | |||||||
|  |  | ||||||
|     if (localStorage["sightCheckbox.checked"] == "true") sightCheckbox.checked = true |     if (localStorage["sightCheckbox.checked"] == "true") sightCheckbox.checked = true | ||||||
|     if (localStorage["highlighterCheckbox.checked"] == "true") highlighterCheckbox.checked = true |     if (localStorage["highlighterCheckbox.checked"] == "true") highlighterCheckbox.checked = true | ||||||
|     loadSavedGame() |  | ||||||
|  |  | ||||||
|     boxes.forEach(box => { |     boxes.forEach(box => { | ||||||
|         box.neighbourhood = new Set(rows[box.rowId].concat(columns[box.columnId]).concat(regions[box.regionId])) |         box.neighbourhood = new Set(rows[box.rowId].concat(columns[box.columnId]).concat(regions[box.regionId])) | ||||||
|         box.andNeighbourhood = Array.from(box.neighbourhood) |         box.andNeighbourhood = Array.from(box.neighbourhood) | ||||||
|         box.neighbourhood.delete(box) |         box.neighbourhood.delete(box) | ||||||
|         box.neighbourhood = Array.from(box.neighbourhood) |         box.neighbourhood = Array.from(box.neighbourhood) | ||||||
|         searchCandidatesOf(box) |  | ||||||
|     }) |     }) | ||||||
|  |  | ||||||
|     insertRadios = Array.from(insertRadioGroup.getElementsByTagName("input")) |     insertRadios = Array.from(insertRadioGroup.getElementsByTagName("input")) | ||||||
| @ -82,16 +80,16 @@ window.onload = function() { | |||||||
|         else if (node.label) node.label.title += shortcut |         else if (node.label) node.label.title += shortcut | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     refreshUI() |     onhashchange() | ||||||
|  |  | ||||||
|     if ("serviceWorker" in navigator) { |     if ("serviceWorker" in navigator) { | ||||||
|         navigator.serviceWorker.register(`service-worker.php?location=${location.pathname}`) |         navigator.serviceWorker.register(`service-worker.php?location=${location.pathname}`) | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| function loadSavedGame() { | onhashchange = function(event) { | ||||||
|     const savedGame = location.hash.slice(1) |     const savedGame = location.hash.slice(1) | ||||||
|     if (savedGame) { |     if (savedGame.match(/[1-9.]{81}/)) { | ||||||
|         boxes.forEach((box, i) => { |         boxes.forEach((box, i) => { | ||||||
|             if (!box.disabled && savedGame[i] != UNKNOWN) { |             if (!box.disabled && savedGame[i] != UNKNOWN) { | ||||||
|                 box.value = savedGame[i] |                 box.value = savedGame[i] | ||||||
| @ -101,11 +99,7 @@ function loadSavedGame() { | |||||||
|         restartButton.disabled = false |         restartButton.disabled = false | ||||||
|         fixGridLink.href = "?" + savedGame |         fixGridLink.href = "?" + savedGame | ||||||
|     } |     } | ||||||
| } |     boxes.forEach(searchCandidatesOf) | ||||||
|  |  | ||||||
| onhashchange = function(event) { |  | ||||||
|     loadSavedGame() |  | ||||||
|     boxes.forEach(box => searchCandidatesOf(box)) |  | ||||||
|     refreshUI() |     refreshUI() | ||||||
| } | } | ||||||
|  |  | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user