Файл: adultscript-2.0.3-pro/files/templates/defboot/js/profile.js
Строк: 262
<?php
$(document).ready(function() {
var user_id = $("input[name='user_id']").val();
$("#more-info").click(function(e) {
if ($(this).hasClass('show-more')) {
$(this).removeClass('show-more').addClass('show-less');
$(this).text(show_less);
$(".more").show();
} else {
$(this).removeClass('show-less').addClass('show-more');
$(this).text(show_more);
$(".more").hide();
}
});
$("#connect-friend").on('click', 'button#profile-friend-del, button#profile-friend-add', function() {
var action = $(this).attr('id').match(/profile-friend-(.*)/)[1];
$.ajax({
url: base_url + '/ajax.php?s=friend_' + action,
cache: false,
type: "POST",
dataType: "json",
data: { user_id: user_id },
success: function(response){
if (response.status == '1') {
$("#connect-response").removeClass('alert-danger').addClass('alert-success');
} else {
$("#connect-response").removeClass('alert-success').addClass('alert-danger');
}
if (response.code != '') {
$("#connect-friend").html(response.code);
}
$("#connect-response").append(response.msg);
$("#connect-response").show();
}
});
});
$("#connect-subscribe").on('click', 'button#profile-subscribe-del, button#profile-subscribe-add', function() {
var action = $(this).attr('id').match(/profile-subscribe-(.*)/)[1];
$.ajax({
url: base_url + '/ajax.php?s=subscribe_' + action,
cache: false,
type: "POST",
dataType: "json",
data: { user_id: user_id },
success: function(response){
if (response.status == '1') {
$("#connect-response").removeClass('alert-danger').addClass('alert-success');
} else {
$("#connect-response").removeClass('alert-success').addClass('alert-danger');
}
if (response.code != '') {
$("#connect-subscribe").html(response.code);
}
$("#connect-response").append(response.msg);
$("#connect-response").show();
}
});
});
$("#connect-block").on('click', 'button#profile-block-del, button#profile-block-add', function() {
var action = $(this).attr('id').match(/profile-block-(.*)/)[1];
$.ajax({
url: base_url + '/ajax.php?s=block_' + action,
cache: false,
type: "POST",
dataType: "json",
data: { user_id: user_id },
success: function(response){
if (response.status == '1') {
$("#connect-response").removeClass('alert-danger').addClass('alert-success');
} else {
$("#connect-response").removeClass('alert-success').addClass('alert-danger');
}
if (response.code != '') {
$("#connect-block").html(response.code);
}
$("#connect-response").append(response.msg);
$("#connect-response").show();
}
});
});
$("button[id='profile-report-add']").click(function(e) {
e.preventDefault();
$.ajax({
url: base_url + '/ajax.php?s=report',
cache: false,
type: "POST",
dataType: "json",
data: { user_id: user_id },
success: function(response) {
if (response.status == '1') {
$("#connect-response").removeClass('alert-danger').addClass('alert-success');
} else {
$("#connect-response").removeClass('alert-success').addClass('alert-danger');
}
$("#connect-report").html(response.code);
$("#connect-response").html(response.msg);
$("#connect-response").show();
}
});
});
$("button[id='post-comment']").click(function(e) {
e.preventDefault();
var comment = $("textarea[name='comment']").val();
var error = false;
var message = 'Your message has been posted!';
if (comment == '') {
message = 'Please enter message!';
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();
return;
}
$.ajax({
url: base_url + '/ajax.php?s=comment',
cache: false,
type: "POST",
dataType: "json",
data: { user_id: user_id, comment: comment},
success: function(response) {
if (response.status == '1') {
$("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=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=comment_pagination',
cache: false,
type: "POST",
dataType: "json",
data: { user_id: user_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();
}
}
}
});
});
});
?>