summaryrefslogtreecommitdiff
path: root/www/js/html5ks.js
diff options
context:
space:
mode:
authorAlex Xu <alex_y_xu@yahoo.ca>2013-08-19 12:17:25 -0400
committerAlex Xu <alex_y_xu@yahoo.ca>2013-08-19 12:41:52 -0400
commitf5a6c301cc9a277f024563ea656f3fe49aa89834 (patch)
tree3572c174c4238b2b40d0ebd4f0308c59967a7080 /www/js/html5ks.js
parentde844dacb31531781e9f97ec25a52ea246f1115b (diff)
downloadhtml5ks-f5a6c301cc9a277f024563ea656f3fe49aa89834.tar.xz
html5ks-f5a6c301cc9a277f024563ea656f3fe49aa89834.zip
www/scripts -> www/json, slim down html5ks.fetch
Diffstat (limited to 'www/js/html5ks.js')
-rw-r--r--www/js/html5ks.js24
1 files changed, 6 insertions, 18 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");
}