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( '
' + 'a lognes
'); $('.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('
FacebookTwitter' + social_share + '
'); 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 += '
  • '; // 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_pipa_paywall() { var emailAlreadyExistsParam = false; var email = ''; if (typeof (ntd_language_active) == "undefined") { return; } if (!('ntd_korea' === ntd_language_active || 'ntd_spanish' === ntd_language_active || 'ntd_french' === ntd_language_active)) { return; } if (ntd_language_active === 'ntd_korea') { if (document.location.href.indexOf('verify_email') > 0 && document.location.href.indexOf('pipa_verify_email') === -1) { $.ajax({ 'url': 'assets/themes/ntd/js/verify_email_reset_pwd_min.js', 'dataType': 'script', 'cache': true, success: function (response) { renderVerifyEmail(window.config['auth_hostname'], window.config['website']); } }); } else if (document.location.href.indexOf('reset_password') > 0 && document.location.href.indexOf('pipa_reset_password') === -1) { $.ajax({ 'url': 'assets/themes/ntd/js/verify_email_reset_pwd_min.js', 'dataType': 'script', 'cache': true, success: function (response) { renderChangePassword(window.config['auth_hostname']); } }); } else if (document.location.href.indexOf('user_login') > 0) { window.ep.push(["init", function () { window.epSubs.showTemplate('signin-popup', 'POPUP'); } ]); } else if (document.location.href.indexOf('email_already_exists') > 0) { const urlParams = new URLSearchParams(window.location.search); email = urlParams.get('email_already_exists'); emailAlreadyExistsParam = true; } } else if (ntd_language_active == 'ntd_french' && typeof ntd_disable_gacookies != 'undefined') { window.ep.push(["config", "noGACookie", ntd_disable_gacookies]); } window.ep.push( ["config", window.config.website], ["init", function () { window.ep.pipaId.show({ displayMode: 'popup', // If we don't wanna refresh by ourselves, overwrite function // loggedIn: function () {}, containerSelector: '#login_wrapper', }); var userEpochID = ''; if (window.ep.pipaId.didLoggedIn()) { console.log("[PIPA]user Logged in Status"); if (typeof $.cookie !== 'undefined') { $.cookie("ads_layout", "logged", {expires: 30, domain: window.config.website}); } userEpochID = ntdGetCookie('epoch_user_id'); if (typeof gtag !== 'undefined') { gtag('set', {'dimension16': userEpochID}); gtag('set', {'user_id': userEpochID}); } } else { if (emailAlreadyExistsParam) { window.epSubs.showTemplate('signin-popup', 'POPUP', undefined, { "email_already_exists": email }); } userEpochID = localStorage.getItem('epoch_gdpr_userid'); if (typeof gtag !== 'undefined') { gtag('set', {'dimension17': userEpochID}); } } var url_path = decodeURI(window.location.pathname); if (url_path.indexOf('theepochtimes.com') > 0) { var arr_path = url_path.split('theepochtimes.com'); if (arr_path.length === 2) { url_path = arr_path[1]; } } if (typeof gtag === 'function') { gtag('event', 'page_view', { 'page_path': url_path }); } window.epSubs.saveVisitorUTMs(); if( !is_korean && $('body.single').length > 0 ) { remark_panel_init(); } }], ["config", "dataDestination", window.config.trackDestination] ); if (typeof ntd_ga_id === "string" && ntd_ga_id.length > 0) { window.ep.push(["config", "GAID", ntd_ga_id]); } if ($('body.single-post').length > 0) { window.ep.push(["tag", ["article"]]); if (ntd_all_term_ids && typeof ntd_all_term_ids === 'string') { window.ep.push(["tag", jet_all_term_ids.split(";")]); } } if ($('body').attr('class').indexOf('our-story') > -1) { window.ep.push(["tag", ["our-story"]]); } if ($('.upper_row .featured_image .video_fit_container').length > 0) { window.ep.push(["tag", ["video-article"]]); } if (ntd_language_active === 'ntd_korea') { const userAgent = navigator.userAgent; const referrer = document.referrer; const agentCond = /KAKAOTALK|Daum|NAVER|BAND/; const referrerCond = /search[?.]|namu.wiki|wikipedia.org|pushengage/; if (agentCond.test(userAgent) || referrerCond.test(referrer)) { window.ep.push(["tag", ["searchAndWiki"]]); } } window.ep.push( ["config", "planid", window.config.planID], ["url", [window.location.href]], ["init", function () { window.epSubs.executePaywallRules(); }] ); } // Track virtual pageviews using Google Analytics function trackPage(url) { if (location.href.indexOf('dev.') > -1) { url = url.replace("/virtual/", "/virtual/dev/"); } if (typeof gtag === 'function') { gtag('event', 'page_view', { 'page_path': url }); } } 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 setShortURLEvent() { $('.social>.text, #shorturl').mouseover(function () { $('#shorturl').focus(); $('#shorturl').select(); }); $('.social>.text, #shorturl').mouseleave(function () { $('#shorturl').focusout(); }); $('.social>.text, #shorturl').click(function () { $('#shorturl').select(); document.execCommand('copy'); $('#dialog').modal(); return false; }); } function ntd_home_ymk_socials(selector) { var postID = 0; var socialPosts = []; $(selector).each(function (index, item) { var itemLink = $(item).attr('href').split('theepochtimes.com')[1]; if (typeof itemLink === 'string' && itemLink.length > 0) { var matchPostID = itemLink.match(/(-|_)(\d+).html/); if (matchPostID && matchPostID.length > 2) { postID = matchPostID[2]; } if (!isNaN(postID) && postID > 0) { socialPosts.push(postID); } } }); var userID = eet_ymk_userID(); if (!userID) return false; if (socialPosts.length > 0 && userID) { $.ajax({ url: 'https://sc.youmaker.com/site/article/count?site=' + window.config['website'] + '&user='+userID+'&postid='+socialPosts.toString(), type: 'GET', success: function (res) { if (res.status == 'ok') { $.each(res.data, function (i, item) { if ($('#share_post_' + item.id).length > 0 && parseInt(item.shareCount) >1) { $('span[id="share_post_' + item.id + '"]').text(item.shareCount); } }); } } }); } if (typeof parseInt(window.commentToShare) === 'number') { socialPosts.push( window.commentToShare ); } if (socialPosts.length > 0) { $.ajax({ url: "https://comment.youmaker.com/api/v1/counts?site=" + window.config['website'] + "&post=id", type: 'POST', dataType: 'json', contentType: 'application/json', processData: false, data: JSON.stringify(socialPosts), success: function (res) { $.each(res, function (i) { if ($('#cmt_post_' + res[i].id).length > 0 && parseInt(res[i].count) > 0) { $('*[id="cmt_post_' + res[i].id + '"]').text(res[i].count); } if ( typeof parseInt(window.commentToShare === 'number') && parseInt(res[i].id) == parseInt(window.commentToShare) && typeof window.listShareCommentPosts === 'object' ){ for (var k = 0; k < window.listShareCommentPosts.length; k++) { postID = window.listShareCommentPosts[k]; cmt_post = $('#cmt_post_' + postID); if (cmt_post.length > 0 && parseInt(res[i].count) > 0) { cmt_post.text(res[i].count); console.log(cmt_post.text(res[i].count)); } } } }); } }); } } 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 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(); document.cookie = name + "=" + value + expires + ";domain=.theepochtimes.com;path=/;SameSite=Lax"; } function ntd_fp_sticky_sidebars() { if ($(window).width() > 1024) { var left_height = right_height = 0; left_height = $('.top_part').offset().top + $('.top_part .left_side').height() - $(window).height(); right_height = $('.top_part').offset().top + $('.top_part .right_side').height() - $(window).height(); var scroll = $(window).scrollTop(); if (scroll > left_height) { $('.top_part .left_side').addClass('sticky_bottom'); } else { $('.top_part .left_side').removeClass('sticky_bottom'); } if (scroll > right_height) { $('.top_part .right_side').addClass('sticky_bottom'); } else { $('.top_part .right_side').removeClass('sticky_bottom'); } if (scroll > $('.top_part').offset().top + $('.top_part').height() - $(window).height()) { $('.top_part .left_side, .top_part .right_side').addClass('keep_bottom'); } else { $('.top_part .left_side, .top_part .right_side').removeClass('keep_bottom'); } } else { $('.top_part .left_side, .top_part .right_side').removeClass('sticky_bottom'); $('.top_part .left_side, .top_part .right_side').removeClass('keep_bottom'); } } function toggleTOC() { var tocContent = document.querySelector('.toc-content'); var tocToggle = document.getElementById('toc-toggle'); var tocIcon = tocToggle.querySelector('.toc-icon'); if (tocContent.style.display === "none") { tocContent.style.display = "block"; tocIcon.src = "/assets/themes/ntd/images/svg/triangle-down.svg"; } else { tocContent.style.display = "none"; tocIcon.src = "/assets/themes/ntd/images/svg/triangle-right.svg"; } }