-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0.html
332 lines (295 loc) · 13.5 KB
/
0.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.js"></script>
<style data-tag="reset-style-sheet">
html { line-height: 1.15;}body { margin: 0;}* { box-sizing: border-box; border-width: 0; border-style: solid;}p,li,ul,pre,div,h1,h2,h3,h4,h5,h6,figure,blockquote,figcaption { margin: 0; padding: 0;}button { background-color: transparent;}button,input,optgroup,select,textarea { font-family: inherit; font-size: 100%; line-height: 1.15; margin: 0;}button,select { text-transform: none;}button,[type="button"],[type="reset"],[type="submit"] { -webkit-appearance: button;}button::-moz-focus-inner,[type="button"]::-moz-focus-inner,[type="reset"]::-moz-focus-inner,[type="submit"]::-moz-focus-inner { border-style: none; padding: 0;}button:-moz-focus,[type="button"]:-moz-focus,[type="reset"]:-moz-focus,[type="submit"]:-moz-focus { outline: 1px dotted ButtonText;}a { color: inherit; text-decoration: inherit;}input { padding: 2px 4px;}img { display: block;}html { scroll-behavior: smooth }
</style>
<style data-tag="default-style-sheet">
html {
font-family: Inter;
font-size: 16px;
}
body {
font-weight: 400;
font-style:normal;
text-decoration: none;
text-transform: none;
letter-spacing: normal;
line-height: 1.15;
color: var(--dl-color-gray-black);
background-color: var(--dl-color-gray-white);
}
</style>
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap"
data-tag="font"
/>
<link rel="stylesheet" href="./style.css" />
<link rel="stylesheet" href="./1.css"/>
</head>
<body onload="getLocation()">
<div>
<link href="./component-1.css" rel="stylesheet" />
<div class="component-1-container">
<div class="component-1-container01">
<h1 id="Tittle" class="component-1-text">Day</h1>
</div>
<div class="component-1-container02">
<div class="component-1-container03">
<h1 class="component-1-text1">Hourly Wind</h1>
</div>
<canvas id="wchart" class="component-1-container04"></canvas>
<div id="dir" class="component-1-container05">
<button onclick="SwitchWind()" viewBox="0 0 877.7142857142857 1024" class="component-1-icon">
<path
d="M365.714 621.714l146.286-73.143-146.286-73.143v146.286zM585.143 284v309.714l-292.571 146.286v-309.714zM749.714 512c0-171.429-139.429-310.857-310.857-310.857s-310.857 139.429-310.857 310.857 139.429 310.857 310.857 310.857 310.857-139.429 310.857-310.857zM877.714 512c0 242.286-196.571 438.857-438.857 438.857s-438.857-196.571-438.857-438.857 196.571-438.857 438.857-438.857 438.857 196.571 438.857 438.857z"
></path>
</button>
</div>
</div>
<div class="component-1-container06">
<div class="component-1-container07">
<h1 class="component-1-text2">
<span>Hourly Temp</span>
<br />
</h1>
</div>
<canvas id="tchart" class="component-1-container08"></canvas>
</div>
<div class="component-1-container09">
<div class="component-1-container10">
<h1 class="component-1-text5">
<span>Per. %</span>
<br />
</h1>
</div>
<canvas id="pchart" class="component-1-container11"></canvas>
</div>
</div>
</div>
<script>
</script>
<script>
const days = ["Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday","Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday"];
let longitude = null;
let latitude = null;
let flink=null;
let forcast = null
let zoneID=null;
let RadarStation=null
let name=null;
let df=null;
let temp=null;
let winds=null;
let windd=null;
let per = null;
let dew = null;
let loc = null;
let hourTemp= null;
hour = null;
let txValues = new Array();
let tyValues = new Array();
let pxValues = new Array();
let pyValues = new Array();
let wxValues = new Array();
let wcValues = new Array();
let bool = null;
function getLocation(){
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(
(position) => {
latitude = position.coords.latitude;
longitude = position.coords.longitude;
console.log("Latitude:", latitude);
console.log("Longitude:", longitude);
// Use the latitude and longitude values in your code
getCords();
//L.map('mapid').setView(latlng, 6);
//return true;
},
(error) => {
console.error("Error getting geolocation:", error);
//return false;
}
);
} else {
console.error("Geolocation is not supported by this browser.");
//return false
}
}
function getCords(){
const url = 'https://api.weather.gov/points/'+latitude+','+longitude;
console.log(url);
const apiKey = 'YOUR_API_KEY';
fetch(url, {
headers: {
'User-Agent': 'Mozilla/5.0',
},
})
.then((response) => response.json())
.then((data) => {
flink= data.properties.forecast;
//zoneID=data.properties.gridId;
console.log(flink);
getForcast();
})
.catch((error) => {
console.error('Error:', error);
});
}
function getForcast(){
const url = flink
console.log(url);
//for(let i = 0; i<5; i++){
fetch(url, {
headers: {
'User-Agent': 'Mozilla/5.0',
},
})
.then((response) => response.json())
.then((data) => {
forcast = data.properties.periods.slice(0,40)
//let name = day;
df = data.properties.periods[1].shortForecast;
console.log(name);
console.log(df);
//console.log("hello world");
hourly();
//let xValues = data.properties.periods.slice(0, 23).temperature;
//console.log(data.properties.periods+"hello");
//let yValues = null;
})
.catch((error) => {
console.error('Error:', error);
});
}
//}
function hours(){
const url = flink+"/hourly"
//console.log(url);
for(let i = 0; i<24; i++){
fetch(url, {
headers: {
'User-Agent': 'Mozilla/5.0',
},
})
.then((response) => response.json())
.then((data) => {
const hour=new Date(data.properties.updated);
hour.setHours(hour.getHours()+i);
let day = days[hour.getDay()];
document.getElementById("Tittle").innerHTML = day;
if(hour.getHours()>12){
//document.getElementById("hour"+i).innerHTML = hour.getHours()-12+":00";
//document.getElementById("whour"+i).innerHTML = hour.getHours()-12+":00";
//document.getElementById("phour"+i).innerHTML = hour.getHours()-12+":00";
tyValues[i]=hour.getHours()-12;
}else{
//document.getElementById("hour"+i).innerHTML = hour.getHours()+":00";
//document.getElementById("whour"+i).innerHTML = hour.getHours()+":00";
//document.getElementById("phour"+i).innerHTML = hour.getHours()+":00";
tyValues[i]=hour.getHours();
}
});
}
}
function hourly(){
const url = flink+"/hourly"
console.log(url);
hours();
for(let i = 0; i<26; i++){
fetch(url, {
headers: {
'User-Agent': 'Mozilla/5.0',
},
})
.then((response) => response.json())
.then((data) => {
if(i>24){
drawCharts();
}else{
txValues[i]=data.properties.periods[i].temperature;
wind=data.properties.periods[i].windSpeed;
pxValues[i]=data.properties.periods[i].probabilityOfPrecipitation.value;
wxValues[i]=data.properties.periods[i].windSpeed.split(" ")[0];
wcValues[i]=tyValues[i]+ ":00 " +data.properties.periods[i].windDirection;
console.log(wcValues);
//document.getElementById("temp"+i).innerHTML = hourTemp+"°F";
//document.getElementById("wind"+i).innerHTML = wind;
//xValues[i]=hourTemp;
//console.log(hourTemp);
//console.log(xValues[i]);
//console.log(hour.getHours());
//console.log(yValues);
}
})
.catch((error) => {
console.error('Error:', error);
});
}
}
function drawCharts(){
console.log("chart renderd")
new Chart("tchart", {
type: "line",
data: {
labels: tyValues,
datasets: [{
fill: false,
lineTension: 0,
backgroundColor: "rgba(0,0,255,1.0)",
borderColor: "rgba(0,0,255,0.1)",
data: txValues
}]
},
options: {
legend: {display: false},
scales: {
yAxes: [{ticks: {min: txValues.sort(function(a,b){return a-b})[0]-5, max: txValues.sort(function(a, b){return b - a})[0]+5}}],
}
}
});
new Chart("pchart", {
type: "line",
data: {
labels: tyValues,
datasets: [{
fill: false,
lineTension: 0,
backgroundColor: "rgba(0,0,255,1.0)",
borderColor: "rgba(0,0,255,0.1)",
data: pxValues
}]
},
options: {
legend: {display: false},
scales: {
yAxes: [{ticks: {min:0, max: 100}}],
}
}
});
new Chart("wchart", {
type: "line",
data: {
labels: wcValues.slice(0,24),
datasets: [{
fill: false,
lineTension: 0,
backgroundColor: "rgba(0,0,255,1.0)",
borderColor: "rgba(0,0,255,0.1)",
//data: wxValues
data:wxValues.slice(0, 24)
}]
},
options: {
legend: {display: false},
scales: {
yAxes: [{ticks: {min:0, max: 25}}],
}
}
});
}
</script>
</body>
</html>