diff options
author | Alex Xu <alex_y_xu@yahoo.ca> | 2014-04-16 15:17:31 -0400 |
---|---|---|
committer | Alex Xu <alex_y_xu@yahoo.ca> | 2014-04-16 15:17:31 -0400 |
commit | e417662dce5cae2e95ef98ee38baa8f53a02b9d5 (patch) | |
tree | dce94fb8524dece7e3fcc677ec0cf908a6ec2a97 /www | |
parent | 6a50d79523cf215001cdd55c74c040bd410775df (diff) | |
download | html5ks-e417662dce5cae2e95ef98ee38baa8f53a02b9d5.tar.xz html5ks-e417662dce5cae2e95ef98ee38baa8f53a02b9d5.zip |
mbleh
Diffstat (limited to 'www')
-rw-r--r-- | www/css/index.css | 30 | ||||
-rw-r--r-- | www/js/api.js | 125 | ||||
-rw-r--r-- | www/js/html5ks.js | 26 | ||||
-rw-r--r-- | www/js/menu.js | 13 | ||||
-rw-r--r-- | www/warn.html | 21 | ||||
-rw-r--r-- | www/warned.html | 16 | ||||
-rw-r--r-- | www/warned.php | 2 |
7 files changed, 97 insertions, 136 deletions
diff --git a/www/css/index.css b/www/css/index.css index bc35230..9c8a62c 100644 --- a/www/css/index.css +++ b/www/css/index.css @@ -36,11 +36,6 @@ h2 { #interstitial { display: none; cursor: auto; -} -.no-js #interstitial { - display: block; -} -#warn { background-color: rgb(128, 128, 128); background-color: rgba(128, 128, 128, 0.8); border-radius: 10px 10px; @@ -53,18 +48,18 @@ h2 { width: 600px; z-index: 100; } -.no-js #warn li { display: none; } -.js #warn #js { display: none; } - #warn #ie { display: none; } -.video #warn #video { display: none; } -.audio #warn #audio { display: none; } - #warn #opus { display: none; } -.fontface #warn #fontface { display: none; } -.csstransforms #warn #csstransforms { display: none; } -#gotit { - text-align: center; +.js.video.audio.fontface.csstransforms #missing-features { + display: none; } -.no-js #gotit { +.no-js #features li:not(#js) { display: none; } +.js #js { display: none; } + #ie { display: none; } +.video #video { display: none; } +.audio #audio { display: none; } + #opus { display: none; } +.fontface #fontface { display: none; } +.csstransforms #csstransforms { display: none; } +.no-js #lets-go { display: none; } @@ -361,6 +356,7 @@ label { } .button:not(.disabled):hover { opacity: 1; + cursor: pointer; } input[type="checkbox"] { display: none; @@ -376,7 +372,7 @@ input[type="checkbox"] + span:before { height: 19px; width: 20px; content: ""; - background: white left bottom no-repeat; + background: left bottom no-repeat; } .no-webp input[type="checkbox"]:checked + span:before { background-image: url("../dump/ui/bt-cf-checked.png"); diff --git a/www/js/api.js b/www/js/api.js index 0043724..67c8320 100644 --- a/www/js/api.js +++ b/www/js/api.js @@ -12,25 +12,24 @@ window.html5ks.api = { _fading: {}, - set_volume: function (target, delay, channel) { + set_volume: function (target, fade, channel) { var audio = html5ks.elements.audio[channel], - step = (target - audio.volume) / (delay * 20); - if (!delay) { - audio.volume = target; - } else { - this._fading[channel] = setInterval(function () { - // clamp new volume 0-1 - audio.volume = Math.min(Math.max(audio.volume + step, 0), 1); - switch (audio.volume) { - case 0: - audio.pause(); - /* falls through */ - case 1: - clearInterval(this._fading[channel]); - delete this._fading[channel]; - } - }.bind(this), 50); - } + step = (target - audio.volume) / (fade * 20); + var nextVol = function () { + // clamp new volume 0-1 + audio.volume = Math.min(Math.max(audio.volume + step, 0), 1); + switch (audio.volume) { + case 0: + audio.pause(); + /* falls through */ + case 1: + clearInterval(this._fading[channel]); + delete this._fading[channel]; + return false; + } + return true; + }; + if (nextVol()) this._fading[channel] = setInterval(nextVol, 50); return when.resolve(); }, @@ -77,7 +76,8 @@ window.html5ks.api = { _nextType(); }, - play: function (channel, name, _, fade) { + play: function (cmd, args) { + var channel = cmd[1]; this.stop(channel); var deferred = when.defer(), audio = html5ks.elements.audio[channel]; @@ -85,13 +85,13 @@ window.html5ks.api = { audio.loop = true; } html5ks.elements.audio[channel] = audio; - html5ks.store[channel] = name; + html5ks.store[channel] = args.file; var src = "dump/", volume; switch (channel) { case "music": - var fname = html5ks.data.music[name]; + var fname = html5ks.data.music[args.file.replace(/ $/, '')]; src += "bgm/" + fname; volume = html5ks.persistent.musicVolume; document.getElementById("current-music-track").innerHTML = fname.replace(/_/g, " "); @@ -104,13 +104,13 @@ window.html5ks.api = { audio.addEventListener("playing", function playing() { audio.removeEventListener("playing", playing, false); - if (fade) { - html5ks.api.set_volume(volume, fade, channel); + if (args.fadein) { + html5ks.api.set_volume(volume, args.fadein, channel); } deferred.resolve(); }, false); - audio.volume = fade ? 0 : volume; + audio.volume = args.fadein ? 0 : volume; this._loadMedia(audio, src, [ ['audio/ogg; codecs="opus"', "opus"], ['audio/ogg; codecs="vorbis"', "ogg"], @@ -194,8 +194,8 @@ window.html5ks.api = { real_target = html5ks.persistent.language + "_" + target.replace(/"/g, ''), i = 0; html5ks.fetch('script', real_target).then(function run(l) { - if (l[i]) { - html5ks.api.runInst(l[i++]).then(run, console.error); + if (l[i++]) { + html5ks.api.runInst(l[i]).then(function(){run(l)}, console.error); } else { deferred.resolve(); } @@ -203,22 +203,28 @@ window.html5ks.api = { return deferred.promise; }, + _safeCall: function (n, f, args) { + if (f) return f.apply(this, args); + else { + console.error("no such function " + n); + debugger; + return when.resolve(); + } + }, + runInst: function (inst) { - var cmd = inst[0].replace(/"/g, ''), - args = inst.slice(1); - if (html5ks.data.characters[cmd]) { - return this.say(cmd, args[0]); - } else { - if (this[cmd]) { - return this[cmd].apply(this, args); - } else if (inst.length === 1) { - return this.say("name_only", cmd); - } else { - console.error("no such cmd " + cmd); - return when.resolve(); - } - } + var cmd = inst[0].replace(/"/g, ''); + return this._safeCall(cmd, this[cmd], inst.slice(1)); + }, + + UserStatement: function (line, parsed) { + var c = parsed[0][0]; + return this._safeCall(c, this[c], parsed); + }, + + With: function () { + return when.resolve(); }, @@ -240,9 +246,9 @@ window.html5ks.api = { }, - scene: function () { + Scene: function () { html5ks.elements.show.innerHTML = ""; - return this.show.apply(this, arguments); + return this.Show.apply(this, arguments); }, @@ -265,8 +271,11 @@ window.html5ks.api = { bgright: { xpos: 0.6, xanchor: 0.5, ypos: 1.0, yanchor: 1.0 } }, - show: function (name, type, location) { + Show: function (imspec) { var deferred = when.defer(); + var name = + console.log(imspec); + return when.resolve(); var lookup = document.getElementById(name), el = lookup || document.createElement("img"); if (!location && !lookup) location = "center"; @@ -406,31 +415,27 @@ window.html5ks.api = { }); }, - say: function (chrName, str, extend) { + Say: function (who, what, with_, extend) { var deferred = when.defer(), - chr = typeof chrName === "string" ? html5ks.data.characters[chrName] : chrName, - w = /{w=?(\d*\.\d*)?}(.*)/.exec(str); + chr = html5ks.data.characters[who], + w = /{w=?(\d*\.\d*)?}(.*)/.exec(what); if (!chr) { - chr = { - name: chrName - }; - } - if (typeof chr.what_prefix === "undefined") { - chr.what_prefix = "“"; - chr.what_suffix = "”"; + chr = { name: who }; } + chr.what_prefix = chr.what_prefix || "“"; + chr.what_suffix = chr.what_suffix || "“"; this._lastchar = chr; if (!extend && chr.what_prefix) { - str = chr.what_prefix + str; + what = chr.what_prefix + what; } if ((!w || !w[1]) && chr.what_suffix) { - str = str + chr.what_suffix; + what += chr.what_suffix; } - var text = this.dlgTag(str), + var text = this.dlgTag(what), say, ctc; if (chr.kind === "nvl") { @@ -478,14 +483,14 @@ window.html5ks.api = { ctc.style.display = "none"; deferred.resolve(); } - html5ks.api._setNextTimeout(str, true); + html5ks.api._setNextTimeout(what, true); }; if (html5ks.persistent.textSpeed == 200) { ptxt(true); } - this._setNextTimeout(str, false); + this._setNextTimeout(what, false); return deferred.promise; }, @@ -501,10 +506,6 @@ window.html5ks.api = { } }, - extend: function (str) { - return this.say(this._lastchar, str, true); - }, - Pause: function (duration) { var deferred = when.defer(); setTimeout(function () { diff --git a/www/js/html5ks.js b/www/js/html5ks.js index 13bd198..4113c1d 100644 --- a/www/js/html5ks.js +++ b/www/js/html5ks.js @@ -143,7 +143,7 @@ window.html5ks = { }, initEvents: function () { window.onresize = html5ks.scale; - this.elements.container.addEventListener("mouseup", function (e) { + this.elements.container.addEventListener("click", function (e) { if (html5ks.store.status === "scene") { switch (e.button) { case 0: @@ -157,39 +157,33 @@ window.html5ks = { e.preventDefault(); }, false); }, - warnUnsupported: function () { + warn: function () { if (!html5ks.persistent.gotit) { var interstitial = document.getElementById("interstitial"); - document.getElementById("gotit").addEventListener("mouseup", function () { - interstitial.style.mozAnimation = "1s dissolveout"; - interstitial.style.webkitAnimation = "1s dissolveout"; - interstitial.style.animation = "1s dissolveout"; - interstitial.style.opacity = 0; + interstitial.style.display = "block"; + document.getElementById("lets-go").addEventListener("click", function () { + interstitial.style.display = "none"; html5ks.persistent.gotit = true; html5ks.start(); }, false); - var warns = document.getElementById("warns").children; + var features = document.getElementById("features").children; if (/MSIE/.test(navigator.userAgent)) { document.getElementById("ie").style.display = "block"; + document.getElementById("missing-features").style.display = "block"; } if (!Modernizr.audio.opus) { document.getElementById("opus").style.display = "block"; - } - for (var i = 0; i < warns.length; i++) { - var warn = warns[i]; - if (window.getComputedStyle(warns[i]).getPropertyValue("display") !== "none") { - warn.style.display = "block"; - return true; - } + document.getElementById("missing-features").style.display = "block"; } } + return !html5ks.persistent.gotit; }, onload: function () { FastClick.attach(document.body); this.initElements(); this.scale(); this.initEvents(); - if (!this.warnUnsupported()) { + if (!this.warn()) { this.start(); } this.i18n.init(); diff --git a/www/js/menu.js b/www/js/menu.js index 93616db..5b646b9 100644 --- a/www/js/menu.js +++ b/www/js/menu.js @@ -5,8 +5,8 @@ html5ks.menu = { this.context(false); html5ks.api.stop("all"); html5ks.api.window("hide"); - html5ks.api.play("music", "music_menus"); - html5ks.api.show("url", "ui/main/bg-main.png"); + html5ks.api.play(['', "music"], {file: "music_menus", fadein: 5}); + html5ks.api.Show("url", "ui/main/bg-main.png"); this.elements.mainMenu.style.display = "block"; html5ks.store.status = "menu"; }, @@ -161,6 +161,15 @@ html5ks.menu = { console.error("unknown option type %s", option.type); } } + + document.getElementById("clear-persistent").addEventListener("click", function () { + if (delete localStorage.persistent) { + alert("clear succeeded, refreshing..."); + location.reload(); + } else { + alert("clear failed"); + } + }, false); }, init: function () { diff --git a/www/warn.html b/www/warn.html deleted file mode 100644 index d3ece15..0000000 --- a/www/warn.html +++ /dev/null @@ -1,21 +0,0 @@ -<!DOCTYPE html> -<html> - <head> - <title>Katawa Shoujo - Disclaimer</title> - </head> - <body> - <p>Okay, before we start, we need to go through a few things first.</p> - <p>If you don't know what Katawa Shoujo is, see <a href="http://www.katawa-shoujo.com/">http://www.katawa-shoujo.com/</a>, then come back.</p> - <p>There's like, a little bit of... inappropriate content, so we have to make you promise you're over 18.</p> - <p>If you don't want to see any, er, explicit content, hit the appropriate checkbox at the bottom of the page.</p> - <p>Also, please don't bother the original developers on the forums or IRC about bugs in this. This is entirely unofficial and not controlled by them whatsoever.<br> - This includes missing features, typos, downtime, and any other glitches of any sort. Bug me instead: <a href="https://bugzilla.happinessforme.com/">https://bugzilla.happinessforme.com/</a>, or use the official distribution until HTML5KS is feature-complete. - </p> - <p>FYI, this site sets a single anonymous cookie (warned=1) so that you won't have to keep seeing this page. It also sets localStorage to keep your settings and saves. The latter always stays on your computer and never goes anywhere. If you live in the EU, please don't sue me.</p> - <form method="GET" action="warned.php"> - <p><input type="checkbox" name="hdisable" id="hdisable"><label for="hdisable">Disable adult content</label> - <br> - <input type="submit" value="Let's go!"> - </form> - </body> -</html> diff --git a/www/warned.html b/www/warned.html deleted file mode 100644 index 3cc0a91..0000000 --- a/www/warned.html +++ /dev/null @@ -1,16 +0,0 @@ -<!DOCTYPE html> -<html><head><script> -document.cookie = "warned=1; Expires=Tue, 19 Jan 2038 00:00:00 GMT; HttpOnly"; -var l = /language=[^&]*/.exec(location.search)[0].replace(/[ \t]/g, '').split(","); -loop: for (var i = 0; i < l.length; i++) { - switch (l[i].split(';')[0]) { - case "en": var lang = "en"; break loop; - case "fr": var lang = "fr"; break loop; - } -} -localStorage.persistent = { - hdisable: location.search.indexOf("hdisable=on") > -1, - language: lang || "en" -}; -location.replace("./"); -</script></head><body>If you're seeing this, something's gone wrong. Go back and try again, and if it still doesn't work, file a bug.</body></html> diff --git a/www/warned.php b/www/warned.php deleted file mode 100644 index 04c300b..0000000 --- a/www/warned.php +++ /dev/null @@ -1,2 +0,0 @@ -<?php -header("Location: /warned.html?".$_SERVER['QUERY_STRING']."&language=".$_SERVER['HTTP_ACCEPT_LANGUAGE']); |