Mercurial > web-gnusto
changeset 83:e813e427fbe6
Saved/restored games are now done on a per-game basis.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Wed, 21 May 2008 15:08:52 -0700 |
parents | 2869ebf025eb |
children | 0f6cf96a6aee |
files | web-zui.js |
diffstat | 1 files changed, 13 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/web-zui.js Wed May 21 11:44:51 2008 -0700 +++ b/web-zui.js Wed May 21 15:08:52 2008 -0700 @@ -192,7 +192,8 @@ // (e.g. Google Gears, HTML 5 database storage, etc) if // available; if none are available, we should return false. - globalStorage[location.hostname]['saveData'] = encode_base64(data); + var saveKey = gStory + '_saveData'; + globalStorage[location.hostname][saveKey] = encode_base64(data); return true; }, @@ -200,7 +201,7 @@ // TODO: Attempt to use other forms of local storage if // available; if none are available, we should return null. - var saveData = globalStorage[location.hostname]['saveData']; + var saveData = globalStorage[location.hostname][gStory + '_saveData']; if (saveData) return decode_base64(saveData.value); else @@ -375,10 +376,13 @@ } function downloadViaProxy(relPath, callback) { - var PROXY_URL = baseUrl + "/cgi-bin/xhr_proxy.py"; + var PROXY_URL = gBaseUrl + "/cgi-bin/xhr_proxy.py"; var url = PROXY_URL + "?file=" + relPath.slice(IF_ARCHIVE_PREFIX.length); - $.ajax({url: url, + // TODO: Ideally the proxy should be communicated with via an HTTP + // POST, since we're trying to change data on the server. + + $.ajax({url: url, success: function(data, textStatus) { if (data.indexOf("SUCCESS") == 0) loadBinaryUrl(relPath, callback, false); @@ -391,7 +395,7 @@ } function loadBinaryUrl(relPath, callback, useProxy) { - var url = baseUrl + "/" + relPath; + var url = gBaseUrl + "/" + relPath; var req = new XMLHttpRequest(); req.open('GET',url,true); //XHR binary charset opt by Marcus Granado 2006 [http://mgran.blogspot.com] @@ -436,13 +440,15 @@ runner.run(); } -var thisUrl = location.protocol + "//" + location.host + location.pathname; -var baseUrl = thisUrl.slice(0, thisUrl.lastIndexOf("/")); +var gThisUrl = location.protocol + "//" + location.host + location.pathname; +var gBaseUrl = gThisUrl.slice(0, gThisUrl.lastIndexOf("/")); +var gStory = ""; var IF_ARCHIVE_PREFIX = "if-archive/"; $(document).ready(function() { var qs = new Querystring(); var story = qs.get("story", "stories/troll.z5"); + gStory = story; loadBinaryUrl(story, _zcodeLoaded, true); });