Compare commits

..

3 commits

3 changed files with 18 additions and 6 deletions

View file

@ -62,6 +62,10 @@
<hr style='width: 75%;' />
${m.text}
`
msg.oncontextmenu = () => {
document.getElementById('msg-context-menu').style.display = 'flex';
return false;
}
let history = document.getElementById('chat-history');
// this is to force update everytime we get a duplicate msg to allow msg editing (yay)
let exists = Array.from(history.children).filter(e => e.style.order == m.id)[0];
@ -137,7 +141,6 @@
background-color:#0f0f2f;
}
.chat-message {
background-color: #ffffd6;
color: #000000;
border-width: 2px;
@ -185,5 +188,10 @@
</div>
</div>
</div>
<div id="msg-context-menu" class="chat-message" style="display: none; position: absolute; z-index: 1000; top: 0px;">
<ul>
<li onclick='document.getElementById("msg-context-menu").style.display="none"'>Edit</li>
</ul>
</div>
</body>
</html>
</html>

View file

@ -1,5 +1,5 @@
const tavern = {
socket: socket = new WebSocket('ws://localhost:3001/ws'),
socket: socket = new WebSocket('ws:/' + window.location.host + '/ws'),
connected: false,
loggedIn: false,
call: (f, ...args) => {
@ -41,4 +41,4 @@ tavern.get_chat_history = (from, amount) => {
tavern.get_last_msgs = (amount) => {
if(!tavern.connected || tavern.loggedIn) { return false; }
tavern.socket.send(JSON.stringify({ get_last_messages: { amount: amount } }))
}
}

View file

@ -41,8 +41,12 @@ impl GameServer {
continue;
}
if msg.source.is_empty() {
msg.source = id.clone();
msg.source = format!("({})", id.clone());
}
else {
msg.source = format!("{} ({})", msg.source, id.clone());
}
self.chat.push((id.clone(), msg.clone()));
_ = broadcast.send((None, api::Response::Message(msg)));
},
@ -70,4 +74,4 @@ impl GameServer {
}
_ = broadcast.send((None, api::Response::Shutdown));
}
}
}