some unrealated code from function. need to display current in progress time onto this…
- User
some unrealated code from function. need to display current in progress time onto this progress bar filled element and then switch back to fixed as it is right now.:
let startTime = null; let overallStartTime = null; let previousGenerationTime = null; let isFirstGeneration = true; function handleProgressBar() { const progressBarFilled = document.querySelector('.progress-bar-filled'); const currentTime = Date.now(); const secondsPassed = ((currentTime - overallStartTime) / 1000 - 1.5).toFixed(0); progressBarFilled.innerText = `done: ${secondsPassed} sec`; } async function generateImage() { if (isGenerating || autoQueueActive) { return; } if (galleryArray.length >= totalLimit) { if (autoSaveEnabled) { saveAllImages().then(() => { clearGallery(); }); } else { clearGallery(); } return; } function clearGallery() { galleryArray.length = 0; updateImageCounter(); bufferContainer.innerHTML = ''; if (autoQueueActive) { generateInterval = setInterval(generateImage, interval); } } isGenerating = true; startTime = Date.now(); overallStartTime = Date.now(); - Assistant
To display the current progress time on the progress bar filled element and then switch back to the fixed state, you can modify the
handleProgressBarfunction as follows:function handleProgressBar() { const progressBarFilled = document.querySelector('.progress-bar-filled'); const currentTime = Date.now(); const secondsPassed = ((currentTime - overallStartTime) / 1000 - 1.5).toFixed(0); // Display progress time progressBarFilled.innerText = `done: ${secondsPassed} sec`; // Switch back to fixed state after 3 seconds setTimeout(() => { progressBarFilled.innerText = 'fixed'; }, 3000); }By adding a
setTimeoutwithin thehandleProgressBarfunction, you can update the progress bar content to "fixed" after 3 seconds. This simulates switching back to the fixed state.