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,11 +41,13 @@
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++) {
if ($votes.downvote.hasClass('voted')) ajax_vote('{{ url('pagevote_upvote') }}', id, 1, function () {
$votes.downvote.removeClass('voted'); if ($votes.downvote.hasClass('voted'))
$votes.upvote.addClass('voted'); $votes.downvote.removeClass('voted');
}); $votes.upvote.addClass('voted');
});
}
} }
}; };
@ -61,11 +63,13 @@
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--) {
if ($votes.upvote.hasClass('voted')) ajax_vote('{{ url('pagevote_downvote') }}', id, -1, function () {
$votes.upvote.removeClass('voted'); if ($votes.upvote.hasClass('voted'))
$votes.downvote.addClass('voted'); $votes.upvote.removeClass('voted');
}); $votes.downvote.addClass('voted');
});
}
} }
}; };