diff options
author | Alex Xu <alex_y_xu@yahoo.ca> | 2013-08-19 12:17:25 -0400 |
---|---|---|
committer | Alex Xu <alex_y_xu@yahoo.ca> | 2013-08-19 12:41:52 -0400 |
commit | f5a6c301cc9a277f024563ea656f3fe49aa89834 (patch) | |
tree | 3572c174c4238b2b40d0ebd4f0308c59967a7080 /www | |
parent | de844dacb31531781e9f97ec25a52ea246f1115b (diff) | |
download | html5ks-f5a6c301cc9a277f024563ea656f3fe49aa89834.tar.xz html5ks-f5a6c301cc9a277f024563ea656f3fe49aa89834.zip |
www/scripts -> www/json, slim down html5ks.fetch
Diffstat (limited to 'www')
-rw-r--r-- | www/js/html5ks.js | 24 | ||||
-rw-r--r-- | www/js/i18n.js | 2 | ||||
-rw-r--r-- | www/js/menu.js | 2 |
3 files changed, 9 insertions, 19 deletions
diff --git a/www/js/html5ks.js b/www/js/html5ks.js index f97a1f0..aea03b1 100644 --- a/www/js/html5ks.js +++ b/www/js/html5ks.js @@ -219,42 +219,30 @@ window.html5ks = { } }, start: function () { - this.fetch("script").then(function () { + this.fetch("json", "script").then(function () { html5ks.api.movie_cutscene("4ls", true).then(function () { html5ks.menu.mainMenu(); }); }); }, - fetch: function (type) { + fetch: function (type, name) { var deferred = when.defer(); var xhr = new XMLHttpRequest(); switch (type) { - case "script": - if (html5ks.data._scriptFetched) { + case "json": + if (html5ks.data[name]) { deferred.resolve(); } else { - xhr.open("GET", "scripts/script.json"); + xhr.open("GET", "json/" + name + ".json"); xhr.onreadystatechange = function () { if (xhr.readyState === 4) { - html5ks.data._scriptFetched = true; - var script = JSON.parse(xhr.responseText); - html5ks.data.script = script; + html5ks.data[name] = JSON.parse(xhr.responseText); deferred.resolve(); } }; xhr.send(); } break; - case "imachine": - xhr.open("GET", "scripts/imachine.json"); - xhr.onreadystatechange = function () { - if (xhr.readyState === 4) { - html5ks.data.imachine = JSON.parse(xhr.responseText); - deferred.resolve(); - } - }; - xhr.send(); - break; default: throw new Error("fetchtype " + type + " not implemented"); } diff --git a/www/js/i18n.js b/www/js/i18n.js new file mode 100644 index 0000000..764a0dd --- /dev/null +++ b/www/js/i18n.js @@ -0,0 +1,2 @@ +html5ks.i18n = { + diff --git a/www/js/menu.js b/www/js/menu.js index 1e0e5a3..e4a8b2c 100644 --- a/www/js/menu.js +++ b/www/js/menu.js @@ -188,7 +188,7 @@ html5ks.imachine.start().then(this.mainMenu.bind(this)); } }.bind(this), false); - html5ks.fetch("imachine").then(function () { + html5ks.fetch("json", "imachine").then(function () { var start = this.elements.main.start; start.className = start.className.replace("disabled", ""); this._imachine_loaded = true; |