dffd
parent
ba409b19f1
commit
a46402a2c6
|
@ -114,12 +114,9 @@ def api_vote_post(post_id, new, v):
|
|||
@validate_formkey
|
||||
def api_vote_comment(comment_id, new, v):
|
||||
|
||||
if new not in ["-1", "0", "1"]:
|
||||
abort(400)
|
||||
if new not in ["-1", "0", "1"]: abort(400)
|
||||
|
||||
# disallow bots
|
||||
if request.headers.get("X-User-Type","") == "Bot":
|
||||
abort(403)
|
||||
if request.headers.get("X-User-Type","") == "Bot": abort(403)
|
||||
|
||||
new = int(new)
|
||||
|
||||
|
|
|
@ -773,65 +773,22 @@
|
|||
}
|
||||
|
||||
register_votes()
|
||||
|
||||
function vote_comment(comment_id, direction) {
|
||||
url="/api/vote/comment/"+ comment_id +"/"+direction;
|
||||
|
||||
callback=function(){
|
||||
thing = document.getElementById("comment-"+ comment_id+"-actions");
|
||||
uparrow1=document.getElementById("comment-"+ comment_id +"-up");
|
||||
downarrow1=document.getElementById("comment-"+ comment_id +"-down");
|
||||
scoreup1=document.getElementById("comment-"+ comment_id +"-score-up");
|
||||
scorenone1=document.getElementById("comment-"+ comment_id +"-score-none");
|
||||
scoredown1=document.getElementById("comment-"+ comment_id +"-score-down");
|
||||
|
||||
if (direction=="1") {
|
||||
thing.classList.add("upvoted");
|
||||
thing.classList.remove("downvoted");
|
||||
uparrow1.onclick=function(){vote_comment(comment_id, 0)};
|
||||
downarrow1.onclick=function(){vote_comment(comment_id, -1)};
|
||||
scoreup1.classList.remove("d-none");
|
||||
scorenone1.classList.add("d-none");
|
||||
scoredown1.classList.add("d-none");
|
||||
}
|
||||
else if (direction=="-1"){
|
||||
thing.classList.remove("upvoted");
|
||||
thing.classList.add("downvoted");
|
||||
uparrow1.onclick=function(){vote_comment(comment_id, 1)};
|
||||
downarrow1.onclick=function(){vote_comment(comment_id, 0)};
|
||||
scoreup1.classList.add("d-none");
|
||||
scorenone1.classList.add("d-none");
|
||||
scoredown1.classList.remove("d-none");
|
||||
}
|
||||
else if (direction=="0"){
|
||||
thing.classList.remove("upvoted");
|
||||
thing.classList.remove("downvoted");
|
||||
uparrow1.onclick=function(){vote_comment(comment_id, 1)};
|
||||
downarrow1.onclick=function(){vote_comment(comment_id, -1)};
|
||||
scoreup1.classList.add("d-none");
|
||||
scorenone1.classList.remove("d-none");
|
||||
scoredown1.classList.add("d-none");
|
||||
}
|
||||
}
|
||||
|
||||
post(url, callback, "Unable to vote at this time. Please try again later.");
|
||||
}
|
||||
</script>
|
||||
{% if v %}
|
||||
<script src="https://js.pusher.com/beams/1.0/push-notifications-cdn.js"></script>
|
||||
|
||||
<script>
|
||||
const beamsClient = new PusherPushNotifications.Client({
|
||||
instanceId: '02ddcc80-b8db-42be-9022-44c546b4dce6',
|
||||
});
|
||||
|
||||
beamsClient
|
||||
.start()
|
||||
.then((beamsClient) => beamsClient.getDeviceId())
|
||||
.then(() => beamsClient.addDeviceInterest(v.strid))
|
||||
.then(() => beamsClient.getDeviceInterests())
|
||||
.catch(console.error);
|
||||
</script>
|
||||
<script src="https://js.pusher.com/beams/1.0/push-notifications-cdn.js"></script>
|
||||
|
||||
<script>
|
||||
const beamsClient = new PusherPushNotifications.Client({
|
||||
instanceId: '02ddcc80-b8db-42be-9022-44c546b4dce6',
|
||||
});
|
||||
|
||||
beamsClient
|
||||
.start()
|
||||
.then((beamsClient) => beamsClient.getDeviceId())
|
||||
.then(() => beamsClient.addDeviceInterest(v.strid))
|
||||
.then(() => beamsClient.getDeviceInterests())
|
||||
.catch(console.error);
|
||||
</script>
|
||||
{% endif %}
|
||||
|
||||
<meta charset="utf-8">
|
||||
|
|
Loading…
Reference in New Issue