Repository navigation
Expand file tree
/
Copy pathmenu_mcrotk.js
More file actions
47 lines (40 loc) · 1.65 KB
/
Copy pathmenu_mcrotk.js
File metadata and controls
47 lines (40 loc) · 1.65 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
43
44
45
46
47
(function() {
function createMenuAndWrapContent() {
const menuHtml = `
<nav class="menu">
<a href="/index.html">Home</a>
<a href="/positions/positions.html">Positions and Education</a>
<a href="/publications.html">Publications</a>
<a href="/awards.html">Honors and Awards</a>
<a href="/talks.html">Talks</a>
<a href="/courses/courses_main.html">Teaching</a>
<a href="/prospectives.html">Working with me</a>
</nav>
`;
// Prepare DOM elements
const contentWrapper = document.createElement('div');
const menuElement = document.createElement('div');
const existingContentContainer = document.createElement('div');
// Set up menu
menuElement.innerHTML = menuHtml.trim();
// Move existing content
while (document.body.firstChild) {
existingContentContainer.appendChild(document.body.firstChild);
}
// Assemble new structure
contentWrapper.appendChild(menuElement);
contentWrapper.appendChild(existingContentContainer);
// Add classes
contentWrapper.className = 'content-wrapper';
menuElement.className = 'menu-container';
existingContentContainer.className = 'content-container';
// Add to DOM
document.body.appendChild(contentWrapper);
}
// Run the function when the DOM is ready
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', createMenuAndWrapContent);
} else {
createMenuAndWrapContent();
}
})();