forked from MarseyWorld/MarseyWorld
test on devrama
parent
c968b1a4df
commit
8f0b2ea9c3
|
@ -187,6 +187,23 @@ socket.on('typing', function (users){
|
|||
}
|
||||
})
|
||||
|
||||
|
||||
function del(t) {
|
||||
t.parentElement.parentElement.parentElement.parentElement.parentElement.remove()
|
||||
const text = t.previousElementSibling.previousElementSibling.innerHTML
|
||||
socket.emit('delete', text);
|
||||
}
|
||||
|
||||
socket.on('delete', function(text) {
|
||||
const text_spans = document.getElementsByClassName('text')
|
||||
for(const span of text_spans) {
|
||||
if (span.innerHTML == text)
|
||||
{
|
||||
span.parentElement.parentElement.parentElement.parentElement.parentElement.remove()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
function scroll_chat() {
|
||||
setTimeout(function () {
|
||||
box.scrollTo(0, box.scrollHeight)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import time
|
||||
from files.helpers.wrappers import auth_required
|
||||
from files.helpers.wrappers import *
|
||||
from files.helpers.sanitize import sanitize
|
||||
from files.helpers.const import *
|
||||
from files.helpers.alerts import *
|
||||
|
@ -133,6 +133,19 @@ def typing_indicator(data, v):
|
|||
return '', 204
|
||||
|
||||
|
||||
@socketio.on('delete')
|
||||
@admin_level_required(2)
|
||||
def delete(text, v):
|
||||
|
||||
for message in messages:
|
||||
if message['text'] == text:
|
||||
messages.remove(message)
|
||||
|
||||
emit('delete', text, broadcast=True)
|
||||
|
||||
return '', 204
|
||||
|
||||
|
||||
def close_running_threads():
|
||||
cache.set(f'{SITE}_chat', messages)
|
||||
cache.set(f'{SITE}_total', total)
|
||||
|
|
|
@ -149,6 +149,9 @@
|
|||
<span class="chat-message text-black text-break"></span>
|
||||
<span class="text d-none"></span>
|
||||
<button class="quote btn" onclick="quote(this)"><i class="fas fa-reply" aria-hidden="true"></i></button>
|
||||
{% if v.admin_level > 1 %}
|
||||
<button class="btn" onclick="del(this)"><i class="fas fa-trash-alt" aria-hidden="true"></i></button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -182,8 +185,11 @@
|
|||
|
||||
<div class="cdiv">
|
||||
<span class="chat-message text-black text-break">{{text_html | safe}}</span>
|
||||
<span class="d-none">{{m['text']}}</span>
|
||||
<span class="text d-none">{{m['text']}}</span>
|
||||
<button class="quote btn" onclick="quote(this)"><i class="fas fa-reply" aria-hidden="true"></i></button>
|
||||
{% if v.admin_level > 1 %}
|
||||
<button class="btn" onclick="del(this)"><i class="fas fa-trash-alt" aria-hidden="true"></i></button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue