Browse Source

can now rescind votes

master
Cerys 4 weeks ago
parent
commit
2f7b6826de
  1. 2
      Public/API/V1/RateTune.php
  2. 13
      Templates/Pages/tune/uuid.html.twig

2
Public/API/V1/RateTune.php

@ -55,6 +55,8 @@ if(sizeof($existingRating) == 0)
}
elseif(sizeof($existingRating) == 1)
{
if($existingRating[0]['Rating'] == $ratingValue)
$ratingValue = 0;
$db->RunUpdate(
queryBuilder: SQLQueryBuilderWrapper::UPDATE(
table: 'TuneRatings'

13
Templates/Pages/tune/uuid.html.twig

@ -7,24 +7,17 @@
<link rel="stylesheet" href="/Static/CSS/ThirdParty/abcjs-audio.css">
<script>
var lastVoteAction = "";
function VoteOnTune(type)
{
if(lastVoteAction === type) return;
lastVoteAction = type;
API_GET('/V1/RateTune.php?tune-id={{ TuneDetails.ID }}&type='+type)
.then(payload => {
console.log(payload);
document.getElementById('LikeButton').classList.remove('active');
document.getElementById('DislikeButton').classList.remove('active');
if(payload['NewVoteValue'] === -1)
{
document.getElementById('LikeButton').classList.remove('active');
document.getElementById('DislikeButton').classList.add('active');
}
else if(payload['NewVoteValue'] === 1)
{
document.getElementById('LikeButton').classList.add('active');
document.getElementById('DislikeButton').classList.remove('active');
}
document.getElementById('LikeCount').innerHTML = payload['LikeCount'];
document.getElementById('DislikeCount').innerHTML = payload['DislikeCount'];
})
@ -34,8 +27,6 @@
}
</script>
{{ MyVote|json_encode }}
<div class="InnerContent">
<div>

Loading…
Cancel
Save