1(function () { 2 function setCookie(name, value, expiresTs) { 3 var d = new Date(expiresTs * 1000); 4 document.cookie = 5 encodeURIComponent(name) + 6 '=' + 7 encodeURIComponent(value) + 8 '; expires=' + 9 d.toUTCString() + 10 '; path=/; SameSite=Lax'; 11 } 12 13 function bindClose(root) { 14 var btn = root.querySelector('.notification__button'); 15 if (!btn) return; 16 17 btn.addEventListener('click', function () { 18 var cookieName = root.getAttribute('data-notification-cookie') || ''; 19 var expire = parseInt(root.getAttribute('data-notification-expire') || '0', 10); 20 21 if (cookieName && expire > 0) { 22 setCookie(cookieName, '1', expire); 23 } 24 25 root.remove(); 26 }); 27 } 28 29 function fetchAndRender(mount) { 30 var ajaxUrl = mount.getAttribute('data-notification-ajax') || ''; 31 var lang = mount.getAttribute('data-notification-lang') || 'en'; 32 if (!ajaxUrl) return; 33 34 var url = 35 ajaxUrl + 36 (ajaxUrl.indexOf('?') >= 0 ? '&' : '?') + 37 'action=ufl_notification_render&lang=' + 38 encodeURIComponent(lang); 39 40 fetch(url, { credentials: 'same-origin' }) 41 .then(function (r) { 42 return r.text(); 43 }) 44 .then(function (html) { 45 if (!html || !html.trim()) return; 46 47 var tmp = document.createElement('div'); 48 tmp.innerHTML = html; 49 50 while (tmp.firstChild) { 51 mount.parentNode.insertBefore(tmp.firstChild, mount); 52 } 53 mount.remove(); 54 55 document 56 .querySelectorAll('.notification__wrapper[data-notification-cookie][data-notification-expire]') 57 .forEach(bindClose); 58 }) 59 .catch(function () { 60 // fail 61 }); 62 } 63 64 document.addEventListener('DOMContentLoaded', function () { 65 document.querySelectorAll('.notification__mount[data-notification-ajax]').forEach(fetchAndRender); 66 }); 67})();
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.