1(function () { 2 var toast = document.getElementById('sc-favorite-toast'); 3 if (!toast) return; 4 5 var timer; 6 var hideTimer; 7 var message = toast.querySelector('[data-toast-message]'); 8 var link = toast.querySelector('[data-toast-link]'); 9 var suffix = toast.querySelector('[data-toast-suffix]'); 10 11 function dismiss() { 12 toast.classList.remove('is-visible'); 13 hideTimer = setTimeout(function () { toast.hidden = true; }, 200); 14 } 15 16 function show(text, label, ending, url) { 17 clearTimeout(timer); 18 clearTimeout(hideTimer); 19 message.textContent = text; 20 link.textContent = label; 21 suffix.textContent = ending; 22 link.href = url; 23 toast.hidden = false; 24 void toast.offsetWidth; 25 toast.classList.add('is-visible'); 26 timer = setTimeout(dismiss, 2000); 27 } 28 29 document.addEventListener('click', function (event) { 30 var button = event.target.closest('[data-sc-favorite-login]'); 31 if (!button) return; 32 event.preventDefault(); 33 show('Please ', 'log in', ' to add favorites.', button.dataset.loginUrl || toast.dataset.loginUrl); 34 }); 35 36 var previousCallback = window.wpfp_after_ajax; 37 window.wpfp_after_ajax = function (button) { 38 var action = new URL(button.attr('href'), window.location.href).searchParams.get('wpfpaction'); 39 if (action === 'add') { 40 show('Added to ', 'Favorites', '', toast.dataset.favoritesUrl); 41 } 42 if (typeof previousCallback === 'function') previousCallback(button); 43 }; 44}());
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.