forked from patorjk/JavaScript-Snake
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
executable file
·90 lines (67 loc) · 2.43 KB
/
index.html
File metadata and controls
executable file
·90 lines (67 loc) · 2.43 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<!DOCTYPE html>
<!--<html manifest="snake.appcache">-->
<head>
<!--
JavaScript Snake
By Patrick Gillespie
http://patorjk.com/games/snake
Forked By Chris Love
and upgraded to a Progressive Web App (PWA)!
Source code is available here: https://github.com/docluv/JavaScript-Snake
-->
<title>JavaScript Snake</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="manifest" href="manifest.json">
<link rel="icon" type="image/png" href="favicon-48-48.png">
<meta name="theme-color" content="#0000A8"/>
<link rel="stylesheet" id="style" type="text/css" href="css/main-snake.css" />
<button onclick=getTheme()>Click to use this theme.</button>
<select id="select">
<option>Dark Theme</option>
<option>Revert To Original</option>
</select>
<div id="mode-wrapper">Select which mode you would like to play in.
<br />
<button id="Easy">Easy</button>
<br />
<button id="Medium">Medium</button>
<br />
<button id="Difficult">Difficult</button>
</div>
<button id="high-score">Get your current high score for this game.</button>
</head>
<body>
<div id="game-area" tabindex="0">
</div>
<script>
function getTheme() {
function changeTheme(Theme) {
document.getElementById('style').setAttribute('href', Theme);
}
var index = document.getElementById("select").selectedIndex;
switch (index) {
case 0:
changeTheme('css/dark-snake.css');
break;
case 1: changeTheme('css/main-snake.css');
}
}
</script>
<script type="text/javascript" src="js/snake.js"></script>
<script type="text/javascript">
var mySnakeBoard = new SNAKE.Board({
boardContainer: "game-area",
fullScreen: true
});
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw.js').then(function (registration) {
// Registration was successful
console.log('ServiceWorker registration successful with scope: ', registration.scope);
}).catch(function (err) {
// registration failed :(
console.log('ServiceWorker registration failed: ', err);
});
}
</script>
</body>
</html>