From: Chris Duncan Date: Sun, 27 Oct 2024 18:55:49 +0000 (-0700) Subject: Rework new/import wallet/account form show/hide. Minor fixes. X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=9fc9fb4729b09afce784b60372b7075266ec15ed;p=nemo-wallet.git Rework new/import wallet/account form show/hide. Minor fixes. --- diff --git a/app/pages/nemo-wallet.html b/app/pages/nemo-wallet.html index 1072802..fccdb39 100644 --- a/app/pages/nemo-wallet.html +++ b/app/pages/nemo-wallet.html @@ -73,6 +73,8 @@ } function switchPage (event) { + const pages = document.getElementsByClassName('page') + Array.from(pages).map(p => p.classList.remove('show')) const oldHash = new URL(event.oldURL)?.hash const newHash = new URL(event.newURL)?.hash if (oldHash) { @@ -91,7 +93,7 @@ _show: (msg, color) => { const container = document.querySelector('#notifications') const notification = document.createElement('dialog') - notification.innerText = msg + notification.innerText = `${msg} ${String.fromCodePoint(0x00D7)}` notification.style.color = color ?? notification.style.color notification.addEventListener('click', (event) => { notification.close() @@ -162,6 +164,7 @@ } case '_new': { try { + document.querySelector(location.hash).classList.remove('show') document.getElementById('wallet-new').classList.add('show') } catch (err) { walletSelect.value = '' @@ -173,6 +176,7 @@ } case '_import': { try { + document.querySelector(location.hash).classList.remove('show') document.getElementById('wallet-import').classList.add('show') } catch (err) { walletSelect.value = '' @@ -301,6 +305,7 @@ switch (accountSelect.value) { case '_new': { try { + document.querySelector(location.hash).classList.remove('show') document.getElementById('account-new').classList.add('show') } catch (err) { accountSelect.value = '' @@ -342,7 +347,7 @@ if (!select) { throw new TypeError(`Select ${id} not found`) } - ([...select.children]) + Array.from(select.children) .filter(o => o.tagName.toLowerCase() === 'option') .filter(o => typeof o.value === 'string') .filter(o => o.value.length > 0) @@ -410,12 +415,13 @@ } async function cancelForm (id) { - await resetDialogInputs() - await document.getElementById(id).classList.remove('show') + await resetFormInputs() + document.getElementById(id).classList.remove('show') + document.querySelector(location.hash).classList.add('show') } - async function resetDialogInputs () { - const fields = document.querySelectorAll('dialog input, dialog select') + async function resetFormInputs () { + const fields = document.querySelectorAll('main form input, main form select') for (const field of fields) { field.value = '' } @@ -447,6 +453,12 @@ }