Fixed bugs, and added a run script.

This commit is contained in:
SolidLiquid
2025-06-05 21:24:36 +12:00
parent 7c44f0ba56
commit 13dfcccaad
3 changed files with 34 additions and 17 deletions

View File

@@ -99,19 +99,28 @@ body {
padding-right: 18px; padding-right: 18px;
} }
.chat-container {
display: flex;
flex-direction: column;
height: 70vh; /* or whatever height works well for your layout */
}
#chat-box { #chat-box {
flex: 1; /* This is the key: allows chat-box to grow and fill vertical space */ flex: 1;
overflow-y: auto; /* Adds a scrollbar when content overflows vertically */ overflow-y: auto;
padding: 10px; padding: 10px;
border: 1px solid var(--secondary-color); /* Visual border for chat box */ border: 1px solid var(--secondary-color);
border-radius: 5px; border-radius: 5px;
margin-bottom: 10px; /* Space between chat box and input */ margin-bottom: 10px;
background-color: var(--tertiary-color); /* Example background for messages */ background-color: var(--tertiary-color);
color: var(--text-color); color: var(--text-color);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
min-height: 0;
} }
#chat-box p { #chat-box p {
margin: 0 0 5px 0; /* Adjust message spacing */ margin: 0 0 5px 0; /* Adjust message spacing */
line-height: 1.4; line-height: 1.4;

View File

@@ -2,12 +2,13 @@
{% block title %}Room {{ room_code }}{% endblock %} {% block title %}Room {{ room_code }}{% endblock %}
{% block content %} {% block content %}
<h1>Room {{ room_code }}</h1> <h1>Room {{ room_code }}</h1>
<div class="chat-container">
<div id="chat-box"></div> <div id="chat-box"></div>
<div class="chat-input-container"> <div class="chat-input-container">
<input type="text" id="chat-input" placeholder="Say something..." /> <input type="text" id="chat-input" placeholder="Say something..." />
<button id="send-button">Send</button> <button id="send-button">Send</button>
</div> </div>
</div>
<script> <script>
const socket = io(); const socket = io();
@@ -16,7 +17,6 @@
const name = localStorage.getItem('username') || 'Anonymous'; const name = localStorage.getItem('username') || 'Anonymous';
socket.emit('join', { room, sender: name }); socket.emit('join', { room, sender: name });
// Fetch message history // Fetch message history
fetch(`/api/room/${room}/messages`) fetch(`/api/room/${room}/messages`)
.then(res => res.json()) .then(res => res.json())
@@ -47,8 +47,7 @@
chatBox.scrollTop = chatBox.scrollHeight; chatBox.scrollTop = chatBox.scrollHeight;
}); });
// Send message on button click
// Send message
document.getElementById('send-button').onclick = () => { document.getElementById('send-button').onclick = () => {
const text = document.getElementById('chat-input').value; const text = document.getElementById('chat-input').value;
const sender = localStorage.getItem('username') || 'Anonymous'; const sender = localStorage.getItem('username') || 'Anonymous';
@@ -62,5 +61,13 @@
document.getElementById('chat-input').value = ''; document.getElementById('chat-input').value = '';
} }
}; };
// Send message on Enter key press
document.getElementById('chat-input').addEventListener('keydown', (event) => {
if (event.key === 'Enter') {
document.getElementById('send-button').click();
}
});
</script> </script>
{% endblock %} {% endblock %}

1
run.sh Executable file
View File

@@ -0,0 +1 @@
gunicorn -k eventlet -w 1 -b 0.0.0.0:8997 main:app