aboutsummaryrefslogtreecommitdiffstats
path: root/js/savegame.js
diff options
context:
space:
mode:
authorpiernov <piernov@piernov.org>2016-05-03 10:37:18 +0200
committerpiernov <piernov@piernov.org>2016-05-03 10:37:18 +0200
commit64e184b901fd4e7c9a829d14c5c34416923171c3 (patch)
tree70b5281ca85a38ef2a077e226dcce56a40ed563a /js/savegame.js
parentadd9d3248a5adc02b071a301005c6f11195f7f7b (diff)
parentb8112f72b322fe5bf7048ac76251c8c637b9fee2 (diff)
downloadcandybox-64e184b901fd4e7c9a829d14c5c34416923171c3.tar.gz
candybox-64e184b901fd4e7c9a829d14c5c34416923171c3.tar.bz2
candybox-64e184b901fd4e7c9a829d14c5c34416923171c3.tar.xz
candybox-64e184b901fd4e7c9a829d14c5c34416923171c3.zip
Merge branch 'master' into alexichi
Diffstat (limited to 'js/savegame.js')
-rw-r--r--js/savegame.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/js/savegame.js b/js/savegame.js
new file mode 100644
index 0000000..4a08f91
--- /dev/null
+++ b/js/savegame.js
@@ -0,0 +1,42 @@
+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() {
+ sendRequest("craftmine.php", "op=deleteSave&filename="+getCheckedSave(), function(ret) {
+ listSaves();
+ });
+}
+
+function saveGame() {
+ sendRequest("craftmine.php", "op=saveGame");
+}
+
+function downGame() {
+ window.open("craftmine.php?op=downSave", "_blank");
+}