()
| 8723 | modal.innerHTML = ''; |
| 8724 | modal.appendChild(template.content.cloneNode(true)); |
| 8725 | |
| 8726 | const htmlEnabledKeys = new Set(['body', 'highlightBody']); |
| 8727 | |
| 8728 | modal.querySelectorAll('[data-delete-history]').forEach(el => { |
| 8729 | const key = el.dataset.deleteHistory; |
| 8730 | if (key && Object.prototype.hasOwnProperty.call(DELETE_HISTORY_COPY, key)) { |
| 8731 | if (htmlEnabledKeys.has(key)) { |
| 8732 | el.innerHTML = DELETE_HISTORY_COPY[key]; |
| 8733 | } else { |
| 8734 | el.textContent = DELETE_HISTORY_COPY[key]; |
| 8735 | } |
| 8736 | } |
| 8737 | }); |
| 8738 | |
| 8739 | this.elements.deleteHistoryCancelBtn = document.getElementById('cancel-delete-history'); |
| 8740 | this.elements.deleteHistoryConfirmBtn = document.getElementById('confirm-delete-history'); |
| 8741 | if (this.elements.deleteHistoryConfirmBtn) { |
| 8742 | this.elements.deleteHistoryConfirmBtn.dataset.originalText = DELETE_HISTORY_COPY.confirmLabel; |
| 8743 | } |
| 8744 | |
| 8745 | this.attachDownloadLinkHandler(modal); |
| 8746 | } |
| 8747 | |
| 8748 | openDeleteHistoryModal() { |
| 8749 | const modal = this.elements.deleteHistoryModal; |
| 8750 | if (!modal) return; |
| 8751 | |
| 8752 | this.deleteHistoryReturnFocusEl = document.activeElement; |
| 8753 | modal.classList.remove('hidden'); |
| 8754 | |
| 8755 | requestAnimationFrame(() => { |
| 8756 | this.elements.deleteHistoryConfirmBtn?.focus(); |
| 8757 | }); |
| 8758 | } |
| 8759 | |
| 8760 | closeDeleteHistoryModal() { |
| 8761 | const modal = this.elements.deleteHistoryModal; |
| 8762 | if (!modal) return; |
| 8763 | |
| 8764 | modal.classList.add('hidden'); |
| 8765 | |
| 8766 | if (this.deleteHistoryReturnFocusEl && typeof this.deleteHistoryReturnFocusEl.focus === 'function') { |
| 8767 | this.deleteHistoryReturnFocusEl.focus(); |
| 8768 | } |
| 8769 | this.deleteHistoryReturnFocusEl = null; |
| 8770 | } |
| 8771 | |
| 8772 | isDeleteHistoryModalOpen() { |
| 8773 | const modal = this.elements.deleteHistoryModal; |
| 8774 | if (!modal) return false; |
| 8775 | return !modal.classList.contains('hidden'); |
| 8776 | } |
| 8777 | |
| 8778 | async handleConfirmDeleteHistory() { |
| 8779 | if (this.isDeletingAllChats) return; |
| 8780 | this.isDeletingAllChats = true; |
| 8781 | |
| 8782 | const confirmBtn = this.elements.deleteHistoryConfirmBtn; |
no test coverage detected