Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b735d5b

Browse files
committed
Fix issue patorjk#116: Refactor var to let and const
1 parent a3dcfb7 commit b735d5b

File tree

4 files changed

+119
-105
lines changed

4 files changed

+119
-105
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ http://patorjk.com/games/snake
1818
## How to use
1919
The index.html file should give an idea of how to use this code. However, below you can see how to initialize it into any div within a webpage.
2020

21-
var mySnakeBoard = new SNAKE.Board( {
21+
const mySnakeBoard = new SNAKE.Board( {
2222
boardContainer: "game-area",
2323
fullScreen: false,
2424
width: 580,

index.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@
2727

2828
function getTheme () {
2929
function changeTheme(themeUrl) {
30-
var elm = document.getElementById("style");
30+
const elm = document.getElementById("style");
3131
elm && elm.remove();
3232

33-
var newCss = document.createElement("link");
33+
const newCss = document.createElement("link");
3434
newCss.id = "style";
3535
newCss.rel = "stylesheet";
3636
newCss.type = "text/css";
3737
newCss.href = themeUrl;
3838
document.head.appendChild(newCss);
3939
}
40-
var index = document.getElementById("select").selectedIndex;
40+
const index = document.getElementById("select").selectedIndex;
4141
switch (index) {
4242
case 0:
4343
changeTheme('css/light-snake.css?' + Math.random());
@@ -70,14 +70,14 @@
7070
}
7171

7272
if (navigator.onLine && window.location.hostname === 'patorjk.com') {
73-
var _gaq = _gaq || [];
73+
const _gaq = _gaq || [];
7474
_gaq.push(['_setAccount', 'UA-3312460-1']);
7575
_gaq.push(['_trackPageview']);
7676

7777
(function() {
78-
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
78+
const ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
7979
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
80-
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
80+
const s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
8181
})();
8282
}
8383
</script>
@@ -126,7 +126,7 @@ <h2>Select which mode you would like to play in.</h2>
126126
<script type="text/javascript" src="./js/init.js"></script>
127127
<script type="text/javascript">
128128
function go_full_screen() {
129-
var elem = document.documentElement;
129+
const elem = document.documentElement;
130130
try {
131131
if (elem.requestFullscreen) {
132132
elem.requestFullscreen();
@@ -144,4 +144,4 @@ <h2>Select which mode you would like to play in.</h2>
144144
}
145145
</script>
146146
</body>
147-
</html>
147+
</html>

js/init.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
var mySnakeBoard = new SNAKE.Board({
1+
const mySnakeBoard = new SNAKE.Board({
22
boardContainer: "game-area",
33
fullScreen: true,
44
premoveOnPause: false
5-
});
5+
});

0 commit comments

Comments
 (0)