Что нового

Модуль вложенных плейлистов для DLE (1 Viewer)

Продолжаю эксперименты, на этот раз вместо селекторов кнопки.

Всё также в fullstory.tpl, в место, где должен быть плеер вставить код, который написан ниже. CSS стили из моего шаблона, потому требуют переделки под себя.

HTML:
<style>
#videoFrame {
    width: 100%;
    height: 320px;
    border-radius: 7px;
    margin-top: 15px;
    background-color: #6d6d6d33;
    background-image: linear-gradient(-20deg, #ffa58c 20%, #f85c6a 100%);
}

#audioButtons {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-bottom: 15px;
    margin-top: 10px;
}

#audioButtons button {
    display: inline-block;
    border: 0;
    padding: 7px 10px;
    background-color: #86868630;
    color: var(--sidebar-post-font-title);
    cursor: pointer;
    font-size: 15px;
    border-radius: 5px;
    font-family: 'Roboto', sans-serif;
}

#episodeButtons {
    max-height: 200px;
    overflow-y: auto;
    display: grid;
    grid-gap: 10px;
}

#episodeButtons div {
    display: flex;
    padding: 7px 35px 7px 10px;
    background-color: #86868630;
    color: var(--sidebar-post-font-title);
    cursor: pointer;
    font-size: 15px;
    border-radius: 5px;
    position: relative;
    line-height: 18px;
}

#episodeButtons div label {
    display: block;
    width: 100%;
    cursor: pointer;
}

#episodeButtons div input[type="checkbox"] {
    position: absolute;
    right: 10px;
    top: 9px;
}

#episodeButtons div.active, #audioButtons button.active {
    background-color: #ff6060;
    color: #fff;
    cursor: not-allowed;
}
</style>

<iframe id="videoFrame" src="" allowfullscreen frameborder="0"></iframe>
<div id="audioButtons" class="button-container"></div>
<div id="episodeButtons" class="button-container"></div>
<script>
    document.addEventListener('DOMContentLoaded', (event) => {
        let jsonArr = [xfvalue_playlist];
   
        let audioButtonContainer = document.getElementById("audioButtons");
        let episodeButtonContainer = document.getElementById("episodeButtons");
        let videoFrame = document.getElementById("videoFrame");
   
        function displayAudioButtons() {
            audioButtonContainer.innerHTML = "";
            jsonArr.forEach(item => {
                let button = document.createElement("button");
                button.textContent = item.title;
                button.addEventListener("click", function() {
                    displayEpisodeButtons(item.folder);
                    // Убираем класс "active" у всех кнопок
                    document.querySelectorAll('#audioButtons button').forEach(btn => btn.classList.remove('active'));
                    // Добавляем класс "active" к выбранной кнопке
                    button.classList.add('active');
                });
                audioButtonContainer.appendChild(button);
            });
        }
   
        function saveCheckboxState(checkbox, watched) {
            let episodeFile = checkbox.getAttribute("data-episode-file");
            if (watched) {
                localStorage.setItem(episodeFile, "watched");
            } else {
                localStorage.removeItem(episodeFile);
            }
        }
   
        function displayEpisodeButtons(folder) {
            episodeButtonContainer.innerHTML = "";
            folder.forEach(item => {
                let buttonContainer = document.createElement("div");
                let checkbox = document.createElement("input");
                checkbox.type = "checkbox";
                checkbox.setAttribute("data-episode-file", item.file);
   
                let label = document.createElement("label");
                label.textContent = item.title;
   
                buttonContainer.appendChild(checkbox);
                buttonContainer.appendChild(label);
   
                if (localStorage.getItem(item.file) === "watched") {
                    checkbox.checked = true;
                }
   
                label.addEventListener("click", function() {
                    videoFrame.src = item.file;
                    // Убираем класс "active" у всех кнопок эпизодов
                    document.querySelectorAll('#episodeButtons div').forEach(btnContainer => btnContainer.classList.remove('active'));
                    // Добавляем класс "active" к выбранной кнопке
                    buttonContainer.classList.add('active');
                    console.log("Selected episode:", item.title);
                });
   
                checkbox.addEventListener("change", function() {
                    if (this.checked) {
                        console.log("Marked as watched:", item.title);
                        saveCheckboxState(this, true); // Сохраняем состояние при выборе
                    } else {
                        console.log("Marked as unwatched:", item.title);
                        saveCheckboxState(this, false); // Сохраняем состояние при снятии отметки
                    }
                });
   
                episodeButtonContainer.appendChild(buttonContainer);
            });
   
            restoreCheckboxesState(); // Добавляем восстановление состояния чекбоксов после создания
        }
   
        function restoreCheckboxesState() {
            let allCheckboxes = document.querySelectorAll('#episodeButtons input[type="checkbox"]');
            allCheckboxes.forEach(checkbox => {
                let episodeFile = checkbox.getAttribute("data-episode-file");
                if (localStorage.getItem(episodeFile) === "watched") {
                    checkbox.checked = true;
                }
            });
        }
   
        displayAudioButtons();
    });
</script>
так же интересно как с <iframe width="560" height="400" class="lazy" data-src="[xfvalue_kodik_iframe]" frameborder="0" allowfullscreen></iframe> сделать вывод через ваш плеер
 
Было бы шикано прикрутить кнопку Плей, чтобы iframe загружался по клику
 
Можете, пожалуйста, обновить до DLE 16 и 17 версий, если есть время
 
как ставить лайки комментариям?
 
А как в этом модуле сделать, что бы открывалась не 1 серия, а последняя. К примеру есть сериал 300 серий, и что бы не мотать так долго.
 
  • Like
Реакции: cord
  • Like
Реакции: cord
Это и так понятно, а когда много сериалов переделывать долго. Как сделать через этот модуль
 
  • Like
Реакции: cord
JavaScript:
/*
    {descr} -- Описание
    {link} -- Ссылка
    {text} -- Текст ссылки
    {THEME} -- путь к папке шаблона

    [descr] выводит текст, если есть описание [/descr]
    [not-descr] выводит текст, если описания нет [/not-descr]
    [text] выводит текст, если есть текст ссылки [/text]
    [not-text] выводит текст, если текста ссылки нет [/not-text]
    [link] выводит текст, если есть ссылка [/link]
    [not-link] выводит текст, если ссылки нет [/not-link]
*/

var playlist_alert = `
<div class="playlists-alert parthner_serialry">
<svg svgicon-svod-tv">
        <g><path class="st0" d="M94,74H46c-0.6,0-1,0.4-1,1c0,0.6,0.4,1,1,1h48c0.6,0,1-0.4,1-1C95,74.4,94.6,74,94,74z"></path><path class="st0" d="M80.3,34.1L64.5,25c-0.3-0.2-0.7-0.2-1,0c-0.3,0.2-0.5,0.5-0.5,0.9v18.2c0,0.4,0.2,0.7,0.5,0.9c0.2,0.1,0.3,0.1,0.5,0.1c0.2,0,0.3,0,0.5-0.1l15.8-9.1c0.3-0.2,0.5-0.5,0.5-0.9C80.8,34.6,80.6,34.3,80.3,34.1z M65,42.4V27.6L77.8,35L65,42.4z"></path><path class="st0" d="M137,20h-7V3c0-1.7-1.3-3-3-3H13c-1.7,0-3,1.3-3,3v30H3c-1.7,0-3,1.3-3,3v41c0,1.7,1.3,3,3,3h23c1.7,0,3-1.3,3-3v-7h88v7c0,1.7,1.3,3,3,3h17c1.7,0,3-1.3,3-3V23C140,21.3,138.7,20,137,20z M10,35h12v13H7V35H10z M2,57h3v6H2V57zM2,50h3v5H2V50z M5,48H2v-5h3V48z M2,65h3v5H2V65z M7,50h15v13H7V50z M27,48h-3v-5h3V48z M27,55h-3v-5h3V55z M24,57h3v6h-3V57zM27,41h-3v-6h2c0.6,0,1,0.4,1,1V41z M2,36c0-0.6,0.4-1,1-1h2v6H2V36z M3,78c-0.6,0-1-0.4-1-1v-5h3v6H3z M7,78V65h15v13H7z M27,77c0,0.6-0.4,1-1,1h-2v-6h3V77z M24,70v-5h3v5H24z M29,68V36c0-1.7-1.3-3-3-3H12V3c0-0.6,0.4-1,1-1h114c0.6,0,1,0.4,1,1v17h-8c-1.7,0-3,1.3-3,3v45H29z M138,77c0,0.6-0.4,1-1,1h-17c-0.6,0-1-0.4-1-1v-7V23c0-0.6,0.4-1,1-1h10h7c0.6,0,1,0.4,1,1V77z"></path><path class="st0" d="M125.5,31c0.8,0,1.5-0.7,1.5-1.5c0-0.8-0.7-1.5-1.5-1.5s-1.5,0.7-1.5,1.5C124,30.3,124.7,31,125.5,31z"></path><path class="st0" d="M131.5,31c0.8,0,1.5-0.7,1.5-1.5c0-0.8-0.7-1.5-1.5-1.5s-1.5,0.7-1.5,1.5C130,30.3,130.7,31,131.5,31z"></path><path class="st0" d="M125.5,37c0.8,0,1.5-0.7,1.5-1.5s-0.7-1.5-1.5-1.5s-1.5,0.7-1.5,1.5S124.7,37,125.5,37z"></path><path class="st0" d="M131.5,37c0.8,0,1.5-0.7,1.5-1.5s-0.7-1.5-1.5-1.5s-1.5,0.7-1.5,1.5S130.7,37,131.5,37z"></path><path class="st0" d="M125.5,40c-0.8,0-1.5,0.7-1.5,1.5s0.7,1.5,1.5,1.5s1.5-0.7,1.5-1.5S126.3,40,125.5,40z"></path><path class="st0" d="M133,41.5c0-0.8-0.7-1.5-1.5-1.5s-1.5,0.7-1.5,1.5s0.7,1.5,1.5,1.5S133,42.3,133,41.5z"></path><path class="st0" d="M128.5,51c-0.8,0-1.5,0.7-1.5,1.5s0.7,1.5,1.5,1.5c0.8,0,1.5-0.7,1.5-1.5S129.3,51,128.5,51z"></path><path class="st0" d="M128.5,59c-0.8,0-1.5,0.7-1.5,1.5s0.7,1.5,1.5,1.5c0.8,0,1.5-0.7,1.5-1.5S129.3,59,128.5,59z"></path><path class="st0" d="M132.5,55c-0.8,0-1.5,0.7-1.5,1.5s0.7,1.5,1.5,1.5c0.8,0,1.5-0.7,1.5-1.5S133.3,55,132.5,55z"></path><path class="st0" d="M124.5,55c-0.8,0-1.5,0.7-1.5,1.5s0.7,1.5,1.5,1.5c0.8,0,1.5-0.7,1.5-1.5S125.3,55,124.5,55z"></path></g>
    </svg>

[descr]<div class="parthner_serialry_text">{descr}</div>[/descr]
    [not-descr]<div class="parthner_serialry_text">[описание не задано]</div>[/not-descr]
    [link]<div class="lgtext">Легально на официальном сайте</div>[/link]
    [link]<a href="{link}" target="_blank" rel="noopener external noreferrer nofollow">{text}</a>[/link]
</div>
`;

function playlists_set(box, video) {
    if ( video.data('descr') || (video.data('file') && video.data('text')) ) {
        box.html(
            playlist_alert
            .replace(/\{descr\}/g, video.data('descr') || '')
            .replace(/\{text\}/g, video.data('text') || '')
            .replace(/\{link\}/g, video.data('file') || '')
            .replace(/\{THEME\}/g, '/templates/' + dle_skin)
            .replace(/\[link\](.*?)\[\/link\]/g, (video.data('file') && video.data('text')) ? '$1' : '')
            .replace(/\[not-link\](.*?)\[\/not-link\]/g, (video.data('file') && video.data('text')) ? '' : '$1')
            .replace(/\[descr\](.*?)\[\/descr\]/g, (video.data('descr')) ? '$1' : '')
            .replace(/\[not-descr\](.*?)\[\/not-descr\]/g, (video.data('descr')) ? '' : '$1')
        );
    } else {
        box.html('<iframe scrolling="no" src="' + video.data('file') + '" allowfullscreen frameborder="0" width="100%" height="100%"></iframe>');
    }

    if( !globalNotification ){
        $('.player-notice').remove();
        if( video.data('notification') ){
            $('.pl-notice').append('<div class="player-notice"><div class="pl-close"></div>' + video.data('notification') + '</div>');
        }
    }
}

var globalNotification = false;

if( $('.player-notice').length){
    globalNotification = true;
}

$('body').on('click', '.playlists-lists li', function() {

    var player = $(this).closest('.playlists-player'),
        id = $(this).data('id'),
        index = $(this).closest('.playlists-items').index(),
        count = $(this).closest('.playlists-lists').find('.playlists-items').length;

    $(this).closest('.playlists-items').find('li').removeClass('active');
    $(this).addClass('active');

    for (i=index+1;i<count;i++) {
        var _tmp = player.find('.playlists-lists .playlists-items:eq(' + i + ')');
        _tmp.find('li').removeClass('active').removeClass('visible');
        _tmp.find('li[data-id^=' + id + ']').addClass('visible');
        _id = _tmp.find('li.visible:eq(0)').addClass('active').data('id');

        if ( typeof _id != 'undefined' ) {
            id = _id;
            _self = _tmp;
        }
    }

    player.find('.playlists-videos').find('li').removeClass('active').removeClass('visible');
    player.find('.playlists-videos').find('li[data-id=' + id + ']').addClass('visible');
    player.find('.playlists-videos li.visible:eq(0)').addClass('active');

    var video = player.find('.playlists-videos li.active');
    var iframe = player.find('.playlists-iframe');

    playlists_set(iframe, video);

    $('.playlists-items').each(function() {
        $(this).sly('reload');
    });

    if ( window.pl_number ) window.pl_number = false;
        else $('.playlists-videos .playlists-items').sly('toStart');
});

$('body').on('click', '.playlists-videos li', function(event) {
    if ( event.target.tagName != 'LI' ) {
        event.stopPropagation();
        return false;
    }

    $(this).closest('.playlists-items').find('li').removeClass('active');
    $(this).addClass('active');

    var video = $(this);
    var iframe = $(this).closest('.playlists-player').find('.playlists-iframe');

    playlists_set(iframe, video);
});

// кнопки отметок для просмотренных серий
$('body').on('click', '.playlists-view', function(event) {
    var news_id = $(this).closest('.playlists-ajax').data('news_id'),
        xfname = $(this).closest('.playlists-ajax').data('xfname'),
        file = $(this).closest('li').data('file'),
        c = 'playlists-' + news_id + '-' + xfname + '-' + file;
    $(this).toggleClass('watched');
    if ( localStorage.getItem(c) === null ) localStorage.setItem(c, '1');
        else localStorage.removeItem(c);
});

// [HASH=8]###[/HASH] кнопки отметок для просмотренных серий
$(document).ready(function(e) {
    $('.playlists-ajax').each(function(index) {
        var _self = $(this)
            xfname = _self.data('xfname'),
            news_id = _self.data('news_id');

        $.ajax({
            url: '/engine/ajax/controller.php',
            data: {mod: 'playlists', news_id: news_id, xfield: xfname},
            dataType: 'JSON',
            success: function(data) {
                if ( !data.success ) {
                    console.log('Playlists', data.message);
                    return false;
                }

                _self.html(data.response);

                var number = parseInt(_self.data('number'));
                var flag = false;

                if ( number > 0 ) {
                    var video = _self.find('.playlists-videos li:eq(' + (number - 1) + ')');

                    if ( video.length ) {
                        _self.find('.playlists-videos li').addClass('visible');
                        video.trigger('click');
                        flag = true;
                    }
                }

                if ( !flag ) {
                    if ( _self.find('.playlists-lists li').length ) {
                        _self.find('.playlists-lists > .playlists-items:first li').addClass('visible');
                        _self.find('.playlists-lists li:first').trigger('click');
                    } else {
                        _self.find('.playlists-videos li').addClass('visible');
                        _self.find('.playlists-videos li:first').trigger('click');
                    }
                }

                // кнопки отметок для просмотренных серий
                _self.find('.playlists-videos li').each(function() {
                    var file = $(this).data('file'),
                        c = 'playlists-' + news_id + '-' + xfname + '-' + file;

                    $(this).append('<span class="playlists-view"></span>');

                    if ( localStorage.getItem(c) !== null ) $(this).find('.playlists-view').addClass('watched');
                });

                // [HASH=8]###[/HASH] кнопки отметок для просмотренных серий
                $('.playlists-items').each(function() {   
                    $(this).append('<div class="playlists-prev"></div><div class="playlists-next"></div>').sly({
                        horizontal: 1,
                        itemNav: 'basic',
                        itemSelector: ':visible',
                        mouseDragging: 1,
                        touchDragging: 1,
                        releaseSwing: 1,
                        startAt: number > 0 ? number - 1 : 0,
                        activateMiddle: true,
                        scrollBy: 3,
                        speed: 2160,
                        easing: 'easeOutExpo',
                        prevPage: $(this).find('.playlists-prev'),
                        nextPage: $(this).find('.playlists-next'),
                        activeClass: false,
                        disabledClass: 'disabled'
                    });
                });
            },
            error: function(a, b, c) {
                console.log('Playlists', 'ERR_REQUEST_FAILED');
            }
        });
    });
});

============================
Вот код как его переделать. Готов отблагодарить.
 
Последнее редактирование модератором:
Кто сможет помочь в настройке?
 
Последнее редактирование модератором:
Вот код как его переделать. Готов отблагодарить.
Проверь скажешь работает или нет
JavaScript:
/**
    {descr} -- Описание
    {link} -- Ссылка
    {text} -- Текст ссылки
    {THEME} -- путь к папке шаблона

    [descr] выводит текст, если есть описание [/descr]
    [not-descr] выводит текст, если описания нет [/not-descr]
    [text] выводит текст, если есть текст ссылки [/text]
    [not-text] выводит текст, если текста ссылки нет [/not-text]
    [link] выводит текст, если есть ссылка [/link]
    [not-link] выводит текст, если ссылки нет [/not-link]
*/

var playlist_alert = `
<div class="playlists-alert parthner_serialry">
<svg svgicon-svod-tv">
        <g><path class="st0" d="M94,74H46c-0.6,0-1,0.4-1,1c0,0.6,0.4,1,1,1h48c0.6,0,1-0.4,1-1C95,74.4,94.6,74,94,74z"></path><path class="st0" d="M80.3,34.1L64.5,25c-0.3-0.2-0.7-0.2-1,0c-0.3,0.2-0.5,0.5-0.5,0.9v18.2c0,0.4,0.2,0.7,0.5,0.9c0.2,0.1,0.3,0.1,0.5,0.1c0.2,0,0.3,0,0.5-0.1l15.8-9.1c0.3-0.2,0.5-0.5,0.5-0.9C80.8,34.6,80.6,34.3,80.3,34.1z M65,42.4V27.6L77.8,35L65,42.4z"></path><path class="st0" d="M137,20h-7V3c0-1.7-1.3-3-3-3H13c-1.7,0-3,1.3-3,3v30H3c-1.7,0-3,1.3-3,3v41c0,1.7,1.3,3,3,3h23c1.7,0,3-1.3,3-3v-7h88v7c0,1.7,1.3,3,3,3h17c1.7,0,3-1.3,3-3V23C140,21.3,138.7,20,137,20z M10,35h12v13H7V35H10z M2,57h3v6H2V57zM2,50h3v5H2V50z M5,48H2v-5h3V48z M2,65h3v5H2V65z M7,50h15v13H7V50z M27,48h-3v-5h3V48z M27,55h-3v-5h3V55z M24,57h3v6h-3V57zM27,41h-3v-6h2c0.6,0,1,0.4,1,1V41z M2,36c0-0.6,0.4-1,1-1h2v6H2V36z M3,78c-0.6,0-1-0.4-1-1v-5h3v6H3z M7,78V65h15v13H7z M27,77c0,0.6-0.4,1-1,1h-2v-6h3V77z M24,70v-5h3v5H24z M29,68V36c0-1.7-1.3-3-3-3H12V3c0-0.6,0.4-1,1-1h114c0.6,0,1,0.4,1,1v17h-8c-1.7,0-3,1.3-3,3v45H29z M138,77c0,0.6-0.4,1-1,1h-17c-0.6,0-1-0.4-1-1v-7V23c0-0.6,0.4-1,1-1h10h7c0.6,0,1,0.4,1,1V77z"></path><path class="st0" d="M125.5,31c0.8,0,1.5-0.7,1.5-1.5c0-0.8-0.7-1.5-1.5-1.5s-1.5,0.7-1.5,1.5C124,30.3,124.7,31,125.5,31z"></path><path class="st0" d="M131.5,31c0.8,0,1.5-0.7,1.5-1.5c0-0.8-0.7-1.5-1.5-1.5s-1.5,0.7-1.5,1.5C130,30.3,130.7,31,131.5,31z"></path><path class="st0" d="M125.5,37c0.8,0,1.5-0.7,1.5-1.5s-0.7-1.5-1.5-1.5s-1.5,0.7-1.5,1.5S124.7,37,125.5,37z"></path><path class="st0" d="M131.5,37c0.8,0,1.5-0.7,1.5-1.5s-0.7-1.5-1.5-1.5s-1.5,0.7-1.5,1.5S130.7,37,131.5,37z"></path><path class="st0" d="M125.5,40c-0.8,0-1.5,0.7-1.5,1.5s0.7,1.5,1.5,1.5s1.5-0.7,1.5-1.5S126.3,40,125.5,40z"></path><path class="st0" d="M133,41.5c0-0.8-0.7-1.5-1.5-1.5s-1.5,0.7-1.5,1.5s0.7,1.5,1.5,1.5S133,42.3,133,41.5z"></path><path class="st0" d="M128.5,51c-0.8,0-1.5,0.7-1.5,1.5s0.7,1.5,1.5,1.5c0.8,0,1.5-0.7,1.5-1.5S129.3,51,128.5,51z"></path><path class="st0" d="M128.5,59c-0.8,0-1.5,0.7-1.5,1.5s0.7,1.5,1.5,1.5c0.8,0,1.5-0.7,1.5-1.5S129.3,59,128.5,59z"></path><path class="st0" d="M132.5,55c-0.8,0-1.5,0.7-1.5,1.5s0.7,1.5,1.5,1.5c0.8,0,1.5-0.7,1.5-1.5S133.3,55,132.5,55z"></path><path class="st0" d="M124.5,55c-0.8,0-1.5,0.7-1.5,1.5s0.7,1.5,1.5,1.5c0.8,0,1.5-0.7,1.5-1.5S125.3,55,124.5,55z"></path></g>
    </svg>

[descr]<div class="parthner_serialry_text">{descr}</div>[/descr]
    [not-descr]<div class="parthner_serialry_text">[описание не задано]</div>[/not-descr]
    [link]<div class="lgtext">Легально на официальном сайте</div>[/link]
    [link]<a href="{link}" target="_blank" rel="noopener external noreferrer nofollow">{text}</a>[/link]
</div>
`;

function playlists_set(box, video) {
    if ( video.data('descr') || (video.data('file') && video.data('text')) ) {
        box.html(
            playlist_alert
            .replace(/\{descr\}/g, video.data('descr') || '')
            .replace(/\{text\}/g, video.data('text') || '')
            .replace(/\{link\}/g, video.data('file') || '')
            .replace(/\{THEME\}/g, '/templates/' + dle_skin)
            .replace(/\[link\](.*?)\[\/link\]/g, (video.data('file') && video.data('text')) ? '$1' : '')
            .replace(/\[not-link\](.*?)\[\/not-link\]/g, (video.data('file') && video.data('text')) ? '' : '$1')
            .replace(/\[descr\](.*?)\[\/descr\]/g, (video.data('descr')) ? '$1' : '')
            .replace(/\[not-descr\](.*?)\[\/not-descr\]/g, (video.data('descr')) ? '' : '$1')
        );
    } else {
        box.html('<iframe scrolling="no" src="' + video.data('file') + '" allowfullscreen frameborder="0" width="100%" height="100%"></iframe>');
    }

    if( !globalNotification ){
        $('.player-notice').remove();
        if( video.data('notification') ){
            $('.pl-notice').append('<div class="player-notice"><div class="pl-close"></div>' + video.data('notification') + '</div>');
        }
    }
}

var globalNotification = false;

if( $('.player-notice').length){
    globalNotification = true;
}

$('body').on('click', '.playlists-lists li', function() {

    var player = $(this).closest('.playlists-player'),
        id = $(this).data('id'),
        index = $(this).closest('.playlists-items').index(),
        count = $(this).closest('.playlists-lists').find('.playlists-items').length;

    $(this).closest('.playlists-items').find('li').removeClass('active');
    $(this).addClass('active');

    for (i=index+1;i<count;i++) {
        var _tmp = player.find('.playlists-lists .playlists-items:eq(' + i + ')');
        _tmp.find('li').removeClass('active').removeClass('visible');
        _tmp.find('li[data-id^=' + id + ']').addClass('visible');
        _id = _tmp.find('li.visible:eq(0)').addClass('active').data('id');

        if ( typeof _id != 'undefined' ) {
            id = _id;
            _self = _tmp;
        }
    }

    player.find('.playlists-videos').find('li').removeClass('active').removeClass('visible');
    player.find('.playlists-videos').find('li[data-id=' + id + ']').addClass('visible');
    player.find('.playlists-videos li.visible:eq(0)').addClass('active');

    var video = player.find('.playlists-videos li.active');
    var iframe = player.find('.playlists-iframe');

    playlists_set(iframe, video);

    $('.playlists-items').each(function() {
        $(this).sly('reload');
    });

    if ( window.pl_number ) window.pl_number = false;
        else $('.playlists-videos .playlists-items').sly('toStart');
});

$('body').on('click', '.playlists-videos li', function(event) {
    if ( event.target.tagName != 'LI' ) {
        event.stopPropagation();
        return false;
    }

    $(this).closest('.playlists-items').find('li').removeClass('active');
    $(this).addClass('active');

    var video = $(this);
    var iframe = $(this).closest('.playlists-player').find('.playlists-iframe');

    playlists_set(iframe, video);
});

// кнопки отметок для просмотренных серий
$('body').on('click', '.playlists-view', function(event) {
    var news_id = $(this).closest('.playlists-ajax').data('news_id'),
        xfname = $(this).closest('.playlists-ajax').data('xfname'),
         file = $(this).closest('li').data('file'),
    c = 'playlists-' + news_id + '-' + xfname + '-' + file;
$(this).toggleClass('watched');
if ( localStorage.getItem(c) === null ) localStorage.setItem(c, '1');
else localStorage.removeItem(c);
});

// [HASH=8]###[/HASH] кнопки отметок для просмотренных серий
$(document).ready(function(e) {
$('.playlists-ajax').each(function(index) {
    var _self = $(this)
        xfname = _self.data('xfname'),
        news_id = _self.data('news_id');

    $.ajax({
        url: '/engine/ajax/controller.php',
        data: {mod: 'playlists', news_id: news_id, xfield: xfname},
        dataType: 'JSON',
        success: function(data) {
            if ( !data.success ) {
                console.log('Playlists', data.message);
                return false;
            }

            _self.html(data.response);

            var number = parseInt(_self.data('number'));
            var flag = false;

            if ( number > 0 ) {
                var video = _self.find('.playlists-videos li:eq(' + (number - 1) + ')');

                if ( video.length ) {
                    _self.find('.playlists-videos li').addClass('visible');
                    video.trigger('click');
                    flag = true;
                }
            }

            if ( !flag ) {
                if ( _self.find('.playlists-lists li').length ) {
                    _self.find('.playlists-lists > .playlists-items:first li').addClass('visible');
                    _self.find('.playlists-lists li:first').trigger('click');
                } else {
                    _self.find('.playlists-videos li').addClass('visible');
                    _self.find('.playlists-videos li:first').trigger('click');
                }
            }

            // кнопки отметок для просмотренных серий
            _self.find('.playlists-videos li').each(function() {
                var file = $(this).data('file'),
                    c = 'playlists-' + news_id + '-' + xfname + '-' + file;

                $(this).append('<span class="playlists-view"></span>');

                if ( localStorage.getItem(c) !== null ) $(this).find('.playlists-view').addClass('watched');
            });

            // [HASH=8]###[/HASH] кнопки отметок для просмотренных серий
            $('.playlists-items').each(function() {  
                $(this).append('<div class="playlists-prev"></div><div class="playlists-next"></div>').sly({
                    horizontal: 1,
                    itemNav: 'basic',
                    itemSelector: ':visible',
                    mouseDragging: 1,
                    touchDragging: 1,
                    releaseSwing: 1,
                    startAt: number > 0 ? number - 1 : 0,
                    activateMiddle: true,
                    scrollBy: 3,
                    speed: 2160,
                    easing: 'easeOutExpo',
                    prevPage: $(this).find('.playlists-prev'),
                    nextPage: $(this).find('.playlists-next'),
                    activeClass: false,
                    disabledClass: 'disabled'
                });
            });
        },
        error: function(a, b, c) {
            console.log('Playlists', 'ERR_REQUEST_FAILED');
        }
    });
});
});
 
Последнее редактирование модератором:
Не работает
 

Пользователи, просматривающие данную тему

Верх