1const NewsletterPopup = { 2// GDPR: used only for technical cookies 3 set_cookie: function (name, value, time) { 4 var e = new Date(); 5 e.setTime(e.getTime() + time * 24 * 60 * 60 * 1000); 6 document.cookie = name + "=" + value + "; expires=" + e.toGMTString() + "; path=/"; 7 }, 8 get_cookie: function (name, def) { 9 var cs = document.cookie.toString().split('; '); 10 var c; 11 for (var i = 0; i < cs.length; i++) { 12 c = cs[i].split("="); 13 if (c[0] === name) 14 return c[1]; 15 } 16 return def; 17 }, 18 open: function () { 19 fetch(newsletter_popup_data.url).then(data => { 20 data.text().then(body => { 21 var modal_body = document.getElementById('tnp-modal-body'); 22 modal_body.innerHTML = body; 23 var modal = document.getElementById('tnp-modal'); 24 modal.style.display = 'block'; 25 var form = document.getElementById('tnp-subscription-popup'); 26 //form.addEventListener("submit", NewsletterPopup.submit); // Do not use can be overwritten by other plugins 27 form.onsubmit = NewsletterPopup.submit; 28 }); 29 }).catch(error => { 30 console.error(error); 31 }); 32 }, 33 submit: async function (event) { 34 event.preventDefault(); 35 var form = document.getElementById('tnp-subscription-popup'); 36 const data = new FormData(form); 37 const response = await fetch(newsletter_popup_data.action, { 38 method: "POST", 39 body: data 40 }); 41 const text = await response.text(); 42 var modal_body = document.getElementById('tnp-modal-body'); 43 modal_body.innerHTML = text; 44 }, 45 close: function () { 46 var modal = document.getElementById('tnp-modal'); 47 modal.style.display = 'none'; 48 NewsletterPopup.set_cookie("tnp-popup-closed", 1, 60); 49 }, 50 outside_click: function (e) { 51// var modal = document.getElementById('tnp-modal'); 52// if (e.target == modal) { 53// modal.style.display = 'none'; 54// } 55 }, 56 57 run: function () { 58 let el = document.getElementById('tnp-modal-close'); 59 if (!el) { 60 return; 61 } 62 document.getElementById('tnp-modal-close').addEventListener('click', this.close); 63 64 if (newsletter_popup_data.test === '1') { 65 this.open(); 66 } else { 67 if (this.get_cookie('tnp-popup-closed', null) === null) { 68 var count = parseInt(this.get_cookie('tnp-popup-count', 0)) + 1; 69 this.set_cookie('tnp-popup-count', count, 30); 70 if (count >= 2) { 71 setTimeout(this.open, 5 * 1000); 72 } 73 } 74 } 75 } 76 77} 78 79if (document.readyState !== 'loading') { 80 NewsletterPopup.run(); 81} else { 82 document.addEventListener("DOMContentLoaded", function () { 83 NewsletterPopup.run(); 84 }); 85}
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.