From a5477a56a85242e3af181224bd80243572f2d46a Mon Sep 17 00:00:00 2001 From: hyperbel Date: Sun, 29 Oct 2023 23:46:31 +0100 Subject: [PATCH] get chat messages --- party/static/css/session.css | 8 ++-- party/static/js/chat.js | 5 +++ party/static/js/session.js | 85 ------------------------------------ 3 files changed, 8 insertions(+), 90 deletions(-) diff --git a/party/static/css/session.css b/party/static/css/session.css index cbc5b61..f2f2294 100644 --- a/party/static/css/session.css +++ b/party/static/css/session.css @@ -347,13 +347,11 @@ cursor: pointer; border-radius: 50%; } -#chat-container { - max-height: 80%; -} +/* Chat */ #chatBox { - max-height: 600px; - border: 1px solid white; + border-top: + height: 200px; } .chat-message { diff --git a/party/static/js/chat.js b/party/static/js/chat.js index b246bc3..37eae88 100644 --- a/party/static/js/chat.js +++ b/party/static/js/chat.js @@ -85,3 +85,8 @@ socket.on('chat-message', (data) => { chatBox.appendChild(message); chatBox.scrollTop = chatBox.scrollHeight; }); + + +window.addEventListener('load', () => { + getNChatMessages(socket, 100, 0); +}); diff --git a/party/static/js/session.js b/party/static/js/session.js index 5280f7c..21ad07c 100644 --- a/party/static/js/session.js +++ b/party/static/js/session.js @@ -1,81 +1,9 @@ const socket = io(); -window.addEventListener('DOMContentLoaded', function() { - var name = sessionStorage.getItem('name'); // Den Namen aus dem SessionStorage abrufen - - if (name) { - document.getElementById('peter').textContent = name; // Den Namen bei dem Element mit der ID "peter" ausgeben - } - }); - - var divs = document.querySelectorAll('.hidden-div'); - var activeButtonIndex = null; - - // Beim Laden der Seite den Zustand wiederherstellen - window.addEventListener('DOMContentLoaded', function() { - var storedIndex = sessionStorage.getItem('position'); - if (storedIndex) { - activeButtonIndex = parseInt(storedIndex); - toggleDiv(activeButtonIndex); - } - }); - - function toggleDiv(index) { - updateButtonStatus(index); - hideAllDivs(); - - var selectedIndex = index - 1; - handleSwitchDiv(index); - - divs[selectedIndex].style.display = 'block'; - - // Index im Session Storage speichern - sessionStorage.setItem('position', index); - } - - function hideAllDivs() { - for (var i = 0; i < divs.length; i++) { - divs[i].style.display = 'none'; - } - } - - function updateButtonStatus(index) { - for (var i = 0; i < divs.length; i++) { - var button = document.getElementsByClassName('seitenbutton')[i]; - button.classList.remove('active-button'); - } - - var activeButton = document.getElementsByClassName('seitenbutton')[index - 1]; - activeButton.classList.add('active-button'); - } - - function togglePopup() { - var popup = document.getElementById("popup"); - popup.style.display = (popup.style.display === "none") ? "block" : "none"; -} - -function handleSwitchDiv(index) { - // reset divs - // 1. reset mate div - var mate_kiste = document.getElementById('mate_kiste'); - mate_kiste.innerHTML = ''; - - switch (index) { - case 4: - // get previous messages - getNChatMessages(socket, 100, 0); - break; - case 6: // Mate - getMateStatus(socket); - break; - } -} - function skipSong() {} function lastSong() {} function pausePlaySong() {} - function updateClock() { var now = new Date(); var hours = now.getHours(); @@ -95,16 +23,3 @@ function updateClock() { } setInterval(updateClock, 1000); - -function showDiv(divId) { - const divToShow = document.getElementById(divId); - const divs = document.querySelectorAll('div'); - - for (const div of divs) { - div.classList.add('hidden'); - } - - divToShow.classList.remove('hidden'); -} - -