-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scissors - Christian #63
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Weather Report</title> | ||
|
||
|
||
|
||
|
||
</head> | ||
<body> | ||
<div id="parent-container"> | ||
<div id="title-container"> | ||
<h1> | ||
Weather Report | ||
</h1> | ||
<h4> | ||
For the lovely city of | ||
</h4> | ||
<h2 id="city-container"> | ||
My Hometown | ||
</h2> | ||
</div> | ||
<div id="cards-container"> | ||
<div id="column-1"> | ||
<div id="temperature-card"> | ||
<h2> | ||
Temperature | ||
</h2> | ||
<div id="up-arrow"> | ||
⬆️ | ||
</div> | ||
<div id="down-arrow"> | ||
⬇️ | ||
</div> | ||
<div id="temperature-indicator" style="color: orange"> | ||
71 | ||
</div> | ||
</div> | ||
<div id="sky-card"> | ||
<h2> | ||
Sky | ||
</h2> | ||
<select id="sky-type"> | ||
<option value="sunny"> | ||
Sunny | ||
</option> | ||
<option value="cloudy"> | ||
Cloudy | ||
</option> | ||
<option value="rainy"> | ||
Rainy | ||
</option> | ||
<option value="snowy"> | ||
snowy | ||
</option> | ||
</select> | ||
</div> | ||
<div id="city-name-card"> | ||
<h2> | ||
City Name | ||
</h2> | ||
<input id="city-name-input" type="text" value="My Hometown"> | ||
<button id="reset-button"> | ||
Reset | ||
</button> | ||
</div> | ||
|
||
</div> | ||
<div id="column-2"> | ||
<h3>Weather Garden</h3> | ||
<div id="landscape-card"> | ||
<p id="sky-landscape"> | ||
☁️ ☁️ ☁️ ☀️ ☁️ ☁️ | ||
</p> | ||
<br> | ||
<br> | ||
<p id="ground-landscape"> | ||
🌸🌿🌼__🌷🌻🌿_☘️🌱_🌻🌷 | ||
</p> | ||
</div> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
<script src="./scripts/index.js"></script> | ||
</body> | ||
|
||
</html> |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,74 @@ | ||||||
const setIndicatorColor = (tag, value) => { | ||||||
if (value >= 80) { | ||||||
tag.style.color = "red"; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider refactoring to assign a className, and then put the styles in the
|
||||||
} else if ((value >= 70) && (value <= 79)) { | ||||||
tag.style.color = "orange"; | ||||||
} else if ((value >= 60) && (value <= 69)) { | ||||||
tag.style.color = "yellow"; | ||||||
} else if ((value >= 50) && (value <= 59)) { | ||||||
tag.style.color = "green"; | ||||||
} else { | ||||||
tag.style.color = "teal" | ||||||
}; | ||||||
}; | ||||||
|
||||||
const setGroundLandscape = (tag, value) => { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Notice that |
||||||
if (value >= 80) { | ||||||
tag.textContent = "🌵__🐍_🦂_🌵🌵__🐍_🏜_🦂"; | ||||||
} else if ((value >= 70) && (value <= 79)) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor note: the && is not necessary for this conditional test, we could just have:
Suggested change
|
||||||
tag.textContent = "🌸🌿🌼__🌷🌻🌿_☘️🌱_🌻🌷"; | ||||||
} else if ((value >= 60) && (value <= 69)) { | ||||||
tag.textContent = "🌾🌾_🍃_🪨__🛤_🌾🌾🌾_🍃"; | ||||||
} else { | ||||||
tag.textContent = "🌲🌲⛄️🌲⛄️🍂🌲🍁🌲🌲⛄️🍂🌲"; | ||||||
}; | ||||||
}; | ||||||
|
||||||
const setSkyLandscape = (tag, value) => { | ||||||
if (value == "sunny") { | ||||||
tag.textContent = "☁️ ☁️ ☁️ ☀️ ☁️ ☁️"; | ||||||
} else if (value == "cloudy") { | ||||||
tag.textContent = "☁️☁️ ☁️ ☁️☁️ ☁️ 🌤 ☁️ ☁️☁️"; | ||||||
} else if (value == "rainy") { | ||||||
tag.textContent = "🌧🌈⛈🌧🌧💧⛈🌧🌦🌧💧🌧🌧 "; | ||||||
} else if (value == "snowy") { | ||||||
tag.textContent = "🌨❄️🌨🌨❄️❄️🌨❄️🌨❄️❄️🌨🌨 "; | ||||||
}; | ||||||
}; | ||||||
|
||||||
const changeSky = () => { | ||||||
var sky = document.getElementById("sky-landscape"); | ||||||
var weather = document.getElementById("sky-type"); | ||||||
var value = weather.value; | ||||||
setSkyLandscape(sky, value); | ||||||
}; | ||||||
|
||||||
var skyType = document.getElementById("sky-type"); | ||||||
skyType.addEventListener("change", changeSky); | ||||||
|
||||||
const increaseTemp = () => { | ||||||
var indicator = document.getElementById("temperature-indicator"); | ||||||
var ground = document.getElementById("ground-landscape"); | ||||||
var temperature = parseInt(indicator.textContent); | ||||||
//temperature++; | ||||||
indicator.textContent = ++temperature; | ||||||
setIndicatorColor(indicator, temperature); | ||||||
setGroundLandscape(ground, temperature); | ||||||
}; | ||||||
|
||||||
var upArrow = document.getElementById("up-arrow"); | ||||||
upArrow.addEventListener("click", increaseTemp, false); | ||||||
|
||||||
const decreaseTemp = () => { | ||||||
var indicator = document.getElementById("temperature-indicator"); | ||||||
var ground = document.getElementById("ground-landscape"); | ||||||
var temperature = parseInt(indicator.textContent); | ||||||
//temperature = temperature - 1; | ||||||
indicator.textContent = --temperature; | ||||||
setIndicatorColor(indicator, temperature); | ||||||
setGroundLandscape(ground, temperature); | ||||||
}; | ||||||
|
||||||
var downArrow = document.getElementById("down-arrow"); | ||||||
downArrow.addEventListener("click", decreaseTemp, false); | ||||||
Comment on lines
+72
to
+73
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider moving all the Event Listener logic into a function called |
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good, clear, semantic HTML. Nice work!