// XSS prevention helper — delegates to lt.escHtml() from web_template/base.js function escapeHtml(text) { return lt.escHtml(text); } // Get ticket ID from URL (handles both /ticket/123 and ?id=123 formats) function getTicketIdFromUrl() { const pathMatch = window.location.pathname.match(/\/ticket\/(\d+)/); if (pathMatch) return pathMatch[1]; const params = new URLSearchParams(window.location.search); return params.get('id'); } /** * Show a terminal-style confirmation modal using the lt.modal system. * Falls back gracefully if dashboard.js has already defined this function. * @param {string} title - Modal title * @param {string} message - Confirmation message * @param {string} type - 'warning' | 'error' | 'info' * @param {Function} onConfirm - Called when user confirms * @param {Function|null} onCancel - Called when user cancels */ if (typeof showConfirmModal === 'undefined') { window.showConfirmModal = function showConfirmModal(title, message, type = 'warning', onConfirm, onCancel = null) { const modalId = 'confirmModal' + Date.now(); const colors = { warning: 'var(--terminal-amber)', error: 'var(--status-closed)', info: 'var(--terminal-cyan)' }; const icons = { warning: '[ ! ]', error: '[ X ]', info: '[ i ]' }; const color = colors[type] || colors.warning; const icon = icons[type] || icons.warning; const safeTitle = lt.escHtml(title); const safeMessage = lt.escHtml(message); document.body.insertAdjacentHTML('beforeend', ` `); const modal = document.getElementById(modalId); lt.modal.open(modalId); const cleanup = (cb) => { lt.modal.close(modalId); setTimeout(() => modal.remove(), 300); if (cb) cb(); }; document.getElementById(`${modalId}_confirm`).addEventListener('click', () => cleanup(onConfirm)); document.getElementById(`${modalId}_cancel`).addEventListener('click', () => cleanup(onCancel)); modal.querySelector('[data-modal-close]').addEventListener('click', () => cleanup(onCancel)); }; }