From 5f74b2b12d24cd8517d4dd47a8b9ce92cddebc51 Mon Sep 17 00:00:00 2001 From: Jesse Hasty <134172009+JesseWx2011@users.noreply.github.com> Date: Thu, 4 Jul 2024 09:48:49 -0400 Subject: [PATCH 01/12] Update scriptcc.js From 8f9024be64c1b9ededba788f82bcc6936a313af1 Mon Sep 17 00:00:00 2001 From: Jesse Hasty <134172009+JesseWx2011@users.noreply.github.com> Date: Thu, 4 Jul 2024 10:09:56 -0400 Subject: [PATCH 02/12] Typo Fix --- js/scriptcc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/scriptcc.js b/js/scriptcc.js index e4ef35e..755ebaf 100644 --- a/js/scriptcc.js +++ b/js/scriptcc.js @@ -27,7 +27,7 @@ } state = response[0].place.state tempFarenheit = response[0].periods[0].tempF -tempC = response[0].perioFds[0].tempC +tempC = response[0].periods[0].tempC const rainr = (response[0].periods[0].precipRateIN ).toFixed(3) document.getElementById('cityname').innerHTML = `
Deluge - Weather for ${response[0].place.name}, ${state}
`; document.getElementById('temp').innerHTML = `${tempFarenheit}°F (${tempC}°C)`; From bf7b86b3e23a0163b4fea646da47367581b5b06c Mon Sep 17 00:00:00 2001 From: Jesse Hasty <134172009+JesseWx2011@users.noreply.github.com> Date: Thu, 4 Jul 2024 10:33:25 -0400 Subject: [PATCH 03/12] Update script.js & notification.js --- js/notification.js | 2 +- js/scriptcc.js | 27 ++++++++++++++++----------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/js/notification.js b/js/notification.js index 5497831..e2d6595 100644 --- a/js/notification.js +++ b/js/notification.js @@ -14,7 +14,7 @@ function notifyMe() { const {response} = data console.log(data) var liteningaudio = "lightning.mp3" - if (response[0].relativeTo.distanceMI !== null) { + if (response[0]?.relativeTo?.distanceMI !== null) { document.getElementById("lightningbutton").style.display = "block" const notification = new Notification("Lightning Alert:", { body: `Lightning struck ${response[0].relativeTo.distanceMI} miles (${response[0].relativeTo.distanceKM} km) ${response[0].relativeTo.bearingENG} of this Location in ${city}.`, diff --git a/js/scriptcc.js b/js/scriptcc.js index 755ebaf..8057337 100644 --- a/js/scriptcc.js +++ b/js/scriptcc.js @@ -117,7 +117,7 @@ tempC = response[0].periods[0].tempC const data = await responsee.json(); const {response} = data; // Placeholder for if no matches for the if statements. - riskphrase = "" + let riskphrase = "" var risktype = response[0].details.risk.name if (risktype === "general risk") { riskphrase = "Isolated Instances of Lightning." @@ -328,19 +328,24 @@ tempC = response[0].periods[0].tempC getAlert(); const alert_url = `https://api.aerisapi.com/alerts/${city}?client_id=${client_id}&client_secret=${client_secret}`; async function getAlert() { - const responsee = await fetch(alert_url); - const data = await responsee.json(); + const results = await fetch(alert_url); + const data = await results.json(); const { response } = data; - document.getElementById('alerts').innerHTML = `
Alert: ${response[0].details.name} in effect for ${response[0].place.name} ${response[0].place.state}.Click Here for more information on alerts
` -if (response[0].details.emergency === true) { - document.getElementById("alerts").innerHTML = `
Alert: ${response[0].details.name} (EMERGENCY) in effect for ${response[0].place.name} ${response[0].place.state}.Click Here for more information on alerts
` -} - if (response[1].details.name !== "undefined") { - alerts.innerHTML = `
Alert: ${response[0].details.name} in effect for ${response[0].place.name} ${response[0].place.state}.Click Here for more information on alerts
Alert: ${response[1].details.name} in effect for ${response[0].place.name} ${response[0].place.state}.
` - } else { - alerts.innerHTML = `
Alert: ${response[0].details.name} in effect for ${response[0].place.name} ${response[0].place.state}.Click Here for more information on alerts
` + + alerts.innerHTML = ""; + + if (response?.length > 0) { + return; + } + + const details = response[0].details; + const place = response[0].place; + + if (details?.name) { + alerts.innerHTML = `
Alert: ${details.name} in effect for ${place.name} ${place.state}.Click Here for more information on alerts
` } } + getAlert(); setInterval(getAlert, 60000) From 90520b1ceff388cd88c2b5873bef851abc3bab40 Mon Sep 17 00:00:00 2001 From: Jesse Hasty <134172009+JesseWx2011@users.noreply.github.com> Date: Thu, 4 Jul 2024 10:37:58 -0400 Subject: [PATCH 04/12] Fix riskphrase Variable --- js/scriptcc.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/js/scriptcc.js b/js/scriptcc.js index 8057337..5459956 100644 --- a/js/scriptcc.js +++ b/js/scriptcc.js @@ -117,7 +117,7 @@ tempC = response[0].periods[0].tempC const data = await responsee.json(); const {response} = data; // Placeholder for if no matches for the if statements. - let riskphrase = "" + riskphrase = "" var risktype = response[0].details.risk.name if (risktype === "general risk") { riskphrase = "Isolated Instances of Lightning." @@ -133,6 +133,7 @@ tempC = response[0].periods[0].tempC riskphrase = "Dangerous Thunderstorms Likely." } + } severeweather() severeweathertommorow() @@ -345,7 +346,7 @@ tempC = response[0].periods[0].tempC alerts.innerHTML = `
Alert: ${details.name} in effect for ${place.name} ${place.state}.Click Here for more information on alerts
` } } - + getAlert(); setInterval(getAlert, 60000) From ad398c469f73ee14ad4e6597973736610d1e5412 Mon Sep 17 00:00:00 2001 From: Jesse Hasty <134172009+JesseWx2011@users.noreply.github.com> Date: Thu, 4 Jul 2024 15:19:22 -0400 Subject: [PATCH 05/12] Fix Lightning Page --- lightning.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lightning.html b/lightning.html index 47bd5ac..890cbec 100644 --- a/lightning.html +++ b/lightning.html @@ -2,9 +2,9 @@ Deluge - Lightning Map - - - + + + From a859696338b53bd4eb369a18c3cf2c62b2dc9608 Mon Sep 17 00:00:00 2001 From: Jesse Hasty <134172009+JesseWx2011@users.noreply.github.com> Date: Thu, 4 Jul 2024 15:26:27 -0400 Subject: [PATCH 06/12] del --- js/script.js | 1 - 1 file changed, 1 deletion(-) delete mode 100644 js/script.js diff --git a/js/script.js b/js/script.js deleted file mode 100644 index 25502ea..0000000 --- a/js/script.js +++ /dev/null @@ -1 +0,0 @@ -console.log('you can do anything!!') From 14fc4332ab574688092a7b25f2bfb94ce25f676c Mon Sep 17 00:00:00 2001 From: Jesse Hasty <134172009+JesseWx2011@users.noreply.github.com> Date: Fri, 5 Jul 2024 14:11:28 -0400 Subject: [PATCH 07/12] Delete hourly.html --- hourly.html | 179 ---------------------------------------------------- 1 file changed, 179 deletions(-) delete mode 100644 hourly.html diff --git a/hourly.html b/hourly.html deleted file mode 100644 index ea9dc1b..0000000 --- a/hourly.html +++ /dev/null @@ -1,179 +0,0 @@ - - - - - - - Hourly Forecast for . - - - - - - -
-
Hourly Forecast
- -
-
Hour 1
-
- -
-
32
-
Wind: 0mph
-
-
-
Hour 2
-
- -
-
32
-
Wind: 0mph
-
-
-
Hour 3
-
- -
-
32
-
Wind: 0mph
-
- -
- - - - From 18463c64daf6d87ea04ee1966f0da22182d0e14e Mon Sep 17 00:00:00 2001 From: Jesse Hasty <134172009+JesseWx2011@users.noreply.github.com> Date: Fri, 5 Jul 2024 14:12:00 -0400 Subject: [PATCH 08/12] Update index.html --- index.html | 1 - 1 file changed, 1 deletion(-) diff --git a/index.html b/index.html index a1ddd56..007a181 100644 --- a/index.html +++ b/index.html @@ -213,7 +213,6 @@

Radar Unav
- From 309db3e506dc8c320f019516bbde681682a849c8 Mon Sep 17 00:00:00 2001 From: Jesse Hasty <134172009+JesseWx2011@users.noreply.github.com> Date: Fri, 5 Jul 2024 14:12:24 -0400 Subject: [PATCH 09/12] Update index.html --- index.html | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/index.html b/index.html index 007a181..9dd5d0c 100644 --- a/index.html +++ b/index.html @@ -295,16 +295,6 @@

Radar Unav ChangeWidth() setInterval(getTime, 5000) - - diff --git a/js/notification.js b/js/notification.js index e2d6595..07c4e9c 100644 --- a/js/notification.js +++ b/js/notification.js @@ -1,4 +1,5 @@ function notifyMe() { + // Request acess to show notifications if (!("Notification" in window)) { } else if (Notification.permission === "granted") { } else if (Notification.permission !== "denied") { @@ -12,7 +13,7 @@ function notifyMe() { const responsee = await fetch(alerts) const data = await responsee.json() const {response} = data - console.log(data) + var liteningaudio = "lightning.mp3" if (response[0]?.relativeTo?.distanceMI !== null) { document.getElementById("lightningbutton").style.display = "block" @@ -34,18 +35,23 @@ function notifyMe() { } notifyMe() alerts(); +// Get Alerts const wxalerts = `https://data.api.xweather.com/alerts/${city}?client_id=${client_id}&client_secret=${client_secret}` async function alerts() { const responsee = await fetch(wxalerts) const data = await responsee.json() const {response} = data; - console.log(data) - + +// JSON returns as ISO-8601 alert = response[0].details.name - starttimeold = response[0].timestamps.beginsISO - endtimeold = response[0].timestamps.expiresISO - tz = response[0].profile.tz - starttime = new Date(starttimeold).toLocaleString("en-US", {timeStyle: "short", timeZone: tz, }); + starttimeold = response[0].timestamps.beginsISO // When Alert Started + endtimeold = response[0].timestamps.expiresISO // When Alert Expires + tz = response[0].profile.tz // Timezone + /* Convert it to a string we are more familiar with + Example: 2021-10-04T17:08:09.000Z + String Conversion: October 4th, 2021 17:08:09 UTC + */ + starttime = new Date(starttimeold).toLocaleString("en-US", {timeStyle: "short", timeZone: tz, }); // endtime = new Date(endtimeold).toLocaleString("en-US", {timeStyle: "short", timeZone: tz, }); console.log(starttime) if (alert !== null) { diff --git a/js/scriptcc.js b/js/scriptcc.js index 5459956..60fe60b 100644 --- a/js/scriptcc.js +++ b/js/scriptcc.js @@ -44,11 +44,12 @@ tempC = response[0].periods[0].tempC document.getElementById('rainrvalue').innerHTML = `${rainr} in./hr`; document.getElementById('solarvalue').innerHTML = `${response[0].periods[0].solradWM2} watts/m²`; document.getElementById("windmetric").innerHTML = `${response[0].periods[0].windSpeedKPH} km/h

`; - document.getElementById("radarimage").innerHTML = `` + radar = document.getElementById("radarimage").innerHTML = `` + + document.getElementById("LoadingScreen").style.display = "none" + document.getElementById("weatherpage").style.display = "block" document.getElementById("windgust").innerHTML = `Gusts to ${response[0].periods[0].windGustMPH} mph` - document.getElementById("LoadingScreen").style.display = "none" - document.getElementById("weatherpage").style.display = "block" // Twitter Card // Function to get the UV Value