moved inline javascript to it's own file

This commit is contained in:
Johannes Erwerle 2026-10-21 21:54:29 +02:00
parent 5813d200dc
commit 26f3d5d033
2 changed files with 26 additions and 24 deletions

View file

@ -0,0 +1,24 @@
//
// Activation script for the bulma burger menu.
// Copied from https://bulma.io/documentation/components/navbar/
//
document.addEventListener('DOMContentLoaded', () => {
// Get all "navbar-burger" elements
const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
// Add a click event on each of them
$navbarBurgers.forEach( el => {
el.addEventListener('click', () => {
// Get the target from the "data-target" attribute
const target = el.dataset.target;
const $target = document.getElementById(target);
// Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
el.classList.toggle('is-active');
$target.classList.toggle('is-active');
});
});
});

View file

@ -8,29 +8,7 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>Community Backup</title> <title>Community Backup</title>
<script type="text/javascript"> <script type="text/javascript" src={% static 'webui/js/webui.js' %}></script>
document.addEventListener('DOMContentLoaded', () => {
// Get all "navbar-burger" elements
const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
// Add a click event on each of them
$navbarBurgers.forEach( el => {
el.addEventListener('click', () => {
// Get the target from the "data-target" attribute
const target = el.dataset.target;
const $target = document.getElementById(target);
// Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
el.classList.toggle('is-active');
$target.classList.toggle('is-active');
});
});
});
</script>
</head> </head>
<body> <body>
<nav class="navbar" role="navigation" aria-label="main navigation" > <nav class="navbar" role="navigation" aria-label="main navigation" >