(bookmark, reason)
| 648 | } |
| 649 | |
| 650 | function addInvalidBookmark(bookmark, reason) { |
| 651 | const invalidList = document.getElementById('invalidList'); |
| 652 | if (!invalidList) return; |
| 653 | |
| 654 | const item = document.createElement('div'); |
| 655 | item.className = 'result-item'; |
| 656 | |
| 657 | // 创建复选框 |
| 658 | const checkbox = document.createElement('input'); |
| 659 | checkbox.type = 'checkbox'; |
| 660 | checkbox.className = 'bookmark-checkbox'; |
| 661 | checkbox.setAttribute('data-id', bookmark.id); |
| 662 | |
| 663 | checkbox.addEventListener('change', (e) => { |
| 664 | if (isScanning) { |
| 665 | e.preventDefault(); |
| 666 | checkbox.checked = !checkbox.checked; |
| 667 | return; |
| 668 | } |
| 669 | |
| 670 | if (e.target.checked) { |
| 671 | selectedBookmarks.add(bookmark.id); |
| 672 | item.classList.add('selected'); |
| 673 | } else { |
| 674 | selectedBookmarks.delete(bookmark.id); |
| 675 | item.classList.remove('selected'); |
| 676 | } |
| 677 | updateDeleteButtonState(); |
| 678 | updateSelectAllButtonState(); // 确保在这里也更新全选按钮状态 |
| 679 | }); |
| 680 | |
| 681 | // 创建其他元素 |
| 682 | const title = document.createElement('div'); |
| 683 | title.className = 'bookmark-title'; |
| 684 | title.textContent = bookmark.title; |
| 685 | |
| 686 | const urlDiv = document.createElement('div'); |
| 687 | urlDiv.className = 'bookmark-url'; |
| 688 | const urlLink = document.createElement('a'); |
| 689 | urlLink.href = bookmark.url; |
| 690 | urlLink.textContent = bookmark.url; |
| 691 | urlLink.target = '_blank'; |
| 692 | urlDiv.appendChild(urlLink); |
| 693 | |
| 694 | const path = document.createElement('div'); |
| 695 | path.className = 'bookmark-path'; |
| 696 | path.textContent = bookmark.path.join(' > '); |
| 697 | |
| 698 | // 创建错误原因标签时使用本地化的错误消息 |
| 699 | const reasonTag = document.createElement('div'); |
| 700 | reasonTag.className = 'bookmark-reason'; |
| 701 | reasonTag.textContent = getLocalizedErrorMessage(reason); |
| 702 | |
| 703 | // 添加 title 属性作为 tooltip |
| 704 | reasonTag.title = getErrorExplanation(reason); |
| 705 | |
| 706 | // 组装 DOM |
| 707 | item.appendChild(checkbox); |
no test coverage detected