woocommerce-paypal-payments/assets/ppcp-uninstall-js-ppcp-clear-db.js

1 line
No EOL
1.1 KiB
JavaScript

(()=>{function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}document.addEventListener("DOMContentLoaded",function(){var t,o=PayPalCommerceGatewayClearDb;if(e(o)){var n=o.clearDb;null===(t=document.querySelector(n.button))||void 0===t||t.addEventListener("click",function(){if(confirm(n.confirmationMessage)){var e=document.querySelector(n.button);e.setAttribute("disabled","disabled"),fetch(n.endpoint,{method:"POST",credentials:"same-origin",body:JSON.stringify({nonce:n.nonce})}).then(function(e){return e.json()}).then(function(t){if(!t.success)throw jQuery(n.failureMessage).insertAfter(e),setTimeout(function(){return jQuery(n.messageSelector).remove()},3e3),e.removeAttribute("disabled"),Error(t.data.message);jQuery(n.successMessage).insertAfter(e),setTimeout(function(){return jQuery(n.messageSelector).remove()},3e3),e.removeAttribute("disabled"),window.location.replace(n.redirectUrl)})}})}})})();