enhance comments
Deploy / deploy (push) Successful in 39s

This commit is contained in:
2026-05-07 18:33:04 +02:00
parent 4634920d00
commit d96606c9a4
+5 -4
View File
@@ -128,7 +128,7 @@ function renderTimeline() {
${renderComments(e)}
</div>
<div class="input-group input-group-sm comment-input-group mt-1">
<input type="text" class="form-control form-control-sm comment-input" placeholder="Write a comment..." data-event-id="${e.id}">
<input type="text" class="form-control form-control-sm comment-input" placeholder="Write a comment..." data-event-id="${e.id}" onkeydown="if(event.key==='Enter') addComment(${e.id}, this)">
<button class="btn btn-outline-secondary btn-sm" onclick="addComment(${e.id}, this)"><i class="bi bi-send"></i></button>
</div>
</div>
@@ -154,8 +154,9 @@ function renderComments(event) {
`).join('');
}
async function addComment(eventId, btn) {
const input = btn.parentElement.querySelector('.comment-input');
async function addComment(eventId, el) {
const container = el.closest('.comment-input-group') || el.parentElement;
const input = container.querySelector('.comment-input');
const body = input.value.trim();
if (!body) return;
const author = prompt('Your name:') || 'Anonymous';
@@ -174,7 +175,7 @@ async function saveEvent() {
description: document.getElementById('eventDescription').value,
severity: document.getElementById('eventSeverity').value,
event_type: document.getElementById('eventType').value,
occurred_at: document.getElementById('eventTime').value || new Date().toISOString().slice(0, 16)
occurred_at: new Date().toISOString().slice(0, 16)
};
if (!data.title) return alert('Title required');
await apiFetch('events', { method: 'POST', body: JSON.stringify(data) });