save to location.hash
This commit is contained in:
parent
80fa25c092
commit
785f1460fb
@ -90,7 +90,7 @@ window.onload = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function loadSavedGame() {
|
function loadSavedGame() {
|
||||||
const savedGame = localStorage[location.search]
|
const savedGame = location.hash.slice(1)
|
||||||
if (savedGame) {
|
if (savedGame) {
|
||||||
boxes.forEach((box, i) => {
|
boxes.forEach((box, i) => {
|
||||||
if (!box.disabled && savedGame[i] != UNKNOWN) {
|
if (!box.disabled && savedGame[i] != UNKNOWN) {
|
||||||
@ -98,6 +98,7 @@ function loadSavedGame() {
|
|||||||
box.previousValue = savedGame[i]
|
box.previousValue = savedGame[i]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
restartButton.disabled = false
|
||||||
fixGridLink.href = "?" + savedGame
|
fixGridLink.href = "?" + savedGame
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -335,6 +336,7 @@ function restart() {
|
|||||||
let history = []
|
let history = []
|
||||||
undoButton.disabled = true
|
undoButton.disabled = true
|
||||||
restartButton.disabled = true
|
restartButton.disabled = true
|
||||||
|
location.hash = ""
|
||||||
boxes.forEach(searchCandidatesOf)
|
boxes.forEach(searchCandidatesOf)
|
||||||
refreshUI()
|
refreshUI()
|
||||||
}
|
}
|
||||||
@ -342,7 +344,7 @@ function restart() {
|
|||||||
|
|
||||||
function save() {
|
function save() {
|
||||||
let saveGame = boxes.map(box => box.value || UNKNOWN).join("")
|
let saveGame = boxes.map(box => box.value || UNKNOWN).join("")
|
||||||
localStorage[location.search] = saveGame
|
location.hash = saveGame
|
||||||
fixGridLink.href = "?" + saveGame
|
fixGridLink.href = "?" + saveGame
|
||||||
saveButton.disabled = true
|
saveButton.disabled = true
|
||||||
alert("Partie sauvegardée")
|
alert("Partie sauvegardée")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user