-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtime.html
111 lines (92 loc) · 2.58 KB
/
time.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title> </title>
<style>
body {
color: #000000;
background-color: #ffffff;
}
.page {
position: fixed;
width: 100%;
height: 100%;
}
.time_container,
.date_container {
width: 100%;
margin: auto;
text-align: center;
}
.time_container {
top: 0;
height: 55%;
}
.date_container {
}
.weather_container {
}
.time {
padding-top: 120px;
font-size: 16rem;
}
.date {
padding-top: 40px;
font-size: 6rem;
}
</style>
</head>
<body>
<div class="page">
<div class="time_container">
<div class="time" id="time">11:27</div>
</div>
<div class="weather_container">
<div id="weaTemp"></div>
</div>
<div class="date_container">
<div class="date" id="date">01/10/2020</div>
<div class="date" id="week">MONDAY</div>
</div>
</div>
<script>
function update() {
var date = new Date()
var utc8DiffMinutes = date.getTimezoneOffset() - 240
date.setMinutes(date.getMinutes() + utc8DiffMinutes)
var timeString = date.getHours() + ':' + ('0' + date.getMinutes()).slice(-2)
var dateString = '0'+(date.getMonth() + 1) + '/' + date.getDate() + '/' + date.getFullYear()
var weekList = [ 'MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'SATURDAY','SUNDAY']
var weekString = weekList[date.getDay()-1]
document.getElementById("time").innerHTML = timeString
document.getElementById("date").innerHTML = dateString
document.getElementById("week").innerHTML = weekString
}
update()
setInterval("update()", 60 * 1000)
getWeather()
function getWea() {
var xhr = createXHR();
xhr.open(
"GET",
"https://tianqiapi.com/free/day?appid=48373524&appsecret=5iHwLsS8",
true
);
xhr.onreadystatechange = function () {
if (this.readyState == 4) {
var weaTemp =
'<div class="tempNum">' +
data.tem +
'<div class="symbol">℃</div>
</div>' ;
document.getElementById("weaTemp").innerHTML = weaTemp;
}
};
xhr.send(null);
}
getWea();
setInterval("getWea()", 60 * 1000 );
</script>
</body>
</html>