From 78ac1e79dbc55fddc810485bb0e102195f489610 Mon Sep 17 00:00:00 2001 From: Khalil Abdellah Date: Sun, 31 Jan 2021 21:09:15 -0500 Subject: [PATCH 1/3] Submission --- index.html | 4 ++++ script.js | 43 +++++++++++++++++++++++++++++++++++++++++++ style.css | 14 ++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 script.js create mode 100644 style.css diff --git a/index.html b/index.html index 3233671..1afe8ae 100644 --- a/index.html +++ b/index.html @@ -4,8 +4,12 @@ Document +

Hola Mundo

+
+

+ \ No newline at end of file diff --git a/script.js b/script.js new file mode 100644 index 0000000..4dd9634 --- /dev/null +++ b/script.js @@ -0,0 +1,43 @@ +const locationDisplay = document.getElementById('location'); +const weatherDisplay = document.getElementById('weather'); + +const userZip = prompt("What's your ZIP Code?"); +const userLink = 'http://api.zippopotam.us/us/' + parseInt(userZip); +let userLon; +let userLat; +const weatherLink = 'http://www.7timer.info/bin/api.pl?output=json&product=civillight&lon=' + userLon + '&lat=' + userLat; + +// http://www.7timer.info/bin/astro.php?lon=113.2&lat=23.1&ac=0&unit=metric&output=xml&tzshift=0 + +var client = new XMLHttpRequest(); + +client.open("GET", userLink, true); +client.onreadystatechange = function() { + if(client.readyState == 4 && client.status === 200) { + + let zipData = JSON.parse(client.responseText); + locationDisplay.innerHTML += ` +

${zipData.places[0]['place name']}, ${zipData.places[0]['state abbreviation']}

+ `; + + userLon = `${zipData.places[0].longitude}`; + userLat = `${zipData.places[0].latitude}`; + + let sevenTimer = new XMLHttpRequest(); + sevenTimer.open("GET", weatherLink, true); + sevenTimer.onreadystatechange = function() { + if(sevenTimer.readyState == 4 && client.status === 200) { + let weatherData = JSON.parse(sevenTimer.responseText); + console.log(weatherData); + weatherDisplay.innerHTML += ` + ${weatherData.dataseries[0].temp2m.max}° + `; + } + } + sevenTimer.send(); + } +}; + +client.send(); + + diff --git a/style.css b/style.css new file mode 100644 index 0000000..883b30f --- /dev/null +++ b/style.css @@ -0,0 +1,14 @@ +body { + font-family: sans-serif, 'Segoe-UI'; + font-size: 24px; + padding: 20px; + position:relative; +} + +#weather { + float: right; + position: absolute; + top: 20px; + right: 40px; +} + From 5c26f3f9e9c4a7e47c455b47d9d16274782a09e1 Mon Sep 17 00:00:00 2001 From: Khalil Abdellah Date: Tue, 2 Feb 2021 12:30:38 -0500 Subject: [PATCH 2/3] Submission2 --- script.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/script.js b/script.js index 4dd9634..90f6661 100644 --- a/script.js +++ b/script.js @@ -5,9 +5,13 @@ const userZip = prompt("What's your ZIP Code?"); const userLink = 'http://api.zippopotam.us/us/' + parseInt(userZip); let userLon; let userLat; -const weatherLink = 'http://www.7timer.info/bin/api.pl?output=json&product=civillight&lon=' + userLon + '&lat=' + userLat; -// http://www.7timer.info/bin/astro.php?lon=113.2&lat=23.1&ac=0&unit=metric&output=xml&tzshift=0 +function convertTemp(weatherLink) { + const celsius = weatherLink -273; + let fahrenheit = Math.floor( celsius * ( 9 / 5 ) + 32 ); + return fahrenheit; +} + var client = new XMLHttpRequest(); @@ -23,14 +27,16 @@ client.onreadystatechange = function() { userLon = `${zipData.places[0].longitude}`; userLat = `${zipData.places[0].latitude}`; + const weatherLink = `https://api.openweathermap.org/data/2.5/onecall?lat=${userLat}&lon=${userLon}&exclude=minutely,hourly&appid=dcf230f9ec9de3db7414b60015a4b1bf`; let sevenTimer = new XMLHttpRequest(); sevenTimer.open("GET", weatherLink, true); sevenTimer.onreadystatechange = function() { if(sevenTimer.readyState == 4 && client.status === 200) { let weatherData = JSON.parse(sevenTimer.responseText); console.log(weatherData); + let currentTemp = convertTemp(weatherData.current.temp); weatherDisplay.innerHTML += ` - ${weatherData.dataseries[0].temp2m.max}° + ${currentTemp}° `; } } From e8eae7c8db0fded41a7ae37e28d1014292e18712 Mon Sep 17 00:00:00 2001 From: Khalil Abdellah <64501924+cv-net@users.noreply.github.com> Date: Tue, 4 May 2021 23:59:34 -0400 Subject: [PATCH 3/3] Delete script.js --- script.js | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 script.js diff --git a/script.js b/script.js deleted file mode 100644 index 90f6661..0000000 --- a/script.js +++ /dev/null @@ -1,49 +0,0 @@ -const locationDisplay = document.getElementById('location'); -const weatherDisplay = document.getElementById('weather'); - -const userZip = prompt("What's your ZIP Code?"); -const userLink = 'http://api.zippopotam.us/us/' + parseInt(userZip); -let userLon; -let userLat; - -function convertTemp(weatherLink) { - const celsius = weatherLink -273; - let fahrenheit = Math.floor( celsius * ( 9 / 5 ) + 32 ); - return fahrenheit; -} - - -var client = new XMLHttpRequest(); - -client.open("GET", userLink, true); -client.onreadystatechange = function() { - if(client.readyState == 4 && client.status === 200) { - - let zipData = JSON.parse(client.responseText); - locationDisplay.innerHTML += ` -

${zipData.places[0]['place name']}, ${zipData.places[0]['state abbreviation']}

- `; - - userLon = `${zipData.places[0].longitude}`; - userLat = `${zipData.places[0].latitude}`; - - const weatherLink = `https://api.openweathermap.org/data/2.5/onecall?lat=${userLat}&lon=${userLon}&exclude=minutely,hourly&appid=dcf230f9ec9de3db7414b60015a4b1bf`; - let sevenTimer = new XMLHttpRequest(); - sevenTimer.open("GET", weatherLink, true); - sevenTimer.onreadystatechange = function() { - if(sevenTimer.readyState == 4 && client.status === 200) { - let weatherData = JSON.parse(sevenTimer.responseText); - console.log(weatherData); - let currentTemp = convertTemp(weatherData.current.temp); - weatherDisplay.innerHTML += ` - ${currentTemp}° - `; - } - } - sevenTimer.send(); - } -}; - -client.send(); - -