fix pagevote score not true

This commit is contained in:
Zhao-Linux 2022-11-17 16:52:46 +07:00
parent 7174fc1066
commit 03db2db899

View file

@ -41,12 +41,14 @@
if ($votes.downvote.hasClass('voted')) { if ($votes.downvote.hasClass('voted')) {
delta = 2; delta = 2;
} }
ajax_vote('{{ url('pagevote_upvote') }}', id, delta, function () { for (let i = 0; i < delta; i++) {
ajax_vote('{{ url('pagevote_upvote') }}', id, 1, function () {
if ($votes.downvote.hasClass('voted')) if ($votes.downvote.hasClass('voted'))
$votes.downvote.removeClass('voted'); $votes.downvote.removeClass('voted');
$votes.upvote.addClass('voted'); $votes.upvote.addClass('voted');
}); });
} }
}
}; };
window.pagevote_downvote = function (id) { window.pagevote_downvote = function (id) {
@ -61,12 +63,14 @@
if ($votes.upvote.hasClass('voted')) { if ($votes.upvote.hasClass('voted')) {
delta = -2; delta = -2;
} }
ajax_vote('{{ url('pagevote_downvote') }}', id, delta, function () { for (let i = 0; i > delta; i--) {
ajax_vote('{{ url('pagevote_downvote') }}', id, -1, function () {
if ($votes.upvote.hasClass('voted')) if ($votes.upvote.hasClass('voted'))
$votes.upvote.removeClass('voted'); $votes.upvote.removeClass('voted');
$votes.downvote.addClass('voted'); $votes.downvote.addClass('voted');
}); });
} }
}
}; };
}); });