summaryrefslogtreecommitdiff
path: root/www
diff options
context:
space:
mode:
authorAlex Xu <alex_y_xu@yahoo.ca>2013-12-03 14:25:39 -0500
committerAlex Xu <alex_y_xu@yahoo.ca>2013-12-03 14:25:39 -0500
commitf54491cd93e77c3c34fc12a7e56f76d19895922a (patch)
tree7a93e108d1636077fe253b7d6197a0208fa55183 /www
parent38779737f641904829b8d07428ea7865309dc907 (diff)
downloadhtml5ks-f54491cd93e77c3c34fc12a7e56f76d19895922a.tar.xz
html5ks-f54491cd93e77c3c34fc12a7e56f76d19895922a.zip
Even more refactoring.
Diffstat (limited to 'www')
-rw-r--r--www/js/api.js34
1 files changed, 10 insertions, 24 deletions
diff --git a/www/js/api.js b/www/js/api.js
index ca8ee85..21e55ab 100644
--- a/www/js/api.js
+++ b/www/js/api.js
@@ -13,8 +13,7 @@ window.html5ks.api = {
_fading: {},
set_volume: function (target, delay, channel) {
- var deferred = when.defer(),
- audio = html5ks.elements.audio[channel],
+ var audio = html5ks.elements.audio[channel],
step = (target - audio.volume) / (delay * 20);
if (!delay) {
audio.volume = target;
@@ -27,8 +26,7 @@ window.html5ks.api = {
}
}.bind(this), 50);
}
- deferred.resolve();
- return deferred.promise;
+ return when.defer().resolve();
},
play: function (channel, name, ignore, fade) {
@@ -81,8 +79,7 @@ window.html5ks.api = {
this.stop("sound", ignore, fade);
return this.stop("ambient", ignore, fade);
}
- var deferred = when.defer(),
- audio = html5ks.elements.audio[channel];
+ var audio = html5ks.elements.audio[channel];
if (this._fading[channel]) {
clearInterval(this._fading[channel]);
}
@@ -91,8 +88,7 @@ window.html5ks.api = {
} else {
audio.pause();
}
- deferred.resolve();
- return deferred.promise;
+ return when.defer().resolve();
},
@@ -182,17 +178,14 @@ window.html5ks.api = {
return this.say(cmd, args[0]);
} else {
console.error("no such cmd " + cmd);
- var deferred = when.defer();
- deferred.resolve();
- return deferred.promise;
+ return when.defer().resolve();
}
}
},
window: function (action, transition) {
- var windw = html5ks.elements.window,
- deferred = when.defer();
+ var windw = html5ks.elements.window;
switch (action) {
case "show":
windw.style.display = "block";
@@ -203,8 +196,7 @@ window.html5ks.api = {
default:
return windw.style.display !== "none";
}
- deferred.resolve(action);
- return deferred.promise;
+ return when.defer().resolve();
},
@@ -304,15 +296,13 @@ window.html5ks.api = {
return deferred.promise;
},
hide: function (name) {
- var deferred = when.defer();
var show = html5ks.elements.show.children;
for (var i = show.length - 1; i >= 0; i--) {
if (show[i].id === name) {
html5ks.elements.show.removeChild(show[i]);
}
}
- deferred.resolve();
- return deferred.promise;
+ return when.defer().resolve();
},
tag: function (str) {
@@ -430,25 +420,21 @@ window.html5ks.api = {
},
nvl: function (action, transition) {
- var deferred = when.defer(),
- nvl = html5ks.elements.nvl;
+ var nvl = html5ks.elements.nvl;
switch (action) {
case "show":
nvl.style.display = "block";
- deferred.resolve();
break;
case "hide":
nvl.style.display = "none";
- deferred.resolve();
break;
case "clear":
html5ks.elements.nvlsay.innerHTML = "";
- deferred.resolve();
break;
default:
console.error("no such nvl action " + action);
}
- return deferred.promise;
+ return when.defer().resolve();
},
centered: function (text) {