try to fix that "maptobraille" to show only 3 decimal places or 3 braille characters:…
- User
try to fix that "maptobraille" to show only 3 decimal places or 3 braille characters: ```let overallStartTime = null; let isFirstGeneration = true; let brailleStartTime = null; function handleProgressBar() { const progressBarFilled = document.querySelector('.progress-bar-filled'); const currentTime = Date.now();
const normalSecondsPassed = Math.max(Math.round((currentTime - overallStartTime) / 1000) - 1, 0);
const brailleSecondsPassed = Math.round((currentTime - brailleStartTime) / 1000); function mapToBraille(time) { const brailleDigits = ['⠝', '⠷', '⠾', '⠄', '⠑', '⠭', '⠱', '⠚', '⠆', '⠤']; const timeString = time.toFixed(2).toString(); let brailleResult = ''; for (let i = 0; i < timeString.length; i++) { const digit = parseInt(timeString[i]); brailleResult += brailleDigits[digit]; } return brailleResult; } if (isGenerating) { const activeTime = normalSecondsPassed - Math.floor(normalSecondsPassed / 10); const brailleTime = mapToBraille(brailleSecondsPassed); progressBarFilled.innerHTML = 'processing ' + brailleTime + ' ' + activeTime + ' sec'; } else { const brailleTime = mapToBraille(brailleSecondsPassed); progressBarFilled.innerHTML = 'done: ' + brailleTime + ' ' + 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 = Date.now(); overallStartTime = Date.now(); updateProgress();```
- Assistant
Here's the modified code to show only 3 decimal places or 3 braille characters:
let overallStartTime = null; let isFirstGeneration = true; let brailleStartTime = null; function handleProgressBar() { const progressBarFilled = document.querySelector('.progress-bar-filled'); const currentTime = Date.now(); const normalSecondsPassed = Math.max(Math.round((currentTime - overallStartTime) / 1000) - 1, 0); const brailleSecondsPassed = Math.round((currentTime - brailleStartTime) / 1000); function mapToBraille(time) { const brailleDigits = ['⠝', '⠷', '⠾', '⠄', '⠑', '⠭', '⠱', '⠚', '⠆', '⠤']; const timeString = time.toFixed(3).toString(); let brailleResult = ''; for (let i = 0; i < timeString.length; i++) { const digit = parseInt(timeString[i]); brailleResult += brailleDigits[digit]; } return brailleResult; } if (isGenerating) { const activeTime = normalSecondsPassed - Math.floor(normalSecondsPassed / 10); const brailleTime = mapToBraille(brailleSecondsPassed); progressBarFilled.innerHTML = 'processing ' + brailleTime + ' ' + activeTime + ' sec'; } else { const brailleTime = mapToBraille(brailleSecondsPassed); progressBarFilled.innerHTML = 'done: ' + brailleTime + ' ' + 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 = Date.now(); overallStartTime = Date.now(); updateProgress(); }