Compare commits
No commits in common. "fd9129469899d34e908270937ca7c903bc11e058" and "41b592fcd1e348a6243824f9b84e0474944daea5" have entirely different histories.
fd91294698
...
41b592fcd1
18
events.py
18
events.py
|
@ -3,14 +3,13 @@
|
|||
SocketIO events.
|
||||
"""
|
||||
import time
|
||||
import random
|
||||
|
||||
import bleach
|
||||
from flask import session
|
||||
from flask_socketio import SocketIO, emit, join_room
|
||||
|
||||
import tools
|
||||
import database as db
|
||||
import tools
|
||||
|
||||
socketio = SocketIO()
|
||||
|
||||
|
@ -94,18 +93,3 @@ def update_post(data):
|
|||
post_id = data["post_id"]
|
||||
db.update_quest_post(post_id, post)
|
||||
emit("update_post", data, room=room)
|
||||
|
||||
|
||||
@socketio.on('dice_post')
|
||||
def dice_post(data):
|
||||
"""
|
||||
Called when the QM posts a new dice call.
|
||||
"""
|
||||
print(data)
|
||||
room = data["room"]
|
||||
res = db.get_quest_meta(quest_id=room)
|
||||
if not res:
|
||||
return
|
||||
if session.get("user_id") != res[3]:
|
||||
return
|
||||
emit("dice_post", data, room=room)
|
||||
|
|
|
@ -30,7 +30,6 @@ img {
|
|||
#questPane {
|
||||
padding-left: 10px;
|
||||
padding-right: 32%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.questPost {
|
||||
|
@ -42,11 +41,6 @@ img {
|
|||
padding-right: 15px;
|
||||
}
|
||||
|
||||
.questPostData {
|
||||
word-wrap: break-word;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
#QMPostPane {
|
||||
display: flex;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<link rel="stylesheet" type="text/css" href="/static/anonkun.css">
|
||||
<script>
|
||||
function toggleHeader() {
|
||||
let xhr = new XMLHttpRequest();
|
||||
var xhr = new XMLHttpRequest();
|
||||
if (document.getElementById('header').style.display == 'initial') {
|
||||
document.getElementById('header').style.display = 'none';
|
||||
document.getElementById('headerHidden').style.display = 'initial';
|
||||
|
@ -23,12 +23,12 @@
|
|||
</head>
|
||||
<body>
|
||||
<ul id="header" class="header" style="{% if session.get("hide_header") == True %}display:none;{% else %}display:initial;{% endif %}">
|
||||
<li><a onclick="toggleHeader();" href="javascript:void(0);">⤒</a></li>
|
||||
<li><a onclick="toggleHeader();" href="javascript:void(0);">^</a></li>
|
||||
<li><a href="{{ url_for('.index') }}">Home</a></li>
|
||||
{% block header %}{% endblock %}
|
||||
</ul>
|
||||
<ul id="headerHidden" class="header" style="{% if session.get("hide_header") == True %}display:initial;{% else %}display:none;{% endif %}">
|
||||
<li><a onclick="toggleHeader();" href="javascript:void(0);">⤓</a></li>
|
||||
<li><a onclick="toggleHeader();" href="javascript:void(0);">^</a></li>
|
||||
</ul>
|
||||
<div id="content">{% block content %}{% endblock %} </div>
|
||||
</body>
|
||||
|
|
|
@ -15,32 +15,30 @@
|
|||
socket.emit('joined', {room: {{ room_id }}});
|
||||
});
|
||||
socket.on('message', function(data) {
|
||||
let date = new Date(data.date * 1000);
|
||||
let date_str = date.getFullYear() + '-' + padToTwo(date.getMonth()+1) + '-' + padToTwo(date.getDate()) + ' ';
|
||||
var date = new Date(data.date * 1000);
|
||||
var date_str = date.getFullYear() + '-' + padToTwo(date.getMonth()+1) + '-' + padToTwo(date.getDate()) + ' ';
|
||||
date_str += padToTwo(date.getHours()) + ':' + padToTwo(date.getMinutes()) + ':' + padToTwo(date.getSeconds());
|
||||
|
||||
let msg_str = '<div class="messageHeader">\n<span class="messageName">' + data.name + '</span> ';
|
||||
var msg_str = '<div class="messageHeader">\n<span class="messageName">' + data.name + '</span> ';
|
||||
msg_str += '<span class="messageDate">' + date_str + '</span>\n</div>\n';
|
||||
msg_str += '<div class="message">' + data.message + '</div>\n<hr>';
|
||||
msg_str += '<div class="message">' + data.message + '</div>\n';
|
||||
|
||||
let mbox = document.getElementById('chatWindow');
|
||||
var mbox = document.getElementById('chatWindow');
|
||||
mbox.innerHTML = mbox.innerHTML + msg_str;
|
||||
mbox.scrollTop = mbox.scrollHeight;
|
||||
});
|
||||
socket.on('new_post', function(data) {
|
||||
let qposts = document.getElementById('questPosts');
|
||||
var qposts = document.getElementById('questPosts');
|
||||
qposts.innerHTML = qposts.innerHTML + '<div class="questPost">' + data.post + '</div>';
|
||||
});
|
||||
socket.on('update_post', function(data) {
|
||||
let post_id = data.post_id;
|
||||
var post_id = data.post_id;
|
||||
document.getElementById('questPostData-' + post_id).innerHTML = data.post;
|
||||
});
|
||||
socket.on('dice_post', function(data) {
|
||||
});
|
||||
let mtarea = document.getElementById('messageTextArea');
|
||||
var mtarea = document.getElementById('messageTextArea');
|
||||
mtarea.addEventListener('keypress', function(event) {
|
||||
if (event.key == 'Enter' && !event.shiftKey) {
|
||||
let text = mtarea.value.trim();
|
||||
var text = mtarea.value.trim();
|
||||
mtarea.value = '';
|
||||
if (text == '') { return; }
|
||||
socket.emit('message', {message: text, name: 'Anonymous', room: {{ room_id }}});
|
||||
|
@ -57,8 +55,8 @@
|
|||
{% if session.get("user_id") == owner_id %}
|
||||
<script>
|
||||
function makePost() {
|
||||
let qparea = document.getElementById('postTextArea');
|
||||
let text = qparea.value.trim();
|
||||
var qparea = document.getElementById('postTextArea');
|
||||
var text = qparea.value.trim();
|
||||
qparea.value = '';
|
||||
if (text == '') { return; }
|
||||
socket.emit('new_post', {post: text, room: {{ room_id }}});
|
||||
|
@ -72,24 +70,14 @@
|
|||
function save_post(post_id) {
|
||||
document.getElementById('questPostData-' + post_id).contentEditable = 'false';
|
||||
document.getElementById('questPostData-' + post_id).style.border = null;
|
||||
let text = document.getElementById('questPostData-' + post_id).innerHTML;
|
||||
var text = document.getElementById('questPostData-' + post_id).innerHTML;
|
||||
socket.emit('update_post', {post_id: post_id, post: text, room: {{ room_id }}});
|
||||
document.getElementById('savePost-' + post_id).style.display = 'none';
|
||||
}
|
||||
function dice_post() {
|
||||
let formData = new FormData(document.getElementById('QMDicePostForm'));
|
||||
formData.append('room', {{ room_id }});
|
||||
let obj = {};
|
||||
formData.forEach(function(value, key) {
|
||||
obj[key] = value;
|
||||
});
|
||||
socket.emit('dice_post', obj);
|
||||
document.getElementById('QMDicePostForm').reset();
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
function openPostTab(event, modeName) {
|
||||
let i, QMPostTabContent, QMPostTab;
|
||||
var i, QMPostTabContent, QMPostTab;
|
||||
|
||||
QMPostTabContent = document.getElementsByClassName("QMPostTabContent");
|
||||
for (i = 0; i < QMPostTabContent.length; i++) {
|
||||
|
@ -148,24 +136,7 @@
|
|||
<input type="submit" name="newPost" value="Post" onclick="makePost();"/>
|
||||
</div>
|
||||
<div id="QMPostDice" class="QMPostTabContent" style="display:none;">
|
||||
Dice for the dice god.<br />
|
||||
<form id="QMDicePostForm" action="javascript:void(0);" onsubmit="dice_post();">
|
||||
Dice: <input type="number" name="diceNum" min="1" max="99"/>
|
||||
d <input type="number" name="diceSides" min="1" max="99"/>
|
||||
±<input type="number" name="diceMod" min="-999" max="999"/>
|
||||
<input type="checkbox" name="diceStrict"/>
|
||||
<span class="tooltip" title="Only take matching rolls.">Strict</span><br />
|
||||
<input type="checkbox" onclick="document.getElementById('diceChal').disabled=!this.checked;"/>
|
||||
<span class="tooltip" title="Dice challenge">DC:</span>
|
||||
<input type="number" name="diceChal" id="diceChal" min="1" max="99" disabled/><br />
|
||||
<input type="checkbox" onclick="document.getElementById('diceRolls').disabled=!this.checked;"/>
|
||||
<span class="tooltip" title="Automatically close the dice call after this many rolls have been made.">Rolls Taken:</span>
|
||||
<input type="number" name="diceRolls" id="diceRolls" min="1" max="99" disabled/><br />
|
||||
<input type="checkbox" onclick="document.getElementById('diceBest').disabled=!this.checked;"/>
|
||||
<span class="tooltip" title="Pick out the N highest rolls after the dice call has been closed. This should be lower than the number of rolls taken.">Best:</span>
|
||||
<input type="number" name="diceBest" id="diceBest" min="1" max="99" disabled/><br />
|
||||
<input type="submit" name="submit" value="Roll 'em"/>
|
||||
</form>
|
||||
Dice for the dice god.
|
||||
</div>
|
||||
<div id="QMPostPoll" class="QMPostTabContent" style="display:none;">
|
||||
The polls are rigged.
|
||||
|
@ -186,7 +157,6 @@
|
|||
</div>
|
||||
<div class="messageMessage">{{ message[4] }}</div>
|
||||
</div>
|
||||
<hr>
|
||||
{% endfor %}
|
||||
{% endautoescape %}
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue
Block a user