From cf19ea13470c5c84a871f98c4bdf704fbc769931 Mon Sep 17 00:00:00 2001 From: Tom Schneider-Swales Date: Tue, 2 Jul 2024 15:59:40 +0200 Subject: [PATCH] Update index.js --- docs/index.js | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/docs/index.js b/docs/index.js index 739fd23..997fddd 100644 --- a/docs/index.js +++ b/docs/index.js @@ -53,6 +53,17 @@ window.addEventListener("DOMContentLoaded", async () => { } }); +window.addEventListener('beforeunload', function() { + const radios = document.querySelectorAll('input[type="radio"]'); + radios.forEach(radio => { + if (radio.defaultChecked) { + radio.checked = true; + } else { + radio.checked = false; + } + }); +}); + function loadCheckoutWeb() { const searchParams = new URLSearchParams(window.location.search); const head = document.getElementsByTagName("head")[0]; @@ -216,10 +227,27 @@ async function initPayment() { switch (componentName) { case "cards": showCardsPaymentMethod(false); + return new Promise((resolve) => { + const message = document.getElementById("custom-override-message"); + message.innerHTML = `onBeforeError called in Cards`; + message.style = "background-color: #FF4800; display: flex;"; + setTimeout(() => { + message.style = "background-color: orange; display: none;"; + resolve(true); + }, 1500); + }); break; case "afterpay": showAfterpayPaymentMethod(false); - break; + return new Promise((resolve) => { + const message = document.getElementById("custom-override-message"); + message.innerHTML = `onBeforeError called in Afterpay`; + message.style = "background-color: #FF4800; display: flex;"; + setTimeout(() => { + message.style = "background-color: orange; display: none;"; + resolve(true); + }, 1500); + }); default: document.getElementById("payment-methods").style.display = "none"; const message = document.getElementById("custom-override-message"); @@ -384,6 +412,10 @@ async function initPayment() { } } +function showError() { + +} + async function getListResult() { // Calculates payment amount based on payment outcome query parameter const amount = getAmount();