()
| 12742 | thumbnailContainer.appendChild(printStatus); |
| 12743 | |
| 12744 | fileElement.appendChild(thumbnailContainer); |
| 12745 | |
| 12746 | // Create file info container |
| 12747 | const fileInfo = document.createElement('div'); |
| 12748 | fileInfo.className = 'file-info'; |
| 12749 | |
| 12750 | // Add file name element |
| 12751 | const fileName = document.createElement('div'); |
| 12752 | fileName.className = 'file-name'; |
| 12753 | fileName.textContent = path.basename(model.filePath); |
| 12754 | fileInfo.appendChild(fileName); |
| 12755 | |
| 12756 | // Add file details |
| 12757 | const fileDetails = document.createElement('div'); |
| 12758 | fileDetails.className = 'file-details'; |
| 12759 | fileDetails.textContent = 'Loading...'; |
| 12760 | fileInfo.appendChild(fileDetails); |
| 12761 | |
| 12762 | fileElement.appendChild(fileInfo); |
| 12763 | |
| 12764 | // Add click handler |
| 12765 | fileElement.addEventListener('click', (e) => handleFileClick(e, model.filePath)); |
| 12766 | |
| 12767 | // Add context menu handler |
| 12768 | addContextMenuHandler(fileElement, model.filePath); |
| 12769 | |
| 12770 | fragment.appendChild(fileElement); |
| 12771 | }); |
| 12772 | |
| 12773 | grid.appendChild(fragment); |
| 12774 | |
| 12775 | // Start loading models and rendering thumbnails |
| 12776 | loadAndRenderModels(modelRefs); |
| 12777 | |
| 12778 | // Hide spinner when initial rendering is done |
| 12779 | document.getElementById('spinner').classList.add('hidden'); |
| 12780 | |
| 12781 | } catch (error) { |
| 12782 | console.error('Error initializing virtual scrolling:', error); |
| 12783 | document.getElementById('spinner').classList.add('hidden'); |
| 12784 | } |
| 12785 | } |
| 12786 | |
| 12787 | // Add this helper function to load and render models |
| 12788 | async function loadAndRenderModels(modelRefs, batchSize = 20) { |
| 12789 | if (!modelRefs || !Array.isArray(modelRefs)) { |
| 12790 | console.warn('Invalid model references provided to loadAndRenderModels'); |
no test coverage detected