blob: 89fa0fa057ee54a8bec12944045e64bba92b865e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
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].classList.add("active"); // Doesn't work with IE < 10 (and Opera Mini), but who cares?
else tabs[i].classList.remove("active");
}
}
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);
}
|