summaryrefslogtreecommitdiff
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
parentde844dacb31531781e9f97ec25a52ea246f1115b (diff)
downloadhtml5ks-f5a6c301cc9a277f024563ea656f3fe49aa89834.tar.xz
html5ks-f5a6c301cc9a277f024563ea656f3fe49aa89834.zip
www/scripts -> www/json, slim down html5ks.fetch
-rw-r--r--.gitignore2
-rw-r--r--unrpyc/Makefile4
-rw-r--r--www/js/html5ks.js24
-rw-r--r--www/js/i18n.js2
-rw-r--r--www/js/menu.js2
5 files changed, 12 insertions, 22 deletions
diff --git a/.gitignore b/.gitignore
index ef69786..5f229f9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,7 +7,7 @@
# generated nginx conf - see nginx.sh
/nginx.gen.conf
# ignore 'copyrighted' contents similar to emulators
-/www/scripts
+/www/json
/www/dump
/rpy
diff --git a/unrpyc/Makefile b/unrpyc/Makefile
index b64bb22..826f1e3 100644
--- a/unrpyc/Makefile
+++ b/unrpyc/Makefile
@@ -27,9 +27,9 @@ test: all
jshint --show-non-errors *.json
install: all
- install -t ../www/scripts script.json script.json.gz imachine.json imachine.json.gz imachine_replay.json imachine_replay.json.gz ui-strings.json ui-strings.json.gz
+ install -t ../www/json script.json script.json.gz imachine.json imachine.json.gz imachine_replay.json imachine_replay.json.gz ui-strings.json ui-strings.json.gz
uninstall:
- rm -f ../www/scripts/*
+ rm -f ../www/json/*
.PHONY: all clean test install
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;