Вход Регистрация
Файл: style/themes/justweb/js/main.js
Строк: 302
<?php
var ds_events = {}
var 
ds_audio = new Audio(); 
var 
ds_playlist = {}
var 
ds_smiles null


var 
eventAudio = new Audio(); 
function 
playAudioMessage(name) {
    
console.log(name); 
    if (!
eventAudio.src)
        
eventAudio.src theme_uri '/audios/' name '.mp3'
    
eventAudio.play(); 
}

function 
lastMessageScroll(behavior) {
    var 
element document.querySelector('.mail_Scroll-helper');
    if (!
element) return ; 
    
    
element.scrollIntoView({
        
behaviorbehavior || 'auto',
        
block'end',
    });
}

function 
appendMessage(msg) {
    $(
'#ds-messages-mail').append(msg); 
    
lastMessageScroll('smooth');

    
setTimeout(function() {
        
lastMessageScroll('smooth');
    }, 
200); 
}

lastMessageScroll(); 
var 
intervalScroll setInterval(function() {
    
lastMessageScroll(); 
}, 
50); 

window.addEventListener("load", function() {
    
clearInterval(intervalScroll); 
})

window.addEventListener('resize', function() {
    
lastMessageScroll(); 
});


function 
swiperEvent(typecallback
{
    var 
start = {};
    
window.addEventListener('touchstart', function(e) {
        
start e.changedTouches[0]; 
    });

    
window.addEventListener('touchend', function(e) {
        
let end e.changedTouches[0]; 
        
let diffX Math.abs(start.pageX end.pageX); 
        
let diffY Math.abs(start.pageY end.pageY); 

        if (
diffX >= 100 && diffY <= 100) {
            if (
type == 'left' && start.pageX end.pageX) {
                
callback(); 
            } else if (
type == 'right' && start.pageX end.pageX) {
                
callback(); 
            }
        }
    });    
}


jQuery(function($) {

    
/** Подгрузка плейлиста **/

    
$events.setEvents('playlist', {
        
data: function() {
            if (
ds_playlist.list != undefined) {
                return 
false;
            }
            
            
console.log('Events: Загрузка плейлиста..'); 
            return 
true
        }, 
        
success: function(event) {
            
ds_playlist event;
            if (
event.list) {
                $.
each(event.list, function(indxelem) {
                    var 
attr = {
                        
'data-id' elem.id
                        
'data-title' elem.title
                        
'data-src' elem.src
                        
'data-hash' elem.hash
                        
'data-uniquie' elem.uniquie
                        
'data-thumbnail' elem.thumbnail
                    }

                    if (
indx == && !ds_audio.src) {
                        $(
'.dpl[data-god="1"]').attr(attr).show().find('.dpl-title').text(elem.title); 
                    }

                    var 
currentPlay getCookie('playerData'); 

                    if (
currentPlay) {
                        var 
data JSON.parse(currentPlay); 
                        if (
data.hash == elem.hash) {
                            $(
'.dpl[data-god="1"]').attr(attr).show().find('.dpl-title').text(elem.title); 
                        }
                    }

                    $(
'.music_playlist').append($('<div/>', $.extend({
                        
'class' 'dpl'
                        
append: [$('<div/>', {
                            class: 
'dpl-toggle'
                        }), $(
'<a/>', {
                            class: 
'dpl-title'
                            
appendelem.title
                            
hrefelem.url
                        }), ]
                    }, 
attr))); 
                }); 
            } 
            
$events.delete('playlist'); 
        }
    }); 

    
/** Подгрузка комментариев **/

    
$events.setEvents('comments', {
        
data: function() {
            var 
ds_comments = []; 
            $(
document).find('[data-comments]').each(function(indxelem) {
                if ($(
elem).data('paged') == 1) {
                    
ds_comments.push({
                        
last_id: $(elem).attr('data-last'),  
                        
first_id: $(elem).attr('data-first'),  
                        
hash: $(elem).attr('data-comments'), 
                    });                     
                }
            }); 

            if (
ds_comments.length 0) {
                
console.log('Events: Проверяем комментарии..'); 
                return 
ds_comments
            }

            return 
false
        }, 
        
success: function(event) {
            $.
each(event, function(idata) {
                var 
commentsList = $(data.container);
                    
commentsList.attr('data-last'data.last_id); 

                $(
'[data-comments-count="' data.hash '"]').text(data.count); 

                $.
each(data.messages, function(midmessage) {
                    if ($(
'.comment-' data.last_id).length == 0) {
                        
commentsList.prepend(message.content); 
                    }
                }); 
            }); 
        }
    }); 

    
/** Подгрузка почты **/

    
$events.setEvents('mail', {
        
data: function() {
            var 
ds_mail false
            $(
document).find('.ds-messages').each(function(indxelem) {
                
ds_mail = {
                    
last_id: $(elem).attr('data-last'),  
                    
first_id: $(elem).attr('data-first'),  
                    
contact_id: $(elem).attr('data-contact'),  
                    
toread: $(elem).attr('data-toread') || 0,  
                    
previus0,
                }

                var 
offset = $('.mail_Pagination-helper').offset(); 
                if (
offset.top >= 0) {
                    
ds_mail.previus 1;
                }

                
console.log('Events: Проверяем почту..');
            }); 

            return 
ds_mail
        }, 
        
success: function(event) {
            
// console.log(event); 

            
$(document).find('.ds-messages').each(function(indxelem) {
                var 
first_id = $(elem).attr('data-first');

                $(
elem).attr('data-last'event.last_id); 
                $(
elem).attr('data-first'event.first_id); 

                if (
event.toread == -1) {
                    $(
elem).attr('data-toread'0); 
                    $(
'.ds-msg-ank.no-read').removeClass('no-read').addClass('read'); 
                }

                $.
each(event.prev, function(midmessage) {
                    $(
elem).prepend(message).attr('data-toread'1); 
                    const 
el document.querySelector('.post-' first_id);
                    
el.scrollIntoView({block"center"});
                }); 

                $.
each(event.messages, function(midmessage) {
                    $(
elem).append(message).attr('data-toread'1); 
                    
lastMessageScroll('smooth'); 
                    
setTimeout(function() {
                        
lastMessageScroll('smooth'); 
                    }, 
300); 
                }); 
            }); 

            if (
event.unread == 0) {
                $(
'.ds-msg-user.no-read').removeClass('no-read').addClass('read'); 
            }
        }
    }); 

    
/** Обновление счетчиков **/ 
    
$events.setEvents('counters', {
        
success: function(event) {
            $.
each(event, function(indexitem) {
                $(
document).find('.counter[data-type="' index '"]').each(function(iel) {
                    var 
count Math.ceil($(el).attr('data-count')); 

                    if (
count != item.count) {
                        if (
item.count count) {
                            
playAudioMessage('message'); 
                        }

                        $(
el).attr('data-count'item.count).text(item.count); 
                    }
                }); 
            }); 
        }
    }); 

    $(
document).ajaxpage(); 

    
/*
    $(document).on('submit', '.comments-form', function() {
        var data = $(this).serialize();
        var action = $(this).attr('action');

        $(this).find('.attachments').html(''); 
        $(this).find('textarea[name="msg"]').removeAttr('style').val(''); 

        $.ajax({
            type: "POST",
            url: action,
            data: data,
            dataType: 'json',
            success: function(data) {
                if (!data.errors) {
                    if (data.append == 'last') {
                        $(data.container).append(data.msg); 

                        lastMessageScroll('smooth');
                        setTimeout(function() {
                            lastMessageScroll('smooth');
                        }, 200);                         
                    } else {
                        $(data.container).prepend(data.msg); 
                    }
                }
            }
        });

        return false; 
    }); 
    */

    
$(document).on('submit''.comments-form', function() {
        var 
data = $(this).serialize();
        var 
action = $(this).attr('action');

        $(
this).find('.attachments').html(''); 
        $(
this).find('textarea[name="msg"]').removeAttr('style').val(''); 

        $.
ajax({
            
type"POST",
            
urlaction,
            
datadata,
            
dataType'json',
            
success: function(data) {
                if (!
data.errors) {
                    var 
commentsList = $(data.container);
                        
commentsList.attr('data-last'data.id); 
                    
                    $(
'[data-comments-count="' data.hash '"]').text(data.count); 

                    if (
data.append == 'last') {
                        $(
data.container).append(data.msg); 
                        
lastMessageScroll('smooth');             
                    } else {
                        $(
data.container).prepend(data.msg); 
                    }
                }
            }
        });

        return 
false
    }); 

    $(
document).mouseup(function(e) {
        var 
= $('.header-player'); 
        if (!
p.is(e.target) && p.has(e.target).length === && $(e.target).closest('.header-music').length === 0) { 
            $(
'#header-player-toggle').prop('checked'false); 
        }
    });

    $(
document).on('click''[data-toggle]', function(e) {
        var 
uid = $(this).attr('data-toggle'); 
        var 
current = $(this).closest('.ds-comment-form').attr('data-panel');

        if (
current == uid) {
            
uid ''
        }

        $(
this).closest('.ds-comment-form').attr('data-panel'uid);
    });

    $(
document).on('click''.mobile-sidebar-toggle', function(e) {
        var 
body = $('body'); 
        if (
body.hasClass('sidebar-active')) {
            
body.removeClass('sidebar-active')
        } else {
            
body.addClass('sidebar-active')
        }
    });

    
swiperEvent('left', function() {
        var 
body = $('body'); 

        if (
body.hasClass('mobile-player-active')) {
            
body.removeClass('mobile-player-active'); 
        } else if (!
body.hasClass('sidebar-active')) {
            
body.addClass('sidebar-active'); 
        }
    }); 

    
swiperEvent('right', function() {
        var 
body = $('body'); 

        if (
body.hasClass('sidebar-active')) {
            
body.removeClass('sidebar-active')
        } else if (!
body.hasClass('sidebar-active')) {
            
body.addClass('mobile-player-active'); 
        } 
    }); 
}); 

console.log(ds_emoji_list);
?>
Онлайн: 1
Реклама