diff options
| author | Jan Tuomi <jan@jantuomi.fi> | 2025-02-11 12:12:37 +0200 |
|---|---|---|
| committer | Jan Tuomi <jan@jantuomi.fi> | 2025-02-11 12:13:00 +0200 |
| commit | e8f3a470ce693bef9303d3dd4c46523cdc691826 (patch) | |
| tree | d5d33eb96de070ccfa2b138295b623a8516cf7ad /browser/templates/base.html.j2 | |
| parent | cc07b3fdc4b8860a1ee1b25f09039ba3f13ee509 (diff) | |
Add structure, introduce progressive enhancement
Diffstat (limited to 'browser/templates/base.html.j2')
| -rw-r--r-- | browser/templates/base.html.j2 | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/browser/templates/base.html.j2 b/browser/templates/base.html.j2 index a8a6cf7..8b41a85 100644 --- a/browser/templates/base.html.j2 +++ b/browser/templates/base.html.j2 @@ -9,12 +9,27 @@ <title>Database browser</title> <meta name="description" content="Database browser for log_db"> {% endblock %} - - <!-- -- https://leanrada.com/htmz/ --> - <iframe hidden name=htmz onload="setTimeout(()=>document.querySelector(contentWindow.location.hash||null)?.replaceWith(...contentDocument.body.childNodes))"></iframe> </head> <body> <h1><a href="/">Database browser</a></h1> {% block content %}{% endblock %} + + <!-- https://leanrada.com/htmz/ --> + <iframe hidden name=htmz onload="setTimeout(()=>document.querySelector(contentWindow.location.hash||null)?.replaceWith(...contentDocument.body.childNodes))"></iframe> + <!-- Enable progressive enhancement for htmz --> + <script> + document.querySelectorAll("form[htmz]").forEach(function (element) { + const input = document.createElement("input"); + input.type = "hidden"; + input.name = "htmz"; + input.value = element.attributes.replace.value; + element.appendChild(input); + + const action = new URL(element.action); + action.hash = element.attributes.replace.value; + element.action = action.toString(); + element.target = "htmz"; + }); + </script> </body> </html> |
