-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathheader.js
More file actions
42 lines (38 loc) · 1.24 KB
/
header.js
File metadata and controls
42 lines (38 loc) · 1.24 KB
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
// Shared header component for Panel Attack website
function loadHeader() {
const headerHTML = `
<div class="header">
<div class="topnav" id="myTopnav">
<a class="logo" href="index.html"><img height="32" src="images/PanelAttackLogoWide.png" alt="Panel Attack"/></a>
<a href="about.html">About</a>
<a href="communities.html">Community</a>
<a href="help.html">Help</a>
<a href="credits.html">Credits</a>
<a href="javascript:void(0);" style="font-size:15px;" class="icon" onclick="myFunction()">☰</a>
</div>
</div>`;
// Insert header at the beginning of the body
document.body.insertAdjacentHTML('afterbegin', headerHTML);
}
// Mobile menu toggle function
function myFunction() {
var x = document.getElementById("myTopnav");
if (x.className === "topnav") {
x.className += " responsive";
} else {
x.className = "topnav";
}
}
// Character scroll function for about page
function scrollToCharacter(characterId) {
const element = document.getElementById(characterId);
if (element) {
element.scrollIntoView({
behavior: 'smooth',
block: 'start',
inline: 'nearest'
});
}
}
// Load header when DOM is ready
document.addEventListener('DOMContentLoaded', loadHeader);