-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculatorScript.js
More file actions
28 lines (25 loc) · 845 Bytes
/
calculatorScript.js
File metadata and controls
28 lines (25 loc) · 845 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
27
28
let lightTheme = "light.css";
let darkTheme = "dark.css";
// Clears the screen when the user clicks the "c" button
function clearScreen() {
document.getElementById("result").value = "";
}
// Displays the entered value on the screen when user clicks on button
function liveScreen(value) {
let res = document.getElementById("result");
if (res.value == "undefined") {
res.value = "";
} res.value += value;
}
// Swaps the style sheet to either dark mode or light mode
function changeTheme() {
let darkMode = document.getElementById("dark-mode");
let theme = document.getElementById("theme");
if (theme.getAttribute("href") == lightTheme) {
theme.href = darkTheme;
darkMode.innerHTML = "Light Mode";
} else {
theme.href = lightTheme;
darkMode.innerHTML = "Dark Mode";
}
}