Fixed MAJOR bugs, currently at a semi-stable state

This commit is contained in:
2025-09-05 11:08:56 -04:00
parent 19f436a17c
commit e05434137c
14 changed files with 1559 additions and 1106 deletions

File diff suppressed because it is too large Load Diff

View File

@ -25,12 +25,6 @@ function saveTicket() {
// Use the correct API path
const apiUrl = '/api/update_ticket.php';
console.log('Sending request to:', apiUrl);
console.log('Sending data:', JSON.stringify({
ticket_id: ticketId,
...data
}));
fetch(apiUrl, {
method: 'POST',
headers: {
@ -42,7 +36,6 @@ function saveTicket() {
})
})
.then(response => {
console.log('Response status:', response.status);
if (!response.ok) {
return response.text().then(text => {
console.error('Server response:', text);
@ -52,7 +45,6 @@ function saveTicket() {
return response.json();
})
.then(data => {
console.log('Response data:', data);
if(data.success) {
const statusDisplay = document.getElementById('statusDisplay');
if (statusDisplay) {
@ -141,6 +133,22 @@ function addComment() {
// Clear the comment box
document.getElementById('newComment').value = '';
// Format the comment text for display
let displayText;
if (isMarkdownEnabled) {
// For markdown, use marked.parse
displayText = marked.parse(commentText);
} else {
// For non-markdown, convert line breaks to <br> and escape HTML
displayText = commentText
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#39;')
.replace(/\n/g, '<br>');
}
// Add new comment to the list
const commentsList = document.querySelector('.comments-list');
const newComment = `
@ -149,9 +157,7 @@ function addComment() {
<span class="comment-user">${data.user_name}</span>
<span class="comment-date">${data.created_at}</span>
</div>
<div class="comment-text">
${isMarkdownEnabled ? marked.parse(commentText) : commentText}
</div>
<div class="comment-text">${displayText}</div>
</div>
`;
commentsList.insertAdjacentHTML('afterbegin', newComment);
@ -180,9 +186,17 @@ function togglePreview() {
}
function updatePreview() {
const preview = document.getElementById('markdownPreview');
const textarea = document.getElementById('newComment');
preview.innerHTML = marked.parse(textarea.value);
const commentText = document.getElementById('newComment').value;
const previewDiv = document.getElementById('markdownPreview');
const isMarkdownEnabled = document.getElementById('markdownMaster').checked;
if (isMarkdownEnabled && commentText.trim()) {
// For markdown preview, use marked.parse which handles line breaks correctly
previewDiv.innerHTML = marked.parse(commentText);
previewDiv.style.display = 'block';
} else {
previewDiv.style.display = 'none';
}
}
function toggleMarkdownMode() {