forked from MarseyWorld/MarseyWorld
fds
parent
1c83004972
commit
4bd2d4e967
|
@ -1,8 +1,6 @@
|
||||||
from files.helpers.const import SITE
|
from files.helpers.const import SITE
|
||||||
|
|
||||||
if SITE in ('pcmemes.net', 'localhost'):
|
if SITE in ('pcmemes.net', 'localhost'):
|
||||||
count = 0
|
|
||||||
|
|
||||||
import time
|
import time
|
||||||
from files.helpers.wrappers import auth_required
|
from files.helpers.wrappers import auth_required
|
||||||
from files.helpers.sanitize import sanitize
|
from files.helpers.sanitize import sanitize
|
||||||
|
@ -14,6 +12,7 @@ if SITE in ('pcmemes.net', 'localhost'):
|
||||||
|
|
||||||
socketio = SocketIO(app, async_mode='gevent')
|
socketio = SocketIO(app, async_mode='gevent')
|
||||||
typing = []
|
typing = []
|
||||||
|
online = []
|
||||||
|
|
||||||
@app.get("/chat")
|
@app.get("/chat")
|
||||||
@auth_required
|
@auth_required
|
||||||
|
@ -37,10 +36,11 @@ if SITE in ('pcmemes.net', 'localhost'):
|
||||||
return '', 204
|
return '', 204
|
||||||
|
|
||||||
@socketio.on('connect')
|
@socketio.on('connect')
|
||||||
def connect():
|
@auth_required
|
||||||
global count
|
def connect(v):
|
||||||
count += 1
|
if v.username not in online:
|
||||||
emit("count", count, broadcast=True)
|
online.append(v.username)
|
||||||
|
emit("online", online, broadcast=True)
|
||||||
|
|
||||||
emit('typing', typing)
|
emit('typing', typing)
|
||||||
return '', 204
|
return '', 204
|
||||||
|
@ -48,9 +48,10 @@ if SITE in ('pcmemes.net', 'localhost'):
|
||||||
@socketio.on('disconnect')
|
@socketio.on('disconnect')
|
||||||
@auth_required
|
@auth_required
|
||||||
def disconnect(v):
|
def disconnect(v):
|
||||||
global count
|
if v.username in online:
|
||||||
count -= 1
|
online.remove(v.username)
|
||||||
emit("count", count, broadcast=True)
|
emit("online", online, broadcast=True)
|
||||||
|
|
||||||
if v.username in typing: typing.remove(v.username)
|
if v.username in typing: typing.remove(v.username)
|
||||||
emit('typing', typing, broadcast=True)
|
emit('typing', typing, broadcast=True)
|
||||||
return '', 204
|
return '', 204
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<div class="border-right py-3 px-3">
|
<div class="border-right py-3 px-3">
|
||||||
<span data-toggle="tooltip" data-placement="bottom" title="people online right now" class="text-muted">
|
<span data-toggle="tooltip" data-placement="bottom" data-bs-title="Users online right now" title="Users online right now" class="text-muted">
|
||||||
<i class="far fa-user fa-sm mr-1"></i>
|
<i class="far fa-user fa-sm mr-1"></i>
|
||||||
<span class="board-chat-count">0</span>
|
<span class="board-chat-count">0</span>
|
||||||
</span>
|
</span>
|
||||||
|
@ -157,8 +157,12 @@
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
socket.on('count', function(data){
|
socket.on('online', function(data){
|
||||||
document.getElementsByClassName('board-chat-count')[0].innerHTML = data
|
document.getElementsByClassName('board-chat-count')[0].innerHTML = data.length
|
||||||
|
let online = ''
|
||||||
|
for (const u of data)
|
||||||
|
online += `<li><a href="/@${u}" class="text-lg">${u}</a></li>`
|
||||||
|
document.getElementById('online').innerHTML = online
|
||||||
})
|
})
|
||||||
|
|
||||||
window.addEventListener('blur', function(){
|
window.addEventListener('blur', function(){
|
||||||
|
|
|
@ -287,11 +287,14 @@
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{% if home or sub and p %}
|
{% block sidebar %}
|
||||||
{% block sidebar %}
|
{% if home or sub and p %}
|
||||||
{% include "sidebar_" + SITE_NAME + ".html" %}
|
{% include "sidebar_" + SITE_NAME + ".html" %}
|
||||||
{% endblock %}
|
{% elif request.path == '/chat' %}
|
||||||
{% endif %}
|
<div id="online" class="col sidebar text-left d-none d-lg-block pt-3 bg-white" style="max-width:300px">
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue