-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
26 lines (22 loc) · 1019 Bytes
/
Copy pathscript.js
File metadata and controls
26 lines (22 loc) · 1019 Bytes
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
document.addEventListener('DOMContentLoaded', () => {
const factsBtn = document.getElementById('toggle-facts');
const factsBox = document.getElementById('facts-box');
const themeBtn = document.getElementById('theme-toggle');
const body = document.body;
factsBtn.addEventListener('click', () => {
const shown = factsBox.style.display === 'block';
factsBox.style.display = shown ? 'none' : 'block';
factsBtn.textContent = shown ? 'Показать факты' : 'Скрыть факты';
});
const savedTheme = localStorage.getItem('theme') || 'light';
if (savedTheme === 'dark') {
body.classList.add('dark');
themeBtn.textContent = '☀️';
}
themeBtn.addEventListener('click', () => {
body.classList.toggle('dark');
const isDark = body.classList.contains('dark');
themeBtn.textContent = isDark ? '☀️' : '🌙';
localStorage.setItem('theme', isDark ? 'dark' : 'light');
});
});