summaryrefslogtreecommitdiff
path: root/www
diff options
context:
space:
mode:
authorAlex Xu <alex_y_xu@yahoo.ca>2014-04-06 19:32:58 -0400
committerAlex Xu <alex_y_xu@yahoo.ca>2014-04-06 19:32:58 -0400
commit6a50d79523cf215001cdd55c74c040bd410775df (patch)
treec7926f1c46b5b68f43e675beddad14d85851210f /www
parentcc4e6587df70f79de8fb23fceefce89d91e2a4bb (diff)
downloadhtml5ks-6a50d79523cf215001cdd55c74c040bd410775df.tar.xz
html5ks-6a50d79523cf215001cdd55c74c040bd410775df.zip
stuff
Diffstat (limited to 'www')
-rw-r--r--www/index.html.dist (renamed from www/index.html)0
-rw-r--r--www/js/api.js6
-rw-r--r--www/js/html5ks.js14
-rw-r--r--www/js/imachine.js3
4 files changed, 11 insertions, 12 deletions
diff --git a/www/index.html b/www/index.html.dist
index f5b0270..f5b0270 100644
--- a/www/index.html
+++ b/www/index.html.dist
diff --git a/www/js/api.js b/www/js/api.js
index 6b5f177..0043724 100644
--- a/www/js/api.js
+++ b/www/js/api.js
@@ -191,9 +191,9 @@ window.html5ks.api = {
iscene: function (target, is_h, is_end) {
html5ks.store.status = "scene";
var deferred = when.defer(),
- real_target = html5ks.persistent.language + "_" + target,
+ real_target = html5ks.persistent.language + "_" + target.replace(/"/g, ''),
i = 0;
- html5ks.fetch('script', html5ks.data.s2s[real_target]).then(function (l) {
+ html5ks.fetch('script', real_target).then(function run(l) {
if (l[i]) {
html5ks.api.runInst(l[i++]).then(run, console.error);
} else {
@@ -214,8 +214,6 @@ window.html5ks.api = {
return this[cmd].apply(this, args);
} else if (inst.length === 1) {
return this.say("name_only", cmd);
- } else if (/^[A-Z]/.test(cmd)) {
- return this.say(cmd, args[0]);
} else {
console.error("no such cmd " + cmd);
return when.resolve();
diff --git a/www/js/html5ks.js b/www/js/html5ks.js
index 7fe493a..13bd198 100644
--- a/www/js/html5ks.js
+++ b/www/js/html5ks.js
@@ -205,7 +205,7 @@ window.html5ks = {
var deferred = when.defer();
var xhr = new XMLHttpRequest();
if (obj[prop]) {
- deferred.resolve();
+ deferred.resolve(obj[prop]);
} else {
xhr.open("GET", path);
xhr.onload = function () {
@@ -217,8 +217,8 @@ window.html5ks = {
xhr.onerror();
}
};
- xhr.onerror = function () {
- deferred.reject();
+ xhr.onerror = function (e) {
+ deferred.reject(new Error(xhr.status));
};
xhr.send();
}
@@ -229,14 +229,14 @@ window.html5ks = {
switch (type) {
case "json":
return this._fetch(html5ks.data, name, "json/" + name + ".json");
- break;
case "script":
- this._fetch(html5ks.data.script, name, "json/script-" + name + ".json").then(function (d) {
+ var filename = html5ks.data.s2s[name];
+ this._fetch(html5ks.data.script, filename, "json/script-" + filename + ".json").then(function (d) {
for (var i in d) {
html5ks.data.script[i] = d[i];
}
- deferred.resolve();
- });
+ deferred.resolve(d[name]);
+ }, deferred.reject);
break;
default:
throw new Error("fetchtype " + type + " not implemented");
diff --git a/www/js/imachine.js b/www/js/imachine.js
index 694aea5..37ce701 100644
--- a/www/js/imachine.js
+++ b/www/js/imachine.js
@@ -21,8 +21,9 @@ html5ks.imachine = {
case "act_op":
case "iscene":
html5ks.api[inst.label].call(html5ks.api, inst['arguments'][0][0][1]).then(runInst, deferred.reject);
+ break;
default:
- throw new Error('unknown Call label');
+ throw new Error('unknown Call label: ' + inst.label);
}
break;
case 'UserStatement':