Skip to content

C24 Possum/Crow Esmeralda & Riley#6

Open
rileydrellishak wants to merge 18 commits into
Ada-C24:mainfrom
rileydrellishak:main
Open

C24 Possum/Crow Esmeralda & Riley#6
rileydrellishak wants to merge 18 commits into
Ada-C24:mainfrom
rileydrellishak:main

Conversation

@rileydrellishak

Copy link
Copy Markdown

No description provided.

@mikellewade mikellewade left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rileydrellishak & @esmerarre, nice work on your weather report project! Sorry for the delay! Even instructors have a backlog sometimes!

Comment thread src/index.js
@@ -0,0 +1,179 @@
const proxyServerURL = 'https://ada-weather-report-proxy-server.onrender.com';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this variable is a true constant, you could follow the convention of the naming the variable in upper/snakecase.

const BASE_URL = 'https://ada-weather-report-proxy-server.onrender.com';

Comment thread src/index.js
const proxyServerURL = 'https://ada-weather-report-proxy-server.onrender.com';

const findLatAndLon = (cityName) => {
let lat, lon;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declaring these variable here makes me think that they will be accessed somewhere in addition to the assignment located in your .then chain. Being they are only being declared here, I would suggest you move the declaration/assignment into the .then entirely. This would also be more secure since it would be locally scoped to the callback of the .then.

Suggested change
let lat, lon;

Comment thread src/index.js
Comment on lines +7 to +8
lat = response.data[0].lat;
lon = response.data[0].lon;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
lat = response.data[0].lat;
lon = response.data[0].lon;
const lat = response.data[0].lat;
const lon = response.data[0].lon;

Comment thread src/index.js
.then( (response) => {
lat = response.data[0].lat;
lon = response.data[0].lon;
return {lat, lon};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return {lat, lon};
return { lat, lon };

Comment thread src/index.js
};

const getWeatherFromLatAndLon = (latitude, longitude) => {
let temp;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same feedback as the let lat, lon; declaration/assignment.

Comment thread src/index.js
Comment on lines +122 to +123
let currentText = document.querySelector('#cityNameInput').value;
let cityHeader = document.querySelector('#headerCityName');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let currentText = document.querySelector('#cityNameInput').value;
let cityHeader = document.querySelector('#headerCityName');
const currentText = document.querySelector('#cityNameInput').value;
const cityHeader = document.querySelector('#headerCityName');

Comment thread src/index.js
Comment on lines +129 to +130
let currentText = document.querySelector('#cityNameInput');
let cityHeader = document.querySelector('#headerCityName');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let currentText = document.querySelector('#cityNameInput');
let cityHeader = document.querySelector('#headerCityName');
const currentText = document.querySelector('#cityNameInput');
const cityHeader = document.querySelector('#headerCityName');

Comment thread src/index.js
Comment on lines +136 to +154
const registerEventHandlers = () => {
const increaseTempControl = document.querySelector('#increaseTempControl');
increaseTempControl.addEventListener('click', increaseTemp);

const decreaseTempControl = document.querySelector('#decreaseTempControl');
decreaseTempControl.addEventListener('click', decreaseTemp);

const changeSkyControl = document.querySelector('#skySelect');
changeSkyControl.addEventListener('change', changeSky);

const cityText = document.querySelector('#cityNameInput');
cityText.addEventListener('keyup', updateCityName);

const resetCity = document.querySelector('#cityNameReset');
resetCity.addEventListener('click', resetCityNameButton);

const getCurrentTemp = document.querySelector('#currentTempButton');
getCurrentTemp.addEventListener('click', getWeatherFromCityName);
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread src/index.js
Comment on lines +156 to +172
const loadControls = () => {
state.tempValue = document.getElementById('tempValue');
state.tempValue.textContent = state.tempNum;
state.tempValue.classList.add('orange');

state.gardenLandscape = document.getElementById('landscape');
state.gardenLandscape.textContent = state.gardenLandscapeText;

state.gardenSkyline = document.getElementById('sky');
state.gardenSkyline.textContent = state.gardenSkyText;

state.gardenContainer = document.getElementById('gardenContent');
state.gardenContainer.classList.add('sunny');

state.headerCityName = document.getElementById('headerCityName');
state.headerCityName.textContent = state.cityName;
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread src/index.js
Comment on lines +174 to +179
const onLoaded = () => {
loadControls();
registerEventHandlers();
};

onLoaded(); No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest just moving the logic of adding event handlers to their respective HTML elements into something like document.addEventListener("DOMContentLoaded", RegisterEventHandlers);. That way we register the event handler functions to run when the DOM content has fully loaded. This ensures all HTML elements and resources are available before attempting to attach event handlers or manipulate the DOM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants