summaryrefslogtreecommitdiff
path: root/www/js
diff options
context:
space:
mode:
authorAlex Xu <alex_y_xu@yahoo.ca>2013-06-26 18:01:39 -0400
committerAlex Xu <alex_y_xu@yahoo.ca>2013-06-26 18:01:39 -0400
commita7760b1e2695669e154f204fea18bbae4dff5db6 (patch)
tree262034681505707afea1d664c30f56924213cb6d /www/js
parentd7c088b5ec377fd85742fe4f661c790d5a0af059 (diff)
downloadhtml5ks-a7760b1e2695669e154f204fea18bbae4dff5db6.tar.xz
html5ks-a7760b1e2695669e154f204fea18bbae4dff5db6.zip
make it work
Diffstat (limited to 'www/js')
-rw-r--r--www/js/api.js27
1 files changed, 15 insertions, 12 deletions
diff --git a/www/js/api.js b/www/js/api.js
index 1171533..41a76f5 100644
--- a/www/js/api.js
+++ b/www/js/api.js
@@ -34,7 +34,9 @@ window.html5ks.api = {
audio.addEventListener("playing", function playing() {
audio.removeEventListener("playing", playing, false);
deferred.resolve();
- html5ks.api.fading(audio, 1, fade);
+ if (fade) {
+ html5ks.api.fading(audio, 1, fade);
+ }
}, false);
audio.addEventListener("error", function error() {
audio.removeEventListener("error", error, false);
@@ -79,15 +81,10 @@ window.html5ks.api = {
window: function (action, transition) {
var windw = html5ks.elements.window,
deferred = when.defer();
- switch (action) {
- case "show":
- windw.style.display = "block";
- break;
- case "hide":
- windw.style.display = "none";
- break;
- default:
- throw new Error("unknown window action " + action);
+ if (action === "show") {
+ windw.style.display = "block";
+ } else {
+ windw.style.display = "none";
}
deferred.resolve(action);
return deferred.promise;
@@ -145,8 +142,14 @@ window.html5ks.api = {
if (html5ks.data.characters[cmd]) {
return this.character(cmd, args);
} else {
- console.log(arguments);
- return this[cmd].apply(this, args);
+ if (this[cmd]) {
+ return this[cmd].apply(this, args);
+ } else {
+ console.error("no such cmd " + cmd);
+ var deferred = when.defer();
+ deferred.resolve();
+ return deferred.promise;
+ }
}
},
runScript: function (label) {