From a7760b1e2695669e154f204fea18bbae4dff5db6 Mon Sep 17 00:00:00 2001 From: Alex Xu Date: Wed, 26 Jun 2013 18:01:39 -0400 Subject: make it work --- www/js/api.js | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'www') 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) { -- cgit v1.2.3-70-g09d2