wp-plugin-cloudflare-cache/assets/js/backend.min.js

1 line
18 KiB
JavaScript
Raw Normal View History

2024-03-27 15:58:02 -04:00
"use strict";let swcfpc_toolbar_cache_status_tries=0,swcfpc_toolbar_cache_status_interval=null;function swcfpc_handle_conditional_settings(e){parseInt(e.value)>0?(document.querySelectorAll(`.${e.dataset.mainoption}`).length>0&&document.querySelectorAll(`.${e.dataset.mainoption}`).forEach((e=>{e.classList.contains("swcfpc_hide")&&e.classList.remove("swcfpc_hide")})),document.querySelectorAll(`.${e.dataset.mainoption}_not`).length>0&&document.querySelectorAll(`.${e.dataset.mainoption}_not`).forEach((e=>{e.classList.add("swcfpc_hide")}))):(document.querySelectorAll(`.${e.dataset.mainoption}`).length>0&&document.querySelectorAll(`.${e.dataset.mainoption}`).forEach((e=>{e.classList.add("swcfpc_hide")})),document.querySelectorAll(`.${e.dataset.mainoption}_not`).length>0&&document.querySelectorAll(`.${e.dataset.mainoption}_not`).forEach((e=>{e.classList.contains("swcfpc_hide")&&e.classList.remove("swcfpc_hide")})))}function swcfpc_lock_screen(){if(!document.querySelector(".swcfpc_please_wait")){const e=document.querySelectorAll("input[type=submit]"),c=document.querySelectorAll("input[type=submit]"),t=document.querySelectorAll("a");e.forEach((e=>{e.classList.add("swcfpc_hide")})),c.forEach((e=>{e.classList.add("swcfpc_hide")})),t.forEach((e=>{e.classList.add("swcfpc_hide")}));const s=document.createElement("div");s.classList.add("swcfpc_please_wait"),document.body.prepend(s)}}function swcfpc_unlock_screen(){const e=document.querySelectorAll("input[type=submit]"),c=document.querySelectorAll("input[type=submit]"),t=document.querySelectorAll("a");e.forEach((e=>{e.classList.remove("swcfpc_hide")})),c.forEach((e=>{e.classList.remove("swcfpc_hide")})),t.forEach((e=>{e.classList.remove("swcfpc_hide")})),document.querySelector(".swcfpc_please_wait").remove()}function swcfpc_redirect_to_page(e){window.location=e}function swcfpc_refresh_page(){window.location.reload()}function swcfpc_display_ok_dialog(e,c,t,s,n,a,o,r,l){t=void 0===t||null==t?350:parseInt(t),s=void 0===s||null==s?300:parseInt(s),a=void 0===a?null:a,o=void 0===o?"Close":o,l=void 0===l?null:l;let _="success";"warning"===(n=void 0===n?null:n)?_="warning":"error"===n?_="error":"info"===n?_="info":"question"===n&&(_="question"),null==(r=void 0===r?null:r)?Swal.fire({title:null!==a?a:"",html:c,icon:_,confirmButtonText:o}):Swal.fire({title:null!==a?a:"",html:c,icon:_,confirmButtonText:o,willClose:()=>{null!=l?r(l):r()}}).then((e=>{e.isConfirmed&&(null!=l?r(l):r())}))}async function swcfpc_purge_varnish_cache(){try{const e=document.getElementById("swcfpc-ajax-nonce").innerText;swcfpc_lock_screen();const c=await fetch(swcfpc_ajax_url,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},body:`action=swcfpc_purge_varnish_cache&security=${e}`,credentials:"same-origin",timeout:1e4});if(c.ok){const e=await c.json();swcfpc_unlock_screen(),"ok"===e.status?swcfpc_display_ok_dialog("Success",`${e.success_msg}`,null,null,"success"):swcfpc_display_ok_dialog("Error",`${e.error}`,null,null,"error")}else swcfpc_unlock_screen()}catch(e){alert(`Error: ${e.status} ${e.message}`),swcfpc_unlock_screen()}}async function swcfpc_purge_fallback_page_cache(){try{const e=document.getElementById("swcfpc-ajax-nonce").innerText;swcfpc_lock_screen();const c=await fetch(swcfpc_ajax_url,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},body:`action=swcfpc_purge_fallback_page_cache&security=${e}`,credentials:"same-origin",timeout:1e4});if(c.ok){const e=await c.json();swcfpc_unlock_screen(),"ok"===e.status?swcfpc_display_ok_dialog("Success",`${e.success_msg}`,null,null,"success"):swcfpc_display_ok_dialog("Error",`${e.error}`,null,null,"error")}else swcfpc_unlock_screen()}catch(e){alert(`Error: ${e.status} ${e.message}`),swcfpc_unlock_screen()}}async function swcfpc_force_purge_everything(){try{const e=document.getElementById("swcfpc-ajax-nonce").innerText;swcfpc_lock_screen();const c=await fetch(swcfpc_ajax_url,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},body:`action=swcfpc_purge_everythin