summaryrefslogtreecommitdiff
path: root/www/js
diff options
context:
space:
mode:
authorAlex Xu <alex_y_xu@yahoo.ca>2014-02-12 17:12:12 -0500
committerAlex Xu <alex_y_xu@yahoo.ca>2014-02-12 17:12:12 -0500
commit1f069412967c751d288cdf63508bb65ad367e3b1 (patch)
treeb8932de487154990b5b0483eaad2a5b9ab1f8ff2 /www/js
parentf7bcc14a493f3714c8a06df5111de8c2a901de61 (diff)
downloadhtml5ks-1f069412967c751d288cdf63508bb65ad367e3b1.tar.xz
html5ks-1f069412967c751d288cdf63508bb65ad367e3b1.zip
stuff
Diffstat (limited to 'www/js')
-rw-r--r--www/js/api.js7
-rw-r--r--www/js/html5ks.js3
-rw-r--r--www/js/menu.js398
3 files changed, 198 insertions, 210 deletions
diff --git a/www/js/api.js b/www/js/api.js
index 3c3864c..225cf38 100644
--- a/www/js/api.js
+++ b/www/js/api.js
@@ -455,7 +455,7 @@ window.html5ks.api = {
ptxt();
- html5ks._next = function _next() {
+ html5ks.next = function () {
if (!done) {
clearTimeout(tm);
ptxt(true);
@@ -463,7 +463,6 @@ window.html5ks.api = {
ctc.style.display = "none";
deferred.resolve();
}
- html5ks._next = _next;
html5ks.api._setNextTimeout(str, true);
};
@@ -482,8 +481,8 @@ window.html5ks.api = {
setTimeout(html5ks.next, str.length + 3.5 * html5ks.persistent.autoModeDelay);
}
} else if (html5ks.api.skip() || str.indexOf("{nw}") > -1) {
- html5ks._next();
- html5ks._nextTimeout = setTimeout(html5ks._next, 50);
+ html5ks.next();
+ html5ks._nextTimeout = setTimeout(html5ks.next, 50);
}
},
diff --git a/www/js/html5ks.js b/www/js/html5ks.js
index 6a7482f..1f52c52 100644
--- a/www/js/html5ks.js
+++ b/www/js/html5ks.js
@@ -117,9 +117,6 @@ window.html5ks = {
html5ks.api.speed("");
html5ks.next();
break;
- case 1:
- html5ks.menu.showImage();
- break;
}
}
}, false);
diff --git a/www/js/menu.js b/www/js/menu.js
index 7bbdd13..89eceef 100644
--- a/www/js/menu.js
+++ b/www/js/menu.js
@@ -1,218 +1,210 @@
-(function () {
- "use strict";
- html5ks.menu = {
- mainMenu: function () {
- html5ks._next = function () {};
- 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");
- this.elements.mainMenu.style.display = "block";
- html5ks.store.status = "menu";
- },
-
- activeDialog: null,
-
- dialog: function (name) {
- this.activeDialog = this.elements.dialog[name];
- this.activeDialog.style.display = "block";
- this.elements.dialogs.style.display = "block";
- this.elements.context.style.display = "none";
- html5ks.elements.gray.style.display = "block";
- },
-
- initElements: function () {
- this.elements = {
- dialogs: document.getElementById("dialogs"),
- dialog: {
- options: document.getElementById("options"),
- retn: document.getElementById("return")
- },
- mainMenu: document.getElementById("main-menu"),
- main: {
- start: document.getElementById("start")
- },
- context: document.getElementById("context"),
- contextMenu: document.getElementById("context-menu"),
- contextInfo: document.getElementById("context-info")
- };
- },
-
- initEvents: function () {
- var options = document.getElementsByClassName("option");
- var change = function (e) {
- var target = e.target;
- html5ks.persistent[target.id] = target.type === "checkbox" ? target.checked : target.value;
- switch (target.id) {
- case "musicVolume":
- case "soundVolume":
- html5ks.api.set_volume(target.value, 0, target.id.replace("Volume", ""));
- break;
- }
- };
+"use strict";
+html5ks.menu = {
+ mainMenu: function () {
+ html5ks._next = function () {};
+ 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");
+ this.elements.mainMenu.style.display = "block";
+ html5ks.store.status = "menu";
+ },
+
+ activeDialog: null,
+
+ dialog: function (name) {
+ this.activeDialog = this.elements.dialog[name];
+ this.activeDialog.style.display = "block";
+ this.elements.dialogs.style.display = "block";
+ this.elements.context.style.display = "none";
+ html5ks.elements.gray.style.display = "block";
+ },
+
+ initElements: function () {
+ this.elements = {
+ dialogs: document.getElementById("dialogs"),
+ dialog: {
+ options: document.getElementById("options"),
+ retn: document.getElementById("return")
+ },
+ mainMenu: document.getElementById("main-menu"),
+ main: {
+ start: document.getElementById("start")
+ },
+ context: document.getElementById("context"),
+ contextMenu: document.getElementById("context-menu"),
+ contextInfo: document.getElementById("context-info")
+ };
+ },
+
+ initEvents: function () {
+ var options = document.getElementsByClassName("option");
+ var change = function (e) {
+ var target = e.target;
+ html5ks.persistent[target.id] = target.type === "checkbox" ? target.checked : target.value;
+ switch (target.id) {
+ case "musicVolume":
+ case "soundVolume":
+ html5ks.api.set_volume(target.value, 0, target.id.replace("Volume", ""));
+ break;
+ }
+ };
- options[0].parentNode.parentNode.addEventListener("change", change, false);
- options[0].parentNode.parentNode.addEventListener("input", change, false);
+ options[0].parentNode.parentNode.addEventListener("change", change, false);
+ options[0].parentNode.parentNode.addEventListener("input", change, false);
- var optionsButton = document.getElementsByClassName("options-button");
+ var optionsButton = document.getElementsByClassName("options-button");
- var showOptions = function (e) {
- html5ks.menu.dialog("options");
- e.stopPropagation();
- };
+ var showOptions = function (e) {
+ html5ks.menu.dialog("options");
+ e.stopPropagation();
+ };
- for (var i = optionsButton.length - 1; i >= 0; i--) {
- optionsButton[i].addEventListener("click", showOptions, false);
- }
+ for (var i = optionsButton.length - 1; i >= 0; i--) {
+ optionsButton[i].addEventListener("click", showOptions, false);
+ }
- 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";
- if (html5ks.store.status === "context") {
- html5ks.menu.context(true);
- } else {
- html5ks.elements.gray.style.display = "none";
+ 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";
+ if (html5ks.store.status === "context") {
+ html5ks.menu.context(true);
+ } else {
+ html5ks.elements.gray.style.display = "none";
+ }
+ e.stopPropagation();
+ }, false);
+
+ // quit
+ var close = function () {
+ window.close();
+ top.open('','_self','');
+ top.close();
+ };
+ ["AppleWebKit", "MSIE", "Trident"].forEach(function (ua) {
+ if (navigator.userAgent.indexOf(ua) > -1) {
+ var quit = document.getElementsByClassName("quit");
+ for (var i = quit.length - 1; i >= 0; i--) {
+ quit[i].classList.remove("disabled");
+ quit[i].addEventListener("click", close, false);
}
+ return false;
+ }
+ }, this);
+
+ // context menu
+ html5ks.elements.container.addEventListener("contextmenu", function (e) {
+ switch (html5ks.store.status) {
+ case "scene":
+ case "context":
+ this.context();
+ e.stopPropagation();
+ }
+ e.preventDefault();
+ }.bind(this), true);
+
+ var contextButtonFactory = function (id, fn, nooff) {
+ document.getElementById(id).addEventListener("click", function (e) {
+ if (!nooff) html5ks.menu.context(false);
+ if (fn) fn(e);
e.stopPropagation();
}, false);
+ };
- // quit
- var close = function () {
- window.close();
- top.open('','_self','');
- top.close();
- };
- ["AppleWebKit", "MSIE", "Trident"].forEach(function (ua) {
- if (navigator.userAgent.indexOf(ua) > -1) {
- var quit = document.getElementsByClassName("quit");
- for (var i = quit.length - 1; i >= 0; i--) {
- quit[i].classList.remove("disabled");
- quit[i].addEventListener("click", close, false);
- }
- return false;
- }
- }, this);
-
- // context menu
- html5ks.elements.container.addEventListener("contextmenu", function (e) {
- switch (html5ks.store.status) {
- case "scene":
- case "context":
- this.context();
- e.stopPropagation();
- }
- e.preventDefault();
- }.bind(this), true);
-
- var contextButtonFactory = function (id, fn, nooff) {
- document.getElementById(id).addEventListener("click", function (e) {
- if (!nooff) html5ks.menu.context(false);
- if (fn) fn(e);
- }, false);
- };
+ contextButtonFactory("context-return");
- contextButtonFactory("context-return");
-
- contextButtonFactory("show-image", function () {
- html5ks.menu.context("showImage");
- var done = function () {
- this.removeEventListener("click", done, true);
- html5ks.menu.context(true);
- };
- html5ks.elements.container.addEventListener("click", done, true);
- }, true);
-
- contextButtonFactory("skip-mode", function () {
- html5ks.api.speed("skip");
- html5ks.next();
- });
-
- contextButtonFactory("auto-mode", function () {
- html5ks.api.speed("auto");
- html5ks.next();
- });
-
- contextButtonFactory("goto-main-menu", function () {
- html5ks.menu.mainMenu();
- });
- },
-
- initOptions: function () {
- var options = document.getElementsByClassName("option"),
- values = html5ks.persistent;
-
- for (var i = options.length - 1; i >= 0; i--) {
- var option = options[i];
- switch (option.type) {
- case "checkbox":
- option.checked = values[option.id];
- break;
- case "range":
- option.value = values[option.id];
- break;
- default:
- console.error("unknown option type %s", option.type);
- }
- }
- },
-
- init: function () {
- this.initElements();
- this.initEvents();
- this.initOptions();
-
- when.all([html5ks.fetch("json", "imachine"),
- html5ks.fetch("json", "script").then(function (d) {
- for (var k in d) {
- if (k.slice(0, 3) === (html5ks.persistent.language === "en" ? "fr_" : "en_")) {
- delete d[k];
- }
- }
- }, console.error)]).then(function () {
- var start = this.elements.main.start;
- start.addEventListener("click", function () {
- this.elements.mainMenu.style.display = "none";
- html5ks.imachine.start().then(this.mainMenu.bind(this), console.error);
- }.bind(this), false);
- start.classList.remove("disabled");
- }.bind(this), console.error);
- },
-
- _state: null,
-
- context: function (show) {
- switch (show) {
- case true:
- // return early if context already on
- if (this.context("status")) return;
- this._state = this._state || {
- window: html5ks.store.window,
- nvl: html5ks.store.nvl,
- status: html5ks.store.status
- };
- html5ks.api.window("hide");
- html5ks.api.nvl("hide");
- html5ks.store.status = "context";
- html5ks.elements.gray.style.display = "block";
- this.elements.context.style.display = "block";
+ contextButtonFactory("show-image", function () {
+ html5ks.menu.context("showImage");
+ var done = function (e) {
+ this.removeEventListener("click", done, true);
+ html5ks.menu.context(true);
+ e.stopPropagation();
+ };
+ html5ks.elements.container.addEventListener("click", done, true);
+ }, true);
+
+ /*
+ contextButtonFactory("skip-mode", function () {
+ html5ks.api.speed("skip");
+ html5ks.next();
+ });
+
+ contextButtonFactory("auto-mode", function () {
+ html5ks.api.speed("auto");
+ html5ks.next();
+ });
+ */
+
+ contextButtonFactory("goto-main-menu", function () {
+ html5ks.menu.mainMenu();
+ });
+ },
+
+ initOptions: function () {
+ var options = document.getElementsByClassName("option"),
+ values = html5ks.persistent;
+
+ for (var i = options.length - 1; i >= 0; i--) {
+ var option = options[i];
+ switch (option.type) {
+ case "checkbox":
+ option.checked = values[option.id];
break;
- case "showImage":
- this.elements.context.style.display = "none";
- html5ks.elements.gray.style.display = "none";
- /* falls through */
- case false:
- if (!this._state) return;
- html5ks.api.window(this._state.window);
- html5ks.api.nvl(this._state.nvl);
- html5ks.store.status = this._state.status;
+ case "range":
+ option.value = values[option.id];
break;
- case "status":
- return this.elements.context.style.display === "block";
default:
- this.context(!this.context("status"));
+ console.error("unknown option type %s", option.type);
}
}
- };
-}());
+ },
+
+ init: function () {
+ this.initElements();
+ this.initEvents();
+ this.initOptions();
+
+ when.all([html5ks.fetch("json", "imachine"),
+ html5ks.fetch("json", "script").then(function (d) {
+ for (var k in d) {
+ if (k.slice(0, 3) === (html5ks.persistent.language === "en" ? "fr_" : "en_")) {
+ delete d[k];
+ }
+ }
+ }, console.error)]).then(function () {
+ var start = this.elements.main.start;
+ start.addEventListener("click", function () {
+ this.elements.mainMenu.style.display = "none";
+ html5ks.imachine.start().then(this.mainMenu.bind(this), console.error);
+ }.bind(this), false);
+ start.classList.remove("disabled");
+ }.bind(this), console.error);
+ },
+
+ context: function (show) {
+ switch (show) {
+ case true:
+ html5ks.elements.window.style.display = "none";
+ html5ks.elements.nvl.style.display = "none";
+ html5ks.store.status = "context";
+ html5ks.elements.gray.style.display = "block";
+ this.elements.context.style.display = "block";
+ break;
+ case false:
+ html5ks.api.window(html5ks.store.window);
+ html5ks.api.nvl(html5ks.store.nvl);
+ html5ks.store.status = html5ks.store.status;
+ /* falls through */
+ case "showImage":
+ this.elements.context.style.display = "none";
+ html5ks.elements.gray.style.display = "none";
+ break;
+ case "status":
+ return this.elements.context.style.display === "block";
+ default:
+ this.context(!this.context("status"));
+ }
+ }
+};