From 03db2db899df8ef96733262963eff0af8934229d Mon Sep 17 00:00:00 2001 From: Zhao-Linux Date: Thu, 17 Nov 2022 16:52:46 +0700 Subject: [PATCH] fix pagevote score not true --- templates/actionbar/media-js.html | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/templates/actionbar/media-js.html b/templates/actionbar/media-js.html index 1605a63..53f08fa 100644 --- a/templates/actionbar/media-js.html +++ b/templates/actionbar/media-js.html @@ -41,11 +41,13 @@ if ($votes.downvote.hasClass('voted')) { delta = 2; } - ajax_vote('{{ url('pagevote_upvote') }}', id, delta, function () { - if ($votes.downvote.hasClass('voted')) - $votes.downvote.removeClass('voted'); - $votes.upvote.addClass('voted'); - }); + for (let i = 0; i < delta; i++) { + ajax_vote('{{ url('pagevote_upvote') }}', id, 1, function () { + if ($votes.downvote.hasClass('voted')) + $votes.downvote.removeClass('voted'); + $votes.upvote.addClass('voted'); + }); + } } }; @@ -61,11 +63,13 @@ if ($votes.upvote.hasClass('voted')) { delta = -2; } - ajax_vote('{{ url('pagevote_downvote') }}', id, delta, function () { - if ($votes.upvote.hasClass('voted')) - $votes.upvote.removeClass('voted'); - $votes.downvote.addClass('voted'); - }); + for (let i = 0; i > delta; i--) { + ajax_vote('{{ url('pagevote_downvote') }}', id, -1, function () { + if ($votes.upvote.hasClass('voted')) + $votes.upvote.removeClass('voted'); + $votes.downvote.addClass('voted'); + }); + } } };