File "string-locator-replace.js"
Full Path: /home/refref/public_html/column/wordfence/plugins/string-locator/build/string-locator-replace.js
File size: 2.97 KB
MIME-type: text/plain
Charset: utf-8
(()=>{"use strict";document.addEventListener("DOMContentLoaded",(function(){const e=document.getElementById("string-locator-replace-new-string"),t=document.getElementById("string-locator-replace-loopback-check"),n=document.getElementById("string-locator-toggle-replace-controls"),c=document.getElementById("notice-btn-toggle-replace-controls"),r=document.getElementById("string-locator-replace-form"),o=document.getElementById("string-locator-replace-form"),l=document.getElementById("string-locator-search-results-table"),a=document.getElementById("string-locator-search-notices"),s=document.getElementById("string-locator-progress-wrapper"),i=document.getElementById("string-locator-search-progress"),d=document.getElementById("string-locator-feedback-text"),g=document.getElementById("string-locator-string"),p=document.getElementById("string-locator-regex"),u=document.getElementById("string-locator-replace-button-all"),m=document.getElementById("string-locator-replace-button-selected"),y=wp.template("string-locator-replace-error");let E,f,b=!1,h=!1;function B(n){const c=new FormData,r={...E[n].dataset};if(i.value=n,h||E[n].getElementsByClassName("check-column-box")[0].checked){c.append("_wpnonce",stringLocatorReplace.rest_nonce),c.append("replace_nonce",stringLocatorReplace.replace_nonce),c.append("replace_string",e.value),c.append("search_string",g.value),c.append("search_regex",p.checked),c.append("replace_loopback",t.checked);for(const e in r)c.append(e,r[e]);fetch(stringLocatorReplace.url.replace,{method:"POST",body:c}).then((e=>e.json())).then((function(e){e?.success?(f=E[n].getElementsByTagName("td")[0],!0!==e.data.replace_string&&(f.innerHTML=e.data.replace_string),n<E.length-1?B(n+1):(s.style.display="none",h=!1)):L(e)})).catch((function(e){L(e)}))}else n<E.length-1?B(n+1):(s.style.display="none",h=!1)}function L(e){a.style.display="block",s.style.display="none",h=!1,a.innerHTML+=y(e)}function k(){if(!b)return u.dispatchEvent(new Event("click")),!1;E=l.getElementsByTagName("tbody")[0].getElementsByTagName("tr"),s.style.display="block",d.innerText=stringLocatorReplace.string.replace_started,a.innerHTML="",i.value=0,i.setAttribute("max",E.length),b=!1,B(0)}o.addEventListener("submit",(function(e){return e.preventDefault(),k(),!1})),u.addEventListener("click",(function(){if(!confirm(stringLocatorReplace.string.confirm_all))return!1;h=!0,b=!0,k()})),m.addEventListener("click",(function(){h=!1,b=!0,k()}));let I=[n];null!==c&&(I=[c,n]),I.forEach((e=>{e.addEventListener("click",(function(){if(r.classList.toggle("visible"),r.classList.contains("visible")?(n.setAttribute("aria-expanded","true"),n.innerText=stringLocatorReplace.string.button_hide):(n.setAttribute("aria-expanded","false"),n.innerText=stringLocatorReplace.string.button_show),"notice-btn-toggle-replace-controls"===e.id){const e=document.querySelector(".plugin-card-instawp-connect");if(e){const t=e.querySelector(".string-locator-instawp-button"),n=e.querySelector(".sl-instawp-install-now");t&&t.click(),n&&n.click()}}}))}))}))})();