var pending_sections = []; var sign_in_translation = 'SIGNED'; var section_threshold = 500; var more_loading = false; var posts_que = window.posts_que || {}; window.ep = window.ep || []; window.config = { pushEngageId: '', more: 'すべて', trackDestination: '', website: '', planID: '' }; var is_korean = typeof ntd_language_active !== 'undefined' && 'ntd_korea' === ntd_language_active; var is_spanish = typeof ntd_language_active !== 'undefined' && 'ntd_spanish' === ntd_language_active; var is_french = typeof ntd_language_active !== 'undefined' && 'ntd_french' === ntd_language_active; if( is_korean ) { window.config.website = "kr.theepochtimes.com"; window.config.planID = "5673c220-caa9-40fc-89cb-e2ca391b9c16"; // window.config.planID = "0d06129a-ee23-401d-9116-b9dfa25fae75"; window.config.trackDestination = 'web_event_data_kr'; window.config.more = 'MORE'; window.listShareCommentPosts = [569018, 525688, 458147]; window.commentToShare = "564169"; } else if( is_spanish ) { window.config.website = "es.theepochtimes.com"; window.config.planID = "d33f3496-1dcf-437a-a771-da1dbf5ee181"; window.config.pushEngageId = '996d32e7c0b26be1057ebc03d9f77ffa'; window.config.trackDestination = 'web_event_data_es'; window.config.more = 'MÁS'; sign_in_translation = 'FIRMARON'; } else if( is_french ) { window.config.website = "www.epochtimes.fr"; window.config.planID = "f937bd7d-0015-409f-b4d9-591f70ec1b0d"; window.config.trackDestination = 'web_event_data_fr'; window.config.more = 'PLUS'; sign_in_translation = 'signatures'; } jQuery.loadAsync = function(url, success_callback) { return jQuery.ajax({ url: url, dataType: "script", cache: true, async: true, success: success_callback || jQuery.noop, }) }; $(document).ready(function () { if( $('body.single').length > 0 ) { if( $('body.ntd-video').length > 0 ) { $('.article > .social').after('
'); } else { $('.upper_row > .social_email').after(''); } // Cogedim if (is_french) { $('.main_content .right_col').append( ''); $('.main_content .right_col').css({'position': 'sticky', 'top': '0'}); } } if (!is_french) { init_pipa_paywall(); } $('form.search_form > button').click(function (e) { if ( $("input[name=s]").val() == '') { return false; } }); $('#header').after($('#ntd_cookie_bar')); $('#font_up').click(function () { if( $('#main .upper_row > .post_content').length > 0 ) { $('.upper_row .post_content').css('font-size', '+=1'); } else { $('#main .content').css('font-size', '+=1'); } }); $('#font_down').click(function () { if( $('#main .upper_row > .post_content').length > 0 ) { $('.upper_row .post_content').css('font-size', '-=1'); } else { $('#main .content').css('font-size', '-=1'); } }); $('#copy_current_url_side').click(function () { copy_to_clipboard(); if( is_korean ) { $(this).text("복사 완료!"); } else if( is_spanish ) { $(this).text("Enlace copiado"); } else if( is_french ) { $(this).text("Lien copié"); } }); $('#copy_current_url_bottom').click(function () { copy_to_clipboard(); if( is_korean ) { alert("주소를 복사했습니다."); } else if( is_spanish ) { alert("El enlace esta copiado."); } else if( is_french ) { alert("Le lien est copié."); } }); if ($('#ntd_date').length > 0) { $('#ntd_date').empty().append(met_get_date()); } $('.toggle').click(function () { $('#hidden_menu').toggleClass('hidden'); $('.toggle').toggleClass('close'); }); $('#hidden_menu .close_icon').click(function () { $('#hidden_menu').addClass('hidden'); $('.toggle').removeClass('close'); }); $('header .language').click(function (e) { var menu = $("header .language_panel ul"); if (menu.hasClass('hidden')) { open_menu_dropdown(menu); } else { close_menu_dropdown(menu); } }); $('header .main_nav li:last').click(function () { if ($(this).text().toUpperCase() == window.config.more) { $('header #hidden_menu').removeClass('hidden'); } }); if ($('.cmt_link').length > 0) { if (typeof ntd_language_active !== 'undefined' && ntd_language_active === 'ntd_french'){ $('.ymk_social').css('display','none'); } setTimeout(ntd_home_ymk_socials('.cmt_link'), 2000); } if( $('body.home').length > 0 ) { $('.share_link').each(function() { var the_link = $(this).siblings('.cmt_link').attr('href'); var the_share = $(this).siblings('.share_dropdown'); var the_title = the_share.data('title'); var title_tw = the_title.replace(/%/g, '%25'); var social_share; if( is_korean ) { social_share = '카카오톡밴드주소복사'; } else if( is_spanish ) { social_share = 'TelegramWhatsappCopiar enlace'; } else if( is_french ) { social_share = 'TelegramEmailCopier le lien'; } if( typeof the_link !== "undefined" && typeof the_share !== "undefined" ) { the_share.append(' '); the_share.hide(); } }); } $('.icons span a, .share .icons span a, .social .icons img, #share_now a, .share_dropdown .share a, .share span, #social_share_widget .panel a').click(function() { var stringToMatch = $(this).attr('href'); var userID = eet_ymk_userID(); if ($(this).attr('onclick')) { stringToMatch = $(this).attr('onclick'); } var matchPostID = stringToMatch.match(/(-|_|share\/|share%2F|share%252F)(\d+)(.html|%3|%253Futm_source|\?|&utm_source)/); console.log("userID:", userID); console.log("matchPostID:", matchPostID); if (!(matchPostID && matchPostID.length > 2) || !userID) { return false; } if (matchPostID && matchPostID.length > 2) { var postID = matchPostID[2]; } console.log("postID:", postID); if (postID > 0 && userID) { $.ajax({ url: 'https://sc.youmaker.com/site/article/share?site=' + window.config['website'] + '&user=' + userID + '&postid=' + postID, method: 'POST' }) .done(function(res) { console.log('share', res); }) } }); $(window).click(function (e) { var hidden_menu = $('header .top_container #hidden_menu'); var menu_icon = $('header .toggle'); var menu_more = $('header .main_nav li:last'); if (!hidden_menu.is(e.target) && hidden_menu.has(e.target).length === 0 && !menu_icon.is(e.target) && menu_icon.has(e.target).length === 0 && !menu_more.is(e.target) && menu_more.has(e.target).length === 0) { $('header #hidden_menu').addClass('hidden'); $('.toggle').removeClass('close'); } var search_pannel = $('header .top_container #search_pannel'); var search_icon = $('header .right_col .search'); if (!search_pannel.is(e.target) && search_pannel.has(e.target).length === 0 && !search_icon.is(e.target) && search_icon.has(e.target).length === 0) { $('header .top_container #search_pannel').addClass('hidden'); } }); $('header .right_col .search').click(function () { $('#search_pannel').toggleClass('hidden'); }); function met_get_date() { if (typeof (ntd_language_active) != "undefined" && $('body.' + ntd_language_active).length > 0) { if ('ntd_korea' == ntd_language_active) { moment.locale('ko'); var value_ko = moment().format('YYYY년 MMMM Do dddd'); return value_ko; } if ('ntd_french' == ntd_language_active) { moment.locale('fr'); var value_fr = moment().format('dddd LL'); return value_fr.charAt(0).toUpperCase() + value_fr.slice(1); } if ('ntd_spanish' == ntd_language_active) { moment.locale('es-us'); var value_es = moment().format('dddd, LL'); return value_es.charAt(0).toUpperCase() + value_es.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; } } function open_menu_dropdown(menu) { menu.removeClass('hidden'); $('body').append(''); $('#ui-widget-overlay').bind('touchstart click', function (e) { e.stopPropagation(); close_menu_dropdown(menu); return false; }); } function close_menu_dropdown(menu) { if (menu !== "undefined") { menu.addClass('hidden'); } $('#ui-widget-overlay').remove(); } if ($("#fb_page").length > 0) { var pageId = $("#fb_page").data('pageid'); add_lazy_load_section('#fb_page', function () { $("#fb_page").append(''); }); } setTimeout(function () { if ($('#recommended_load_next_page').length > 0 && typeof $('#recommended_load_next_page').data('posts') !== "undefined" && $('#recommended_load_next_page').data('posts').length > 0) { posts_que = $('#recommended_load_next_page').data('posts'); more_loading = false; } }, 2000); 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 .posts_list').html(); if (content) { var location = $('#category_load_more').offset().top - 100; $('.article_list .posts_list').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: 1000 }); } } }); } return false; }); if ($.fn.laziestloader) { $("img.lazy").laziestloader({ threshold: 1000 }); $(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); } }); $("#backtotop").hide(); $("#backtotop a").click(function () { $("body,html").animate({ scrollTop: 0 }, 800); return false; }); // open links in post content in new window/tab $('.post_content a').each(function () { let href = $(this).attr('href'); if (href && href.startsWith('#')) { $(this).attr("target", "_self"); } else { $(this).attr("target", "_blank"); } }); if ($('body.single').length > 0) { setShortURLEvent(); } 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; } if (window.config.pushEngageId != '') { window._peq = window._peq || []; window._peq.push(["init", initEngageCat]); jQuery.loadAsync('https://clientcdn.pushengage.com/core/' + window.config.pushEngageId + '.js', jQuery.noop); } } var lastShareDropdown = null; $('.share_link').click(function (event) { event.stopPropagation(); var curPos = $(this).offset(); var parentPos = $(this).parent().offset(); // var idPattern = 'share_post_'; // var elId = $(this).find('.share').attr('id'); // var postID = elId.substring( idPattern.length ); var postID = $(this).find('.share').data('post-id'); // var this_share = $(this).siblings('.share_dropdown'); // if (!this_share) var this_share = $('#share_dropdown_' + postID); // else // this_share.attr('id', '#share_dropdown_' + postID); this_share.appendTo(document.body); var targetTop = curPos.top - parentPos.top; var targetTop = parentPos.top; var targetLeft = curPos.left - parentPos.left; var targetLeft = parentPos.left; if (this_share && this_share.is(':visible')) { this_share.hide(); lastShareDropdown = null; } else if (curPos && parentPos && this_share) { this_share.css({top: targetTop, left: targetLeft}); $('.share_dropdown').hide(); this_share.show(); lastShareDropdown = this_share; } return false; }); $(window).click(function (e) { if (lastShareDropdown && lastShareDropdown.is(':visible')) { $('.share_dropdown').hide(); } }); $('.trackClick').on('click touchstart', function (e) { e.stopPropagation(); if (typeof gtag === 'function') { var category = this.hasAttribute('data-category') ? this.getAttribute('data-category') : "businessTrack"; var action = this.hasAttribute('data-action') ? this.getAttribute('data-action') : "trackClick"; var label = this.hasAttribute('data-label') ? this.getAttribute('data-label') : "trackLabel"; var conversion_tag = this.getAttribute('data-conversion'); console.log('gtag detect click:' + category + "/" + action + "/" + label + "/" + conversion_tag); gtag('event', action, { 'event_category': category, 'event_label': label }); if (typeof conversion_tag === "string") { console.log('gtag run over link'); gtag('event', 'conversion', { 'send_to': conversion_tag }); } } return true; }); if ($('body.home').length > 0) { var didScrollHome = null; jQuery(window).scroll(function () { didScrollHome = true; }); setInterval(function () { if (didScrollHome) { didScrollHome = false; // ntd_fp_sticky_sidebars(); } }, 100); } 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); } $('.premium_programs .search').click(function() { $('#search_panel').show(); }); $(".premium_programs #search_panel .close").click(function() { $("#search_panel").hide(); }); }); /* end document ready */ document.addEventListener('copy', (event) => { if (!document.getElementById("copy_cmt_link") && !document.getElementById("copy_url") && document.getElementById("copyright_clipboard")) { event.clipboardData.setData('text', document.getSelection() + " " + document.getElementById("copyright_clipboard").getAttribute('data-source')); event.preventDefault(); } }); 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_korean ) { alert("주소를 복사했습니다."); } else if( is_spanish ) { alert("El enlace esta copiado."); } else if( is_french ) { alert("Le lien est copié."); } } function copy_to_clipboard() { var textarea = document.createElement('textarea'); textarea.setAttribute('id', 'copy_url'); var link = window.location.href.split("?utm_source")[0]; var utm_source = '?utm_source=copy-link-btn'; textarea.textContent = link + utm_source; if( is_korean ) { textarea.textContent = window.location.origin + '/share/' + ntd_post_id; } document.body.appendChild(textarea); textarea.select(); textarea.setSelectionRange(0, 999); document.execCommand('copy'); document.body.removeChild(textarea); } 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 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 }); } // throttled scroll events var didScroll = null; jQuery(window).scroll(function () { didScroll = true; }); setInterval(function () { if (didScroll) { didScroll = false; check_sections_on_scroll(); eet_back_to_top(); ntd_fix_top_video(); ntd_load_recm_posts(); } }, 250); function eet_back_to_top() { if ($(window).scrollTop() > 800 && !$("#backtotop").is(':visible')) { $("#backtotop").fadeIn(); } else if ($(window).scrollTop() < 800 && $("#backtotop").is(':visible')) { $("#backtotop").fadeOut(); } } 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(); console.log(shifted); render_recommended_posts(shifted); } } } function render_recommended_posts(post) { if (more_loading == false) { more_loading = true; var html = ''; html += '