diff --git a/webaccount/account.js b/webaccount/account.js index 2975e0d..f6b2b4a 100644 --- a/webaccount/account.js +++ b/webaccount/account.js @@ -762,29 +762,39 @@ const localStorageRemove = (k) => { }; const client = new api.Client().withOptions({ csrfHeader: 'x-mox-csrf', login: login }).withAuthToken(localStorageGet('webaccountcsrftoken') || ''); const link = (href, anchorOpt) => dom.a(attr.href(href), attr.rel('noopener noreferrer'), anchorOpt || href); -const crumblink = (text, link) => dom.a(text, attr.href(link)); -const crumbs = (...l) => [ - dom.div(style({ float: 'right' }), localStorageGet('webaccountaddress') || '(unknown)', ' ', dom.clickbutton('Logout', attr.title('Logout, invalidating this session.'), async function click(e) { - const b = e.target; - try { - b.disabled = true; - await client.Logout(); - } - catch (err) { - console.log('logout', err); - window.alert('Error: ' + errmsg(err)); - } - finally { - b.disabled = false; - } - localStorageRemove('webaccountaddress'); - localStorageRemove('webaccountcsrftoken'); - // Reload so all state is cleared from memory. - window.location.reload(); - })), - dom.h1(l.map((e, index) => index === 0 ? e : [' / ', e])), - dom.br() -]; +const crumblink = (text, path) => { + return { + text: text, + path: path + }; +}; +const crumbs = (...l) => { + const crumbtext = (e) => typeof e === 'string' ? e : e.text; + document.title = l.map(e => crumbtext(e)).join(' - '); + const crumblink = (e) => typeof e === 'string' ? e : dom.a(e.text, attr.href(e.path)); + return [ + dom.div(style({ float: 'right' }), localStorageGet('webaccountaddress') || '(unknown)', ' ', dom.clickbutton('Logout', attr.title('Logout, invalidating this session.'), async function click(e) { + const b = e.target; + try { + b.disabled = true; + await client.Logout(); + } + catch (err) { + console.log('logout', err); + window.alert('Error: ' + errmsg(err)); + } + finally { + b.disabled = false; + } + localStorageRemove('webaccountaddress'); + localStorageRemove('webaccountcsrftoken'); + // Reload so all state is cleared from memory. + window.location.reload(); + })), + dom.h1(l.map((e, index) => index === 0 ? crumblink(e) : [' / ', crumblink(e)])), + dom.br() + ]; +}; const errmsg = (err) => '' + (err.message || '(no error message)'); const footer = dom.div(style({ marginTop: '6ex', opacity: 0.75 }), link('https://www.xmox.nl', 'mox'), ' ', moxversion); const domainName = (d) => { diff --git a/webaccount/account.ts b/webaccount/account.ts index c1b0fa3..298bd1a 100644 --- a/webaccount/account.ts +++ b/webaccount/account.ts @@ -103,33 +103,45 @@ const client = new api.Client().withOptions({csrfHeader: 'x-mox-csrf', login: lo const link = (href: string, anchorOpt: string) => dom.a(attr.href(href), attr.rel('noopener noreferrer'), anchorOpt || href) -const crumblink = (text: string, link: string) => dom.a(text, attr.href(link)) -const crumbs = (...l: ElemArg[]) => [ - dom.div( - style({float: 'right'}), - localStorageGet('webaccountaddress') || '(unknown)', - ' ', - dom.clickbutton('Logout', attr.title('Logout, invalidating this session.'), async function click(e: MouseEvent) { - const b = e.target! as HTMLButtonElement - try { - b.disabled = true - await client.Logout() - } catch (err) { - console.log('logout', err) - window.alert('Error: ' + errmsg(err)) - } finally { - b.disabled = false - } +const crumblink = (text: string, path: string) => { + return { + text: text, + path: path + } +} +const crumbs = (...l: ({text: string, path: string} | string)[]) => { + const crumbtext = (e: {text: string, path: string} | string) => typeof e === 'string' ? e : e.text + document.title = l.map(e => crumbtext(e)).join(' - ') - localStorageRemove('webaccountaddress') - localStorageRemove('webaccountcsrftoken') - // Reload so all state is cleared from memory. - window.location.reload() - }), - ), - dom.h1(l.map((e, index) => index === 0 ? e : [' / ', e])), - dom.br() -] + const crumblink = (e: {text: string, path: string} | string) => + typeof e === 'string' ? e : dom.a(e.text, attr.href(e.path)) + return [ + dom.div( + style({float: 'right'}), + localStorageGet('webaccountaddress') || '(unknown)', + ' ', + dom.clickbutton('Logout', attr.title('Logout, invalidating this session.'), async function click(e: MouseEvent) { + const b = e.target! as HTMLButtonElement + try { + b.disabled = true + await client.Logout() + } catch (err) { + console.log('logout', err) + window.alert('Error: ' + errmsg(err)) + } finally { + b.disabled = false + } + + localStorageRemove('webaccountaddress') + localStorageRemove('webaccountcsrftoken') + // Reload so all state is cleared from memory. + window.location.reload() + }), + ), + dom.h1(l.map((e, index) => index === 0 ? crumblink(e) : [' / ', crumblink(e)])), + dom.br() + ] +} const errmsg = (err: unknown) => ''+((err as any).message || '(no error message)') diff --git a/webadmin/admin.js b/webadmin/admin.js index e26ff92..d45e36e 100644 --- a/webadmin/admin.js +++ b/webadmin/admin.js @@ -1456,28 +1456,38 @@ const yellow = '#ffe400'; const red = '#ff7443'; const blue = '#8bc8ff'; const link = (href, anchorOpt) => dom.a(attr.href(href), attr.rel('noopener noreferrer'), anchorOpt || href); -const crumblink = (text, link) => dom.a(text, attr.href(link)); -const crumbs = (...l) => [ - dom.div(style({ float: 'right' }), dom.clickbutton('Logout', attr.title('Logout, invalidating this session.'), async function click(e) { - const b = e.target; - try { - b.disabled = true; - await client.Logout(); - } - catch (err) { - console.log('logout', err); - window.alert('Error: ' + errmsg(err)); - } - finally { - b.disabled = false; - } - localStorageRemove('webadmincsrftoken'); - // Reload so all state is cleared from memory. - window.location.reload(); - })), - dom.h1(l.map((e, index) => index === 0 ? e : [' / ', e])), - dom.br() -]; +const crumblink = (text, path) => { + return { + text: text, + path: path + }; +}; +const crumbs = (...l) => { + const crumbtext = (e) => typeof e === 'string' ? e : e.text; + document.title = l.map(e => crumbtext(e)).join(' - '); + const crumblink = (e) => typeof e === 'string' ? e : dom.a(e.text, attr.href(e.path)); + return [ + dom.div(style({ float: 'right' }), dom.clickbutton('Logout', attr.title('Logout, invalidating this session.'), async function click(e) { + const b = e.target; + try { + b.disabled = true; + await client.Logout(); + } + catch (err) { + console.log('logout', err); + window.alert('Error: ' + errmsg(err)); + } + finally { + b.disabled = false; + } + localStorageRemove('webadmincsrftoken'); + // Reload so all state is cleared from memory. + window.location.reload(); + })), + dom.h1(l.map((e, index) => index === 0 ? crumblink(e) : [' / ', crumblink(e)])), + dom.br() + ]; +}; const errmsg = (err) => '' + (err.message || '(no error message)'); const footer = dom.div(style({ marginTop: '6ex', opacity: 0.75 }), link('https://www.xmox.nl', 'mox'), ' ', moxversion, ' ', moxgoversion, ' ', moxgoos, '/', moxgoarch); const age = (date, future, nowSecs) => { diff --git a/webadmin/admin.ts b/webadmin/admin.ts index f77c0a9..01e4451 100644 --- a/webadmin/admin.ts +++ b/webadmin/admin.ts @@ -92,30 +92,42 @@ const blue = '#8bc8ff' const link = (href: string, anchorOpt?: string) => dom.a(attr.href(href), attr.rel('noopener noreferrer'), anchorOpt || href) -const crumblink = (text: string, link: string) => dom.a(text, attr.href(link)) -const crumbs = (...l: ElemArg[]) => [ - dom.div( - style({float: 'right'}), - dom.clickbutton('Logout', attr.title('Logout, invalidating this session.'), async function click(e: MouseEvent) { - const b = e.target! as HTMLButtonElement - try { - b.disabled = true - await client.Logout() - } catch (err) { - console.log('logout', err) - window.alert('Error: ' + errmsg(err)) - } finally { - b.disabled = false - } +const crumblink = (text: string, path: string) => { + return { + text: text, + path: path + } +} +const crumbs = (...l: ({text: string, path: string} | string)[]) => { + const crumbtext = (e: {text: string, path: string} | string) => typeof e === 'string' ? e : e.text + document.title = l.map(e => crumbtext(e)).join(' - ') - localStorageRemove('webadmincsrftoken') - // Reload so all state is cleared from memory. - window.location.reload() - }), - ), - dom.h1(l.map((e, index) => index === 0 ? e : [' / ', e])), - dom.br() -] + const crumblink = (e: {text: string, path: string} | string) => + typeof e === 'string' ? e : dom.a(e.text, attr.href(e.path)) + return [ + dom.div( + style({float: 'right'}), + dom.clickbutton('Logout', attr.title('Logout, invalidating this session.'), async function click(e: MouseEvent) { + const b = e.target! as HTMLButtonElement + try { + b.disabled = true + await client.Logout() + } catch (err) { + console.log('logout', err) + window.alert('Error: ' + errmsg(err)) + } finally { + b.disabled = false + } + + localStorageRemove('webadmincsrftoken') + // Reload so all state is cleared from memory. + window.location.reload() + }), + ), + dom.h1(l.map((e, index) => index === 0 ? crumblink(e) : [' / ', crumblink(e)])), + dom.br() + ] +} const errmsg = (err: unknown) => ''+((err as any).message || '(no error message)')