aboutsummaryrefslogtreecommitdiffstats
path: root/js/gui.js
diff options
context:
space:
mode:
authorpiernov <piernov@piernov.org>2016-04-25 22:36:33 +0200
committerpiernov <piernov@piernov.org>2016-04-25 22:36:33 +0200
commit54635d17eef27eb2546d69599e4107b242509ced (patch)
tree86d18cbb6e021b78ba1ce87307447d71d1802ad3 /js/gui.js
parentf98b06a25d71cc02bf29d7c525da0095688ea872 (diff)
parent8140617aeb2f32f7095a443ca743c6d6915739c6 (diff)
downloadcandybox-54635d17eef27eb2546d69599e4107b242509ced.tar.gz
candybox-54635d17eef27eb2546d69599e4107b242509ced.tar.bz2
candybox-54635d17eef27eb2546d69599e4107b242509ced.tar.xz
candybox-54635d17eef27eb2546d69599e4107b242509ced.zip
Merge branch 'alexichi' of ssh://piernov.org/srv/git/candybox into alexichi
Diffstat (limited to 'js/gui.js')
-rw-r--r--js/gui.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/js/gui.js b/js/gui.js
new file mode 100644
index 0000000..bdf1710
--- /dev/null
+++ b/js/gui.js
@@ -0,0 +1,42 @@
+var MESSAGE_TIMEOUT = 4000;
+
+function changeTab() {
+ var hashtype = window.location.hash.substr(1,3);
+ if(hashtype != "tab") return;
+ var id = window.location.hash.substr(4);
+ var tabs = document.querySelectorAll("#tabs-panel > ul > li");
+ for(var i=0; i < tabs.length; i++) {
+ if(i == id-1)
+ tabs[i].className = "active";
+ else
+ tabs[i].className = "";
+ }
+
+}
+
+function showMessage(type, msg) {
+ var msg_box = document.getElementById(type+"-box");
+ msg_box.style.display = "initial";
+ var msg_list = msg_box.firstElementChild.firstElementChild.firstElementChild;
+ msg_list.innerHTML = "<li>" + msg + "</li>\n" + msg_list.innerHTML;
+
+ window.setTimeout(hideMessage.bind(null, type), MESSAGE_TIMEOUT);
+}
+
+function hideMessage(type) {
+ var msg_box = document.getElementById(type+"-box");
+ var msg_list = msg_box.firstElementChild.firstElementChild.firstElementChild;
+ var item = msg_list.lastElementChild;
+ msg_list.removeChild(item);
+
+ if(msg_list.children.length <= 0)
+ msg_box.style.display = "none";
+}
+
+function showError(msg) {
+ showMessage("error", msg);
+}
+
+function showInfo(msg) {
+ showMessage("info", msg);
+}