This commit is contained in:
Aevann1 2021-12-11 05:18:14 +02:00
parent 8c13a0c879
commit 2a965e9ff5
4 changed files with 29 additions and 26 deletions

View file

@ -1,11 +1,11 @@
function togglePostEdit(id){ function bet_vote(cid) {
body=document.getElementById("post-body"); for(let el of document.getElementsByClassName('bet')) {
title=document.getElementById("post-title"); el.disabled = true;
form=document.getElementById("edit-post-body-"+id); }
box=document.getElementById("post-edit-box-"+id); var scoretext = document.getElementById('bet-' + cid);
var score = Number(scoretext.textContent);
body.classList.toggle("d-none"); scoretext.textContent = score + 1;
title.classList.toggle("d-none"); post('/bet/' + cid);
form.classList.toggle("d-none"); document.getElementById("user-coins-amount").innerText = parseInt(document.getElementById("user-coins-amount").innerText) - 200;
autoExpand(box); document.getElementById(`span-${cid}`).classList.add('bet_voted')
}; }

View file

@ -0,0 +1,11 @@
function togglePostEdit(id){
body=document.getElementById("post-body");
title=document.getElementById("post-title");
form=document.getElementById("edit-post-body-"+id);
box=document.getElementById("post-edit-box-"+id);
body.classList.toggle("d-none");
title.classList.toggle("d-none");
form.classList.toggle("d-none");
autoExpand(box);
};

View file

@ -24,6 +24,8 @@ else: cc = "country club"
@app.get("/distribute/<cid>") @app.get("/distribute/<cid>")
@admin_level_required(2) @admin_level_required(2)
def distribute(v, cid): def distribute(v, cid):
try: int(cid)
except: abort(400)
votes = g.db.query(CommentVote).filter_by(comment_id=cid) votes = g.db.query(CommentVote).filter_by(comment_id=cid)
autobetter = g.db.query(User).filter_by(id=AUTOBETTER_ID).first() autobetter = g.db.query(User).filter_by(id=AUTOBETTER_ID).first()
coinsperperson = int(autobetter.coins / votes.count()) coinsperperson = int(autobetter.coins / votes.count())

View file

@ -13,20 +13,6 @@
{% block title %} {% block title %}
<script>
function bet_vote(cid) {
for(let el of document.getElementsByClassName('bet')) {
el.disabled = true;
}
var scoretext = document.getElementById('bet-' + cid);
var score = Number(scoretext.textContent);
scoretext.textContent = score + 1;
post('/bet/' + cid);
document.getElementById("user-coins-amount").innerText = parseInt(document.getElementById("user-coins-amount").innerText) - 200;
document.getElementById(`span-${cid}`).classList.add('bet_voted')
}
</script>
{% if p.award_count("train") %} {% if p.award_count("train") %}
<style> <style>
@keyframes train { @keyframes train {
@ -806,7 +792,11 @@
{% endif %} {% endif %}
{% if v and (v.id == p.author_id or v.admin_level > 1 and v.admin_level > 2) %} {% if v and (v.id == p.author_id or v.admin_level > 1 and v.admin_level > 2) %}
<script src="/assets/js/submission.js?v=3"></script> <script src="/assets/js/togglePostEdit.js?v=3"></script>
{% endif %}
{% if v %}
<script src="/assets/js/submission.js?v=5"></script>
{% endif %} {% endif %}
{% if not v or v.highlightcomments %} {% if not v or v.highlightcomments %}