aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiernov <piernov@piernov.org>2016-05-04 14:52:35 +0200
committerpiernov <piernov@piernov.org>2016-05-04 14:52:35 +0200
commit35ec65de0869c77fc66bf3f2702c561efd98f4af (patch)
treeb73ff5366be110a40d1ddd6ab0c91b9600faf7de
parentfcf504d0cb37545d6157f384eccdfd82daaa55e4 (diff)
downloadcandybox-35ec65de0869c77fc66bf3f2702c561efd98f4af.tar.gz
candybox-35ec65de0869c77fc66bf3f2702c561efd98f4af.tar.bz2
candybox-35ec65de0869c77fc66bf3f2702c561efd98f4af.tar.xz
candybox-35ec65de0869c77fc66bf3f2702c561efd98f4af.zip
Move onhashchange event hook from XHTML to JavaScript
Add some comments
-rw-r--r--index.xhtml2
-rw-r--r--js/craftmine.js7
2 files changed, 5 insertions, 4 deletions
diff --git a/index.xhtml b/index.xhtml
index bd2cdf3..f242f76 100644
--- a/index.xhtml
+++ b/index.xhtml
@@ -18,7 +18,7 @@
<script type="text/javascript" charset="utf-8" src="js/dungeon.js"></script>
<script type="text/javascript" charset="utf-8" src="js/savegame.js"></script>
</head>
-<body onload="init()" onhashchange="changeTab()">
+<body onload="init()">
<div class="container-fluid">
<div class="row">
<h1>CraftMine</h1>
diff --git a/js/craftmine.js b/js/craftmine.js
index 61abbf7..0e95aa3 100644
--- a/js/craftmine.js
+++ b/js/craftmine.js
@@ -70,7 +70,8 @@ function updateMine() {
function init() {
initCraftMine();
- changeTab();
- listSaves();
- window.setInterval(updateMine, 1000);
+ changeTab(); // Switch to tab specified in URL
+ listSaves(); // Update save list on page load
+ window.setInterval(updateMine, 1000); // Increase mine amount every 1 second
+ window.onhashchange = changeTab; // Hook changeTab from js/gui.js to hashchange event
}