const PAGE_SIZE = 24; let page = 1; let totalPhotos = 0; let currentPhotos = []; let groupsLoaded = false; let studentsLoaded = false; let sourcesLoaded = false; let searchTimer = null; function humanSize(b) { if (!b) return ''; if (b < 1024) return b + ' Б'; if (b < 1048576) return (b / 1024).toFixed(1) + ' КБ'; return (b / 1048576).toFixed(1) + ' МБ'; } function photoLink(p) { if (p.source_type === 'entry') return `journal.html#entry-${p.source_id}`; if (p.source_type === 'entry_photo') return `journal.html#entry-${p.source_id}`; if (p.source_type === 'group_photo') return 'groups.html'; if (p.source_type === 'student_photo') return 'students.html'; if (p.source_type === 'module_photo') return 'modules.html'; return ''; } function photoCardHTML(p) { const url = p.path; const meta = []; if (p.student_name) meta.push(esc(p.student_name)); if (p.group_name) meta.push(esc(p.group_name)); const link = photoLink(p); return `