1window._scroll_debug = false; 2 3( function ($) { 4 'use strict'; 5 var lastScrollTop = 0; 6 $.fn.isInViewport = function() { 7 var elementTop = $(this).offset().top; 8 var elementBottom = elementTop + $(this).outerHeight(); 9 10 var viewportTop = $(window).scrollTop(); 11 var viewportBottom = viewportTop + $(window).height(); 12 13 return elementBottom > viewportTop && elementTop < viewportBottom; 14 }; 15 16 var array_of_urls = new Array(); 17 array_of_urls.push( window.location.href ); 18 $( document ).ready( function() { 19 20 var ajaxModel = { 21 loading: false, 22 performed: false, 23 errored: false, 24 done: false 25 }; 26 27 $(window).scroll(function() { 28 // HOME PAGE INFINITE SCROLL 29 /* if( _digitrend_infinite_scroll.is_home && _digitrend_infinite_scroll.infinite_scroll_homepage == 'true' ) { 30 if( !ajaxModel.done ) { 31 $('footer').css({ 'opacity': '0', 'height': '0px' }); 32 $('#copy').css({ 'opacity': '0', 'height': '0px' }); 33 } else { 34 $('footer').css({ 'opacity': '1', 'height': 'initial' }); 35 $('#copy').css({ 'opacity': '1', 'height': 'initial' }); 36 } 37 if ( $(window).scrollTop() >= ( ( $(document).height() - $(window).height() ) - 1000 ) && ! ajaxModel.performed ) { 38 39 ajaxModel.performed = true; 40 ajaxModel.loading = true; 41 42 $.ajax({ 43 type: 'GET', 44 dataType: 'json', 45 url: _digitrend_infinite_scroll.ajaxurl, 46 data: { 47 'action': _digitrend_infinite_scroll.default_action, 48 'exclude_posts': digitrend_exlcuded_ids, 49 }, 50 error: function(response) { 51 if( response.status == 414 ) { 52 ajaxModel.done = true; 53 } 54 55 ajaxModel.errored = true; 56 }, 57 success: function(response) { 58 if( response.status == 200 ) { 59 digitrend_exlcuded_ids = response.exclude_posts; 60 $( '#flow' ).append( response.templates ); 61 } 62 $('<div class="digitrend-roller"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>').insertBefore('footer'); 63 64 ajaxModel.loading = false; 65 66 } 67 }) 68 .done( function(data) { 69 setTimeout(() => { 70 ajaxModel.performed = false; 71 $('.digitrend-roller').remove(); 72 }, 1000); 73 }); 74 75 } 76 } */ 77 78 // POSTS INFINITE SCROLL 79 if( _digitrend_infinite_scroll.is_home == '' && window.location.search.indexOf('google_preview') == -1 ) { 80 81 /* 82 if( jQuery('main[data-permalink="' + window.location.href + '"]').length ) { 83 var viewportHeight = window.innerHeight; 84 var scrollTop = window.scrollY; 85 var elementOffsetTop = jQuery('main[data-permalink="' + window.location.href + '"]').offset().top; 86 var elementHeight = jQuery('main[data-permalink="' + window.location.href + '"]').height(); 87 88 // Calculate percentage of the element that's been seen 89 var distance = (scrollTop + viewportHeight) - elementOffsetTop; 90 var percentage = Math.round(distance / ((viewportHeight + elementHeight) / 100)); 91 92 // Restrict the range to between 0 and 100 93 // console.log( Math.min(100, Math.max(0, percentage)) + "%"); 94 } 95 */ 96 97 $($('main').get().reverse()).each( function(index, element) { 98 var scrollTollerance = (window.innerHeight/2); 99 var st = window.pageYOffset || document.documentElement.scrollTop; 100 if (st < lastScrollTop){ 101 scrollTollerance = window.innerHeight; 102 } 103 lastScrollTop = st <= 0 ? 0 : st; // For Mobile or negative scrolling 104 105 if(window._scroll_debug) { 106 jQuery('main').css({backgroundColor: 'transparent'}); 107 $(element).css({backgroundColor: 'red'}); 108 } 109 if( ($(window).scrollTop() + scrollTollerance) - $(element).offset().top > 0 ) { 110 111 if( window.location.href == $(element).data('permalink') ) { 112 return false;
113 } 114 115 console.log('Window Location: ', window.location.href); 116 console.log("Element data permalink: ", $(element).data('permalink')); 117 118 history.replaceState({}, null, $(element).data('permalink')); 119 document.getElementsByTagName('title')[0].innerText = $(element).data('title'); 120 121 if (!array_of_urls.includes($(element).data('permalink'))) 122 array_of_urls.push($(element).data('permalink')); 123 124 if (window.dataLayer.length > 0) 125 for (var i = 0; i < array_of_urls.length; i++){ 126 if (array_of_urls[i] == $(element).data('permalink') && i > 0){ 127 /*gtag('event', 'lettura_articolo_infinite_scroll', { 128 'event_label':'Infinite Scroll'.concat(' ', i), 129 'event_category':'Infinite Scroll', 130 'non_interaction':false, 131 'value':i, 132 'send_to':[ 'UA-3351701-1' ] 133 }); 134 135 gtag('config', 'UA-3351701-1', { 136 page_title:$(element).data('title'), 137 page_location:window.location.href + '?dp=' + i, 138 page_path:window.location.pathname + '?dp=' + i, 139 });*/ 140 141 gtag('event', 'page_view', { 142 'page_title':$(element).data('title'), 143 'page_location':window.location.href + '?dp=' + i, 144 'page_path':window.location.pathname, 145 'send_to':[ 'G-M4ZJPB673T' ] 146 }); 147 } 148 149 if (array_of_urls[i] == $(element).data('permalink') && i == 0) 150 console.log('NEVER TRACK FIRST ARTICLE'); 151 } 152 153 document.querySelectorAll('head meta').forEach(function(ce,) { 154 if(ce.getAttribute('http-equiv') == 'refresh') { 155 ce.setAttribute('content', '300;URL='.concat( $(element).data('permalink'), '?refresh_ce' ) ); 156 } 157 }); 158 159 return false; 160 } 161 }); 162 163 if ( ( $('#digitrend-infinite-scroll-delimiter').isInViewport() && ! ajaxModel.performed ) && ( _digitrend_infinite_scroll.digitrend_infinite_scroll_show_x_posts == 0 || _digitrend_infinite_scroll.scroll_count <= _digitrend_infinite_scroll.digitrend_infinite_scroll_show_x_posts ) ) 164 { 165 if( !ajaxModel.done ) { 166 // $('footer').css({ 'opacity': '0', 'height': '0px' }); 167 // $('#copy').css({ 'opacity': '0', 'height': '0px' }); 168 } else { 169 // $('footer').css({ 'opacity': '1', 'height': 'initial' }); 170 // $('#copy').css({ 'opacity': '1', 'height': 'initial' }); 171 } 172 173 jQuery('#digitrend-infinite-scroll-delimiter').append('<div class="digitrend-roller"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>'); 174 175 ajaxModel.performed = true; 176 ajaxModel.loading = true; 177 178 $.ajax({ 179 type: 'GET', 180 dataType: 'json', 181 url: _digitrend_infinite_scroll.ajaxurl, 182 data: { 183 'action': _digitrend_infinite_scroll.action, 184 'skip': _digitrend_infinite_scroll.skip, 185 'limit': _digitrend_infinite_scroll.number_of_posts, 186 'current_post': _digitrend_infinite_scroll.current_post, 187 'scroll_count': _digitrend_infinite_scroll.scroll_count 188 }, 189 error: function(response) { 190 if( response.status == 414 ) { 191 ajaxModel.done = true; 192 } 193 ajaxModel.errored = true; 194 }, 195 success: function(response) { 196 197 if( response.status == 200 ) { 198 jQuery( response.data ).insertBefore( "#digitrend-infinite-scroll-delimiter" );
199 _digitrend_infinite_scroll.skip = parseInt(_digitrend_infinite_scroll.skip) + parseInt(_digitrend_infinite_scroll.number_of_posts); 200 } 201 202 ajaxModel.loading = false; 203 } 204 }) 205 .done( function(data) { 206 setTimeout(() => { 207 ajaxModel.performed = false; 208 $('.digitrend-roller').remove(); 209 }, 1000); 210 _digitrend_infinite_scroll.scroll_count++; 211 }); 212 } 213 214 215 }; 216 }); 217 }); 218})(jQuery);; 219// For compatibility with optimizers 220if (document.readyState !== 'loading') { 221 //console.log('Newsletter loaded (late)'); 222 tnp_ajax_init(); 223} else { 224 document.addEventListener("DOMContentLoaded", function () { 225 //console.log('Newsletter loaded'); 226 tnp_ajax_init(); 227 }); 228} 229 230function tnp_ajax_init() { 231 document.querySelectorAll('form.tnp-ajax').forEach(el => { 232 el.addEventListener('submit', async function(ev) { 233 ev.preventDefault(); 234 ev.stopPropagation(); 235 const response = await fetch(newsletter_data.action_url + '?action=tnp&na=sa', { 236 method: "POST", 237 body: new FormData(this) 238 }); 239 this.innerHTML = await response.text(); 240 }); 241 }); 242} 243 244 245 246;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.