1const PopupRDT = { 2 _getIndexRamdom: function(data) { 3 const arr = []; 4 jQuery('#popup-rdt li').each(function(i, e) { 5 if (data.indexOf(jQuery(e).find('a').attr('href')) == -1) { 6 for(let j = 0; j < (jQuery(e).attr('weight') || 1); j++) { 7 arr.push(i); 8 } 9 } 10 }); 11 if (arr.length == 0) return -1; 12 return arr[Math.floor(Math.random() * arr.length)]; 13 }, 14 _getCookieKey: function() { 15 let key = jQuery("#popup-rdt").attr('data'); 16 if (!key || !key.match(/^[a-z0-9]*$/)) { 17 key = 'rdt'; 18 } 19 return key; 20 }, 21 _getCookie: function() { 22 let key = PopupRDT._getCookieKey(); 23 for (let c of document.cookie.split(/; ?/)) { 24 c = c.split('='); 25 if (c[0] == key) { 26 return c[1].split(','); 27 } 28 } 29 return []; 30 }, 31 _saveCookie: function(data, value) { 32 let now = new Date(); 33 data.push(value); 34 data = data.filter((e, i) => data.indexOf(e) === i); 35 let key = PopupRDT._getCookieKey(); 36 document.cookie = key + "=" + now.getTime() + ',' + data.join(',') + ";path=/;max-age=" + (60*60*24); 37 }, 38 init: function() { 39 if (jQuery("#popup-rdt").length == 0) return; 40 this._remodal = jQuery("#popup-rdt").remodal(); 41 }, 42 popup: function() { 43 let now = new Date(); 44 if (!this._remodal || this._remodal.getState() != 'closed') return; 45 const data = PopupRDT._getCookie(); 46 const last_date = parseInt(data.shift()); 47 if (now.getTime() < (last_date + (1000 * 60 * 60))) 48 return; 49 const index = PopupRDT._getIndexRamdom(data); 50 if (index < 0) return; 51 jQuery("#popup-rdt li").hide(); 52 jQuery("#popup-rdt li").eq(index).show(); 53 this._remodal.open(); 54 let href = jQuery("#popup-rdt li").eq(index).find('a').attr('href'); 55 PopupRDT._saveCookie(data, href); 56 ga('send', 'event', 'popup', 'impression', href); 57 } 58}; 59window.addEventListener('DOMContentLoaded', function(){ 60 PopupRDT.init(); 61 jQuery(window).on("blur", function() { 62 PopupRDT.popup(); 63 }); 64});
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.