From 864d115f229ce8cbd20deb8670831802da8c9216 Mon Sep 17 00:00:00 2001 From: Alex Xu Date: Wed, 1 Jan 2014 13:19:22 -0500 Subject: More stuff. --- www/index.html | 4 +-- www/js/api.js | 71 ++++++++++++++++++++++++++++++++++++---------------- www/js/characters.js | 4 +-- www/js/html5ks.js | 10 +++++--- www/js/menu.js | 62 +++++++++++++++++++++------------------------ 5 files changed, 88 insertions(+), 63 deletions(-) diff --git a/www/index.html b/www/index.html index 7d46027..f2f9dec 100644 --- a/www/index.html +++ b/www/index.html @@ -100,8 +100,8 @@
-
-
+
+
diff --git a/www/js/api.js b/www/js/api.js index 14b6a97..768face 100644 --- a/www/js/api.js +++ b/www/js/api.js @@ -98,8 +98,11 @@ window.html5ks.api = new (function () { src = "dump/video/" + vid_src + "."; this.stop("all"); - this.speed("auto", false); - this.speed("skip", false); + clearInterval(html5ks._nextTimeout); + + if (html5ks.state.skip) { + return deferred.resolve(); + } var types = { "webm": "webm", @@ -187,9 +190,11 @@ window.html5ks.api = new (function () { window: function (action, transition) { var windw = html5ks.elements.window; switch (action) { + case true: case "show": windw.style.display = "block"; break; + case false: case "hide": windw.style.display = "none"; break; @@ -437,21 +442,32 @@ window.html5ks.api = new (function () { ptxt(true); } else { ctc.style.display = "none"; - if (html5ks.state.auto) { - setTimeout(html5ks.next, 3.5 * html5ks.persistent.autoModeDelay); - } deferred.resolve(); } html5ks._next = _next; + html5ks.api._setNextTimeout(str, true); }; - if (html5ks.state.skip || str.indexOf("{nw}") > -1) { - html5ks._next(); - setTimeout(html5ks._next, 50); + if (html5ks.persistent.textSpeed === "200") { + ptxt(true); } + + this._setNextTimeout(str, false); + return deferred.promise; }, + _setNextTimeout: function (str, done) { + if (done) { + if (html5ks.state.auto) { + setTimeout(html5ks.next, 3.5 * html5ks.persistent.autoModeDelay); + } + } else if (html5ks.state.skip || str.indexOf("{nw}") > -1) { + html5ks._next(); + html5ks._nextTimeout = setTimeout(html5ks._next, 50); + } + }, + extend: function (str) { return this.say(this._lastchar, str, true); }, @@ -467,17 +483,21 @@ window.html5ks.api = new (function () { nvl: function (action, transition) { var nvl = html5ks.elements.nvl; switch (action) { - case "show": - nvl.style.display = "block"; - break; - case "hide": - nvl.style.display = "none"; - break; - case "clear": - html5ks.elements.nvlsay.innerHTML = ""; - break; - default: - console.error("no such nvl action " + action); + case "status": + return nvl.style.display === "block"; + case true: + case "show": + nvl.style.display = "block"; + break; + case false: + case "hide": + nvl.style.display = "none"; + break; + case "clear": + html5ks.elements.nvlsay.innerHTML = ""; + break; + default: + console.error("no such nvl action " + action); } return when.defer().resolve(); }, @@ -490,6 +510,8 @@ window.html5ks.api = new (function () { centered.innerHTML = ""; deferred.resolve(); }; + this._setNextTimeout(text, false); + this._setNextTimeout(text, true); return deferred.promise; }, @@ -518,7 +540,14 @@ window.html5ks.api = new (function () { }, speed: function (type, status) { - html5ks.state[type] = status; - document.getElementById(type).style.display = status ? "block" : "none"; + switch (type) { + case "all": + this.speed("skip", status); + this.speed("auto", status); + break; + default: + html5ks.state[type] = status; + document.getElementById(type).style.display = status ? "block" : "none"; + } } };})(); diff --git a/www/js/characters.js b/www/js/characters.js index df6209c..27687a0 100644 --- a/www/js/characters.js +++ b/www/js/characters.js @@ -60,7 +60,5 @@ window.html5ks.data.characters = { rinbabble: {name: null, kind: "nvl", what_prefix: "{color: #FF8D7C}{b}Rin{/b}{/color}\nā€œ", - what_suffix: "ā€"}, - - Iwanako: {name: "Iwanako"} + what_suffix: "ā€"} }; diff --git a/www/js/html5ks.js b/www/js/html5ks.js index 6cd6306..7f3d0f0 100644 --- a/www/js/html5ks.js +++ b/www/js/html5ks.js @@ -1,4 +1,8 @@ "use strict"; +console = console || { + log: function () {}, + error: alert +}; window.html5ks = { data: {}, persistent: {}, @@ -27,7 +31,7 @@ window.html5ks = { return v; }, set: function (value) { - v = value; + v = '' + value; localStorage.persistent = JSON.stringify(html5ks.persistent); }, enumerable: true @@ -140,10 +144,10 @@ window.html5ks = { window.onresize = html5ks.scale; this.elements.container.addEventListener("mouseup", function (e) { if (html5ks.state.status === "scene") { - html5ks.api.speed("skip", false); - html5ks.api.speed("auto", false); switch (e.button) { case 0: + html5ks.api.speed("skip", false); + html5ks.api.speed("auto", false); html5ks.next(); break; case 1: diff --git a/www/js/menu.js b/www/js/menu.js index eb878a5..c03523e 100644 --- a/www/js/menu.js +++ b/www/js/menu.js @@ -45,26 +45,6 @@ var target = e.target; html5ks.persistent[target.id] = target.type === "checkbox" ? target.checked : target.value; switch (target.id) { - case "fullscreen": - if (target.checked) { - html5ks.fullscreen(); - } else { - html5ks.fullscreen(false); - } - break; - case "scaleAll": - var scaleVideo = document.getElementById("scaleVideo"); - if (!target.checked) { - scaleVideo.checked = false; - scaleVideo.parentNode.className += " disabled"; - } else { - scaleVideo.checked = true; - scaleVideo.parentNode.className = scaleVideo.parentNode.className.replace("disabled", ""); - } - // fall-through - case "scaleVideo": - html5ks.scale(); - break; case "musicVolume": case "soundVolume": html5ks.api.set_volume(target.value, 0, target.id.replace("Volume", "")); @@ -121,21 +101,25 @@ case "scene": case "context": this.context(); + e.stopPropagation(); } e.preventDefault(); - }.bind(this), false); + }.bind(this), true); document.getElementById("context-return").addEventListener("click", function () { html5ks.menu.context(false); }, false); document.getElementById("show-image").addEventListener("click", function () { + var state = html5ks.menu._state; + html5ks.menu._state = {}; html5ks.menu.context(false); - html5ks.elements.window.style.display = "none"; - html5ks.elements.container.addEventListener("click", function click() { - this.removeEventListener("click", click, true); + var done = function () { + this.removeEventListener("click", done, true); + html5ks.menu._state = state; html5ks.menu.context(true); - }, true); + }; + html5ks.elements.container.addEventListener("click", done, true); }, false); document.getElementById("skip-mode").addEventListener("click", function () { @@ -194,28 +178,38 @@ }.bind(this)); }, - _hadWindow: null, + _state: null, context: function (show) { switch (show) { case true: - this._hadWindow = this._hadWindow !== null ? this._hadWindow : html5ks.api.window(); + // return early if context already on + if (this.context("status")) return; + this._state = this._state || { + window: html5ks.api.window(), + nvl: html5ks.api.nvl("status"), + status: html5ks.state.status + }; + html5ks.api.window("hide"); + html5ks.api.nvl("hide"); html5ks.state.status = "context"; html5ks.elements.gray.style.display = "block"; - html5ks.elements.window.style.display = "none"; this.elements.context.style.display = "block"; break; case false: - html5ks.state.status = "scene"; + this.elements.context.style.display = "none"; html5ks.elements.gray.style.display = "none"; - if (html5ks.state.status === "scene" && this._hadWindow) { - this._hadWindow = null; - html5ks.elements.window.style.display = "block"; + if (this._state) { + html5ks.api.window(this._state.window); + html5ks.api.nvl(this._state.nvl); + html5ks.state.status = this._state.status; + this._state = null; } - this.elements.context.style.display = "none"; break; + case "status": + return this.elements.context.style.display === "block"; default: - this.context(this.elements.context.style.display !== "block"); + this.context(!this.context("status")); } } }; -- cgit v1.2.3-70-g09d2