-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathswitch.js
36 lines (36 loc) · 894 Bytes
/
switch.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
/**
* switch to a page
* @param {string} i - the page yoy want to switch to
* @example
* _switch('code')
*/
function _switch(i) {
// all the pages
var pages = [
'_index_',
'_instructions',
'_images',
'_code',
'_3d',
'_pcbs',
'_sch',
'_bom',
'_info',
];
// loop through and hide everything
for (let index = 0; index < pages.length; index++) {
const element = pages[index];
switch_visibility(element, false);
}
// enable the page
switch_visibility('_' + i, true);
}
/**
* switch the visibility of an element
* @param {string} i -tle element you want to switch
* @param {boolean} s - tun it on or off
*/
function switch_visibility(i, s) {
document.getElementById(i).style.display,
(document.getElementById(i).style.display = 1 == s ? 'block' : 'none');
}