From 37713a974ca0abff773a36e29fb5a23c22023310 Mon Sep 17 00:00:00 2001 From: Mechiel Lukkien Date: Mon, 6 Feb 2023 15:23:33 +0100 Subject: [PATCH] consistently use finally {} for cleanup in html/js --- http/account.html | 4 ++-- http/admin.html | 35 ++++++++++++++++++----------------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/http/account.html b/http/account.html index 839f528..1048af2 100644 --- a/http/account.html +++ b/http/account.html @@ -161,7 +161,7 @@ const index = async () => { window.alert('Password has been changed.') form.reset() } catch (err) { - console.log('error', err) + console.log({err}) window.alert('Error: ' + err.message) } finally { fieldset.disabled = false @@ -193,7 +193,7 @@ const init = async () => { dom._kids(page, 'page not found') } } catch (err) { - console.log('error', err) + console.log({err}) window.alert('Error: ' + err.message) window.location.hash = curhash curhash = window.location.hash diff --git a/http/admin.html b/http/admin.html index 5fc2b0e..9521752 100644 --- a/http/admin.html +++ b/http/admin.html @@ -216,10 +216,10 @@ const index = async () => { } catch (err) { console.log({err}) window.alert('Error: ' + err.message) - fieldset.disabled = false return + } finally { + fieldset.disabled = false } - fieldset.disabled = false window.location.hash = '#domains/' + domain.value }, fieldset=dom.fieldset( @@ -433,10 +433,10 @@ const accounts = async () => { } catch (err) { console.log({err}) window.alert('Error: ' + err.message) - fieldset.disabled = false return + } finally { + fieldset.disabled = false } - fieldset.disabled = false window.location.hash = '#accounts/'+account.value }, fieldset=dom.fieldset( @@ -515,10 +515,10 @@ const account = async (name) => { } catch (err) { console.log({err}) window.alert('Error: ' + err.message) - e.target.disabled = false return + } finally { + e.target.disabled = false } - e.target.disabled = false window.location.reload() // todo: reload just the list }), ), @@ -545,10 +545,10 @@ const account = async (name) => { } catch (err) { console.log({err}) window.alert('Error: ' + err.message) - fieldset.disabled = false return + } finally { + fieldset.disabled = false } - fieldset.disabled = false form.reset() window.location.reload() // todo: only reload the destinations }, @@ -585,8 +585,9 @@ const account = async (name) => { window.alert('Password has been changed.') formPassword.reset() } catch (err) { - console.log('error', err) + console.log({err}) window.alert('Error: ' + err.message) + return } finally { fieldsetPassword.disabled = false } @@ -605,10 +606,10 @@ const account = async (name) => { } catch (err) { console.log({err}) window.alert('Error: ' + err.message) - e.target.disabled = false return + } finally { + e.target.disabled = false } - e.target.disabled = false window.location.hash = '#accounts' }), ) @@ -689,10 +690,10 @@ const domain = async (d) => { } catch (err) { console.log({err}) window.alert('Error: ' + err.message) - e.target.disabled = false return + } finally { + e.target.disabled = false } - e.target.disabled = false window.location.reload() // todo: only reload the localparts }), ), @@ -712,10 +713,10 @@ const domain = async (d) => { } catch (err) { console.log({err}) window.alert('Error: ' + err.message) - fieldset.disabled = false return + } finally { + fieldset.disabled = false } - fieldset.disabled = false form.reset() window.location.reload() // todo: only reload the addresses }, @@ -755,10 +756,10 @@ const domain = async (d) => { } catch (err) { console.log({err}) window.alert('Error: ' + err.message) - e.target.disabled = false return + } finally { + e.target.disabled = false } - e.target.disabled = false window.location.hash = '#' }), )