-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
80 lines (72 loc) · 2.16 KB
/
index.html
File metadata and controls
80 lines (72 loc) · 2.16 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
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
<!DOCTYPE html>
<html lang="tr">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Sıcaklık Takibi</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
padding: 50px;
background: #f3f3f3;
}
#temp {
font-size: 3em;
margin-bottom: 10px;
}
#time {
font-size: 1em;
color: #555;
margin-bottom: 30px;
}
.bar-container {
width: 50px;
height: 300px;
background: #ccc;
margin: auto;
border-radius: 5px;
overflow: hidden;
position: relative;
}
.bar {
width: 100%;
position: absolute;
bottom: 0;
background: red;
height: 0;
transition: height 0.5s;
}
</style>
</head>
<body>
<h1>Ortam Sıcaklığı</h1>
<div id="temp">Yükleniyor...</div>
<div id="time"></div>
<div class="bar-container">
<div class="bar" id="bar"></div>
</div>
<script>
async function fetchTemperature() {
try {
const originalUrl = "https://script.google.com/macros/s/AKfycbyHup5Xolp6ojJYc9lRjTz7S1d5ezFh2J2B_u82X-sSGwqCxZb8fab1CZVmkYCkSDWpYQ/exec?nocache=" + new Date().getTime();
const proxyUrl = "https://api.allorigins.win/raw?url=" + encodeURIComponent(originalUrl);
const response = await fetch(proxyUrl);
const data = await response.json();
const temp = parseFloat(data.temperature);
const time = new Date(data.timestamp).toLocaleString('tr-TR');
document.getElementById("temp").innerText = temp.toFixed(1) + " °C";
document.getElementById("time").innerText = "Son güncelleme: " + time;
const heightPercent = Math.min(100, (temp / 50) * 100);
document.getElementById("bar").style.height = heightPercent + "%";
} catch (error) {
document.getElementById("temp").innerText = "Veri alınamadı";
document.getElementById("time").innerText = "-";
console.error("Veri çekme hatası:", error);
}
}
fetchTemperature();
setInterval(fetchTemperature, 5000);
</script>
</body>
</html>