-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrisbane.js
More file actions
595 lines (494 loc) · 17 KB
/
Copy pathbrisbane.js
File metadata and controls
595 lines (494 loc) · 17 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
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
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
import init, { /*get_weather_name, get_url,*/ call_prog, show_line_ticks } from './pkg/hot_or_not_3.js';
await init();
import * as root from './pkg/hot_or_not_3.js'
window.callbacks = root;
console.log("test");
console.log(window.callbacks);
window.mutate_chart_object = function (v) {
if (v.id == ("bar")) {
v.options.scales.y1.ticks = {
callback:
function (value, _index, _values) {
return '$' + value.toFixed(2);
}
};
}
return v
};
function cityText(city) {
let parent = document.querySelector('#content2');
switch (city) {
case 0:
parent.textContent = "Melbourne";
break;
case 1:
parent.textContent = "Adelaide";
break;
case 2:
parent.textContent = "Sydney";
break;
case 3:
parent.textContent = "Brisbane";
break;
}
}
let miner = 999;
let maxer = -999;
async function getAverages() {
const baseURL = window.location.origin;
const requestURL = baseURL + "/Jeather2/averages.json";
// For local hosting:
// const requestURL = "http://127.0.0.1:5500/averages.json";
const request = new Request(requestURL);
const response = await fetch(request);
let averagesJSON = await response.json();
return averagesJSON;
}
let averages = await getAverages();
let quotes = [
"If you’re offered a seat on a rocket ship, don’t ask what seat! Just get on. Sheryl Sandberg"
,
"First, have a definite, clear practical ideal; a goal, an objective. Second, have the necessary means to achieve your ends; wisdom, money, materials, and methods. Third, adjust all your means to that end. Aristotle"
,
"If the wind will not serve, take to the oars. Latin Proverb"
,
"You can’t fall if you don’t climb. But there’s no joy in living your whole life on the ground. Unknown"
,
"We must believe that we are gifted for something, and that this thing, at whatever cost, must be attained. Marie Curie"
,
"Too many of us are not living our dreams because we are living our fears. Les Brown"
,
"Challenges are what make life interesting and overcoming them is what makes life meaningful. Joshua J. Marine"
,
"If you want to lift yourself up, lift up someone else. Booker T. Washington"
,
"I have been impressed with the urgency of doing. Knowing is not enough; we must apply. Being willing is not enough; we must do. Leonardo da Vinci"
,
"Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless. Jamie Paolinetti"
,
"You take your life in your own hands, and what happens? A terrible thing, no one to blame. Erica Jong"
,
"What’s money? A man is a success if he gets up in the morning and goes to bed at night and in between does what he wants to do. Bob Dylan"
,
"I didn’t fail the test. I just found 100 ways to do it wrong. Benjamin Franklin"
,
"In order to succeed, your desire for success should be greater than your fear of failure. Bill Cosby"
,
"A person who never made a mistake never tried anything new. Albert Einstein"
,
"The person who says it cannot be done should not interrupt the person who is doing it. Chinese Proverb"
,
"There are no traffic jams along the extra mile. Roger Staubach"
,
"It is never too late to be what you might have been. George Eliot"
,
"You become what you believe. Oprah Winfrey"
,
"I would rather die of passion than of boredom. Vincent van Gogh"
,
"A truly rich man is one whose children run into his arms when his hands are empty. Unknown"
,
"It is not what you do for your children, but what you have taught them to do for themselves, that will make them successful human beings. Ann Landers"
,
"If you want your children to turn out well, spend twice as much time with them, and half as much money. Abigail Van Buren"
,
"Build your own dreams, or someone else will hire you to build theirs. Farrah Gray"
,
"The battles that count aren’t the ones for gold medals. The struggles within yourself–the invisible battles inside all of us–that’s where it’s at. Jesse Owens"
,
"Education costs money. But then so does ignorance. Sir Claus Moser"
,
"I have learned over the years that when one’s mind is made up, this diminishes fear. Rosa Parks"
,
"It does not matter how slowly you go as long as you do not stop. Confucius"
,
"If you look at what you have in life, you’ll always have more. If you look at what you don’t have in life, you’ll never have enough. Oprah Winfrey"
,
"Remember that not getting what you want is sometimes a wonderful stroke of luck. Dalai Lama"
,
"You can’t use up creativity. The more you use, the more you have. Maya Angelou"
,
"Dream big and dare to fail. Norman Vaughan"
,
"Our lives begin to end the day we become silent about things that matter. Martin Luther King Jr."
,
"Do what you can, where you are, with what you have. Teddy Roosevelt"
,
"If you do what you’ve always done, you’ll get what you’ve always gotten. Tony Robbins"
,
"Dreaming, after all, is a form of planning. Gloria Steinem"
,
"It’s your place in the world; it’s your life. Go on and do all you can with it, and make it the life you want to live. Mae Jemison"
,
"You may be disappointed if you fail, but you are doomed if you don’t try. Beverly Sills"
,
"Remember no one can make you feel inferior without your consent. Eleanor Roosevelt"
,
"Life is what we make it, always has been, always will be. Grandma Moses"
,
"The question isn’t who is going to let me; it’s who is going to stop me. Ayn Rand"
,
"When everything seems to be going against you, remember that the airplane takes off against the wind, not with it. Henry Ford"
,
"It’s not the years in your life that count. It’s the life in your years. Abraham Lincoln"
,
"Change your thoughts and you change your world. Norman Vincent Peale"
,
"Either write something worth reading or do something worth writing. Benjamin Franklin"
,
"Nothing is impossible, the word itself says, “I’m possible!” –Audrey Hepburn"
,
"The only way to do great work is to love what you do. Steve Jobs"
,
"If you can dream it, you can achieve it. Zig Ziglar"
];
function randomQuote() {
let parent2 = document.getElementById('bot-box');
let randomInt = Math.floor(Math.random() * 47);
let actual = document.createElement('p');
actual.id = 'quote';
actual.textContent = quotes[randomInt];
parent2.appendChild(actual);
}
async function run(city) {
await init();
randomQuote();
let a = await call_prog();
//test("https://reg.bom.gov.au/fwo/IDV60901/IDV60901.95936.json");
const url = "https://api.weather.bom.gov.au/v1/locations/r7hgdm/forecasts/hourly";
const urls = [
"https://api.weather.bom.gov.au/v1/locations/r7hgdm/forecasts/hourly",
"https://api.weather.bom.gov.au/v1/locations/r7hgdm/forecasts/hourly",
"http://www.bom.gov.au/fwo/IDV60901/IDV60901.94854.json"
];
const url2 = "https://api.weather.bom.gov.au/v1/locations/r7hgdm/forecasts/hourly";
const headers = {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'POST,PATCH,OPTIONS'
}
const response = {
statusCode: 200,
headers: headers,
body: JSON.stringify(urls[city]),
};
const responses = {
statusCode: 200,
headers: headers,
body: JSON.stringify(url2),
};
const xValues = [];
const yValues = [];
await fetch(String(urls[0]))
.then((response) => response.json())
.then((observations) => {
let ci = observations.data[0].temp;
let ci2 = observations.data[0].temp_feels_like;
let parent = document.querySelector('#content2');
const barColors = ["red", "green", "blue", "orange", "brown"];
for (let i = 0; i < 1; i++) {
let ci = observations.data[i].temp;
let p = document.createElement('p');
let timer = new Date();
let realtimer = new Date(observations.data[i].time);
let now = new Date();
let currentTime = realtimer.toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit', second: '2-digit' });
let nozero = realtimer.getHours().toString();
let nonzero = nozero.replace(/^0+/, '');
let formatTime = nozero;
let date = new Date();
let dateform = date.toLocaleDateString();
switch (nozero.toString()) {
case "0": formatTime = dateform;
break;
case "1": formatTime = "1am";
break;
case "2": formatTime = "2am";
break;
case "3": formatTime = "3am";
break;
case "4": formatTime = "4am";
break;
case "5": formatTime = "5am";
break;
case "6": formatTime = "6am";
break;
case "7": formatTime = "7am";
break;
case "8": formatTime = "8am";
break;
case "9": formatTime = "9am";
break;
case "10": formatTime = "10am";
break;
case "11": formatTime = "11am";
break;
case "12": formatTime = "12pm";
break;
case "13": formatTime = "1pm";
break;
case "14": formatTime = "2pm";
break;
case "15": formatTime = "3pm";
break;
case "16": formatTime = "4pm";
break;
case "17": formatTime = "5pm";
break;
case "18": formatTime = "6pm";
break;
case "19": formatTime = "7pm";
break;
case "20": formatTime = "8pm";
break;
case "21": formatTime = "9pm";
break;
case "22": formatTime = "10pm";
break;
case "23": formatTime = "11pm";
break;
defualt: "Unknown time!";
break;
}
let jont = document.createElement('p');
jont.textContent = "Jont's Temp: " + (observations.data[i].temp_feels_like + 3) + "°C.";
p.textContent = formatTime + ". Temp: " + observations.data[i].temp + "°C.";
parent.appendChild(p);
parent.appendChild(jont);
let q = document.createElement('p');
q.textContent = "UV: " + observations.data[i].uv + "."
let uv = document.createElement('p');
uv.textContent = "Humidity: " + (observations.data[i].relative_humidity) + "%.";
let wind_dir = "South";
// for direction formatting --
// switch ((observations.data[i].wind.direction)){
// "S"
// }
let wind = document.createElement('p');
wind.textContent = "Wind: " + (observations.data[i].wind.speed_kilometre) + "km/h " + (observations.data[i].wind.direction) + " ";
let rain = document.createElement('p');
rain.textContent = "Rain: " + ((observations.data[i].rain.amount.min + observations.data[i].rain.amount.max) / 2) + "mm";
let averageDiff = observations.data[i].temp - averages.averages[0].month[10];
let avg = document.createElement('p');
let brk = document.createElement('hr');
if (averageDiff > 0) {
avg.textContent = "This day is hotter than average by " + averageDiff + "°C.";
}
else {
avg.textContent = "This day is cooler than average by " + averageDiff + "°C.";
}
parent.appendChild(q);
parent.appendChild(uv);
parent.appendChild(wind);
parent.appendChild(rain);
parent.appendChild(avg);
}
for (let i = 24; i > -1; i--) {
let ci = observations.data[i].temp;
if (ci < miner) {
miner = ci;
}
if (ci > maxer) {
maxer = ci;
}
let p = document.createElement('p');
let timer = new Date();
let realtimer = new Date(observations.data[i].time);
let now = new Date();
let currentTime = realtimer.toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit', second: '2-digit' });
let nozero = realtimer.getHours().toString();
let nonzero = nozero.replace(/^0+/, '');
yValues[i] = observations.data[i].temp;
let formatdate = new Date();
let nextdate = formatdate.toLocaleDateString();
if (observations.data[i].time === "undefined") {
xValues[i] = "Not found";
}
else {
let formatTime = nozero;
switch (nozero.toString()) {
case "0": formatTime = nextdate;
break;
case "1": formatTime = "1am";
break;
case "2": formatTime = "2am";
break;
case "3": formatTime = "3am";
break;
case "4": formatTime = "4am";
break;
case "5": formatTime = "5am";
break;
case "6": formatTime = "6am";
break;
case "7": formatTime = "7am";
break;
case "8": formatTime = "8am";
break;
case "9": formatTime = "9am";
break;
case "10": formatTime = "10am";
break;
case "11": formatTime = "11am";
break;
case "12": formatTime = "12pm";
break;
case "13": formatTime = "1pm";
break;
case "14": formatTime = "2pm";
break;
case "15": formatTime = "3pm";
break;
case "16": formatTime = "4pm";
break;
case "17": formatTime = "5pm";
break;
case "18": formatTime = "6pm";
break;
case "19": formatTime = "7pm";
break;
case "20": formatTime = "8pm";
break;
case "21": formatTime = "9pm";
break;
case "22": formatTime = "10pm";
break;
case "23": formatTime = "11pm";
break;
defualt: "Unknown time!";
break;
};
xValues[i] = formatTime;
}
parent.appendChild(p);
}
}
)
.then((temp) => {
}
);
const plugin = {
id: 'customCanvasBackgroundColor',
beforeDraw: (chart, args, options) => {
const { ctx } = chart;
ctx.save();
ctx.globalCompositeOperation = 'destination-over';
ctx.fillStyle = options.color || '#99ffff';
ctx.fillRect(0, 0, chart.width, chart.height);
ctx.restore();
}
};
new Chart("myChart", {
type: "line",
data: {
labels: xValues,
datasets: [{
label: '',
pointRadius: 0,
borderColor: "pink",
fill: true,
backgroundColor: 'rgba(85, 85, 85, 1)',
data: yValues
}
]
},
options: {
label: {
display: false
},
legend: {
display: false
},
tooltips: {
enabled: false
},
plugins: {
customCanvasBackgroundColor: {
color: '#121213',
},
legend: {
display: false
},
},
datalabels: {
display: false
},
title: {
display: false,
fontColor: 'white',
text: "yessir",
},
scales: {
x: {
title: false,
ticks: {
color: 'rgba(190, 190, 190, 1)'
}
},
y: {
max: maxer + 2,
min: miner - 2,
ticks: {
color: 'rgba(190, 190, 190, 1)'
}
},
},
},
plugins: [plugin],
});
var z = document.createElement("h2");
z.setAttribute("id", "placeholder");
document.body.appendChild(z);
function readMore() {
var dots = document.getElementById("dots");
var moreText = document.getElementById("more");
var btnText = document.getElementById("myBtn");
if (dots.style.display === "none") {
dots.style.display = "inline";
btnText.innerHTML = "Display more";
moreText.style.display = "none";
} else {
dots.style.display = "none";
btnText.innerHTML = "Display less";
moreText.style.display = "inline";
}
}
}
function removeData(chart) {
chart.data.labels.pop();
chart.data.datasets.forEach((dataset) => {
dataset.data.pop();
});
chart.update();
}
document.getElementById("social").addEventListener("click", function (e) {
window.location.href = "social.html";
});
document.getElementById("melb").addEventListener("click", function (e) {
runner(0);
window.location.href = "index.html";
});
document.getElementById("adel").addEventListener("click", function (e) {
runner(1);
window.location.href = "adelaide.html";
});
document.getElementById("sydn").addEventListener("click", function (e) {
runner(2);
window.location.href = "sydney.html";
});
document.getElementById("bris").addEventListener("click", function (e) {
runner(3);
window.location.href = "brisbane.html";
});
document.getElementById("more").addEventListener("click", function (e) {
runner(3);
window.location.href = "more.html";
});
function runner(city) {
cityText(city);
console.log("RUNNER");
location.reload;
run(city);
}
run(1);
window.run = run;