From 8c0851a7d4db8be1bac99e034c745a45c64cc3ba Mon Sep 17 00:00:00 2001 From: piernov Date: Mon, 2 May 2016 15:51:08 +0200 Subject: Add various JS functions to work with game save --- js/savegame.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) 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[i] + "\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"); } -- cgit v1.2.3-54-g00ecf