Skip to content

Commit

Permalink
Update background
Browse files Browse the repository at this point in the history
  • Loading branch information
leonquenix committed Nov 22, 2023
1 parent 05a2f6b commit 21eca3b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
Binary file added background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 30 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
font-family: Arial, sans-serif;
margin: 0;
background-color: #ffffff; /* Set background color to white */
background-image: url('https://img.freepik.com/vetores-gratis/aquarela-floral-abstrato_52683-134424.jpg'); /* Add your floral background image */
background-image: url('./background.png'); /* Add your floral background image */
background-repeat: repeat; /* Repeat the background image */
background-size: cover; /* Cover the entire background */
}
Expand All @@ -38,18 +38,42 @@
const startDate = new Date('2023-08-28');
startDate.setDate(startDate.getDate() - (8 * 7 + 1));

function updateCounter() {
const now = new Date();
function getCounterOutput(date) {
const startDate = new Date('2023-08-28');
startDate.setDate(startDate.getDate() - (8 * 7 + 1));

const now = new Date(date);
const diffTime = Math.abs(now - startDate);
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
const diffWeeks = Math.floor(diffDays / 7);
const remainingDays = diffDays % 7;

document.getElementById('counter').textContent = `Maria Eduarda tem ${diffWeeks}
semanas e ${remainingDays} dias de vida 🥰👶`;
return `Maria Eduarda tem ${diffWeeks} semanas e ${remainingDays} dias de vida 🥰👶`;
}

// Generate dates between two dates
function getDates(startDate, endDate) {
const dates = [];
let currentDate = startDate;

while (currentDate <= endDate) {
dates.push(new Date(currentDate));
currentDate.setDate(currentDate.getDate() + 1);
}

return dates;
}

// Tests
getDates(new Date('2023-08-29'), new Date('2024-04-07')).forEach(date => {
console.log(date.toLocaleDateString(), getCounterOutput(date.toISOString().split('T')[0]));
});

function updateCounter() {
const now = new Date();
document.getElementById('counter').textContent = getCounterOutput(now);
}

updateCounter();
setInterval(updateCounter, 1000 * 60 * 60);
</script>
</body

0 comments on commit 21eca3b

Please sign in to comment.