qm post tabs and fixed error with posting

This commit is contained in:
iou1name 2018-06-27 08:43:00 -04:00
parent 7bcf9d3007
commit a302a45506
2 changed files with 58 additions and 21 deletions

View File

@ -66,7 +66,7 @@ def new_post(data):
post = data["post"]
post = bleach.clean(post.strip())
post = post.replace("\n", "<br />")
message = tools.handle_img(message)
post = tools.handle_img(post)
data["post"] = [post]
db.insert_quest_post(room, post, int(time.time()))
@ -87,7 +87,7 @@ def update_post(data):
post = data["post"]
post = post.strip().replace("<br>", "<br />")
message = tools.handle_img(message)
post = tools.handle_img(post)
data["post"] = post
post_id = data["post_id"]

View File

@ -75,6 +75,24 @@
document.getElementById('savePost-' + post_id).style.display = 'none';
}
</script>
<script>
function openPostTab(event, modeName) {
var i, QMPostTabContent, QMPostTab;
QMPostTabContent = document.getElementsByClassName("QMPostTabContent");
for (i = 0; i < QMPostTabContent.length; i++) {
QMPostTabContent[i].style.display = "none";
}
QMPostTab = document.getElementsByClassName("QMPostTab");
for (i = 0; i < QMPostTab.length; i++) {
QMPostTab[i].className = QMPostTab[i].className.replace(" active", "");
}
document.getElementById(modeName).style.display = "block";
event.currentTarget.className += " active";
}
</script>
{% endif %}
{% endblock %}
{% block header %}
@ -86,29 +104,48 @@
<div id="questContainer">
<div id="questPane">
<center><h1>{{ quest_title }}</h1></center>
{% for quest_post in quest_posts %}
<div class="questPost">
<div class="questPostMeta">
{{ quest_post[3] | strftime }}
{% if session.get("user_id") == owner_id %}
<br /><a href="javascript:void(0);" onclick="edit_post('{{ quest_post[0] }}')">Edit</a>
<a href="javascript:void(0);" id="savePost-{{ quest_post[0] }}" onclick="save_post('{{ quest_post[0] }}')" style="display:none;">Save</a>
{% endif %}
</div>
<div class="questPostData" id="questPostData-{{ quest_post[0] }}">
{% autoescape false %}
{{ quest_post[2] }}
{% endautoescape %}
</div>
</div><br />
{% endfor %}
<div id="questPosts">
{% for quest_post in quest_posts %}
<div class="questPost">
<div class="questPostMeta">
{{ quest_post[3] | strftime }}
{% if session.get("user_id") == owner_id %}
<br /><a href="javascript:void(0);" onclick="edit_post('{{ quest_post[0] }}')">Edit</a>
<a href="javascript:void(0);" id="savePost-{{ quest_post[0] }}" onclick="save_post('{{ quest_post[0] }}')" style="display:none;">Save</a>
{% endif %}
</div>
<div class="questPostData" id="questPostData-{{ quest_post[0] }}">
{% autoescape false %}
{{ quest_post[2] }}
{% endautoescape %}
</div>
</div><br />
{% endfor %}
</div>
{% if session.get("user_id") == owner_id %}
<div id="postTextDiv">
<textarea id="postTextArea"></textarea><br />
<input type="submit" name="newPost" value="Post" onclick="makePost();"/>
<div id="QMPostPane">
<div>
<ul id="QMPostTabs">
<li><a class="QMPostTab active" href="javascript:void(0);" onclick="openPostTab(event, 'QMPostText')">Text</a></li>
<li><a class="QMPostTab" href="javascript:void(0);" onclick="openPostTab(event, 'QMPostDice')">Dice</a></li>
<li><a class="QMPostTab" href="javascript:void(0);" onclick="openPostTab(event, 'QMPostPoll')">Poll</a></li>
</ul>
</div>
<div id="QMPostText" class="QMPostTabContent" style="display:initial;">
<textarea id="postTextArea"></textarea><br />
<input type="submit" name="newPost" value="Post" onclick="makePost();"/>
</div>
<div id="QMPostDice" class="QMPostTabContent" style="display:none;">
Dice for the dice god.
</div>
<div id="QMPostPoll" class="QMPostTabContent" style="display:none;">
The polls are rigged.
</div>
</div>
{% endif %}
</div>
<br />
<br />
<div id="chatPane">
<h1>Chat</h1>
<div id="chatWindow">