progressBarFilled.innerText = done: ${secondsPassed} sec;
}
previousGenerationTime = Date.now();
} else {
progressBarFilled.innerText = ‘’;
}
}
// Call the handleProgressBar function periodically based on generateImage procession
setInterval(handleProgressBar, 1000);

Now, the setInterval only includes the handleProgressBar function, which will be called every second to update the progress bar based on the isGenerating state and the elapsed time since the last generation. The generateImage function can be invoked separately as needed without being triggered by the interval.

you cannot use funct by funct evaluations in intervals in javascript or what? as: "setInterval(handleProgressBar - generateImage) / 1000;" progbar will be based on genimg.

Apologies for the confusion. You’re correct that you can’t directly use function evaluations in setInterval in JavaScript. The setInterval function requires a reference to a single function to be called at the specified interval.
If you want the handleProgressBar function to be called periodically based on the processing of the generateImage function, you can modify the code as follows:

let startTime = null;
let previousGenerationTime = null;
let isFirstGeneration = true;
function generateImage() {
isGenerating = true;
// Rest of the generateImage logic
isGenerating = false;
}
function handleProgressBar() {
const progressBarFilled = document.querySelector(‘.progress-bar-filled’);
if (isGenerating || isFirstGeneration) {
if (isFirstGeneration) {
startTime = Date.now();
isFirstGeneration = false;
progressBarFilled.innerText = ‘loading’;
} else {
const currentTime = Date.now();
const secondsPassed = Math.floor((currentTime - previousGenerationTime) / 1000);
progressBarFilled.innerText = done: ${secondsPassed} sec;
}
previousGenerationTime = Date.now();
} else {
progressBarFilled.innerText = ‘’;
}
}
// Call the handleProgressBar function periodically and trigger the generateImage function in that interval
setInterval(() => {
generateImage();
handleProgressBar();
}, 1000);

In this updated code, the generateImage function is called within the interval, followed by the handleProgressBar function. This way, the handleProgressBar function will be called periodically based on the processing of the generateImage function.

because in that case it can complexify things in what is based on which timer here, which is all wrong.

Apologies for the confusion. If you want the handleProgressBar function to be called periodically based on the processing time of the generateImage function, you can modify the code as follows:

let startTime = null;
let previousGenerationTime = null;
let isFirstGeneration = true;
function generateImage() {
isGenerating = true;
// Rest of the generateImage logic
isGenerating = false;
}
function handleProgressBar() {
const progressBarFilled = document.querySelector(‘.progress-bar-filled’);
if (isGenerating || isFirstGeneration) {
if (isFirstGeneration) {
startTime = Date.now();
isFirstGeneration = false;
progressBarFilled.innerText = ‘loading’;
} else {
const currentTime = Date.now();
const secondsPassed = Math.floor((currentTime - previousGenerationTime) / 1000);
progressBarFilled.innerText = done: ${secondsPassed} sec;
}
previousGenerationTime = Date.now();
} else {
progressBarFilled.innerText = ‘’;
}
}
// Call the handleProgressBar function periodically
setInterval(handleProgressBar, 1000);
// Trigger the generateImage function separately as needed
generateImage();

In this updated code, the handleProgressBar function is called periodically using setInterval to update the progress bar. The generateImage function is triggered separately as needed, unaffected by the interval. This way, the handleProgressBar function will be based on the processing time of the generateImage function without triggering the generateImage function itself within the setInterval.

no, I'm just saying that everything is wrong in all these motherfucking programmings and javascripts.

I apologize if I couldn’t provide a satisfactory solution for your specific requirements. If you need any further assistance or have any specific concerns, please let me know, and I’ll do my best to assist you.

"please let me know". write some poem on how everything is wrong in programmings.