This repository has been archived by the owner on Jan 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.js
50 lines (44 loc) · 1.51 KB
/
main.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
// Toggles between adding and removing the "responsive" class to topnav when the
// user clicks on the icon.
function navbarResize() {
var x = document.getElementById("myTopnav");
if (x.className === "topnav") {
x.className += " responsive";
} else {
x.className = "topnav";
}
}
function setActive(activeID) {
var menu_item = document.getElementById( activeID );
menu_item.className += ' active';
}
// Resizes the height of the div with id="main" of the page to fill in the whole
// page, except the navbar and header.
function mainDivResize(activeID) {
if (activeID != null) {
setActive(activeID);
}
const body = document.body;
const html = document.documentElement;
const height = Math.max(
body.scrollHeight, body.offsetHeight, html.clientHeight,
html.scrollHeight, html.offsetHeight);
const navbarHeight =
document.getElementById('myTopnav').getBoundingClientRect().height;
document.getElementById('main').style.height =
String(height - navbarHeight) + 'px';
}
// Resizes the header when the user scroll, so that it does not take up that
// much space.
function scrollCallback(event, bannerID) {
if (event.target.scrollTop < 40) {
document.getElementById(bannerID).style.height = '50px';
}
else if (event.target.scrollTop<190) {
document.getElementById(bannerID).style.height = String(
240-event.target.scrollTop) + 'px';
}
else if (event.target.scrollTop>=190) {
document.getElementById(bannerID).style.height = '50px';
}
}