-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
142 lines (132 loc) · 4.36 KB
/
index.html
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<!DOCTYPE html>
<html lang="en">
<head>
<!--
Source code is available here: https://github.com/patorjk/JavaScript-Snake
-->
<meta charset="utf-8">
<title>JavaScript Snake</title>
<link rel=stylesheet id="style" type="text/css" href="./css/main-snake.css" />
<link rel="shortcut icon" href="css/images/favicon.png" />
<style>
.snake-toolbar {
position: absolute;
top: 0;
left: 0;
z-index:10000;
padding: 5px;
}
</style>
<script>
function getTheme () {
function changeTheme(themeUrl) {
var elm = document.getElementById("style");
elm && elm.remove();
var newCss = document.createElement("link");
newCss.id = "style";
newCss.rel = "stylesheet";
newCss.type = "text/css";
newCss.href = themeUrl;
document.head.appendChild(newCss);
}
var index = document.getElementById("select").selectedIndex;
switch (index) {
case 0:
changeTheme('css/light-snake.css?' + Math.random());
break;
case 1:
changeTheme('css/main-snake.css?' + Math.random());
break;
case 2:
changeTheme('css/dark-snake.css?' + Math.random());
break;
case 3:
changeTheme('css/green-snake.css?' + Math.random());
break;
case 4:
changeTheme('css/matrix-snake.css?' + Math.random());
break;
case 5:
changeTheme('css/Senura-snake.css?' + Math.random());
break;
case 6:
changeTheme('css/head-snake.css?' + Math.random());
break;
default:
changeTheme('css/main-snake.css?' + Math.random());
break;
}
setTimeout(function() {
document.getElementById('game-area').focus();
}, 10);
}
if (navigator.onLine && window.location.hostname === 'patorjk.com') {
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-3312460-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
}
</script>
</head>
<body>
<div class="snake-toolbar">
<div style="display:inline-block;margin-right:10px;">
<span>Theme:</span>
<select autocomplete="off" onchange="getTheme()" id="select">
<option>Light</option>
<option selected>FS Theme by Jesse</option>
<option>Dark</option>
<option>Green</option>
<option>Matrix</option>
</select>
</div>
<div style="display:inline-block;margin-right:10px;">
<span>Mode:</span>
<select id="selectMode">
<option value="100">Easy</option>
<option value="75" selected>Medium</option>
<option value="50">Hard</option>
<option value="25">Impossible</option>
<option value="110">Rush</option>
</select>
</div>
<button onclick="go_full_screen()">Full Screen</button><br />
</div>
<!--
<h2>CHOOSE A DIFFICULTY</h2>
<button id="Easy">Easy</button><br />
<button id="Medium">Medium</button><br />
<button id="Difficult">Difficult</button>
<button id="high-score">Get your current high score for this game.</button>
-->
<div id="mode-wrapper" style="display: inline; width: auto;">
</div>
<div id="game-area" tabindex="0">
</div>
<script type="text/javascript" src="./js/snake.js"></script>
<script type="text/javascript" src="./js/init.js"></script>
<script type="text/javascript">
function go_full_screen() {
var elem = document.documentElement;
try {
if (elem.requestFullscreen) {
elem.requestFullscreen();
} else if (elem.msRequestFullscreen) {
elem.msRequestFullscreen();
} else if (elem.mozRequestFullScreen) {
elem.mozRequestFullScreen();
} else if (elem.webkitRequestFullscreen) {
elem.webkitRequestFullscreen();
}
} catch(err) {
console.error(err);
alert("Sorry, fullscreen won't work in this setup.");
}
}
</script>
</body>
</html>