2018-10-09 19:45:26 +00:00
|
|
|
$(function() {
|
2018-10-09 20:12:41 +00:00
|
|
|
var csrftoken = $("#csrf-token input").val();
|
2018-10-09 19:57:39 +00:00
|
|
|
|
2018-10-09 19:45:26 +00:00
|
|
|
$(".vote-up").click(function() {
|
2018-10-09 19:57:39 +00:00
|
|
|
var reviewId = $(this).attr("data-review-id");
|
2018-10-09 20:32:16 +00:00
|
|
|
var data = {
|
|
|
|
'csrfmiddlewaretoken': csrftoken,
|
|
|
|
'helpful': true
|
|
|
|
};
|
2018-10-09 19:45:26 +00:00
|
|
|
// Vote up
|
2018-10-09 20:32:16 +00:00
|
|
|
$.post(
|
2018-10-10 14:27:04 +00:00
|
|
|
'/api/postings/reviews/' + reviewId + '/helpful_vote/',
|
|
|
|
data,
|
|
|
|
function(result) { console.log(result); }
|
2018-10-09 20:32:16 +00:00
|
|
|
);
|
2018-10-10 14:27:04 +00:00
|
|
|
// Hide vote buttons
|
|
|
|
$("#review-votes-" + reviewId + " .review-vote-buttons").hide();
|
2018-10-09 19:45:26 +00:00
|
|
|
});
|
|
|
|
$(".vote-down").click(function() {
|
2018-10-10 14:27:04 +00:00
|
|
|
var reviewId = $(this).attr("data-review-id");
|
2018-10-09 20:32:16 +00:00
|
|
|
var data = {
|
|
|
|
'csrfmiddlewaretoken': csrftoken,
|
|
|
|
'helpful': false
|
|
|
|
};
|
2018-10-09 19:45:26 +00:00
|
|
|
// Vote down
|
2018-10-09 20:32:16 +00:00
|
|
|
$.post(
|
2018-10-10 14:27:04 +00:00
|
|
|
'/api/postings/reviews/' + reviewId + '/helpful_vote/',
|
|
|
|
data,
|
|
|
|
function(result) { console.log(result); }
|
2018-10-09 20:32:16 +00:00
|
|
|
);
|
2018-10-10 14:27:04 +00:00
|
|
|
// Hide vote buttons
|
|
|
|
$("#review-votes-" + reviewId + " .review-vote-buttons").hide();
|
2018-10-09 19:45:26 +00:00
|
|
|
});
|
|
|
|
});
|