diff --git a/source/templates/index.html b/source/templates/index.html index 1f01539..03a2e35 100644 --- a/source/templates/index.html +++ b/source/templates/index.html @@ -521,18 +521,29 @@ window.appendChat = function(user, msg, classes) { const now = new Date(); - const timeString = now.toLocaleDateString('de-DE') + " " + now.toLocaleTimeString('de-DE', {hour: '2-digit', minute:'2-digit'}); + const timeString = now.toLocaleTimeString('de-DE', {hour: '2-digit', minute:'2-digit'}); const win = document.getElementById('chat-window'); - const msgDiv = document.createElement("div"); - msgDiv.className = `message ${role}`; - msgDiv.innerHTML = ` -
${text}
-
${timeString}
- `; - chatBox.appendChild(msgDiv); - chatBox.scrollTop = chatBox.scrollHeight; // Automatisch nach unten scrollen + + // Nachricht formatieren (Markdown nur für J.A.R.V.I.S.) let formattedMsg = (user === "J.A.R.V.I.S.") ? marked.parse(msg) : msg; - win.innerHTML += `
${user}
${formattedMsg}
`; + + // Das HTML-Gerüst für die Nachricht zusammenbauen + const messageHtml = ` +
+
+ ${user} + ${timeString} +
+
+ ${formattedMsg} +
+
+ `; + + // Nachricht an das Fenster anhängen + win.innerHTML += messageHtml; + + // Automatisch nach unten scrollen win.scrollTop = win.scrollHeight; };