mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-07 19:54:15 +08:00
Run eslint autofix
This commit is contained in:
parent
36a13f6500
commit
11105d913b
141 changed files with 14160 additions and 11825 deletions
|
@ -1,43 +1,57 @@
|
|||
document.addEventListener(
|
||||
'DOMContentLoaded',
|
||||
() => {
|
||||
const config = PayPalCommerceGatewayClearDb;
|
||||
if (!typeof (config)) {
|
||||
return;
|
||||
}
|
||||
document.addEventListener( 'DOMContentLoaded', () => {
|
||||
const config = PayPalCommerceGatewayClearDb;
|
||||
if ( ! typeof config ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const clearDbConfig = config.clearDb;
|
||||
const clearDbConfig = config.clearDb;
|
||||
|
||||
document.querySelector(clearDbConfig.button)?.addEventListener('click', function () {
|
||||
const isConfirmed = confirm(clearDbConfig.confirmationMessage);
|
||||
if (!isConfirmed) {
|
||||
return;
|
||||
}
|
||||
document
|
||||
.querySelector( clearDbConfig.button )
|
||||
?.addEventListener( 'click', function () {
|
||||
const isConfirmed = confirm( clearDbConfig.confirmationMessage );
|
||||
if ( ! isConfirmed ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const clearButton = document.querySelector(clearDbConfig.button);
|
||||
const clearButton = document.querySelector( clearDbConfig.button );
|
||||
|
||||
clearButton.setAttribute('disabled', 'disabled');
|
||||
fetch(clearDbConfig.endpoint, {
|
||||
method: 'POST',
|
||||
credentials: 'same-origin',
|
||||
body: JSON.stringify({
|
||||
nonce: clearDbConfig.nonce,
|
||||
})
|
||||
}).then((res)=>{
|
||||
return res.json();
|
||||
}).then((data)=>{
|
||||
if (!data.success) {
|
||||
jQuery(clearDbConfig.failureMessage).insertAfter(clearButton);
|
||||
setTimeout(()=> jQuery(clearDbConfig.messageSelector).remove(),3000);
|
||||
clearButton.removeAttribute('disabled');
|
||||
throw Error(data.data.message);
|
||||
}
|
||||
clearButton.setAttribute( 'disabled', 'disabled' );
|
||||
fetch( clearDbConfig.endpoint, {
|
||||
method: 'POST',
|
||||
credentials: 'same-origin',
|
||||
body: JSON.stringify( {
|
||||
nonce: clearDbConfig.nonce,
|
||||
} ),
|
||||
} )
|
||||
.then( ( res ) => {
|
||||
return res.json();
|
||||
} )
|
||||
.then( ( data ) => {
|
||||
if ( ! data.success ) {
|
||||
jQuery( clearDbConfig.failureMessage ).insertAfter(
|
||||
clearButton
|
||||
);
|
||||
setTimeout(
|
||||
() =>
|
||||
jQuery(
|
||||
clearDbConfig.messageSelector
|
||||
).remove(),
|
||||
3000
|
||||
);
|
||||
clearButton.removeAttribute( 'disabled' );
|
||||
throw Error( data.data.message );
|
||||
}
|
||||
|
||||
jQuery(clearDbConfig.successMessage).insertAfter(clearButton);
|
||||
setTimeout(()=> jQuery(clearDbConfig.messageSelector).remove(),3000);
|
||||
clearButton.removeAttribute('disabled');
|
||||
window.location.replace(clearDbConfig.redirectUrl);
|
||||
});
|
||||
})
|
||||
},
|
||||
);
|
||||
jQuery( clearDbConfig.successMessage ).insertAfter(
|
||||
clearButton
|
||||
);
|
||||
setTimeout(
|
||||
() => jQuery( clearDbConfig.messageSelector ).remove(),
|
||||
3000
|
||||
);
|
||||
clearButton.removeAttribute( 'disabled' );
|
||||
window.location.replace( clearDbConfig.redirectUrl );
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue