need to do styles for '⠿⠿⠿' in green color when it's done, and for "brailleTime" when…
- User
need to do styles for '⠿⠿⠿' in green color when it's done, and for "brailleTime" when it's in activetime as red.:let overallStartTime = null; function handleProgressBar() { const progressBarFilled = document.querySelector('.progress-bar-filled'); const currentTime = performance.now(); const normalSecondsPassed = Math.ceil((currentTime - overallStartTime) / 900) - 1; const brailleSecondsPassed = Math.ceil((currentTime - overallStartTime) / 90) - 1; function mapToBraille(time) { const brailleDigits = ['⠝', '⠷', '⠾', '⠄', '⠑', '⠭', '⠱', '⠚', '⠆', '⠤']; const seconds = Math.floor(time) % 1000; let brailleResult = ''; const secondsString = seconds.toString().padStart(3, '0'); for (let i = 0; i < secondsString.length; i++) { const digit = parseInt(secondsString[i]); if (!isNaN(digit)) { brailleResult += brailleDigits[digit]; } } return brailleResult; } const brailleTime = mapToBraille(brailleSecondsPassed); if (isGenerating) { const activeTime = normalSecondsPassed - Math.floor(normalSecondsPassed / 10); progressBarFilled.innerHTML = brailleTime + ' ' + activeTime + ' sec'; } else { progressBarFilled.innerHTML = '⠿⠿⠿' + ' ' + normalSecondsPassed + ' sec'; } } async function generateImage() { if (isGenerating || autoQueueActive) { return; } if (galleryArray.length >= totalLimit) { if (autoSaveEnabled) { saveAllImages().then(() => { clearGallery(); }); } else { clearGallery(); } return; } function updateProgress() { handleProgressBar(); if (isGenerating) { requestAnimationFrame(updateProgress); } } function clearGallery() { galleryArray.length = 0; updateImageCounter(); bufferContainer.innerHTML = ''; if (autoQueueActive) { generateInterval = setInterval(generateImage, interval); } } isGenerating = true; startTime = performance.now(); overallStartTime = performance.now(); updateProgress();
To style the ‘⠿⠿⠿’ in green, you can add the following code:
const progressBarFilled = document.querySelector(‘.progress-bar-filled’); progressBarFilled.innerHTML = ‘<span style=“color: green;”>⠿⠿⠿’ + ’ ’ + normalSecondsPassed + ’ sec’;
To style “brailleTime” in red when it’s in active time, you can add the following code:
if (isGenerating) { const activeTime = normalSecondsPassed - Math.floor(normalSecondsPassed / 10); progressBarFilled.innerHTML = ‘<span style=“color: red;”>’ + brailleTime + ‘’ + ’ ’ + activeTime + ’ sec’; } else { progressBarFilled.innerHTML = ‘⠿⠿⠿’ + ’ ’ + normalSecondsPassed + ’ sec’; }
Make sure to place the code in the appropriate places within your existing code.
why the fuck it tells "Uncaught SyntaxError: unexpected token: identifier" on?: progressBarFilled.innerHTML = '⠿⠿⠿' + ' ' + normalSecondsPassed + ' sec';. ok, cover them all in s, including activeTime, sec, normalSecondsPassed.
- Assistant
The reason for the "Uncaught SyntaxError: unexpected token: identifier" error is that you are using single quotes within single quotes without escaping them properly. To resolve the issue, you can change the inner quotes to double quotes or use escape characters for the inner quotes.
Corrected code:
progressBarFilled.innerHTML = "⠿⠿⠿" + ' ' + normalSecondsPassed + ' sec';
To cover all the elements in
<sub>tags, you can modify the code as follows:progressBarFilled.innerHTML = "𝧍𝦿𝦿" + ' ' + normalSecondsPassed + ' sec';
This will wrap the '⠿⠿⠿' and 'sec' in
<span>tags and the 'normalSecondsPassed' in a<sub>tag. - User
no, just cover them all completely in s: progressBarFilled.innerHTML = '' + brailleTime + '' + ' ' + activeTime + ' sec'; } else { progressBarFilled.innerHTML = '⠿⠿⠿' + ' ' + normalSecondsPassed + ' sec';
- Assistant
Apologies for the misunderstanding. You can cover all the elements completely in
<sub>tags by modifying the code as follows:codeprogressBarFilled.innerHTML = `<sub style="color: red;">${brailleTime}</sub> <sub style="color: red;">${activeTime}</sub> <sub>sec</sub>`; } else { progressBarFilled.innerHTML = `<span style="color: green;">⠿⠿⠿</span> <sub>${normalSecondsPassed}</sub> <sub>sec</sub>`;This will wrap
brailleTime,activeTime,normalSecondsPassed, and 'sec' in<sub>tags, applying the specified styles accordingly.