Skip to content

Commit

Permalink
Update index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
Weather-Arkansas authored Sep 6, 2024
1 parent 5449cd9 commit 291a540
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,45 @@ <h1>Welcome to Weather Arkansas</h1>
const rainContainer = document.querySelector('.rain');
const sun = document.querySelector('.sun');
const content = document.querySelector('.content');

// Function to set a cookie
function setCookie(name, value, days) {
const date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
const expires = "expires=" + date.toUTCString();
document.cookie = name + "=" + value + ";" + expires + ";path=/";
}

// Function to get a cookie
function getCookie(name) {
const cname = name + "=";
const decodedCookie = decodeURIComponent(document.cookie);
const ca = decodedCookie.split(';');
for (let i = 0; i < ca.length; i++) {
let c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(cname) == 0) {
return c.substring(cname.length, c.length);
}
}
return "";
}

// Check if it's raining from the cookie
const isRaining = getCookie("isRaining") === "true";

if (isRaining) {
rainContainer.style.display = 'block';
document.body.style.background = '#2F4F4F'; // Dark slate gray background
content.style.color = '#fff'; // White text color
sun.style.display = 'none'; // Hide the sun
clouds.forEach(cloud => {
cloud.style.background = '#A9A9A9'; // Dark grey clouds
});
}

setInterval(() => {
rainContainer.style.display = 'block';
document.body.style.background = '#2F4F4F'; // Dark slate gray background
Expand All @@ -155,6 +194,7 @@ <h1>Welcome to Weather Arkansas</h1>
clouds.forEach(cloud => {
cloud.style.background = '#A9A9A9'; // Dark grey clouds
});
setCookie("isRaining", "true", 1); // Set cookie to remember it's raining
for (let i = 0; i < 100; i++) {
const raindrop = document.createElement('div');
raindrop.classList.add('raindrop');
Expand All @@ -170,6 +210,7 @@ <h1>Welcome to Weather Arkansas</h1>
clouds.forEach(cloud => {
cloud.style.background = '#fff'; // White clouds
});
setCookie("isRaining", "false", 1); // Set cookie to remember it's not raining
while (rainContainer.firstChild) {
rainContainer.removeChild(rainContainer.firstChild);
}
Expand All @@ -179,3 +220,4 @@ <h1>Welcome to Weather Arkansas</h1>
</script>
</body>
</html>

0 comments on commit 291a540

Please sign in to comment.