diff options
author | Alex Xu <alex_y_xu@yahoo.ca> | 2014-04-06 19:32:58 -0400 |
---|---|---|
committer | Alex Xu <alex_y_xu@yahoo.ca> | 2014-04-06 19:32:58 -0400 |
commit | 6a50d79523cf215001cdd55c74c040bd410775df (patch) | |
tree | c7926f1c46b5b68f43e675beddad14d85851210f | |
parent | cc4e6587df70f79de8fb23fceefce89d91e2a4bb (diff) | |
download | html5ks-6a50d79523cf215001cdd55c74c040bd410775df.tar.xz html5ks-6a50d79523cf215001cdd55c74c040bd410775df.zip |
stuff
-rw-r--r-- | .gitignore | 11 | ||||
-rw-r--r-- | Makefile | 10 | ||||
-rw-r--r-- | www/index.html.dist (renamed from www/index.html) | 0 | ||||
-rw-r--r-- | www/js/api.js | 6 | ||||
-rw-r--r-- | www/js/html5ks.js | 14 | ||||
-rw-r--r-- | www/js/imachine.js | 3 |
6 files changed, 26 insertions, 18 deletions
@@ -1,15 +1,16 @@ # ignore 'copyrighted' contents similar to emulators -/www/favicon.ico -/www/json -/www/dump -/rpy /ast2json/*.json* /ast2json/*.rpyc +/rpy +/www/dump +/www/favicon.ico +/www/json # generated files /Makefile.inc -/www/js/all.min.js* /node_modules +/www/index.html +/www/js/all.min.js* # generated nginx conf - see nginx.sh /nginx.gen.conf @@ -1,7 +1,7 @@ null := SPACE := $(null) $(null) -all: js json video audio images +all: html js json video audio images Makefile: Makefile.inc @@ -12,6 +12,14 @@ include Makefile.inc UGLIFYJS := node_modules/.bin/uglifyjs $(UGLIFYJSFLAGS) +# === HTML === + +html: www/index.html + +www/index.html: www/index.html.dist + $(if $(DEBUG), sed -e 's:$(subst www/,,$(JSOUT)):$(subst $(SPACE),"></script><script src=",$(subst www/,,$(JS))):' $^ > $@, \ + cp $^ $@) + # === JS === MYJS := www/js/html5ks.js www/js/menu.js www/js/api.js \ 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': |