/*
{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');
}
});
});
});