Файл: adultscript-2.0.3-pro/files/templates/defboot/js/playlist.js
Строк: 191
<?php
$(document).ready(function() {
var playlist_id = $("input[name='playlist_id']").val();
$("button[id='like'],button[id='dislike']").click(function(e) {
e.preventDefault();
var rating = 1;
if ($(this).attr('id') == 'dislike') {
rating = 0;
}
$.ajax({
url: base_url + '/ajax.php?s=playlist_rate',
cache: false,
type: "POST",
dataType: "json",
data: {playlist_id: playlist_id, rating: rating},
success: function(response) {
if (response.status == '1') {
var color = 'text-success';
var id = 'like-icon';
if (rating == '0') {
color = 'text-muted';
id = 'dislike-icon';
}
$("i[id='" + id + "']").addClass(color);
$("button[id='rating']").html(response.code);
$("button[id='like'],button[id='dislike']").prop('disabled', true);
} else {
$("#response").html(close + response.msg);
$("#response").removeClass('alert-success').addClass('alert-danger');
$("#response").show();
}
}
});
});
$("button[id='share']").click(function(e) {
e.preventDefault();
if ($("#share-container").is(':visible')) {
$("#share-container").hide();
} else {
$("#share-container").show();
}
});
$("button[id='favorite']").click(function(e) {
e.preventDefault();
$.ajax({
url: base_url + '/ajax.php?s=playlist_favorite',
cache: false,
type: "POST",
dataType: "json",
data: {playlist_id: playlist_id},
success: function(response) {
if (response.status == '1') {
$("i[id='favorite-icon']").addClass('text-danger');
$("button[id='favorite']").prop('disabled', true);
} else {
$("#response").html(close + response.msg);
$("#response").removeClass('alert-success').addClass('alert-danger');
$("#response").show();
}
}
});
});
$("button[id='post-comment']").click(function(e) {
e.preventDefault();
var comment = $("textarea[name='comment']").val();
var nickname = $("input[name='nickname']").val();
var error = false;
var message = 'Your message has been posted!';
if (comment == '') {
message = 'Please enter your comment!';
error = true;
} else if (comment.length > 500) {
message = 'Comment can contain maximum 500 characters!';
error = true;
}
if (error) {
$("#response-comment").html(close + message);
$("#response-comment").removeClass('alert-succes').addClass('alert-danger');
$("#response-comment").show();
}
$.ajax({
url: base_url + '/ajax.php?s=playlist_comment',
cache: false,
type: "POST",
dataType: "json",
data: { playlist_id: playlist_id, comment: comment, nickname: nickname },
success: function(response) {
if (response.status == '1') {
$("input[id='nickname']").val();
$("textarea[name='comment']").val('');
$("#no-comments").hide();
$("#comments-container").prepend(response.code);
$("#response-comment").removeClass('alert-danger').addClass('alert-success');
} else {
$("#response-comment").removeClass('alert-success').addClass('alert-danger');
}
$("#response-comment").html(close + response.msg);
$("#response-comment").show();
}
});
});
$("#comments-container").on('click', "button[id^='comment-delete-']", function(e) {
e.preventDefault();
var comment_id = $(this).attr('id').match(/comment-delete-(.*)/)[1];
$.ajax({
url: base_url + '/ajax.php?s=playlist_comment_delete',
cache: false,
type: "POST",
dataType: "json",
data: { comment_id: comment_id },
success: function(response) {
if (response.status == '1') {
$("#comment-" + comment_id).css('border', '1px solid red');
$("#comment-" + comment_id).fadeOut(1000);
}
if (!$(".media:visible").length) {
$("#comments-container").html('<div id="no-comments" class="none">No comments yet!</div>');
}
}
});
});
$("button[id='comment-pagination']").click(function(e) {
e.preventDefault();
var page = $("input[name='comment-page']").val();
$.ajax({
url: base_url + '/ajax.php?s=playlist_comment_pagination',
cache: false,
type: "POST",
dataType: "json",
data: { playlist_id: playlist_id, page: page },
success: function(response) {
if (response.status == '1') {
$("input[name='comment-page']").val(response.page);
$("#comments-container").append(response.code);
if (response.end == '1') {
$("button[id='comment-pagination']").fadeOut();
}
}
}
});
});
});
?>