-
Notifications
You must be signed in to change notification settings - Fork 2
/
setContent.js
44 lines (44 loc) · 1.64 KB
/
setContent.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
/* Content Management */
function AccessContent(){
var sections = document.getElementsByClassName('a42-component');
var menu = document.querySelectorAll('#menu li a');
var menuRef = new Array;
var inboard = document.getElementsByClassName('a42-inboard');
setSection(sections, menu);
document.getElementById('presentation').style.display = 'block';
menu[0].setAttribute('title',menu[0].lastChild.nodeValue+' section active');
menu[0].className = 'active';
for ( var i=0; i < menu.length; i++ ) {
menuRef[menu[i].getAttribute('href').substring(1)] = menu[i];
menu[i].addEventListener('click', function () {
setSection(sections, menu);
var target = this.getAttribute('href').substring(1);
this.className = 'active';
this.setAttribute('title',this.lastChild.nodeValue + ' section active');
document.getElementById(target).style.display = 'block';
document.getElementById(target).focus();
},
false);
}
for ( var i=0; i < inboard.length; i++ ) {
inboard[i].addEventListener('click', function () {
setSection(sections, menu);
var target = this.getAttribute('href').substring(1);
menuRef[target].className='active';
menuRef[target].setAttribute('title',menuRef[target].lastChild.nodeValue + ' section active');
document.getElementById(target).style.display = 'block';
document.getElementById(target).focus();
},
false);
}
}
/* utilities */
function setSection(sections, menu){
for ( var i=0; i < menu.length; i++ ) {
menu[i].removeAttribute('class');
menu[i].removeAttribute('title');
}
for ( var i=0; i < sections.length; i++ ) {
sections[i].style.display = 'none';
}
}