MCPcopy Create free account
hub / github.com/error311/FileRise / renderGallery

Function renderGallery

public/js/sharedFolderView.js:787–857  ·  view source on GitHub ↗
(items)

Source from the content-addressed store, hash-verified

785 }
786
787 function renderGallery(items) {
788 if (!galleryEl) return;
789 galleryEl.textContent = '';
790
791 items.forEach((entry) => {
792 const name = String(entry.name || '');
793 const type = String(entry.type || 'file');
794 const isFolder = type === 'folder';
795 const fullPath = joinPath(currentPath, name);
796
797 const card = document.createElement('div');
798 card.className = 'fr-share-card-item ' + (isFolder ? 'is-folder' : 'is-file');
799
800 const preview = document.createElement('div');
801 preview.className = 'fr-share-card-preview';
802
803 if (isFolder) {
804 const icon = document.createElement('div');
805 icon.className = 'fr-share-icon fr-share-icon-folder';
806 icon.textContent = 'DIR';
807 preview.appendChild(icon);
808 } else {
809 const previewType = getPreviewType(name);
810 if (previewType === 'image') {
811 const img = document.createElement('img');
812 img.src = buildDownloadFileUrl(fullPath, true);
813 img.alt = name;
814 preview.appendChild(img);
815 } else {
816 const icon = document.createElement('div');
817 icon.className = 'fr-share-icon fr-share-icon-file';
818 const ext = getExt(name).toUpperCase();
819 icon.textContent = ext ? ext.slice(0, 4) : 'FILE';
820 preview.appendChild(icon);
821 }
822 }
823
824 const meta = document.createElement('div');
825 meta.className = 'fr-share-card-meta';
826
827 const title = document.createElement('div');
828 title.className = 'fr-share-card-title';
829 title.textContent = name || '(unnamed)';
830 meta.appendChild(title);
831
832 if (!isFolder) {
833 const sub = document.createElement('div');
834 sub.className = 'fr-share-card-sub';
835 sub.textContent = formatBytes(entry.size);
836 meta.appendChild(sub);
837 }
838
839 card.appendChild(preview);
840 card.appendChild(meta);
841
842 card.addEventListener('click', function () {
843 if (isFolder) {
844 window.location.href = buildShareUrl(fullPath);

Callers 1

renderAllFunction · 0.85

Calls 7

joinPathFunction · 0.85
getPreviewTypeFunction · 0.85
buildDownloadFileUrlFunction · 0.85
openMethod · 0.80
getExtFunction · 0.70
formatBytesFunction · 0.70
buildShareUrlFunction · 0.70

Tested by

no test coverage detected