var pending_sections = []; var sign_in_translation = 'SIGNED'; var section_threshold = 500; var more_loading = false; var posts_que = window.posts_que || {}; const host = getMainHost(window.location) const CONFIG = { 'epochtimes.com.br': { siteId: 'epochtimes.br', siteIdForSocialApi: 'www.epochtimes.com.br', lang: 'pt', flowId: 'brazil-et' }, 'theepochtimes.com': { siteId: 'es.theepochtimes.com', siteIdForSocialApi: 'es.theepochtimes.com', lang: 'es', flowId: 'live-global', } } window.siteConfig = CONFIG[host] var is_spanish = typeof ntd_language_active !== 'undefined' && 'ntd_spanish' === ntd_language_active; var is_portuguese = typeof ntd_language_active !== 'undefined' && 'ntd_portuguese' === ntd_language_active; if( is_spanish ) { sign_in_translation = 'FIRMARON'; (function (w, d) { w.PushEngage = w.PushEngage || []; w._peq = w._peq || []; PushEngage.push(['init', { appId: '996d32e7c0b26be1057ebc03d9f77ffa' }]); var e = d.createElement('script'); e.src = 'https://clientcdn.pushengage.com/sdks/pushengage-web-sdk.js'; e.async = true; e.type = 'text/javascript'; d.head.appendChild(e); })(window, document); } jQuery.loadAsync = function(url, success_callback) { return jQuery.ajax({ url: url, dataType: "script", cache: true, async: true, success: success_callback || jQuery.noop, }) }; function add_lazy_load_section(selector, callback, threshold) { var offset = jQuery(selector).offset(); if (!offset) return; if (!threshold || threshold < 0) threshold = section_threshold; pending_sections.push({ selector: selector, callback: callback, threshold: threshold }); } $(document).ready(function () { if( $('body.single').length > 0 ) { if( $('body.ntd-video').length > 0 ) { $('.article > .social').after('
'); } else { $('.upper_row > .social_email').after('
'); } } if (is_portuguese || is_spanish) { init_paywall_express(); } if (is_portuguese) { var url_path = decodeURI(window.location.pathname); if (url_path.indexOf('epochtimes.com.br') > 0) { var arr_path = url_path.split('epochtimes.com.br'); if (arr_path.length === 2) { url_path = arr_path[1]; } } } if (!is_spanish) { $('#header').after($('#ntd_cookie_bar')); } if ($('#ntd_date').length > 0) { $('#ntd_date').empty().append(met_get_date()); } function met_get_date() { if (typeof (ntd_language_active) != "undefined" && $('body.' + ntd_language_active).length > 0) { if (is_spanish) { moment.locale('es-us'); var value_es = moment().format('dddd, LL'); return value_es.charAt(0).toUpperCase() + value_es.slice(1); } if (is_portuguese) { moment.locale('pt-br'); var value_br = moment().format('dddd, LL'); return value_br.charAt(0).toUpperCase() + value_br.slice(1); } return moment().format('dddd, MMM D, YYYY'); } else { var today = new Date(); var weekday = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); var month = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); var dd = today.getDate(); var mm = month[today.getMonth()]; var yyyy = today.getFullYear(); weekday = weekday[today.getDay()]; today = weekday + ', ' + mm + ' ' + dd + ', ' + yyyy; return today; } } var page_num = 2; $('#category_load_more span').click(function () { var page_total = $(this).parent().data('page-num'); url = window.location.href; if (page_num <= page_total) { if ($('#category_load_more').hasClass('is_search')) { //url = url.replace('/?s=', ('/page/' + page_num + '/?s=')); url = url.replace('/?s=', ('/search/')); url += '/page/' + page_num; } $.ajax({ type: 'GET', url: url, success: function (data) { page_num++; var content = $(data).find('.article_list ul').html(); if (content) { var location = $('#category_load_more').offset().top - 100; $('.article_list ul').append(content); if (location) { $("body,html").animate({ scrollTop: location }, 800); } } }, complete: function (data) { if (page_num >= page_total) { $('#category_load_more').hide(); } if ($.fn.laziestloader) { $("img.lazy").laziestloader({ threshold: 500 }); } } }); } return false; }); if ($.fn.laziestloader) { $("img.lazy").laziestloader({ threshold: 500 }); $(window).trigger('scroll'); } //resize ratio for video from vhostapi.ntd.tv $.each($('.video_fit_container > iframe, .video_fit_container > div.wp-video, .video_fit_container > div.player-container'), function () { var attr = $(this).attr('data-ratio'); if (!attr) { attr = $(this).siblings('script').attr('data-ratio'); } if (typeof (attr) !== 'undefined' && attr !== false) { $(this).parent('.video_fit_container').css('padding-top', attr); } }); // open links in post content in new window/tab $('.post_content a').each(function () { $(this).attr("target", "_blank"); }); var epoch_gdpr_agreement = localStorage.getItem("epoch_gdpr_agreement"); /* show or hide cookie bar in the bottom of the page * followed French CNIL request * 2. to condition this registration and this access to a prior positive action of the persons concerned; * all the field should be deselect as default. */ if (!is_spanish) { setTimeout(function () { var epoch_gdpr_userid = eet_ymk_userID(); var preferSelectedAll= ['ntd-gdpr-basic,ntd-analytics-storage','ntd-media-storage','ntd-advertisment-storage']; var ntd_storage_prefer = localStorage.getItem('ntd_storage_prefer'); if ( epoch_gdpr_agreement !== '1' ) { $(".cookie-bar").show(); } $(".accept-btn").click(function () { $.ajax({ type: "GET", url: "https://www.youmaker.com/g/log?user=" + epoch_gdpr_userid, complete: function (data) { if ( data.statusText === "OK" || data.statusText === "ok" || data === "ok" || data.responseText === "ok" ) { localStorage.setItem('epoch_gdpr_agreement', '1'); } } }); $(".cookie-bar").slideUp(); return false; }); $("#x_close").click(function () { $(".cookie-bar").slideUp(); return false; }); }, 2000); } var edition = localStorage.getItem("ntd_homepage_edition"); var geo_country = localStorage.getItem('ntd_geo_country') // const edition_countries = ["mx", "es"]; const edition_countries = ["mx"]; if ( epoch_gdpr_agreement !== null && ( typeof( $("body.home.ntd_spanish" )[0] ) != "undefined" )){ if (geo_country === null || typeof(geo_country) === "undefined") { $.ajax({ type: 'GET', url: 'https://pwe.epochbase.com/geo', success: function(res) { if (res.status === 'ok') { localStorage.setItem('ntd_geo_country', res.data.country.toLowerCase()); geo_country = res.data.country; } }, }); } (function() { if (typeof(edition)== "undefined" || edition == null || edition.length < 1) { if (edition_countries.indexOf(geo_country)>-1) { var local_versions = { "mx": ["mx", "mx", "MÉXICO"], // "es": ["es", "es", "España"], }; ntd_show_edition_popup(local_versions[geo_country][0], local_versions[geo_country][1], local_versions[geo_country][2]); } } $(".toprow .language_panel li.esall").click(function() { if (edition_countries.indexOf(edition)<0) return true; localStorage.setItem("backup_homepage_edition", edition); localStorage.setItem("ntd_homepage_edition", "esall"); return true; }); var editionBackup = localStorage.getItem("backup_homepage_edition"); if (document.location.pathname != "/") return true; setTimeout(function() { if ((edition_countries.indexOf(editionBackup)>-1) && edition == "esall") { localStorage.setItem("ntd_homepage_edition", editionBackup ); edition = editionBackup; return true; } }, 5000); })(); } if ($('.premium_programs_home .show_list').length > 0) { var slick_settings = { slidesToShow: 5, slidesToScroll: 5, dots: true, infinite: false, prevArrow: '
', nextArrow: '
', responsive: [{ breakpoint: 1024, settings: { slidesToShow: 3, slidesToScroll: 3, infinite: true, dots: true } }, { breakpoint: 540, settings: { slidesToShow: 1, slidesToScroll: 1, infinite: true, centerMode: true, dots: true } }] }; $('.premium_programs_home .show_list').slick(slick_settings); } if (typeof ntd_language_active !== 'undefined') { var initEngageCat = ''; if (typeof ntd_page_type === 'undefined') { ntd_page_type = 'home'; } if (ntd_page_type == 'home') { initEngageCat = 'front-page'; } else if (ntd_page_type == 'category') { initEngageCat = ntd_cat_names; } else if (ntd_page_type == 'post') { initEngageCat = ntd_primary_category_name; } } }); /* end document ready */ function ntd_show_edition_popup(geo_country, geo_country_url, geo_country_name) { $("body").append( '
' + '
' + '
Puede cambiar de edición desde el menú de arriba a la izquierda.
' + '
Elija su edición de  The Epoch Times
' + '
' + 'PÁGINA DE INICIO PRINCIPAL' + '' + geo_country_name + '' + "
" + '
Recordaremos su edición preferida en sus futuras visitas.
' + "
" + '
' ); $("#ui-widget-overlay").bind("click", function(e) { e.stopPropagation(); if ($(".homepage_edition_opt") !== "undefined") { $(".homepage_edition_opt").addClass("hidden"); } $("#ui-widget-overlay").remove(); return false; }); $(".homepage_edition_opt .close").bind("touchstart click", function(e) { e.stopPropagation(); $(".homepage_edition_opt").addClass("hidden"); $("#ui-widget-overlay").remove(); return false; }); $(".homepage_edition_opt .edition_opt span").click(function(e) { e.stopPropagation(); var opt = $(this).attr("class"); localStorage.setItem("ntd_homepage_edition", opt); localStorage.setItem("backup_homepage_edition", null); if (opt == "mx") { window.location.replace( window.location.protocol + "//" + window.location.hostname + "/mx" ); return true; } else { $(".homepage_edition_opt").addClass("hidden"); $("#ui-widget-overlay").remove(); } }); } //var local_version = ''; if (localStorage.getItem('ntd_geo_country') === "mx" ) { // local_version = 'MÉXICO'; } window.addEventListener( 'load', () => { var srcURL = document.getElementsByTagName( "iframe" ); for ( var i = 0; i < srcURL.length; i++ ) { if( srcURL[i].getAttribute( "data2-src" )) { srcURL[i].setAttribute( "src",srcURL[i].getAttribute( "data2-src" )); } } }); function copy_cmt_link(the_link) { var temp = document.createElement("input"); temp.setAttribute("id", "copy_cmt_link"); temp.setAttribute("value", the_link); document.body.appendChild(temp); temp.select(); temp.setSelectionRange(0, 999); document.execCommand("copy"); document.body.removeChild(temp); if (is_spanish) { alert("El enlace esta copiado."); } else if( is_portuguese ) { alert("Copiar o link."); } } function copy_to_clipboard(data_url) { var input = document.querySelector('#copy_current_url_bottom > input'); if ( !input ) { input = document.createElement('input'); var link = data_url; var utm_source = '?utm_source=copy-link-btn'; var utm_medium = '&utm_medium=sharedFromMember'; input.setAttribute('value', link + utm_source); } var value = input.value; if ( typeof (navigator) !== 'undefined' && navigator.permissions ) { navigator.permissions.query({ name: 'clipboard-read' }) .then(res => { if ( res.state === 'prompt' && navigator.clipboard.writeText ) { navigator.clipboard.writeText(input.value) .catch(() => { clipboard_fallback(input, value, 'rejected: clipboard.writeText'); }); } else { clipboard_fallback(input, value, 'undefined: clipboard.writeText'); } }) .catch(() => { clipboard_fallback(input, value, 'rejected: navigator.permissions'); }); } else { clipboard_fallback(input, value, 'undefined: navigator.permissions'); } } function clipboard_fallback(input, value, log) { if ( $('#copy_current_url_bottom > input').length < 1 ) { $('#copy_current_url_bottom').append(input); } $('#copy_current_url_bottom > input').val(value).select(); document.execCommand('copy'); console.log(log); } function check_sections_on_scroll() { var scroll = jQuery(window).scrollTop(); pending_sections = pending_sections.filter(function (item) { if (typeof jQuery(item.selector) === "undefined" || typeof jQuery(item.selector).offset() === "undefined") return false; var section_top = jQuery(item.selector).offset().top - jQuery(window).height(); // Show the section if the user scrolls near or past the section. if (section_top - scroll < item.threshold || scroll > section_top) { item.callback(); // Remove this section from the pending list. return false; } return true; }); } function ntd_fix_top_video() { if ($('body.single .left_col .active').length > 0) { var offset_ori = $('.left_col .active').offset(); if (typeof offset_ori !== 'undefined') { var fixTopStartPos = offset_ori.top; } } // fix TOP VIDEOS if ($('body.single').length > 0 && typeof fixTopStartPos !== 'undefined') { var offset = $('.active .post_title').offset(); if (typeof offset !== 'undefined' && fixTopStartPos != offset.top) { fixTopStartPos = offset.top; } var active_video = $('.active .featured_image .video_fit_container'); if (active_video.length > 0) { var video_height = $('.active .featured_image').height(); var bottom_offset = $('#footer').offset(); if ($(window).scrollTop() < fixTopStartPos && active_video.hasClass('fixtop') == true || (typeof bottom_offset !== 'undefined' && $(window).scrollTop() > fixTopStartPos && $(window).scrollTop() > bottom_offset.top - $(window).height())) { active_video.removeClass('fixtop'); active_video.find('#video_close').remove(); active_video.attr('style', ''); $('.active .featured_image').height(""); try { window.dispatchEvent(new Event('resize')); } catch (e) { } } else if ( $(window).scrollTop() >= fixTopStartPos && active_video.hasClass('fixtop') == false && typeof bottom_offset !== 'undefined' && $(window).scrollTop() < bottom_offset.top - $(window).height() && active_video.hasClass('nofix') == false) { active_video.addClass('fixtop'); active_video.append(''); $('.active .featured_image').height(video_height); active_video.css('right', ($(window).width() - $('.main_content').width()) / 2); active_video.css('padding', 0); try { window.dispatchEvent(new Event('resize')); } catch (e) { } } $("#video_close").click(function () { active_video.removeClass('fixtop'); active_video.addClass('nofix'); active_video.find('#video_close').remove(); active_video.attr('style', ''); $('.active .featured_image').height(""); try { window.dispatchEvent(new Event('resize')); } catch (e) { } }); } $(window).resize(function () { $('.active .video_fit_container.fixtop').css('right', ($(window).width() - $('.main_content').width()) / 2); }); } } function ntdGetCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') c = c.substring(1, c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); } return null; } function ntd_load_recm_posts() { if (false == more_loading) { // load list from 450px top of the footer if ($('#recommended_load_next_page').length > 0 && $(window).scrollTop() + $(window).height() > $(document).height() - $('footer').height() - 700 && false == more_loading && posts_que.length > 0) { var shifted = posts_que.shift(); render_recommended_posts(shifted); } } } function render_recommended_posts(post) { if (more_loading == false) { more_loading = true; var html = ''; html += '
  • '; // html += '
    '; // html += '
    ' + post['date'] + '
    '; html += '

    ' + post['title'] + '

    '; html += '' + post['video_icon'] + ''; // html += '
    ' + post['author'] + '
    '; html += '' + post['excerpt'] + ''; /* html += ''; */ html += '
  • ' $('#recommended_load_next_page').append(html); more_loading = false; if ($.fn.laziestloader) { $("img.lazy").laziestloader({ threshold: 500 }); } } } function epochGUID() { function s4() { return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1); } return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4(); } var windows_focused = false; $(window).on("blur focus scroll click", function (e) { windows_focused = !(e.type == 'blur'); }); function init_paywall_express() { var pageType = "page"; var tagIds, tagNames, categoryIds, categoryNames, authorIds, authorNames, termIds, termNames = []; if (location.pathname === "/") { pageType = "home"; } else if (ntd_primary_category) { pageType = "post"; } else if (ntd_cat_ids) { pageType = "category"; } if (window.ntd_cat_ids) { categoryIds = window.ntd_cat_ids.split(";"); } if (window.ntd_cat_names_full) { categoryNames = window.ntd_cat_names_full.split(";"); } if (window.ntd_user_id) { authorIds = [window.ntd_user_id]; } if (window.ntd_author_nicename) { authorNames = [window.ntd_author_nicename + "-" + window.ntd_user_id]; } if (window.ntd_term_ids) { termIds = window.ntd_term_ids.split(";"); } if (window.ntd_term_names_full) { termNames = window.ntd_term_names_full.split(";"); } if (window.ntd_tag_ids) { tagIds = window.ntd_tag_ids.split(","); } if (window.ntd_tag_names_full) { tagNames = window.ntd_tag_names_full.split(";"); } window.paywall = window.paywall || []; window.paywall.push({ siteId: window.siteConfig.siteId, language: window.siteConfig.lang, pageInfo: { pageType: pageType, postId: window.ntd_post_id, primaryCategoryId: findTermById(ntd_cat_names_full, ntd_primary_category, ';'), primaryCategoryName: window.ntd_primary_category ? window.ntd_primary_category_name + "-" + window.ntd_primary_category : undefined, categoryIds: categoryNames, categoryNames: joinStringArrays(window.ntd_cat_names, window.ntd_cat_ids, ';', '-'), tagIds: tagNames, tagNames: joinStringArrays(window.ntd_tags, window.ntd_tag_ids, ';', '-'), authorIds: authorNames, authorNames: joinStringArrays(window.ntd_author_name, window.ntd_user_id, ';', '-'), termIds: termNames, termNames: joinStringArrays(window.ntd_term_names, window.ntd_term_names_full, ';', '-'), isPremium: false, publishDate: window.ntd_publish_date, }, onInit: function (user) { window.paywall.showNavbarTemplate(); window.paywall.executePaywallFlow({ flowId: window.siteConfig.flowId, }); var userEpochID = ''; if (user.info.id) { if (typeof $.cookie !== 'undefined') { $.cookie("ads_layout", "logged", { expires: 30, domain: host }); } userEpochID = user.info.id; if (typeof gtag !== 'undefined') { gtag('set', { 'user_id': userEpochID }); } } if ($('body.single').length > 0 && $('body.no-comment').length == 0) { remark_panel_init(user.info.token); } }, }); } function joinStringArrays(str1, str2, delimiter, joiner) { if (typeof str1 !== 'string' || typeof str2 !== 'string') { //console.error('Error: Both inputs must be strings'); return []; } var array1 = str1.split(delimiter); var array2 = str2.split(delimiter); if (array1.length !== array2.length) { //console.error('Error: Arrays must be of the same length'); return []; } var result = []; for (var i = 0; i < array1.length; i++) { result.push(array1[i] + joiner + array2[i]); } return result; } function findTermById(inputStr, id, delimiter) { if (typeof inputStr !== 'string' || typeof id !== 'string') { //console.error('Error: Both inputStr and id must be strings'); return undefined; } var terms = inputStr.split(delimiter); for (var i = 0; i < terms.length; i++) { if (terms[i].endsWith(id)) { return terms[i]; } } //console.error('Error: ID not found'); return undefined; } function trackEvent(category, action, label, value, noninteraction) { action = action || ''; label = label || ''; value = value || 0; noninteraction = noninteraction || false; label = label.replace('::articleTitle', document.title); if (location.href.indexOf('dev.') > -1) { action = "[dev]" + action; console.log('GA trackEvent [dev]'); } if (typeof gtag === 'function') { gtag( 'event', action, { 'event_category': category, 'event_label': label, 'value': value, 'non_interaction': noninteraction }); } } function eet_ymk_userID() { if (typeof window.ymkAuth !== 'undefined' && typeof window.ymkAuth.ymkUserData !== 'undefined' && window.ymkAuth.ymkUserData) { return window.ymkAuth.ymkUserData; } var userID = localStorage.getItem("epoch_gdpr_userid"); if (!userID) { userID = epochGUID(); localStorage.setItem('epoch_gdpr_userid', userID); } return userID; } function getMainHost(location) { var host = location.host var parts = host.split('.'); return parts.slice((parts[parts.length - 1].length < 3) ? -3 : -2).join('.'); } function ntd_set_cookie(name, value, days) { var expires = ""; var date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); expires = "; expires=" + date.toGMTString(); var mainDomain = getMainHost(window.location) document.cookie = name + "=" + value + expires + ";domain=."+mainDomain+";path=/;SameSite=Lax"; } function deleteCookie(name) { $.cookie(name, null, { expires: -1 }); } function loadScript(url, callback) { var script = document.createElement("script"); script.type = "text/javascript"; script.src = url; if (callback) { script.onload = function () { callback(); }; } document.head.appendChild(script); } function loadCSS(url, callback) { var link = document.createElement("link"); link.rel = "stylesheet"; link.href = url; if (callback) { link.onload = function () { callback(); }; } document.head.appendChild(link); }