Ubuntu

­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­ !function(){const m=[];new PerformanceObserver(e=>{for(const t of e.getEntries())"largest-contentful-paint"===t.entryType&&m.push(t)}).observe({type:"largest-contentful-paint",buffered:!0}),window.addEventListener("load",()=>{const d=document.querySelector(".wd-lcp-loader");if(!d||0===m.length)return;d.classList.add("wd-loading");setTimeout(()=>{d.classList.remove("wd-loading");if(0===m.length)return;let t=null;let o="";let n="";let e="";var r=document.body.className.split(/\s+/);var a=m[m.length-1];const i=a.element;const s=document.querySelector(".wd-lcp-admin-bar");const c=s.querySelector(".wd-loader-overlay");r.forEach(function(e){e=e.match(/(?:page-id|postid)-(\d+)/);e&&(t=parseInt(e[1],10))});if(!t)return;["IMG","PICTURE"].includes(i.tagName)?"high"!==i.getAttribute("fetchpriority")&&(o=i.currentSrc||i.src,n="image"):(a=getComputedStyle(i).backgroundImage)&&a.includes("url")&&(r=a.match(/url\(["']?(.*?)["']?\)/))&&(o=r[1],n="background");o?(e=woodmart_settings.lcp_image_confirmed,i.classList.add("wd-lcp-highlight"),i.scrollIntoView({behavior:"smooth",block:"center"}),a=document.createElement("div"),(r=document.createElement("img")).src=o,a.appendChild(r),a.className="wd-lcp-thumb",s.querySelector(".wd-lcp-content").prepend(a)):e=woodmart_settings.lcp_without_image_confirmed;l(e,!1,o).then(e=>{if(!e)return i.classList.remove("wd-lcp-highlight"),e=window.location.origin+window.location.pathname,window.history.replaceState({},document.title,e),s.classList.remove("wd-opened"),void s.classList.remove("hover");c.classList.add("wd-loading");e=new URLSearchParams(window.location.search);e=e.get("security");jQuery.ajax({url:woodmart_settings.ajaxurl,data:{action:"woodmart_update_lcp_image",image_url:o,image_type:n,post_id:t,security:e,device:768<=woodmartThemeModule.windowWidth?"desktop":"mobile"},dataType:"json",method:"GET",success:function(e){e.hasOwnProperty("data")&&(s.classList.add("wd-saved"),l(e.data.message,!0))},error:function(){console.error("Something wrong with AJAX response.")},complete:function(){var e=window.location.origin+window.location.pathname,e=(window.history.replaceState({},document.title,e),Array.from(s.children).filter(e=>e.classList&&e.classList.contains("ab-item"))[0]);e&&(e.remove(),(e=document.createElement("div")).className="ab-item ab-empty-item",e.setAttribute("role","menuitem"),e.setAttribute("aria-expanded","false"),e.textContent="LCP Image",s.prepend(e)),c.classList.remove("wd-loading"),i.classList.remove("wd-lcp-highlight"),s.querySelector(".wd-done").addEventListener("click",e=>{e.preventDefault();location.reload();s.classList.remove("wd-saved");s.classList.remove("wd-opened");s.classList.remove("hover")})}})})},2500);function l(d="",l=!1,m=!0){return new Promise(t=>{var e=document.querySelector(".wd-lcp-admin-bar");var o=e.querySelector(".wd-lcp-desc");const n=e.querySelector(".wd-confirm");const r=e.querySelector(".wd-cancel");var a=e.querySelector(".wd-done");d&&(o.textContent=d);e.classList.add("wd-opened");!l&&(m||l||woodmart_settings.lcp_has_image)||(n.classList.add("wd-hide"),r.classList.add("wd-hide"),a.classList.remove("wd-hide"));m||l||woodmart_settings.lcp_has_image||a.addEventListener("click",c);function i(){n.removeEventListener("click",s),r.removeEventListener("click",c)}function s(e){e.preventDefault(),i(),t(!0)}function c(e){e.preventDefault(),i(),t(!1)}n.addEventListener("click",s);r.addEventListener("click",c)})}})}();