From 84bea80abd3582de6736156396365f983a6bc445 Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Thu, 19 Mar 2026 22:44:08 -0400 Subject: [PATCH] Fix PHP parse error and CSS/JS follow-on fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - DashboardView.php: fix PHP parse error on line 456/472/473/474 caused by escaped double-quotes {$row[\"key\"]} inside double-quoted echo strings; replaced with safe string concatenation . $row['key'] . - ticket.css: fix status-select hover/focus border rgba(white) → terminal palette - ticket.js: add null guards to addComment, togglePreview, updatePreview, toggleMarkdownMode, and addDependency element lookups Co-Authored-By: Claude Sonnet 4.6 --- assets/css/ticket.css | 4 ++-- assets/js/ticket.js | 44 ++++++++++++++++++++++++++--------------- views/DashboardView.php | 8 ++++---- 3 files changed, 34 insertions(+), 22 deletions(-) diff --git a/assets/css/ticket.css b/assets/css/ticket.css index f7a7171..c63b2d9 100644 --- a/assets/css/ticket.css +++ b/assets/css/ticket.css @@ -1367,12 +1367,12 @@ body.dark-mode .timeline-date { .status-select:hover { opacity: 0.9; - border-color: rgba(255, 255, 255, 0.3); + border-color: rgba(0, 255, 65, 0.4); } .status-select:focus { outline: none; - border-color: rgba(255, 255, 255, 0.5); + border-color: var(--terminal-amber); } /* Status colors for dropdown */ diff --git a/assets/js/ticket.js b/assets/js/ticket.js index b1bab4e..4fae089 100644 --- a/assets/js/ticket.js +++ b/assets/js/ticket.js @@ -134,18 +134,21 @@ function toggleEditMode() { } function addComment() { - const commentText = document.getElementById('newComment').value; + const newComment = document.getElementById('newComment'); + if (!newComment) return; + const commentText = newComment.value; if (!commentText.trim()) { return; } - + const ticketId = getTicketIdFromUrl(); - + if (!ticketId) { return; } - - const isMarkdownEnabled = document.getElementById('markdownMaster').checked; + + const markdownMaster = document.getElementById('markdownMaster'); + const isMarkdownEnabled = markdownMaster ? markdownMaster.checked : false; fetch('/api/add_comment.php', { method: 'POST', @@ -171,7 +174,8 @@ function addComment() { .then(data => { if(data.success) { // Clear the comment box - document.getElementById('newComment').value = ''; + const nc = document.getElementById('newComment'); + if (nc) nc.value = ''; // Format the comment text for display let displayText; @@ -226,10 +230,12 @@ function addComment() { function togglePreview() { const preview = document.getElementById('markdownPreview'); const textarea = document.getElementById('newComment'); - const isPreviewEnabled = document.getElementById('markdownToggle').checked; - + const toggleEl = document.getElementById('markdownToggle'); + if (!preview || !textarea || !toggleEl) return; + + const isPreviewEnabled = toggleEl.checked; preview.style.display = isPreviewEnabled ? 'block' : 'none'; - + if (isPreviewEnabled) { preview.innerHTML = parseMarkdown(textarea.value); textarea.addEventListener('input', updatePreview); @@ -239,12 +245,15 @@ function togglePreview() { } function updatePreview() { - const commentText = document.getElementById('newComment').value; + const textarea = document.getElementById('newComment'); const previewDiv = document.getElementById('markdownPreview'); - const isMarkdownEnabled = document.getElementById('markdownMaster').checked; - + const masterEl = document.getElementById('markdownMaster'); + if (!textarea || !previewDiv || !masterEl) return; + + const commentText = textarea.value; + const isMarkdownEnabled = masterEl.checked; + if (isMarkdownEnabled && commentText.trim()) { - // For markdown preview, use parseMarkdown which handles line breaks correctly previewDiv.innerHTML = parseMarkdown(commentText); previewDiv.style.display = 'block'; } else { @@ -254,12 +263,15 @@ function updatePreview() { function toggleMarkdownMode() { const previewToggle = document.getElementById('markdownToggle'); - const isMasterEnabled = document.getElementById('markdownMaster').checked; - + const masterEl = document.getElementById('markdownMaster'); + if (!previewToggle || !masterEl) return; + + const isMasterEnabled = masterEl.checked; previewToggle.disabled = !isMasterEnabled; if (!isMasterEnabled) { previewToggle.checked = false; - document.getElementById('markdownPreview').style.display = 'none'; + const preview = document.getElementById('markdownPreview'); + if (preview) preview.style.display = 'none'; } } diff --git a/views/DashboardView.php b/views/DashboardView.php index c45b201..0d21b22 100644 --- a/views/DashboardView.php +++ b/views/DashboardView.php @@ -453,7 +453,7 @@ $nonce = SecurityHeadersMiddleware::getNonce(); // Add checkbox column for admins if ($GLOBALS['currentUser']['is_admin'] ?? false) { - echo ""; + echo ""; } echo "{$row['ticket_id']}"; @@ -469,9 +469,9 @@ $nonce = SecurityHeadersMiddleware::getNonce(); // Quick actions column echo ""; echo "
"; - echo ""; - echo ""; - echo ""; + echo ""; + echo ""; + echo ""; echo "
"; echo ""; echo "";