-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
33 lines (30 loc) · 1.01 KB
/
app.js
File metadata and controls
33 lines (30 loc) · 1.01 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
const piElement = document.getElementById("pi");
const fontSizeInput = document.getElementById("fontSize");
const groupsInput = document.getElementById("groups");
function generatePiDigits() {
const digits = [];
for (let i = 0; i < Math.floor(Math.random() * 10) + 3; i++) {
digits.push(i % 10);
}
piElement.innerHTML = digits.join("");
}
generatePiDigits();
function changeFontSize() {
const fontSize = parseInt(fontSizeInput.value);
document.body.style.fontSize = `${fontSize}px`;
}
function toggleTheme() {
const darkMode = document.getElementById("darkMode");
const body = document.querySelector("body");
if (darkMode.checked) {
body.style.backgroundColor = "#212121";
piElement.style.color = "white";
groupsInput.style.backgroundColor = "#333";
fontSizeInput.style.backgroundColor = "#333";
} else {
body.style.backgroundColor = "white";
piElement.style.color = "black";
groupsInput.style.backgroundColor = "white";
fontSizeInput.style.backgroundColor = "white";
}
}