render sandbox and live connect button and toggle between those depending on sandbox checkbox

This commit is contained in:
David Remer 2020-09-24 09:58:28 +03:00
parent b70819847b
commit 6f870ec7a5
3 changed files with 137 additions and 43 deletions

View file

@ -25,3 +25,31 @@ function onboardingCallback(authCode, sharedId) {
}
);
}
const sandboxSwitch = (element) => {
const toggleConnectButtons = (showProduction) => {
if (showProduction) {
document.querySelector('#connect-to-production').style.display = '';
document.querySelector('#connect-to-sandbox').style.display = 'none';
return;
}
document.querySelector('#connect-to-production').style.display = 'none';
document.querySelector('#connect-to-sandbox').style.display = '';
}
toggleConnectButtons(! element.checked);
element.addEventListener(
'change',
(event) => {
toggleConnectButtons(! element.checked);
}
);
};
(() => {
const sandboxSwitchElement = document.querySelector('#ppcp-sandbox_on');
if (sandboxSwitchElement) {
sandboxSwitch(sandboxSwitchElement);
}
})();