forked from SLO-AI/website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
treeview.js
29 lines (27 loc) · 928 Bytes
/
treeview.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
/*
* initTreeview adds an eventlistner to elements of class
* caret. The evenlistner toggles the visibility of
* an element in the parent of class nested
*/
function initTreeview()
{
var toggler = document.getElementsByClassName("caret");
var i;
for (i = 0; i < toggler.length; i++) {
toggler[i].addEventListener("click", function() {
this.parentElement.querySelector(".nested").classList.toggle("active");
this.classList.toggle("caret-down");
});
}
}
/*
* addPathLead adds a path in leading to this website to the path to a page
* present in this website.
*/
function addPathLead(elemid="path_lead")
{
// change the path_lead variable to your needs
const path_lead='<a href="https://www.johnval.nl" target="_parent">John Val</a>/<a href="../../informatica/index.htm" target="_parent">Informatica</a>/';
let obj = document.getElementById(elemid);
if(obj) obj.innerHTML = path_lead+obj.innerHTML;
}