diff options
author | Alex Xu <alex_y_xu@yahoo.ca> | 2013-08-24 12:28:41 -0400 |
---|---|---|
committer | Alex Xu <alex_y_xu@yahoo.ca> | 2013-08-24 12:28:41 -0400 |
commit | 4d93002bd9bcd90edf88e2e0b7a82fac0acbb4f6 (patch) | |
tree | 58a022519469037bfd9dca79a006ae084b84dae3 /www | |
parent | 718936110b9511631fa1f4396be992752bf8b719 (diff) | |
download | html5ks-4d93002bd9bcd90edf88e2e0b7a82fac0acbb4f6.tar.xz html5ks-4d93002bd9bcd90edf88e2e0b7a82fac0acbb4f6.zip |
stuff.
Diffstat (limited to 'www')
-rw-r--r-- | www/js/api.js | 77 |
1 files changed, 40 insertions, 37 deletions
diff --git a/www/js/api.js b/www/js/api.js index a7b06d8..783876d 100644 --- a/www/js/api.js +++ b/www/js/api.js @@ -18,13 +18,13 @@ window.html5ks.api = { if (!delay) { audio.volume = target; } else { - var f = setInterval(function () { + this._fading[channel] = setInterval(function () { // clamp new volume 0-1 audio.volume = Math.min(Math.max(audio.volume + step, 0), 1); if (audio.volume === 0 || audio.volume === 1) { - clearInterval(f); + clearInterval(this._fading); } - }, 50); + }.bind(this), 50); } deferred.resolve(); return deferred.promise; @@ -64,6 +64,9 @@ window.html5ks.api = { } var deferred = when.defer(), audio = html5ks.elements.audio[channel]; + if (this._fading[channel]) { + clearInterval(this._fading[channel]); + } if (fade) { this.set_volume(0, fade, channel); } else { @@ -342,45 +345,45 @@ window.html5ks.api = { deferred.resolve(); html5ks.next = function () {}; }; - return deferred.promise; - } - var who = html5ks.elements.who; - if (!extend) { - who.innerHTML = char.name; - if (char.color) { - who.style.color = char.color; - } else { - who.style.color = "#ffffff"; + } else { + var who = html5ks.elements.who; + if (!extend) { + who.innerHTML = char.name; + if (char.color) { + who.style.color = char.color; + } else { + who.style.color = "#ffffff"; + } } - } - if (extend) { - html5ks.elements.say.innerHTML += text; - } else { - html5ks.elements.say.innerHTML = text; - } + if (extend) { + html5ks.elements.say.innerHTML += text; + } else { + html5ks.elements.say.innerHTML = text; + } - if (w) { - html5ks.next = function () { - html5ks.next = function () {}; - html5ks.api.extend(w[2]).then(function () { - deferred.resolve(); - }); - }; - if (w[1]) { - setTimeout(function () { - html5ks.next(); - }, parseFloat(w[1], 10) * 1000); - return deferred.promise; + if (w) { + html5ks.next = function () { + html5ks.next = function () {}; + html5ks.api.extend(w[2]).then(function () { + deferred.resolve(); + }); + }; + if (w[1]) { + setTimeout(function () { + html5ks.next(); + }, parseFloat(w[1], 10) * 1000); + return deferred.promise; + } + } else { + html5ks.next = function () { + html5ks.elements.ctc.style.display = "none"; + deferred.resolve(text); + html5ks.next = function () {}; + }; } - } else { - html5ks.next = function () { - html5ks.elements.ctc.style.display = "none"; - deferred.resolve(text); - html5ks.next = function () {}; - }; + html5ks.elements.ctc.style.display = "block"; } - html5ks.elements.ctc.style.display = "block"; if (html5ks.state.skip || str.indexOf("{nw}") > -1) { html5ks.next(); } else if (html5ks.state.auto) { |