From 44715b3dc6791037569dd370ea9b8e7e23b4da50 Mon Sep 17 00:00:00 2001 From: Katharyn Lynn Oggenfuss Date: Sun, 31 Jan 2021 17:24:19 -0500 Subject: [PATCH 01/10] first commit --- index.html | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index 3233671..46b35f9 100644 --- a/index.html +++ b/index.html @@ -3,9 +3,14 @@ - Document + + Weather App - -

Hola Mundo

+ +
+

Hola Mundo!

+

Temperature

+
- \ No newline at end of file + + From 48ad62acfcb7bf2f5181d0874564b4ab2098b9ea Mon Sep 17 00:00:00 2001 From: Katharyn Lynn Oggenfuss Date: Sun, 31 Jan 2021 17:24:48 -0500 Subject: [PATCH 02/10] first commit --- style.css | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 style.css diff --git a/style.css b/style.css new file mode 100644 index 0000000..07ece9b --- /dev/null +++ b/style.css @@ -0,0 +1,15 @@ +body { + display: block; + font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; +} + +.container { + display: inline; +} +.cityState { + +} + +.temperature { + font-size: 50px; +} From b758df50c80b038bd161c14dea6fd64c0dffeab6 Mon Sep 17 00:00:00 2001 From: Katharyn Lynn Oggenfuss Date: Sun, 31 Jan 2021 17:25:17 -0500 Subject: [PATCH 03/10] first commit --- weather.js | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 weather.js diff --git a/weather.js b/weather.js new file mode 100644 index 0000000..1526167 --- /dev/null +++ b/weather.js @@ -0,0 +1,50 @@ + + +// DOM Elements +const cityState = document.querySelector(".cityState"); +const temperature = document.querySelector(".temperature"); + +//Ask user zip code +// const userZip = prompt(`What's your Zip Code?`); +// const userLink = '' + parseInt(userZip); + + + +/* Fetch Functions */ + +// Fetch location using Geolocator as shown in https://www.youtube.com/watch?v=Xd43hZKaUS0&feature=youtu.be + const successfulLookup = async (position) => { + try { + const {latitude, longitude} = position.coords; + const response = await fetch(`https://api.opencagedata.com/geocode/v1/json?q=${latitude}+${longitude}&key=68824d84dff94b6a8921c156b462a3d1`) + const data = await response.json(); + const city = data.results[0].components.city; + const state = data.results[0].components.state_code; + console.log(`${city}, ${state}`); + + cityState.textContent = `$[city], ${state}`; + currentTemp(city, state); + } + catch(error) { + console.log(error); + } +} + + +navigator.geolocation.getCurrentPosition(successfulLookup, console.log); + +// Fetch weather at openweathermap api + const currentTemp = async (city, state) => { + try { + const temp = await fetch(`http://api.openweathermap.org/data/2.5/weather?q=${city},${state}&appid=0312d87f192d54ce3485295a535d403f`) + const data = await temp.json(); + let currTemp = Math.trunc(data.main.temp/10); + //currTemp = 29; + temperature.innerHTML = `${currTemp}℉`; + + } + catch(error) { + console.log(error); + } + } + From 806fd27eb8bd2290cac3e46ffb66acfd8df56f2f Mon Sep 17 00:00:00 2001 From: Katharyn Lynn Oggenfuss Date: Sun, 31 Jan 2021 17:26:01 -0500 Subject: [PATCH 04/10] first commit --- package-lock.json | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 package-lock.json diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..ff68f68 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,33 @@ +{ + "requires": true, + "lockfileVersion": 1, + "dependencies": { + "cross-fetch": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.0.6.tgz", + "integrity": "sha512-KBPUbqgFjzWlVcURG+Svp9TlhA5uliYtiNx/0r8nv0pdypeQCRJ9IaSIc3q/x3q8t3F75cHuwxVql1HFGHCNJQ==", + "requires": { + "node-fetch": "2.6.1" + } + }, + "dotenv": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz", + "integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==" + }, + "node-fetch": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", + "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==" + }, + "opencage-api-client": { + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/opencage-api-client/-/opencage-api-client-0.10.0.tgz", + "integrity": "sha512-t3DaDmXDC9oi3LFJlic76L2iLgs2yoaIIEBZe76CMAvW6hX/QfNUAIwlg3mj9A3JLEvf/2LTw5llyJa1yuesrA==", + "requires": { + "cross-fetch": "^3.0.6", + "dotenv": "^8.2.0" + } + } + } +} From 10da5efe33deb1a628af06612360acf3b36aecc7 Mon Sep 17 00:00:00 2001 From: Katharyn Lynn Oggenfuss Date: Sun, 31 Jan 2021 19:16:48 -0500 Subject: [PATCH 05/10] added function --- index.html | 2 +- indexTemp.html | 10 ++++++++++ style.css | 15 ++++++++++++--- weather.js | 32 ++++++++++++++++++++------------ 4 files changed, 43 insertions(+), 16 deletions(-) create mode 100644 indexTemp.html diff --git a/index.html b/index.html index 46b35f9..fc1bcdc 100644 --- a/index.html +++ b/index.html @@ -8,7 +8,7 @@
-

Hola Mundo!

+

Hola Mundo!

Temperature

diff --git a/indexTemp.html b/indexTemp.html new file mode 100644 index 0000000..a02b12b --- /dev/null +++ b/indexTemp.html @@ -0,0 +1,10 @@ + + +
+

+
+ +

+
+
+
\ No newline at end of file diff --git a/style.css b/style.css index 07ece9b..a41b09d 100644 --- a/style.css +++ b/style.css @@ -1,15 +1,24 @@ body { display: block; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; + font-size: 1 rem; } -.container { +h1 { display: inline; } + +.container { + display: grid; +} .cityState { - + justify-self: start; + padding-left: 100px; + font-size: 2rem; } .temperature { - font-size: 50px; + justify-self: end; + padding-right: 100px; + font-size: 3rem; } diff --git a/weather.js b/weather.js index 1526167..13f02f8 100644 --- a/weather.js +++ b/weather.js @@ -1,14 +1,17 @@ -// DOM Elements +/* DOM Elements */ const cityState = document.querySelector(".cityState"); const temperature = document.querySelector(".temperature"); -//Ask user zip code -// const userZip = prompt(`What's your Zip Code?`); -// const userLink = '' + parseInt(userZip); +/* Helper Functions */ +function convertTemp(temp) { + const celsius = temp -273; + let fahrenheit = Math.floor(celsius * (9/5) + 32); + return fahrenheit; +} /* Fetch Functions */ @@ -18,12 +21,15 @@ const temperature = document.querySelector(".temperature"); const {latitude, longitude} = position.coords; const response = await fetch(`https://api.opencagedata.com/geocode/v1/json?q=${latitude}+${longitude}&key=68824d84dff94b6a8921c156b462a3d1`) const data = await response.json(); - const city = data.results[0].components.city; - const state = data.results[0].components.state_code; - console.log(`${city}, ${state}`); + + console.log(results); + + const city1 = data.results[0].components.city; + const stateData = data.results[0].components.state_code; + + cityState.textContent = `${city1}, ${stateData}`; - cityState.textContent = `$[city], ${state}`; - currentTemp(city, state); + currentTemp(city1, stateData); } catch(error) { console.log(error); @@ -31,15 +37,16 @@ const temperature = document.querySelector(".temperature"); } -navigator.geolocation.getCurrentPosition(successfulLookup, console.log); + // Fetch weather at openweathermap api const currentTemp = async (city, state) => { try { const temp = await fetch(`http://api.openweathermap.org/data/2.5/weather?q=${city},${state}&appid=0312d87f192d54ce3485295a535d403f`) const data = await temp.json(); - let currTemp = Math.trunc(data.main.temp/10); - //currTemp = 29; + + let currTemp = convertTemp(data.main.temp); + temperature.innerHTML = `${currTemp}℉`; } @@ -48,3 +55,4 @@ navigator.geolocation.getCurrentPosition(successfulLookup, console.log); } } + navigator.geolocation.getCurrentPosition(successfulLookup, console.log); \ No newline at end of file From 59f435c28f318690a02a2b8d769132cc7c671219 Mon Sep 17 00:00:00 2001 From: Katharyn Lynn Oggenfuss Date: Sun, 31 Jan 2021 19:56:47 -0500 Subject: [PATCH 06/10] added function --- weather.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/weather.js b/weather.js index 13f02f8..9cefe84 100644 --- a/weather.js +++ b/weather.js @@ -21,15 +21,13 @@ function convertTemp(temp) { const {latitude, longitude} = position.coords; const response = await fetch(`https://api.opencagedata.com/geocode/v1/json?q=${latitude}+${longitude}&key=68824d84dff94b6a8921c156b462a3d1`) const data = await response.json(); - - console.log(results); - const city1 = data.results[0].components.city; + const cityData = data.results[0].components.city; const stateData = data.results[0].components.state_code; - cityState.textContent = `${city1}, ${stateData}`; + cityState.textContent = `${cityData}, ${stateData}`; - currentTemp(city1, stateData); + currentTemp(latitude, longitude); } catch(error) { console.log(error); @@ -40,12 +38,12 @@ function convertTemp(temp) { // Fetch weather at openweathermap api - const currentTemp = async (city, state) => { + const currentTemp = async (latitude, longitude) => { try { - const temp = await fetch(`http://api.openweathermap.org/data/2.5/weather?q=${city},${state}&appid=0312d87f192d54ce3485295a535d403f`) + const temp = await fetch(`https://api.openweathermap.org/data/2.5/onecall?lat=${latitude}&lon=${longitude}&exclude=minutely,hourly&exclude={part}&appid=0312d87f192d54ce3485295a535d403f=0312d87f192d54ce3485295a535d403f`) const data = await temp.json(); - let currTemp = convertTemp(data.main.temp); + let currTemp = convertTemp(data.current.temp); temperature.innerHTML = `${currTemp}℉`; From a73867605508e4727dacff7a58a02c7223f42ccb Mon Sep 17 00:00:00 2001 From: Katharyn Lynn Oggenfuss Date: Sun, 31 Jan 2021 20:04:34 -0500 Subject: [PATCH 07/10] changed api call --- weather.js | 84 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 62 insertions(+), 22 deletions(-) diff --git a/weather.js b/weather.js index 9cefe84..e955a95 100644 --- a/weather.js +++ b/weather.js @@ -1,56 +1,96 @@ -/* DOM Elements */ -const cityState = document.querySelector(".cityState"); -const temperature = document.querySelector(".temperature"); +// /* DOM Elements */ +// const cityState = document.querySelector(".cityState"); +// const temperature = document.querySelector(".temperature"); -/* Helper Functions */ +// /* Helper Functions */ + +// function convertTemp(temp) { +// const celsius = temp -273; +// let fahrenheit = Math.floor(celsius * (9/5) + 32); +// return fahrenheit; +// } + +// /* Fetch Functions */ + +// // Fetch location using Geolocator as shown in https://www.youtube.com/watch?v=Xd43hZKaUS0&feature=youtu.be +// const successfulLookup = async (position) => { +// try { +// const {latitude, longitude} = position.coords; +// const response = await fetch(`https://api.opencagedata.com/geocode/v1/json?q=${latitude}+${longitude}&key=68824d84dff94b6a8921c156b462a3d1`) +// const data = await response.json(); + +// const cityData = data.results[0].components.city; +// const stateData = data.results[0].components.state_code; + +// cityState.textContent = `${cityData}, ${stateData}`; + +// currentTemp(latitude, longitude); +// } +// catch(error) { +// console.log(error); +// } +// } + + + + +// // Fetch weather at openweathermap api +// const currentTemp = async (latitude, longitude) => { +// try { +// const temp = await fetch(`https://api.openweathermap.org/data/2.5/onecall?lat=${latitude}&lon=${longitude}&exclude=minutely,hourly&exclude={part}&appid=0312d87f192d54ce3485295a535d403f=0312d87f192d54ce3485295a535d403f`) +// const data = await temp.json(); + +// let currTemp = convertTemp(data.current.temp); + +// temperature.innerHTML = `${currTemp}℉`; + +// } +// catch(error) { +// console.log(error); +// } +// } + +// navigator.geolocation.getCurrentPosition(successfulLookup, console.log); +const cityState = document.querySelector(".cityState"); +const temperature = document.querySelector(".temperature"); +/* Helper Functions */ function convertTemp(temp) { const celsius = temp -273; let fahrenheit = Math.floor(celsius * (9/5) + 32); return fahrenheit; } - /* Fetch Functions */ - // Fetch location using Geolocator as shown in https://www.youtube.com/watch?v=Xd43hZKaUS0&feature=youtu.be const successfulLookup = async (position) => { try { - const {latitude, longitude} = position.coords; + const {latitude, longitude} = position.coords; const response = await fetch(`https://api.opencagedata.com/geocode/v1/json?q=${latitude}+${longitude}&key=68824d84dff94b6a8921c156b462a3d1`) const data = await response.json(); - - const cityData = data.results[0].components.city; + const city1 = data.results[0].components.city; const stateData = data.results[0].components.state_code; - - cityState.textContent = `${cityData}, ${stateData}`; - + cityState.textContent = `${city1}, ${stateData}`; + console.log(latitude, longitude) currentTemp(latitude, longitude); } catch(error) { console.log(error); } } - - - - // Fetch weather at openweathermap api const currentTemp = async (latitude, longitude) => { try { - const temp = await fetch(`https://api.openweathermap.org/data/2.5/onecall?lat=${latitude}&lon=${longitude}&exclude=minutely,hourly&exclude={part}&appid=0312d87f192d54ce3485295a535d403f=0312d87f192d54ce3485295a535d403f`) + const temp = await fetch(`https://api.openweathermap.org/data/2.5/onecall?lat=${latitude}&lon=${longitude}&exclude=minutely,hourly&exclude={part}&appid=0312d87f192d54ce3485295a535d403f`); const data = await temp.json(); - + console.log(data); let currTemp = convertTemp(data.current.temp); - temperature.innerHTML = `${currTemp}℉`; - } catch(error) { console.log(error); } } - - navigator.geolocation.getCurrentPosition(successfulLookup, console.log); \ No newline at end of file + navigator.geolocation.getCurrentPosition(successfulLookup, console.log); \ No newline at end of file From a9ba08cdf6a96e31c68ca77397450d6edd3fc3ee Mon Sep 17 00:00:00 2001 From: Katharyn Lynn Oggenfuss Date: Sun, 31 Jan 2021 20:30:54 -0500 Subject: [PATCH 08/10] changed element --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index fc1bcdc..46b35f9 100644 --- a/index.html +++ b/index.html @@ -8,7 +8,7 @@
-

Hola Mundo!

+

Hola Mundo!

Temperature

From 1a582f4a96e2a9db57e760d6840803593e1de356 Mon Sep 17 00:00:00 2001 From: Katharyn Lynn Oggenfuss Date: Sun, 31 Jan 2021 20:31:33 -0500 Subject: [PATCH 09/10] changed passed arguments --- weather.js | 64 +++++++----------------------------------------------- 1 file changed, 8 insertions(+), 56 deletions(-) diff --git a/weather.js b/weather.js index e955a95..87ff696 100644 --- a/weather.js +++ b/weather.js @@ -1,69 +1,19 @@ - - -// /* DOM Elements */ -// const cityState = document.querySelector(".cityState"); -// const temperature = document.querySelector(".temperature"); - - -// /* Helper Functions */ - -// function convertTemp(temp) { -// const celsius = temp -273; -// let fahrenheit = Math.floor(celsius * (9/5) + 32); -// return fahrenheit; -// } - -// /* Fetch Functions */ - -// // Fetch location using Geolocator as shown in https://www.youtube.com/watch?v=Xd43hZKaUS0&feature=youtu.be -// const successfulLookup = async (position) => { -// try { -// const {latitude, longitude} = position.coords; -// const response = await fetch(`https://api.opencagedata.com/geocode/v1/json?q=${latitude}+${longitude}&key=68824d84dff94b6a8921c156b462a3d1`) -// const data = await response.json(); - -// const cityData = data.results[0].components.city; -// const stateData = data.results[0].components.state_code; - -// cityState.textContent = `${cityData}, ${stateData}`; - -// currentTemp(latitude, longitude); -// } -// catch(error) { -// console.log(error); -// } -// } - - - - -// // Fetch weather at openweathermap api -// const currentTemp = async (latitude, longitude) => { -// try { -// const temp = await fetch(`https://api.openweathermap.org/data/2.5/onecall?lat=${latitude}&lon=${longitude}&exclude=minutely,hourly&exclude={part}&appid=0312d87f192d54ce3485295a535d403f=0312d87f192d54ce3485295a535d403f`) -// const data = await temp.json(); - -// let currTemp = convertTemp(data.current.temp); - -// temperature.innerHTML = `${currTemp}℉`; - -// } -// catch(error) { -// console.log(error); -// } -// } - -// navigator.geolocation.getCurrentPosition(successfulLookup, console.log); +/* DOM Elements */ const cityState = document.querySelector(".cityState"); const temperature = document.querySelector(".temperature"); + + /* Helper Functions */ function convertTemp(temp) { const celsius = temp -273; let fahrenheit = Math.floor(celsius * (9/5) + 32); return fahrenheit; } + + /* Fetch Functions */ + // Fetch location using Geolocator as shown in https://www.youtube.com/watch?v=Xd43hZKaUS0&feature=youtu.be const successfulLookup = async (position) => { try { @@ -80,6 +30,8 @@ function convertTemp(temp) { console.log(error); } } + + // Fetch weather at openweathermap api const currentTemp = async (latitude, longitude) => { try { From c0e1e52747040085ce6a40aa0798ebf91ba0eb48 Mon Sep 17 00:00:00 2001 From: Katharyn Lynn Oggenfuss Date: Sun, 31 Jan 2021 20:35:02 -0500 Subject: [PATCH 10/10] Update indexTemp.html --- indexTemp.html | 9 --------- 1 file changed, 9 deletions(-) diff --git a/indexTemp.html b/indexTemp.html index a02b12b..8b13789 100644 --- a/indexTemp.html +++ b/indexTemp.html @@ -1,10 +1 @@ - -
-

-
- -

-
-
-
\ No newline at end of file