qm poll post ui added

This commit is contained in:
iou1name 2018-07-09 18:59:16 -04:00
parent 7f24914046
commit b35883146d
3 changed files with 46 additions and 0 deletions

View File

@ -54,6 +54,8 @@ app.wsgi_app = ReverseProxied(app.wsgi_app)
app.register_blueprint(views) app.register_blueprint(views)
app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024
app.config['SESSION_TYPE'] = 'filesystem' app.config['SESSION_TYPE'] = 'filesystem'
app.jinja_env.trim_blocks = True
app.jinja_env.lstrip_blocks = True
Session(app) Session(app)
socketio.init_app(app) socketio.init_app(app)
paranoid = Paranoid(app) paranoid = Paranoid(app)
@ -93,6 +95,17 @@ def get_dice_challenge(post_id):
return db.get_dice_call(post_id)[3] return db.get_dice_call(post_id)[3]
@app.after_request
def minify(res):
"""
Minify the HTML response to decrease bandwidth usage.
"""
if res.content_type == "text/html; charset=utf-8" and False:
res.set_data(
res.get_data(as_text=True).replace("\n", "").replace("\t", ""))
return res
init() init()
if __name__ == "__main__": if __name__ == "__main__":
app.run(host='0.0.0.0', port=5050) app.run(host='0.0.0.0', port=5050)

View File

@ -101,6 +101,15 @@ h3 {
border-bottom: 1px dotted black; border-bottom: 1px dotted black;
} }
#QMPollPostForm a {
text-decoration: none;
}
.pollOption {
width: 70%;
margin: 0.1em;
}
#chatPane { #chatPane {
height: 100%; height: 100%;
width: 30%; width: 30%;

View File

@ -147,6 +147,18 @@
post.children[0].children[1].outerHTML = ""; post.children[0].children[1].outerHTML = "";
} }
} }
function insertPollOption() {
let opts = document.getElementById('pollOptions');
let num = opts.children.length+1;
let temp = document.createElement('template');
temp.innerHTML = '<div><input type="text" name="pollOption-' + num + '" class="pollOption" placeholder="Option ' + num + '" /></div>';
opts.appendChild(temp.content);
}
function removePollOption() {
let opts = document.getElementById('pollOptions');
if (opts.children.length == 0) { return; }
opts.children[opts.children.length-1].outerHTML = '';
}
</script> </script>
<script> <script>
function openPostTab(event, modeName) { function openPostTab(event, modeName) {
@ -252,6 +264,18 @@
</div> </div>
<div id="QMPostPoll" class="QMPostTabContent" style="display:none;"> <div id="QMPostPoll" class="QMPostTabContent" style="display:none;">
The polls are rigged. The polls are rigged.
<form id="QMPollPostForm" action="javascript:void(0);" onsubmit="poll_post();">
<a href="javascript:void(0);" id="pollInsertNewOption" onclick="insertPollOption()">[+]</a>
<a href="javascript:void(0);" onclick="removePollOption()">[-]</a>
<div id="pollOptions">
<div><input type="text" name="pollOption-1" class="pollOption" placeholder="Option 1" /></div>
<div><input type="text" name="pollOption-2" class="pollOption" placeholder="Option 2" /></div>
</div>
<hr>
<input type="checkbox" name="pollAllowMultipleChoices" />Allow multiple choices<br />
<input type="checkbox" name="pollAllowUserOptions" />Allow user-created options<br />
<input type="submit" name="submit" value="Submit" />
</form>
</div> </div>
</div> </div>
{% endif %} {% endif %}