forked from siwoolol/myheater
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
123 lines (105 loc) · 4.5 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Heater</title>
<link rel="icon" type="image/x-icon" href="/img/favicon.ico">
<link rel="stylesheet" href="css/stylesheet.css"/>
</head>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel="stylesheet">
<body style="margin: 0;">
<div class="heater-box">
<div class="who-alert"><p></p></div>
<div class="who"><p></p></div>
<img src="img/heater1.png" class="heater">
</div>
<h1></h1>
<div class="temp-box">
<p><b class="temp">30</b>°C</p>
</div>
<div class="heater-box">
<button class="plus" onclick="increaseTemp()">+</button>
<button class="minus" onclick="decreaseTemp()">-</button>
<script>
let currentTemp = 30; // Define the initial temperature
function increaseTemp() {
currentTemp++; // Increment the temperature
document.getElementsByClassName("temp")[0].innerHTML = currentTemp;
}
function decreaseTemp() {
if (currentTemp > 0) { // Check if temperature is above 0
currentTemp--;
}
document.getElementsByClassName("temp")[0].innerHTML = currentTemp;
}
</script>
<!-- sound button -->
<script>
function on() {
var audio = document.getElementById("audio");
audio.play();
var onbutton = document.getElementById(".brown-noise2");
onbutton.style.opacity = "20%";
var offbutton = document.getElementById(".brown-noise3");
offbutton.style.opacity = "100%";
}
function off() {
var audio = document.getElementById("audio");
audio.pause();
var offbutton = document.getElementById(".brown-noise3");
offbutton.style.opacity = "20%";
var onbutton = document.getElementById(".brown-noise2");
onbutton.style.opacity = "100%";
}
</script>
<button id=".brown-noise2" value="PLAY" onclick="on()">ON</button>
<button id=".brown-noise3" value="STOP" onclick="off()" style="opacity: 20%;">OFF</button>
<audio id="audio" src="brown-noise.ogg" autoplay loop></audio>
</div>
<div class="heater-box" style="margin-top: 20px;">
</div>
<div class="dialogs">
<dialog style="font-size: 11px;">
<p>+ button pressed count : <span class="plusCount">0</span></p>
<p>- button pressed count : <span class="minusCount">0</span></p>
<button class="close-dialog1" autofocus>Close</button>
</dialog>
<span class="show-dialog1">Stats</span>
<dialog style="font-size: 11px;">
<p>- Brown noise generator to focus and relax</p>
<p>- click on button to turn on heater</p>
<p>- Made by Github Rootpye</p>
<button class="close-dialog2" autofocus>Close</button>
</dialog>
<span class="show-dialog2">About</span>
</div>
<script>
const dialog = document.querySelectorAll("dialog");
const showButton1 = document.querySelector(".show-dialog1");
const showButton2 = document.querySelector(".show-dialog2");
const closeButton1 = document.querySelector(".close-dialog1");
const closeButton2 = document.querySelector(".close-dialog2");
// stats modal
showButton1.addEventListener("click", () => {
var plus = localStorage.getItem('+')
var minus = localStorage.getItem('-')
document.querySelector('.plusCount').innerHTML = plus || '0'
document.querySelector('.minusCount').innerHTML = minus || '0'
dialog[0].showModal();
});
closeButton1.addEventListener("click", () => {
dialog[0].close();
});
// about modal
showButton2.addEventListener("click", () => {
dialog[1].showModal();
});
closeButton2.addEventListener("click", () => {
dialog[1].close();
});
</script>
</body>
</html>