Compare commits
No commits in common. "9921cd7745ea349793f630060d3d3c8ba9c2ce78" and "71eebf5898f63afa1e41d7b30c5e319729070714" have entirely different histories.
9921cd7745
...
71eebf5898
|
@ -261,30 +261,6 @@ def poll_post(socket, data):
|
||||||
socket.send('new_post', data)
|
socket.send('new_post', data)
|
||||||
|
|
||||||
|
|
||||||
def edit_post(socket, data):
|
|
||||||
"""
|
|
||||||
Called when the QM saves an edited post.
|
|
||||||
"""
|
|
||||||
post_id = data.get('post_id')
|
|
||||||
post_text = data.get('post_text')
|
|
||||||
|
|
||||||
# cleaning
|
|
||||||
post_text = bleach.clean(post_text.strip())
|
|
||||||
post_text = post_text.replace("\n", "<br>")
|
|
||||||
|
|
||||||
# handle image
|
|
||||||
|
|
||||||
p = Post.objects.get(id=post_id)
|
|
||||||
p.post_text = post_text
|
|
||||||
p.save()
|
|
||||||
|
|
||||||
data = {}
|
|
||||||
data['post_text'] = post_text
|
|
||||||
data['post_type'] = 'text'
|
|
||||||
data['post_id'] = p.id
|
|
||||||
socket.send('update_post', data)
|
|
||||||
|
|
||||||
|
|
||||||
def close_post(socket, data):
|
def close_post(socket, data):
|
||||||
"""
|
"""
|
||||||
Called when the QM closes an open post.
|
Called when the QM closes an open post.
|
||||||
|
|
|
@ -37,11 +37,6 @@ h3 {
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
.editPostText {
|
|
||||||
width: 100%;
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
#QMPostTabs {
|
#QMPostTabs {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
|
|
|
@ -13,26 +13,6 @@ socket.onmessage = function(e) {
|
||||||
if (socket.events[event] === undefined) { return; }
|
if (socket.events[event] === undefined) { return; }
|
||||||
socket.events[event](data);
|
socket.events[event](data);
|
||||||
}
|
}
|
||||||
socket.onclose = async function(e) {
|
|
||||||
console.log('WebSocket lost connection to server. Re-trying...');
|
|
||||||
let old_socket = socket;
|
|
||||||
while (true) {
|
|
||||||
await sleep(5000);
|
|
||||||
try {
|
|
||||||
socket = new WebSocket(this.url);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
console.log('WebSocket lost connection to server. Re-trying...');
|
|
||||||
// this still throws an error in the console for some reason
|
|
||||||
}
|
|
||||||
}
|
|
||||||
socket.oldSend = old_socket.oldSend;
|
|
||||||
socket.send = old_socket.send;
|
|
||||||
socket.events = old_socket.events;
|
|
||||||
socket.onmessage = old_socket.onmessage;
|
|
||||||
socket.onclose = old_socket.onclose;
|
|
||||||
}
|
|
||||||
function load() {
|
function load() {
|
||||||
document.getElementById('chatWindow').scrollTop = document.getElementById('chatWindow').scrollHeight;
|
document.getElementById('chatWindow').scrollTop = document.getElementById('chatWindow').scrollHeight;
|
||||||
let mtarea = document.getElementById('messageTextArea');
|
let mtarea = document.getElementById('messageTextArea');
|
||||||
|
@ -184,9 +164,6 @@ function strftime(date) {
|
||||||
function sort_by_votes(a, b) {
|
function sort_by_votes(a, b) {
|
||||||
return b.cells[2].textContent.localeCompare(a.cells[2].textContent);
|
return b.cells[2].textContent.localeCompare(a.cells[2].textContent);
|
||||||
}
|
}
|
||||||
function sleep(ms) {
|
|
||||||
return new Promise(resolve => setTimeout(resolve, ms));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* DOM editing */
|
/* DOM editing */
|
||||||
function quote(message_id) {
|
function quote(message_id) {
|
||||||
|
|
|
@ -12,7 +12,7 @@ socket.events['new_post'] = function(data) {
|
||||||
post_str += '<div class="questPostMeta">' + data.date;
|
post_str += '<div class="questPostMeta">' + data.date;
|
||||||
/* QM only */
|
/* QM only */
|
||||||
if (data.post_type === 'text') {
|
if (data.post_type === 'text') {
|
||||||
post_str += '<br /><a href="javascript:void(0);" id="editPost-' + data.post_id + '"onclick="edit_post(\'' + data.post_id + '\')">Edit</a>';
|
post_str += '<br /><a href="javascript:void(0);" onclick="edit_post(\'' + data.post_id + '\')">Edit</a>';
|
||||||
post_str += '<a href="javascript:void(0);" id="savePost-' + data.post_id + '" onclick="save_post(\'' + data.post_id + '\')" style="display:none;">Save</a>';
|
post_str += '<a href="javascript:void(0);" id="savePost-' + data.post_id + '" onclick="save_post(\'' + data.post_id + '\')" style="display:none;">Save</a>';
|
||||||
} else if (data.post_type === 'dice' || data.post_type === 'poll') {
|
} else if (data.post_type === 'dice' || data.post_type === 'poll') {
|
||||||
post_str += '<br /><a href="javascript:void(0);" id="closePost-' + data.post_id + '" onclick="close_post(' + data.post_id + ')">Close</a>';
|
post_str += '<br /><a href="javascript:void(0);" id="closePost-' + data.post_id + '" onclick="close_post(' + data.post_id + ')">Close</a>';
|
||||||
|
@ -53,15 +53,6 @@ function makePost() {
|
||||||
if (text === '') { return; }
|
if (text === '') { return; }
|
||||||
socket.send('text_post', {text: text, page_num: page_num, quest_id: quest_id});
|
socket.send('text_post', {text: text, page_num: page_num, quest_id: quest_id});
|
||||||
}
|
}
|
||||||
function save_post(post_id) {
|
|
||||||
let post = document.getElementById('questPostData-' + post_id);
|
|
||||||
let post_text = post.firstElementChild.value.trim();
|
|
||||||
socket.send('edit_post', {post_text: post_text, post_id: post_id});
|
|
||||||
post_text = post_text.replace(/\n/g, '<br>')
|
|
||||||
post.innerHTML = post_text;
|
|
||||||
document.getElementById('savePost-' + post_id).style.display = 'none';
|
|
||||||
document.getElementById('editPost-' + post_id).style.display = 'initial';
|
|
||||||
}
|
|
||||||
function form_post(form_id, event) {
|
function form_post(form_id, event) {
|
||||||
let formData = new FormData(document.getElementById(form_id));
|
let formData = new FormData(document.getElementById(form_id));
|
||||||
let obj = {};
|
let obj = {};
|
||||||
|
@ -95,14 +86,17 @@ function open_post_send(post_id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* DOM editing */
|
/* DOM editing */
|
||||||
function edit_post(post_id) {
|
function openPostTab(event, modeName) {
|
||||||
let post = document.getElementById('questPostData-' + post_id);
|
let QMPostTabContent = document.getElementsByClassName("QMPostTabContent");
|
||||||
let post_text = post.innerHTML.trim();
|
for (let i = 0; i < QMPostTabContent.length; i++) {
|
||||||
post_text = post_text.replace(/<br>/g, '\n');
|
QMPostTabContent[i].style.display = "none";
|
||||||
post.innerHTML = '<textarea class="editPostText">' + post_text + '</textarea>';
|
}
|
||||||
post.firstElementChild.style.height = post.firstElementChild.scrollHeight + 'px';
|
let QMPostTab = document.getElementsByClassName("QMPostTab");
|
||||||
document.getElementById('savePost-' + post_id).style.display = 'initial';
|
for (let i = 0; i < QMPostTab.length; i++) {
|
||||||
document.getElementById('editPost-' + post_id).style.display = 'none';
|
QMPostTab[i].className = QMPostTab[i].className.replace(" active", "");
|
||||||
|
}
|
||||||
|
document.getElementById(modeName).style.display = "block";
|
||||||
|
event.currentTarget.className += " active";
|
||||||
}
|
}
|
||||||
function close_post(post_id) {
|
function close_post(post_id) {
|
||||||
let post = document.getElementById('questPostData-' + post_id);
|
let post = document.getElementById('questPostData-' + post_id);
|
||||||
|
@ -143,18 +137,6 @@ function open_post(post_id) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function openPostTab(event, modeName) {
|
|
||||||
let QMPostTabContent = document.getElementsByClassName("QMPostTabContent");
|
|
||||||
for (let i = 0; i < QMPostTabContent.length; i++) {
|
|
||||||
QMPostTabContent[i].style.display = "none";
|
|
||||||
}
|
|
||||||
let QMPostTab = document.getElementsByClassName("QMPostTab");
|
|
||||||
for (let i = 0; i < QMPostTab.length; i++) {
|
|
||||||
QMPostTab[i].className = QMPostTab[i].className.replace(" active", "");
|
|
||||||
}
|
|
||||||
document.getElementById(modeName).style.display = "block";
|
|
||||||
event.currentTarget.className += " active";
|
|
||||||
}
|
|
||||||
function insertPollOption() {
|
function insertPollOption() {
|
||||||
let opts = document.getElementById('pollOptions');
|
let opts = document.getElementById('pollOptions');
|
||||||
let num = opts.children.length+1;
|
let num = opts.children.length+1;
|
||||||
|
|
2
todo
2
todo
|
@ -16,6 +16,7 @@ Quote backlinks
|
||||||
Make chat hideable
|
Make chat hideable
|
||||||
|
|
||||||
Improvements:
|
Improvements:
|
||||||
|
Revamp post editing
|
||||||
More options for text posts (lists and so on)
|
More options for text posts (lists and so on)
|
||||||
More rigorous input checking in events.py
|
More rigorous input checking in events.py
|
||||||
New post displays chat message
|
New post displays chat message
|
||||||
|
@ -29,4 +30,5 @@ Only last 100 (50?) chat messages are loaded on page load
|
||||||
Adjust quote preview postioning
|
Adjust quote preview postioning
|
||||||
|
|
||||||
Port from old code:
|
Port from old code:
|
||||||
|
Edit post
|
||||||
Images
|
Images
|
||||||
|
|
Loading…
Reference in New Issue
Block a user