diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-06-12 00:13:02 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-06-12 00:13:02 +0200 |
commit | da8d1467dff8b27af7a3ae649d92ead5cbf704d8 (patch) | |
tree | cd4231abb8ec24d79dd3a4a8b5e563ee2bb82219 /static/user | |
parent | Add number of TODO's. (diff) | |
parent | Handle error for user-additions salar. (diff) | |
download | calp-da8d1467dff8b27af7a3ae649d92ead5cbf704d8.tar.gz calp-da8d1467dff8b27af7a3ae649d92ead5cbf704d8.tar.xz |
Allow HTML output of all routes.
XHTML is still the far supperior format. However; Chrome(-like) browsers
Lighthouse feature is worth quite a bit when it comes to ensuring a good
web page, and Lighthouse refuses to work on anything except text/html.
This is my work-around for that.
Diffstat (limited to 'static/user')
-rw-r--r-- | static/user/user-additions.js | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/static/user/user-additions.js b/static/user/user-additions.js index 0de825e8..c0579df5 100644 --- a/static/user/user-additions.js +++ b/static/user/user-additions.js @@ -34,8 +34,10 @@ window.formatters.set('description', (el, d) => { window.salar = new Promise((resolve, reject) => fetch('/static/user/salar.json') - .then(d => d.json()) - .then(d => resolve(d))) + .then(resp => { if (! resp.ok) reject("404"); else resp.json() }) + .then(d => resolve(d)) + .catch(err => reject(err)) +) window.formatters.set('location', async function(el, d) { @@ -46,7 +48,12 @@ window.formatters.set('location', async function(el, d) { return; } - let salar = await window.salar; + try { + let salar = await window.salar; + } catch (e) { + console.warn("Location formatter failed", e); + return; + } let name = m[1] let frag = salar[name]; |