summaryrefslogtreecommitdiff
path: root/www
diff options
context:
space:
mode:
authorAlex Xu <alex_y_xu@yahoo.ca>2013-09-29 10:12:59 -0400
committerAlex Xu <alex_y_xu@yahoo.ca>2013-09-29 10:13:29 -0400
commit693755517e6dff6cfeb9c67c5875d37a440f48eb (patch)
tree126857956cbd3c5c3cee58ad73e9e6a2f041c4fe /www
parentd10491524e0582d8d216d68d2b9f61028fd72f5e (diff)
downloadhtml5ks-693755517e6dff6cfeb9c67c5875d37a440f48eb.tar.xz
html5ks-693755517e6dff6cfeb9c67c5875d37a440f48eb.zip
misc js bugs
Diffstat (limited to 'www')
-rw-r--r--www/js/api.js127
-rw-r--r--www/js/html5ks.js2
-rw-r--r--www/js/menu.js5
3 files changed, 70 insertions, 64 deletions
diff --git a/www/js/api.js b/www/js/api.js
index 869b1cf..799d917 100644
--- a/www/js/api.js
+++ b/www/js/api.js
@@ -3,9 +3,52 @@ window.html5ks.api = {
init: function () {
var chars = html5ks.data.characters;
for (var ch in chars) {
- var char = chars[ch];
- if (char.name) {
- char.name = this.tag(char.name);
+ var chr = chars[ch];
+ if (chr.name) {
+ chr.name = this.tag(chr.name);
+ }
+ }
+ },
+
+
+ iscene: function (target, is_h, is_end) {
+ html5ks.state.status = "scene";
+ var deferred = when.defer(),
+ label = html5ks.data.script[html5ks.persistent.language + "_" + target],
+ i = 0;
+ if (target === "timeskip") {
+ deferred.resolve();
+ return deferred.promise;
+ }
+ (function run(ret) {
+ if (label[i]) {
+ html5ks.api.runInst(label[i]).then(run, console.error);
+ i++;
+ } else {
+ deferred.resolve(ret);
+ }
+ }());
+ return deferred.promise;
+ },
+
+
+ runInst: function (inst) {
+ var cmd = inst[0].replace(/"/g, ''),
+ args = inst.slice(1);
+ if (html5ks.data.characters[cmd]) {
+ return this.character(cmd, args[0]);
+ } else {
+ if (this[cmd]) {
+ return this[cmd].apply(this, args);
+ } else if (inst.length === 1) {
+ return this.character("name_only", cmd);
+ } else if (/^[A-Z]/.test(cmd)) {
+ return this.character(cmd, args[0]);
+ } else {
+ console.error("no such cmd " + cmd);
+ var deferred = when.defer();
+ deferred.resolve();
+ return deferred.promise;
}
}
},
@@ -154,45 +197,6 @@ window.html5ks.api = {
},
- iscene: function (target, is_h, is_end) {
- html5ks.state.status = "scene";
- var deferred = when.defer(),
- label = html5ks.data.script[html5ks.persistent.language + "_" + target],
- i = 0;
- (function run(ret) {
- if (label[i]) {
- html5ks.api.runInst(label[i]).then(run, console.error);
- i++;
- } else {
- deferred.resolve(ret);
- }
- }());
- return deferred.promise;
- },
-
-
- runInst: function (inst) {
- var cmd = inst[0].replace(/"/g, ''),
- args = inst.slice(1);
- if (html5ks.data.characters[cmd]) {
- return this.character(cmd, args[0]);
- } else {
- if (this[cmd]) {
- return this[cmd].apply(this, args);
- } else if (inst.length === 1) {
- return this.character("name_only", cmd);
- } else if (/^[A-Z]/.test(cmd)) {
- return this.character(cmd, args[0]);
- } else {
- console.error("no such cmd " + cmd);
- var deferred = when.defer();
- deferred.resolve();
- return deferred.promise;
- }
- }
- },
-
-
window: function (action, transition) {
var windw = html5ks.elements.window,
deferred = when.defer();
@@ -311,11 +315,11 @@ window.html5ks.api = {
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]);
+ show[i].style.display = "none";
+ deferred.resolve();
+ return deferred.promise;
}
}
- deferred.resolve();
- return deferred.promise;
},
tag: function (str) {
@@ -346,29 +350,29 @@ window.html5ks.api = {
character: function (charName, str, extend) {
var deferred = when.defer(),
text = this.tag(str),
- char = typeof charName === "string" ? html5ks.data.characters[charName] : charName,
+ chr = typeof charName === "string" ? html5ks.data.characters[charName] : charName,
w = /{w=?(\d*\.\d*)?}(.*)/.exec(str);
- if (!char) {
- char = {
+ if (!chr) {
+ chr = {
name: charName
};
}
- if (typeof char.what_prefix === "undefined") {
- char.what_prefix = "“";
- char.what_suffix = "”";
+ if (typeof chr.what_prefix === "undefined") {
+ chr.what_prefix = "“";
+ chr.what_suffix = "”";
}
- this._lastchar = char;
+ this._lastchar = chr;
- if (!extend && char.what_prefix) {
- text = char.what_prefix + text;
+ if (!extend && chr.what_prefix) {
+ text = chr.what_prefix + text;
}
- if ((!w || !w[1]) && char.what_suffix) {
- text = text + char.what_suffix;
+ if ((!w || !w[1]) && chr.what_suffix) {
+ text = text + chr.what_suffix;
}
- if (char.kind === "nvl") {
+ if (chr.kind === "nvl") {
html5ks.elements.nvlsay.innerHTML += "<span class='nvl-block'>" + text + "</span>";
html5ks.elements.nvlctc.style.display = "block";
html5ks.next = function () {
@@ -379,9 +383,9 @@ window.html5ks.api = {
} else {
var who = html5ks.elements.who;
if (!extend) {
- who.innerHTML = char.name;
- if (char.color) {
- who.style.color = char.color;
+ who.innerHTML = chr.name;
+ if (chr.color) {
+ who.style.color = chr.color;
} else {
who.style.color = "#ffffff";
}
@@ -468,7 +472,8 @@ window.html5ks.api = {
return deferred.promise;
},
- menu: function (choices) {
+ menu: function () {
+ var args = Array.prototype.slice.call(arguments, 0);
var deferred = when.defer();
var menu = html5ks.elements.choices,
frag = document.createDocumentFragment(),
diff --git a/www/js/html5ks.js b/www/js/html5ks.js
index c7aba9b..89b978d 100644
--- a/www/js/html5ks.js
+++ b/www/js/html5ks.js
@@ -57,7 +57,7 @@ window.html5ks = {
kenji: 0,
sc: 0,
hanako: 0
- },
+ }
},
state: {},
next: function () {},
diff --git a/www/js/menu.js b/www/js/menu.js
index 77ae7ee..f2fbacd 100644
--- a/www/js/menu.js
+++ b/www/js/menu.js
@@ -28,7 +28,7 @@
dialogs: document.getElementById("dialogs"),
dialog: {
options: document.getElementById("options"),
- return: document.getElementById("return")
+ retn: document.getElementById("retn")
},
mainMenu: document.getElementById("main-menu"),
main: {
@@ -62,6 +62,7 @@
scaleVideo.checked = true;
scaleVideo.parentNode.className = scaleVideo.parentNode.className.replace("disabled", "");
}
+ // fall-through
case "scaleVideo":
html5ks.scale();
break;
@@ -86,7 +87,7 @@
optionsButton[i].addEventListener("click", showOptions, false);
}
- this.elements.dialog.return.addEventListener("click", function (e) {
+ this.elements.dialog.retn.addEventListener("click", function (e) {
html5ks.menu.activeDialog.style.display = "none";
html5ks.menu.activeDialog = null;
html5ks.menu.elements.dialogs.style.display = "none";