-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
18 lines (17 loc) · 662 Bytes
/
app.js
File metadata and controls
18 lines (17 loc) · 662 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Set current year in footer automatically
document.addEventListener('DOMContentLoaded', function() {
var yearSpan = document.getElementById('current-year');
if (yearSpan) {
yearSpan.textContent = new Date().getFullYear();
}
});
// Set the documentElement, which then overwrites CSS variables
function toggleTheme() {
!document.documentElement.hasAttribute('theme') ?
document.documentElement.setAttribute('theme', 'alternate') :
document.documentElement.removeAttribute('theme')
}
window.addEventListener('load', () => {
const themeButton = document.querySelector('.themeToggle')
themeButton.addEventListener('click', toggleTheme)
})