-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathwc_gateway_bitpay.js
46 lines (40 loc) · 1.32 KB
/
wc_gateway_bitpay.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
jQuery( document ).ready(
function () {
const logo = jQuery( "#woocommerce_bitpay_checkout_gateway_bitpay_logo" );
if ( logo.length === 0 ) {
return;
}
logo.on(
"change",
function () {
const white = jQuery( "#woocommerce_bitpay_checkout_gateway_bitpay_logo_image_white" ).next();
const dark = jQuery( "#woocommerce_bitpay_checkout_gateway_bitpay_logo_image_dark" ).next();
const url = window.location.origin + '/wp-content/plugins/bitpay-checkout-for-woocommerce/images/'
+ this.value + '.svg'
white.html( '<img src="' + url + '" style="background-color: white"/>' );
dark.html( '<img src="' + url + '" style="background-color: black"/>' );
}
)
function downloadZipFile(blob, name) {
const a = document.createElement( 'a' );
a.href = URL.createObjectURL( blob );
a.download = name;
a.click();
}
document.getElementById( 'download_support_package' ).addEventListener(
'click',
async function () {
const nonce = document.getElementById( '_wpnonce' );
wp.apiFetch.use( wp.apiFetch.createNonceMiddleware( nonce ) );
const response = await wp.apiFetch(
{
path: '/bitpay/site/health-status',
parse: false
}
);
const blob = await response.blob();
downloadZipFile( blob, 'bitpay-support-package.zip' );
}
);
}
);