Fixed bugs, and added a run script.
This commit is contained in:
@@ -99,19 +99,28 @@ body {
|
|||||||
padding-right: 18px;
|
padding-right: 18px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#chat-box {
|
.chat-container {
|
||||||
flex: 1; /* This is the key: allows chat-box to grow and fill vertical space */
|
display: flex;
|
||||||
overflow-y: auto; /* Adds a scrollbar when content overflows vertically */
|
flex-direction: column;
|
||||||
padding: 10px;
|
height: 70vh; /* or whatever height works well for your layout */
|
||||||
border: 1px solid var(--secondary-color); /* Visual border for chat box */
|
|
||||||
border-radius: 5px;
|
|
||||||
margin-bottom: 10px; /* Space between chat box and input */
|
|
||||||
background-color: var(--tertiary-color); /* Example background for messages */
|
|
||||||
color: var(--text-color);
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#chat-box {
|
||||||
|
flex: 1;
|
||||||
|
overflow-y: auto;
|
||||||
|
padding: 10px;
|
||||||
|
border: 1px solid var(--secondary-color);
|
||||||
|
border-radius: 5px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
background-color: var(--tertiary-color);
|
||||||
|
color: var(--text-color);
|
||||||
|
display: flex;
|
||||||
|
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;
|
||||||
|
|||||||
@@ -2,11 +2,12 @@
|
|||||||
{% 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>
|
||||||
@@ -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 %}
|
||||||
|
|||||||
Reference in New Issue
Block a user