-
Notifications
You must be signed in to change notification settings - Fork 3
/
masterDetail.js
85 lines (76 loc) · 2.54 KB
/
masterDetail.js
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
let originalTitle;
window.onresize = changeSeperatorState;
document.onmouseover = function () {
window.innerDocClick = true;
}
document.onmouseleave = function () {
window.innerDocClick = false;
}
window.onhashchange = function () {
if (!window.innerDocClick) {
var i, tablinks;
tablinks = document.getElementsByClassName('tab')[0].getElementsByTagName('button');
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
setCurrentPage(window.location.hash.substr(1));
}
}
function initMasterDetail() {
originalTitle = document.title;
document.getElementById('loader').style.display = "none";
document.getElementById('elements').style.display = "block";
if (window.location.hash) {
setCurrentPage(window.location.hash.substr(1));
} else {
document.getElementById("defaultOpen").click();
}
changeSeperatorState();
window.scrollTo(0, 0);
}
function openPage(evt, pageName) {
setCurrentPage(pageName);
let tablinks = document.getElementsByClassName('tab')[0].getElementsByTagName('button');
for (var i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
evt.currentTarget.className += " active";
document.title = evt.currentTarget.getAttribute('aria-label') + " - " + originalTitle;
}
function loadSearch() {
var input, filter, ul, li, i;
input = document.getElementsByClassName("searchbox")[0];
filter = input.value.toUpperCase();
ul = document.getElementById("tablinks");
li = ul.children;
for (i = 0; i < li.length; i++) {
if (li[i].innerHTML.toUpperCase().indexOf(filter) > -1) {
li[i].style.display = "";
}
else {
li[i].style.display = "none";
}
changeSeperatorState();
}
}
function changeSeperatorState() {
if (window.innerWidth <= 800) {
document.getElementById("Seperator").className = "horizontalSeperator";
}
else {
document.getElementById("Seperator").className = "verticalSeperator";
}
}
function setCurrentPage(pageName) {
let i;
let tabcontent = document.getElementsByTagName('article');
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
document.getElementById(pageName).style.display = "block";
window.location.hash = "#" + pageName;
}
function navigateToHash(hash) {
window.location.hash = '#' + hash;
window.location.reload();
}