(page)
| 415 | const totalPages = Math.ceil(total / pageSize); |
| 416 | |
| 417 | function drawPage(page) { |
| 418 | const endIdx = Math.min(page * pageSize, total); |
| 419 | const visible = subfolders.slice(0, endIdx); |
| 420 | |
| 421 | const badgeText = formatSourceBadgeText(getSourceMetaById(sourceId)); |
| 422 | const badgeHtml = badgeText |
| 423 | ? `<div class="folder-strip-badge fr-source-badge" title="Source: ${escapeHTML(badgeText)}">${escapeHTML(badgeText)}</div>` |
| 424 | : ''; |
| 425 | |
| 426 | let html = badgeHtml + visible.map(sf => ` |
| 427 | <div class="folder-item" |
| 428 | data-folder="${sf.full}" |
| 429 | draggable="true"> |
| 430 | <span class="folder-svg"></span> |
| 431 | <div class="folder-name"> |
| 432 | ${escapeHTML(sf.name)} |
| 433 | </div> |
| 434 | </div> |
| 435 | `).join(""); |
| 436 | |
| 437 | if (endIdx < total) { |
| 438 | html += ` |
| 439 | <button type="button" |
| 440 | class="folder-strip-load-more"> |
| 441 | ${t('load_more_folders') || t('load_more') || 'Load more folders'} |
| 442 | </button> |
| 443 | `; |
| 444 | } |
| 445 | |
| 446 | strip.innerHTML = html; |
| 447 | |
| 448 | applyFolderStripLayout(strip); |
| 449 | wireFolderStripItems(strip, sourceId); |
| 450 | |
| 451 | const loadMoreBtn = strip.querySelector(".folder-strip-load-more"); |
| 452 | if (loadMoreBtn) { |
| 453 | loadMoreBtn.addEventListener("click", e => { |
| 454 | e.preventDefault(); |
| 455 | e.stopPropagation(); |
| 456 | drawPage(page + 1); |
| 457 | }); |
| 458 | } |
| 459 | } |
| 460 | |
| 461 | drawPage(1); |
| 462 | } |
no test coverage detected