-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* trying to fix background * styling * last edit of the day * including left out files * small edit * updated functions * added checkboxes * added button to refresh data(CRUD delete) * moved button * added image * added background * updated image * updated logo * fixed image * updated checkboxes * added html * added new Logo * changed image * added Plan drawing * fixed checkbox box * updated buttons * added font style * added delete button * complete app * added logo * updatet css * added shadow to text * updated bergen --------- Co-authored-by: bax082024 <bax082024@gmail.com>
- Loading branch information
Showing
12 changed files
with
301 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/obj | ||
/bin | ||
wwwroot/ | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,54 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Bax Weather Network</title> | ||
<link rel="stylesheet" href="styles.css" /> | ||
</head> | ||
<body> | ||
<header> | ||
<h1 class="logo">Bax Weather Network</h1> | ||
<p class="local-only">Local weather ONLY</p> | ||
</header> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Bax Weather Network</title> | ||
<link rel="stylesheet" href="styles.css" /> | ||
<script defer src="script.js"></script> | ||
|
||
|
||
<div class="divider-line"></div> | ||
<main> | ||
|
||
</head> | ||
<body> | ||
<header> | ||
<div class="logo"> | ||
<img src="images/BaxAma2.png" alt="BaxAma"> | ||
</div> | ||
</header> | ||
|
||
<main> | ||
<div class="content-wrapper"> | ||
<div class="weather-container"> | ||
<h1 class="bergen">Bergen</h1> | ||
<p>Current weather in Bergen, Norway.</p> | ||
<p>_____________________________</p> | ||
<hr class="divider"> | ||
<p id="temperature">Temperature: Loading...</p> | ||
<p id="windspeed">Windspeed: Loading...</p> | ||
<p id="condition">Condition: Loading...</p> | ||
</div> | ||
</main> | ||
|
||
<script> | ||
async function fetchWeather() { | ||
try { | ||
const response = await fetch("/api/weather"); | ||
if (!response.ok) { | ||
throw new Error("Failed to fetch weather data"); | ||
} | ||
<p id="is-day">Day or Night: Loading...</p> | ||
<p id="visibility">Visibility: Loading...</p> | ||
<p id="humidity">Humidity: Loading...</p> | ||
<p id="windspeed">Windspeed: Loading...</p> | ||
|
||
const weatherData = await response.json(); | ||
console.log("Received Weather Data: ", weatherData); | ||
<button id="refreshButton">Refresh Weather Data</button> | ||
</div> | ||
|
||
// Update the HTML elements with the fetched data | ||
document.getElementById("temperature").innerText = `Temperature: ${weatherData.temperature}`; | ||
document.getElementById("windspeed").innerText = `Windspeed: ${weatherData.windspeed}`; | ||
document.getElementById("condition").innerText = `Condition: ${weatherData.condition}`; | ||
|
||
} catch (error) { | ||
console.error("Error: ", error.message); | ||
document.getElementById("temperature").innerText = "Temperature: Error"; | ||
document.getElementById("windspeed").innerText = "Windspeed: Error"; | ||
document.getElementById("condition").innerText = "Condition: Error"; | ||
} | ||
} | ||
<div class="checkbox-container"> | ||
<div class="checkbox-list minimized"> | ||
<p class="choose-condition">Choose conditions</p> | ||
<label><input type="checkbox" id="toggle-temperature" checked> Temperature</label><br> | ||
<label><input type="checkbox" id="toggle-windspeed" checked> Windspeed</label><br> | ||
<label><input type="checkbox" id="toggle-condition" checked> Condition</label><br> | ||
<label><input type="checkbox" id="toggle-is-day" checked> Day or Night</label><br> | ||
<label><input type="checkbox" id="toggle-visibility" checked> Visibility</label><br> | ||
<label><input type="checkbox" id="toggle-humidity" checked> Humidity</label><br> | ||
|
||
// Call the function when the page loads | ||
window.onload = fetchWeather; | ||
</script> | ||
</body> | ||
</html> | ||
<button id="resetButton" onclick="resetSelection()">Delete</button> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
</main> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// Function to uncheck all checkboxes | ||
function resetSelection() { | ||
const checkboxes = document.querySelectorAll('.checkbox-list input[type="checkbox"]'); | ||
|
||
checkboxes.forEach(checkbox => { | ||
checkbox.checked = false; | ||
}); | ||
|
||
toggleElements(); | ||
} | ||
|
||
document.getElementById("resetButton").addEventListener("click", resetSelection); | ||
|
||
window.onload = function () { | ||
fetchWeather(); | ||
toggleElements(); | ||
document.getElementById("refreshButton").addEventListener("click", refreshWeather); // Add the event listener for the refresh button here | ||
}; | ||
|
||
// Function to toggle visibility of weather elements based on checkbox states | ||
function toggleElements() { | ||
const temperatureEl = document.getElementById("temperature"); | ||
const windspeedEl = document.getElementById("windspeed"); | ||
const conditionEl = document.getElementById("condition"); | ||
const isDayEl = document.getElementById("is-day"); | ||
const visibilityEl = document.getElementById("visibility"); | ||
const humidityEl = document.getElementById("humidity"); | ||
|
||
if (temperatureEl && windspeedEl && conditionEl && isDayEl && visibilityEl && humidityEl) { | ||
temperatureEl.style.display = document.getElementById("toggle-temperature").checked ? "block" : "none"; | ||
windspeedEl.style.display = document.getElementById("toggle-windspeed").checked ? "block" : "none"; | ||
conditionEl.style.display = document.getElementById("toggle-condition").checked ? "block" : "none"; | ||
isDayEl.style.display = document.getElementById("toggle-is-day").checked ? "block" : "none"; | ||
visibilityEl.style.display = document.getElementById("toggle-visibility").checked ? "block" : "none"; | ||
humidityEl.style.display = document.getElementById("toggle-humidity").checked ? "block" : "none"; | ||
} | ||
} | ||
|
||
document.querySelectorAll('input[type="checkbox"]').forEach((checkbox) => { | ||
checkbox.addEventListener('change', toggleElements); | ||
}); | ||
|
||
// Fetch weather data function | ||
async function fetchWeather() { | ||
try { | ||
const response = await fetch("/api/weather"); | ||
if (!response.ok) { | ||
throw new Error("Failed to fetch weather data"); | ||
} | ||
|
||
const weatherData = await response.json(); | ||
console.log("Received Weather Data: ", weatherData); // Added to check that Api data is received | ||
|
||
// Ensure weatherData contains the required fields | ||
if (weatherData) { | ||
// Update the HTML elements with the fetched data | ||
document.getElementById("temperature").innerText = `Temperature: ${weatherData.temperature || 'N/A'}`; | ||
document.getElementById("windspeed").innerText = `Windspeed: ${weatherData.windspeed || 'N/A'}`; | ||
document.getElementById("condition").innerText = `Condition: ${weatherData.condition || 'N/A'}`; | ||
document.getElementById("is-day").innerText = `Day or Night: ${weatherData.isDay || 'N/A'}`; | ||
document.getElementById("visibility").innerText = `Visibility: ${weatherData.visibility || 'N/A'}`; | ||
document.getElementById("humidity").innerText = `Humidity: ${weatherData.humidity || 'N/A'}`; | ||
} | ||
} catch (error) { | ||
console.error("Error fetching weather data: ", error.message); | ||
|
||
// Handle errors by showing "Error" in the text fields | ||
document.getElementById("temperature").innerText = "Temperature: Error"; | ||
document.getElementById("windspeed").innerText = "Windspeed: Error"; | ||
document.getElementById("condition").innerText = "Condition: Error"; | ||
document.getElementById("is-day").innerText = "Day or Night: Error"; | ||
document.getElementById("visibility").innerText = "Visibility: Error"; | ||
document.getElementById("humidity").innerText = "Humidity: Error"; | ||
} | ||
} | ||
|
||
// Function to refresh weather data | ||
function refreshWeather() { | ||
|
||
document.getElementById("temperature").innerText = "Temperature: Loading..."; | ||
document.getElementById("windspeed").innerText = "Windspeed: Loading..."; | ||
document.getElementById("condition").innerText = "Condition: Loading..."; | ||
document.getElementById("is-day").innerText = "Day or Night: Loading..."; | ||
document.getElementById("visibility").innerText = "Visibility: Loading..."; | ||
document.getElementById("humidity").innerText = "Humidity: Loading..."; | ||
|
||
|
||
fetchWeather(); | ||
} |
Oops, something went wrong.