Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.

Commit 9c392e0

Browse files
authored
Merge pull request #4 from JesseWx2011/main
Code Adjustments, Added Comments
2 parents 6258c43 + c4c7935 commit 9c392e0

8 files changed

+43
-223
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
Contibutors:
55
No Other Contributors :/</div>
66
<div class="info">This uses an api made by Aeris Weather.</div>
7-
<div class="info">This Project was last updated 7/4/24.</div>
7+
<div class="info">This Project was last updated on July 5th, 2024.</div>
88
<div class="info">To see the latest updates, go to "changelog.txt".</div>
99
<img align="center" src="https://github-readme-stats.vercel.app/api?username=JesseWx2011&include_all_commits=true&count_private=true&show_icons=true&line_height=20&title_color=2B5BBD&icon_color=1124BB&text_color=A1A1A1&bg_color=0,000001,130F40" alt="my Github Stats"/>
1010
Go to <a href="https://drive.google.com/file/d/1Wft1JEjsMZ_UdUvqw4yiDK1jXy4fm_-/view">here</a> for a demo.
1111
<h2 align="center">Any Questions? Create an issue on the "Issues" page.</h2>
1212
<h1>Previews, Taken as of v2.5 Build 1, Released July 3rd, 2024<h1>
1313
<div align="center">
14-
Apple iPad
14+
<div align="center">Apple iPad</div>
1515
<img src="iPad.png"></img>
16-
Apple iPhone (iPhone 14, 6.7")
16+
<div align="center">Apple iPhone (iPhone 14, 6.7")</div>
1717
<img src="iPhone.png"></img>
18-
Laptop (Windows PC)
18+
<div>Laptop (Windows PC)</div>
1919
<img src="Windows PC.png"></img>
2020
</div>

hourly.html

Lines changed: 0 additions & 179 deletions
This file was deleted.

index.html

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ <h1 style="position: absolute; margin-top: 78px; margin-left: 550px;">Radar Unav
213213
</div>
214214
<div class="bottomnavbar" id="bottombar">
215215
<button onclick="lightningredirect()" class="lightningbutton" id="lightningbutton">Closest Lightning Strike</button>
216-
<button onclick="hourlycity()" id="hourlybutton" class="linkbutton">Hourly Forecast</button>
217216
<button class="linkbutton" onclick="extendedforecast()" style="margin-left: 250px;">Full Forecast</button>
218217
<button onclick="spcoutlook()" id="spcbutton" class="linkbutton"
219218
style="margin-left: 220px; width: 110px;">Convective Outlook (USA Only)</button>
@@ -222,7 +221,6 @@ <h1 style="position: absolute; margin-top: 78px; margin-left: 550px;">Radar Unav
222221
</div>
223222
</div>
224223
</div>
225-
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
226224

227225
</body>
228226

@@ -296,16 +294,6 @@ <h1 style="position: absolute; margin-top: 78px; margin-left: 550px;">Radar Unav
296294
ChangeWidth()
297295
setInterval(getTime, 5000)
298296
</script>
299-
<script>
300-
function hourlycity() {
301-
const hbutton = document.getElementById("hourlybutton")
302-
hbutton.addEventListener("click", function () {
303-
location.replace(`./hourly.html?city=${city}`)
304-
})
305-
}
306-
hourlycity();
307-
</script>
308-
309297
<script>
310298
$(function () {
311299
$(document).keyup(function (e) {

js/lightning.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ async function litening() {
1414
const responsee = await fetch(alerts)
1515
const data = await responsee.json()
1616
const {response} = data
17-
console.log(data)
1817
var locs = {
1918
lat: response[0].loc.lat,
2019
lon: response[0].loc.long

js/notification.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
function notifyMe() {
2+
// Request acess to show notifications
23
if (!("Notification" in window)) {
34
} else if (Notification.permission === "granted") {
45
} else if (Notification.permission !== "denied") {
@@ -12,9 +13,9 @@ function notifyMe() {
1213
const responsee = await fetch(alerts)
1314
const data = await responsee.json()
1415
const {response} = data
15-
console.log(data)
16+
1617
var liteningaudio = "lightning.mp3"
17-
if (response[0].relativeTo.distanceMI !== null) {
18+
if (response[0]?.relativeTo?.distanceMI !== null) {
1819
document.getElementById("lightningbutton").style.display = "block"
1920
const notification = new Notification("Lightning Alert:", {
2021
body: `Lightning struck ${response[0].relativeTo.distanceMI} miles (${response[0].relativeTo.distanceKM} km) ${response[0].relativeTo.bearingENG} of this Location in ${city}.`,
@@ -34,18 +35,23 @@ function notifyMe() {
3435
}
3536
notifyMe()
3637
alerts();
38+
// Get Alerts
3739
const wxalerts = `https://data.api.xweather.com/alerts/${city}?client_id=${client_id}&client_secret=${client_secret}`
3840
async function alerts() {
3941
const responsee = await fetch(wxalerts)
4042
const data = await responsee.json()
4143
const {response} = data;
42-
console.log(data)
43-
44+
45+
// JSON returns as ISO-8601
4446
alert = response[0].details.name
45-
starttimeold = response[0].timestamps.beginsISO
46-
endtimeold = response[0].timestamps.expiresISO
47-
tz = response[0].profile.tz
48-
starttime = new Date(starttimeold).toLocaleString("en-US", {timeStyle: "short", timeZone: tz, });
47+
starttimeold = response[0].timestamps.beginsISO // When Alert Started
48+
endtimeold = response[0].timestamps.expiresISO // When Alert Expires
49+
tz = response[0].profile.tz // Timezone
50+
/* Convert it to a string we are more familiar with
51+
Example: 2021-10-04T17:08:09.000Z
52+
String Conversion: October 4th, 2021 17:08:09 UTC
53+
*/
54+
starttime = new Date(starttimeold).toLocaleString("en-US", {timeStyle: "short", timeZone: tz, }); //
4955
endtime = new Date(endtimeold).toLocaleString("en-US", {timeStyle: "short", timeZone: tz, });
5056
console.log(starttime)
5157
if (alert !== null) {

js/script.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

js/scriptcc.js

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
}
2828
state = response[0].place.state
2929
tempFarenheit = response[0].periods[0].tempF
30-
tempC = response[0].perioFds[0].tempC
30+
tempC = response[0].periods[0].tempC
3131
const rainr = (response[0].periods[0].precipRateIN ).toFixed(3)
3232
document.getElementById('cityname').innerHTML = `<div class="city">Deluge - Weather for ${response[0].place.name}, ${state}</div>`;
3333
document.getElementById('temp').innerHTML = `${tempFarenheit}°F (${tempC}°C)`;
@@ -44,11 +44,12 @@ tempC = response[0].perioFds[0].tempC
4444
document.getElementById('rainrvalue').innerHTML = `${rainr} in./hr`;
4545
document.getElementById('solarvalue').innerHTML = `${response[0].periods[0].solradWM2} watts/m²`;
4646
document.getElementById("windmetric").innerHTML = `${response[0].periods[0].windSpeedKPH} km/h</div>`;
47-
document.getElementById("radarimage").innerHTML = `<img style="width: 617px;" src="https://maps.aerisapi.com/${client_id}_${client_secret}/flat-dk,water-depth,satellite,radar,alerts-warnings-outlines,counties,lightning-strikes-15m-icons,roads,interstates,rivers,admin-cities-dk/1280x878/${city},9/current.png"/>`
47+
radar = document.getElementById("radarimage").innerHTML = `<img style="width: 617px;" src="https://maps.aerisapi.com/${client_id}_${client_secret}/flat-dk,water-depth,satellite,radar,alerts-warnings-outlines,counties,lightning-strikes-15m-icons,roads,interstates,rivers,admin-cities-dk/1280x878/${city},9/current.png"/>`
48+
49+
document.getElementById("LoadingScreen").style.display = "none"
50+
document.getElementById("weatherpage").style.display = "block"
4851
document.getElementById("windgust").innerHTML = `Gusts to ${response[0].periods[0].windGustMPH} mph`
4952

50-
document.getElementById("LoadingScreen").style.display = "none"
51-
document.getElementById("weatherpage").style.display = "block"
5253

5354
// Twitter Card
5455
// Function to get the UV Value
@@ -117,7 +118,7 @@ tempC = response[0].perioFds[0].tempC
117118
const data = await responsee.json();
118119
const {response} = data;
119120
// Placeholder for if no matches for the if statements.
120-
riskphrase = ""
121+
riskphrase = ""
121122
var risktype = response[0].details.risk.name
122123
if (risktype === "general risk") {
123124
riskphrase = "Isolated Instances of Lightning."
@@ -133,6 +134,7 @@ tempC = response[0].perioFds[0].tempC
133134
riskphrase = "Dangerous Thunderstorms Likely."
134135
}
135136

137+
136138
}
137139
severeweather()
138140
severeweathertommorow()
@@ -328,19 +330,24 @@ tempC = response[0].perioFds[0].tempC
328330
getAlert();
329331
const alert_url = `https://api.aerisapi.com/alerts/${city}?client_id=${client_id}&client_secret=${client_secret}`;
330332
async function getAlert() {
331-
const responsee = await fetch(alert_url);
332-
const data = await responsee.json();
333+
const results = await fetch(alert_url);
334+
const data = await results.json();
333335
const { response } = data;
334-
document.getElementById('alerts').innerHTML = `<div style="background-color: #${response[0].details.color};">Alert: ${response[0].details.name} in effect for ${response[0].place.name} ${response[0].place.state}.<a href="alertdetail.html?city=${city}">Click Here for more information on alerts</a></div>`
335-
if (response[0].details.emergency === true) {
336-
document.getElementById("alerts").innerHTML = `<div style="background-color: #${response[0].details.color};">Alert: ${response[0].details.name} (EMERGENCY) in effect for ${response[0].place.name} ${response[0].place.state}.<a href="alertdetail.html?city=${city}">Click Here for more information on alerts</a></div>`
337-
}
338-
if (response[1].details.name !== "undefined") {
339-
alerts.innerHTML = `<div style="background-color: #${response[0].details.color};">Alert: ${response[0].details.name} in effect for ${response[0].place.name} ${response[0].place.state}.<a href="alertdetail.html?city=${city}">Click Here for more information on alerts</a></div><div style="background-color: #${response[1].details.color};">Alert: ${response[1].details.name} in effect for ${response[0].place.name} ${response[0].place.state}.</div>`
340-
} else {
341-
alerts.innerHTML = `<div style="background-color: #${response[0].details.color};">Alert: ${response[0].details.name} in effect for ${response[0].place.name} ${response[0].place.state}.<a href="alertdetail.html?city=${city}">Click Here for more information on alerts</a></div>`
336+
337+
alerts.innerHTML = "";
338+
339+
if (response?.length > 0) {
340+
return;
341+
}
342+
343+
const details = response[0].details;
344+
const place = response[0].place;
345+
346+
if (details?.name) {
347+
alerts.innerHTML = `<div style="background-color: #${details.color};">Alert: ${details.name} in effect for ${place.name} ${place.state}.<a href="alertdetail.html?city=${city}">Click Here for more information on alerts</a></div>`
342348
}
343349
}
350+
344351
getAlert();
345352
setInterval(getAlert, 60000)
346353

lightning.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<head>
33
<title id="title">Deluge - Lightning Map</title>
44
<meta charset="UTF-8">
5-
<link rel="stylesheet" href="stylecurrentconditions.css" />
6-
<script type="text/javascript" src="config.js"></script>
7-
<script type="text/javascript" src="lightning.js"></script>
5+
<link rel="stylesheet" href="./css/stylecurrentconditions.css" />
6+
<script type="text/javascript" src="./js/config.js"></script>
7+
<script type="text/javascript" src="./js/lightning.js"></script>
88
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
99
<meta name="authors" content="Jesse Hasty">
1010
<meta name='viewport' content='width=device-width; content='width = 425; initial-scale=1.0; maximum-scale=1.0; user-scalable=yes; target-densitydpi=160dpi'>

0 commit comments

Comments
 (0)