From 0b5c241cd34c8f2f59c62e8c6b6b6ca5f2e1501a Mon Sep 17 00:00:00 2001 From: Alexander Yakovlev Date: Fri, 15 Jan 2016 08:59:46 +0700 Subject: [PATCH] Save/load buttons Save is broken now. Reasons unknown. --- html/index.html | 7 ++++--- lib/interface.coffee | 4 ++++ lib/undum.js | 6 ++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/html/index.html b/html/index.html index 66bced9..e1b39f3 100644 --- a/html/index.html +++ b/html/index.html @@ -45,10 +45,11 @@ diff --git a/lib/interface.coffee b/lib/interface.coffee index 60b85b5..2c8a1be 100644 --- a/lib/interface.coffee +++ b/lib/interface.coffee @@ -10,4 +10,8 @@ $(document).ready(() -> $("#inventory").on("click", "a", (event) -> event.preventDefault() ) + $("#load").on("click", "a", (event) -> + event.preventDefault() + window.location.reload() + ) ) diff --git a/lib/undum.js b/lib/undum.js index c92b36f..864369b 100644 --- a/lib/undum.js +++ b/lib/undum.js @@ -1395,6 +1395,7 @@ var processLink = function(code) { // We're able to save, if we weren't already. $("#save").attr('disabled', false); + $("#save").removeClass('disabled'); }; /* This gets called to actually do the work of processing a code. @@ -1620,7 +1621,10 @@ var saveGame = function() { // Switch the button highlights. $("#erase").attr('disabled', false); + $("#erase").removeClass('disabled'); + $("#load").removeClass('disabled'); $("#save").attr('disabled', true); + $("#save").addClass('disabled'); }; /* Loads the game from the given data */ @@ -1632,6 +1636,7 @@ var loadGame = function(characterData) { // Empty the display $("#content").empty(); + $("#intro").empty(); showQualities(); // Now play through the actions so far: @@ -1671,6 +1676,7 @@ var begin = function () { var save = $("#save").click(saveGame); var storedCharacter = localStorage[getSaveId()]; + console.log(storedCharacter) if (storedCharacter) { try { loadGame(JSON.parse(storedCharacter));