aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiernov <piernov@piernov.org>2016-05-02 15:51:08 +0200
committerpiernov <piernov@piernov.org>2016-05-02 15:51:08 +0200
commit8c0851a7d4db8be1bac99e034c745a45c64cc3ba (patch)
tree89479205742cd1135613aa22b6d8570164e8983c
parentf53549e4c2668ca268c8e31ef4c7cf3718fe08b5 (diff)
downloadcandybox-8c0851a7d4db8be1bac99e034c745a45c64cc3ba.tar.gz
candybox-8c0851a7d4db8be1bac99e034c745a45c64cc3ba.tar.bz2
candybox-8c0851a7d4db8be1bac99e034c745a45c64cc3ba.tar.xz
candybox-8c0851a7d4db8be1bac99e034c745a45c64cc3ba.zip
Add various JS functions to work with game save
-rw-r--r--js/savegame.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/js/savegame.js b/js/savegame.js
index 2a83f77..438be0a 100644
--- a/js/savegame.js
+++ b/js/savegame.js
@@ -1,3 +1,35 @@
+function listSaves() {
+ sendRequest("craftmine.php", "op=listSaves", function(ret) {
+ var tmphtml=""
+ for(var i=0; i<ret.length; i++) {
+ tmphtml += "<label class=\"radio\"><input name=\"saveRadio\" value=\"" + i + "\" type=\"radio\" />" + ret[i] + "</label>\n";
+ }
+ console.log(tmphtml);
+ document.getElementById("listsaves").innerHTML = tmphtml;
+ });
+}
+
+function getCheckedSave() {
+ var radios = document.getElementsByName('saveRadio');
+ for (var i = 0, length = radios.length; i < length; i++) {
+ if (radios[i].checked) return radios[i].parentNode.textContent;
+ }
+ return -1;
+}
+
+function loadSave() {
+ sendRequest("craftmine.php", "op=loadSave&filename="+getCheckedSave(), function(ret) {
+ initCraftMine();
+ });
+}
+
+function downloadSave() {
+ window.open("craftmine.php?op=downSave&filename="+getCheckedSave(), "_blank");
+}
+
+function deleteSave() {
+}
+
function saveGame() {
sendRequest("craftmine.php", "op=saveGame");
}