-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
61 lines (58 loc) · 2.14 KB
/
index.html
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
51
52
53
54
55
56
57
58
59
60
61
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Dillon Harindiran</title>
<link rel="stylesheet" href="styles.css">
<link rel="icon" href="favicon.png" type="image/png"> <!-- Favicon Link -->
</head>
<body>
<div class="content">
<!-- Tile container for text -->
<div class="tile">
<pre id="textDisplay"></pre>
</div>
</div>
<!-- Dark mode toggle -->
<div class="toggle-container">
<label class="switch">
<input type="checkbox" id="darkModeToggle">
<span class="slider"></span>
</label>
</div>
<script>
// Fetch and display the text content
fetch('index.txt')
.then(response => response.text())
.then(text => document.getElementById('textDisplay').textContent = text)
.catch(() => document.getElementById('textDisplay').textContent = "Failed to load content.");
// Dark mode toggle functionality
const toggle = document.getElementById('darkModeToggle');
const html = document.documentElement;
// Check and apply saved user preference or set default to dark mode
const savedMode = localStorage.getItem('darkMode');
if (savedMode === 'enabled' || savedMode === null) {
html.classList.add('dark-mode');
toggle.checked = true;
if (savedMode === null) {
localStorage.setItem('darkMode', 'enabled'); // Save default as dark mode
}
} else {
html.classList.remove('dark-mode');
toggle.checked = false;
}
// Listen for toggle change
toggle.addEventListener('change', () => {
if (toggle.checked) {
html.classList.add('dark-mode');
localStorage.setItem('darkMode', 'enabled');
} else {
html.classList.remove('dark-mode');
localStorage.setItem('darkMode', 'disabled');
}
});
</script>
</body>
</html>