jQuery(function($) {
len = $('.play_video_bloc').length;
if(len) $('.play_video_bloc').removeClass('play_video_bloc').addClass('play_video_block');
window.get_end = new Date();
dif2 = (window.get_end - window.start_l) / 1000;
window.get_start = new Date();
len = $('.edit_template').length;
if(len) return;
i = $('.extras_container').text();
b = $('.rel_v_block').attr('i');
im = $('.video_featured img').attr('src');
if(i) {
$('[entity="posts_tab"][type="files"].thin_image').show();
postto('api/loh_post/get_1', {i,b,im}, 'loh_extra');
}
else {
$('[entity="posts_tab"][type="files"]').addClass('hide');
$('[entity="posts_tab"][type="pdf"]').addClass('hide');
// $('[entity="posts_tab"][type="body"]').each(function(){
// th = $(this);
// if(th.is('.flex')) th.css('display', 'flex');
// else th.show();
// });
activate_castle('comments');
}
i = $('.rel_v_block').attr('i');
postto('api/loh_post/get_2', {i}, 'loh_com');
postto('api/loh_post/get_u', {i}, 'loh_u');
$(document).on('click', '.subscribe_button', function() {
th = $(this);
next = th.attr('next');
next = encodeURI(next);
showme(``, 'play_error');
$('.main_wrapper').addClass('transparent_30');
});
$(document).on('click', '.savvids', function() {
th = $(this);
i = $('.rel_v_block').attr('i');
un = th.attr('un');
th.append(' ' + fa_spinner);
$.post('/ajax/post/savvids', {i, un}, function(data){
data = JSON.parse(data);
loader_remove();
error = data.error;
result = data.result;
nextun = data.nextun;
thi = data.i;
if(error) showme(error);
else {
$(`.savvids`).html(result);
$(`.savvids`).attr('un', nextun);
}
});
});
$(document).on('click', '.rec_vid .tag', function() {
th = $(this);
ty = get_c('defttt');
ty = th.attr('type');
len = th.find('.fa-spinner').length;
if(len) return;
th.append(' ' + fa_spinner);
o = $('.newest_but').attr('type');
$('.rec_vid .tag').removeClass('active');
th.addClass('active');
set_c('defttt', ty, 100 * 60 * 24 * 30);
i = $('.rel_v_block').attr('i');
$.post('/ajax/custom/post/rel_po', {ty, o, i}, function(data){
$('.rel_v_block').css('opacity', '0');
$('.rel_v_block').html(data);
loader_remove();
$('.rel_v_block').css('opacity', '1');
});
});
const scrollContainer = document.querySelector(".horizontal_slider_container");
right_fix();
scrollContainer.addEventListener("wheel", (evt) => {
evt.preventDefault();
scrollContainer.scrollLeft += evt.deltaY;
scroll = evt.deltaY;
if(scroll > 0) {
right_fix();
$('.slider_left_arrow').css('display', 'flex');
}
else {
left_fix();
$('.slider_right_arrow').css('display', 'flex');
}
});
const slider = document.querySelector('.horizontal_slider_container');
let mouseDown = false;
let startX, scrollLeft;
distance = 180;
let startDragging = function (e) {
mouseDown = true;
startX = e.pageX - slider.offsetLeft;
scrollLeft = slider.scrollLeft;
};
let stopDragging = function (event) {
mouseDown = false;
};
slider.addEventListener('mousemove', (e) => {
e.preventDefault();
if(!mouseDown) { return; }
const x = e.pageX - slider.offsetLeft;
const scroll = x - startX;
if(scroll < 0) {
right_fix();
$('.slider_left_arrow').css('display', 'flex');
}
else {
left_fix();
$('.slider_right_arrow').css('display', 'flex');
}
slider.scrollLeft = scrollLeft - scroll;
});
// Add the event listeners
slider.addEventListener('mousedown', startDragging, false);
slider.addEventListener('mouseup', stopDragging, false);
slider.addEventListener('mouseleave', stopDragging, false);
$(document).on('click', '.slider_right_arrow i', function(){
scrollContainer.scrollLeft += distance;
left = scrollContainer.scrollLeft;
offset_left = scrollContainer.offsetLeft;
divisible = solucao(left, distance);
right_fix();
$('.slider_left_arrow').css('display', 'flex');
if(!divisible) $('.slider_right_arrow').hide();
});
$(document).on('click', '.slider_left_arrow i', function(){
scrollContainer.scrollLeft -= distance;
left = scrollContainer.scrollLeft;
offset_left = slider.offsetLeft;
$('.slider_right_arrow').css('display', 'flex');
left_fix();
if(left == 0) $('.slider_left_arrow').hide();
});
function right_fix(){
setTimeout(() => {
sl = $('.horizontal_slider_container');
total = sl[0].offsetWidth;
left = sl.scrollLeft();
var $elem= sl;
var newScrollLeft = Math.round($elem.scrollLeft()),
width=Math.round($elem.width()),
scrollWidth=$elem.get(0).scrollWidth;
//console.log(scrollWidth, width, newScrollLeft);
dif = scrollWidth - width - newScrollLeft;
if(dif < 10) {
slider.scrollLeft += distance;
$('.slider_right_arrow').hide();
}
else $('.slider_right_arrow').show();
}, 200);
}
function left_fix() {
setTimeout(() => {
sl = $('.horizontal_slider_container');
total = sl[0].offsetWidth;
left = sl.scrollLeft();
if(left < distance) {
slider.scrollLeft -= distance;
$('.slider_left_arrow').hide();
}
}, 200);
}
function solucao(numero, x){
if (numero % x == 0){
return true
}
else {
return false
}
}
});
function set_otyppp(type) {
new_type = '';
if(type == 'd') {
new_type = 'a';
}
else if(type == 'a') {
new_type = 'd';
}
if(new_type) {
newest_but = $('.newest_but');
newest_but.attr('type', new_type);
if(new_type == 'a') {
newest_but.find('.toggle_on_newest').show();
newest_but.find('.toggle_off_newest').hide();
}
else {
newest_but.find('.toggle_off_newest').show();
newest_but.find('.toggle_on_newest').hide();
}
}
return new_type;
}
$(document).on('click', '.newest_but', function(){
th = $(this);
type = th.attr('type');
if(!type) type = 'd';
new_type = set_otyppp(type);
if(new_type) {
th.attr('type', new_type);
$('.rec_vid .active.tag').trigger('click');
set_c('defooo', new_type, 100 * 60 * 24 * 30);
}
});
function show_play_but() {
$('.video_featured i.fa-play-circle').show();
$('.video_featured img').css('filter', 'brightness(0.7)');
}
function show_login_but() {
$('.video_featured .login_subscribe_button').show();
$('.play_video_block').removeClass('but').removeClass('play_video_block');
}
function show_signup_but() {
$('.video_featured .signup_button').addClass('try_subscription').attr('product', '56').attr('products','56').attr('only_step_2', '1').show();
}
function show_prod_but(prod) {
$('.video_featured .subscribe_button').css('display','flex');
$('.video_featured .subscribe_button').removeClass('subscribe_button');
$('.video_featured .buttons_block').css('height', '100%');
}
function loh_u(uidat) {
uidat = JSON.parse(uidat);
if(uidat.gen == '1') {
i = $('.rel_v_block').attr('i');
postto('api/loh_post/get_edi', {i}, 'loh_ed');
}
saved = uidat.saved;
if(saved) {
$('.savvids').html(saved);
$('.savvids').attr('un', '1');
}
sub = $('.play_video_block .video_featured').attr('subscription');
if(sub == '1') {
//vidipo
if(uidat.sub != 1) {
prod = uidat.prod;
if(prod) {
show_prod_but(prod);
if(!uidat.i) show_login_but();
}
else if(!uidat.i) {
show_login_but();
show_signup_but();
}
else {
show_prod_but();
}
}
else {
show_play_but();
}
}
else {
//vidifroo
if(!uidat.i) {
show_signup_but();
show_login_but();
}
else {
show_play_but();
}
}
}
function loh_ed(pdata) {
pdata = JSON.parse(pdata);
error = pdata.error;
post_link_result = pdata.result;
if(!error && post_link_result) {
$('.ed_bl').html(post_link_result);
$('.ed_bl').show(500);
}
}
function loh_extra(data) {
if(data) {
data = JSON.parse(data);
audio = data.audio;
pdf = data.pdf;
if(audio) {
$('.extras_container').html(audio);
//$('.extras_container').html(audio).show();
$('.extras_container').find('[type=ziyuan]').attr('type','files');
}
else {
//$('.post_tab[type="body"]').addClass('active');
$('.post_tab[type="files"]').addClass('hide');
}
if(pdf) {
$('.post_tab[type="pdf"].thin_image').show();
$('.pdf_container').html(pdf);
}
else {
$('.post_tab[type="pdf"]').addClass('hide');
}
}
}
function loh_com(data) {
data = JSON.parse(data);
r = data.r;
count = data.count;
$('.post_tab_el.comments_block').html(r);
if(count) {
//$('.castle_image[type=comments]').removeClass('no_comments_name');
//$('.castle_image[type=comments]').append(`