-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
24 lines (22 loc) · 1.13 KB
/
script.js
File metadata and controls
24 lines (22 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
window.onload = function(){
var startButton = document.getElementById("btn-start");
startButton.onclick = function(){
var size = document.getElementById("select-size").options[document.getElementById("select-size").selectedIndex].value;
var fieldBorder = document.getElementById("field-border").options[document.getElementById("field-border").selectedIndex].value;
var difficulty = document.getElementById("difficulty").options[document.getElementById("difficulty").selectedIndex].value;
if (typeof(Storage) !== "undefined") {
localStorage.setItem("fieldBorder", fieldBorder);
localStorage.setItem("size", size);
localStorage.setItem("difficulty", difficulty);
}
window.location.href = "snake/snake.html";
}
if (typeof(Storage) !== "undefined") {
var fieldBorder = localStorage.getItem("fieldBorder") || 0;
document.getElementById("field-border").selectedIndex = fieldBorder;
var size = localStorage.getItem("size") || 1;
document.getElementById("select-size").selectedIndex = size;
var difficulty = localStorage.getItem("difficulty") || 1;
document.getElementById("difficulty").selectedIndex = difficulty;
}
}