Вход Регистрация
Файл: adultscript-2.0.3-pro/files/templates/defboot/js/channel.js
Строк: 84
<?php
$(document).ready(function() {
    var 
width = $(window).width();
    
    if (
width < 991) {
        $(
".panel-collapse").removeClass('in');
    }

    $(
window).resize(function() {
        if ($(
window).width() < 991) {
            $(
".panel-collapse").removeClass('in');
        } else {
            $(
".panel-collapse").addClass('in');
        }
    });
    
    var 
channel_id = $("input[name='channel_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=channel_rate',
            
cache: false,
            
type: "POST",
            
dataType: "json",
            
data: {channel_id: channel_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();
                }
            }
        });
    });
    
    $(
"div[id='subscribe-container']").on('click', 'button#subscribe, button#unsubscribe', function(e) {
        
e.preventDefault();

        var 
id = 'subscribe';
        if ($(
this).attr('id') == 'unsubscribe') {
            
id = 'unsubscribe';
        }

        $.
ajax({
            
url: base_url + '/ajax.php?s=channel_' + id,
            
cache: false,
            
type: "POST",
            
dataType: "json",
            
data: {channel_id: channel_id},
            
success: function(response) {
                if (
response.status == '1') {
                    $(
"#subscribe-container").html(response.code);
                } else {
                    $(
"#response").html(close + response.msg);
                    $(
"#response").removeClass('alert-success').addClass('alert-danger');
                    $(
"#response").show();
                }
            }
        });
    });     
});
?>
Онлайн: 2
Реклама