Current directory: /home/klas4s23/domains/585455.klas4s23.mid-ica.nl/public_html/Gastenboek/uploads
// Get the element with the class you want to update
const bar = document.querySelector('.progress');
const text = document.querySelector('.progress-text');
// Function to update the width
function updateWidth() {
// Calculate the new width here
const newWidth = calculateProgress();
// Update the width of the element
bar.style.width = newWidth + '%';
text.innerHTML = newWidth.toFixed(8) + '%';
// Call the function again on the next frame
requestAnimationFrame(updateWidth);
}
function calculateProgress() {
const currentDate = new Date();
const startOfYear = new Date(currentDate.getFullYear(), 0, 1);
const endOfYear = new Date(currentDate.getFullYear(), 11, 32);
const totalDays = (endOfYear - startOfYear) / (1000 * 60 * 60 * 24);
const passedDays = (currentDate - startOfYear) / (1000 * 60 * 60 * 24);
const progress = (passedDays / totalDays) * 100;
return progress;
}
// Call the function to start updating the width
updateWidth();