diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2025-05-11 21:38:22 -0600 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-05-18 20:35:04 -0600 |
| commit | 4d2093c8f449d85fed4df9761ce808e030534a07 (patch) | |
| tree | 50f6e09d690f8bc352b5a09b3ad7f7db58ef903a /html/template.html | |
| parent | 37acd982268df214ae13646d9174ef2490ac16f4 (diff) | |
| download | muhqs-game-4d2093c8f449d85fed4df9761ce808e030534a07.tar.gz muhqs-game-4d2093c8f449d85fed4df9761ce808e030534a07.zip | |
make rules in html linkable
Diffstat (limited to 'html/template.html')
| -rw-r--r-- | html/template.html | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/html/template.html b/html/template.html index bae64042..6d58af7d 100644 --- a/html/template.html +++ b/html/template.html @@ -250,6 +250,11 @@ $if(toc)$ padding-left: 10px; } $endif$ + +li.linkable-rule:active, li.linkable-rule:hover { + background-color: #d79921; + list-style-image: url(link.svg); +} </style> $for(css)$ @@ -265,6 +270,26 @@ $endif$ $for(header-includes)$ $header-includes$ $endfor$ +<script> +window.onload = function() { + for (let e of document.querySelectorAll(".rule")) { + // Add class via js to ensure there is no wrong + // sense of functionality in browsers without js + e.classList.add("linkable-rule"); + // TODO: support nested lists + e.onclick = function() { + if (e.matches(':hover') || e.matches(':active')) { + const origin = window.location.origin; + const path = window.location.pathname; + const anchor = e.id; + let url = origin + '/' + path + '#' + anchor; + navigator.clipboard.writeText(url); + // document.getElementsByTagName("body")[0].focus(); + } + } + } +} +</script> </head> <body> $for(include-before)$ |
