diff --git a/quest/events.py b/quest/events.py
index 6d27439..eea96b3 100644
--- a/quest/events.py
+++ b/quest/events.py
@@ -3,6 +3,7 @@
Individual functions for handling WebSocket events. Gets called by the
QuestConsumer object in consumers.py.
"""
+import re
import time
import types
@@ -23,6 +24,23 @@ def message(socket, data):
return
tags = ["b", "code", "i", "s"]
message = bleach.clean(message, tags=tags)
+
+ lines = []
+ for line in message.splitlines():
+ if line.startswith(">") and not line.startswith(">>"):
+ line = '' + line + ''
+ lines.append(line)
+ message = "
".join(lines)
+
+ quotes = re.findall(r">>\d+", message)
+ for quote in quotes:
+ msg_id = quote.replace(">>", "")
+ msg = '' + quote + ''
+ message = message.replace(quote, msg)
+
user = socket.scope['user']
m = Message(
diff --git a/quest/jinja2/quest/quest.html b/quest/jinja2/quest/quest.html
index f56aab5..ffb1d0b 100644
--- a/quest/jinja2/quest/quest.html
+++ b/quest/jinja2/quest/quest.html
@@ -145,7 +145,7 @@
{{ message.message }}
diff --git a/quest/static/quest.js b/quest/static/quest.js
index 4d4d080..a859fcd 100644
--- a/quest/static/quest.js
+++ b/quest/static/quest.js
@@ -1,3 +1,4 @@
+/* House keeping */
var socket = new WebSocket('wss://' + document.domain + SCRIPT_NAME + '/ws/quest/' + quest_id + '/');
socket.oldSend = socket.send;
socket.send = function(event_title, data) {
@@ -12,7 +13,21 @@ socket.onmessage = function(e) {
if (socket.events[event] === undefined) { return; }
socket.events[event](data);
}
+function load() {
+ document.getElementById('chatWindow').scrollTop = document.getElementById('chatWindow').scrollHeight;
+ let mtarea = document.getElementById('messageTextArea');
+ mtarea.addEventListener('keypress', function(event) {
+ if (event.key == 'Enter' && !event.shiftKey) {
+ let text = mtarea.value.trim();
+ mtarea.value = '';
+ if (text == '') { return; }
+ document.getElementById('chatWindow').scrollTop = document.getElementById('chatWindow').scrollHeight;
+ socket.send('message', {message: text, quest_id: quest_id});
+ }
+ });
+}
+/* Websocket events */
socket.events['message'] = function(data) {
let msg_str = '';
msg_str = '