diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2025-05-11 21:38:22 -0600 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-08-20 15:57:16 +0200 |
| commit | 1cbb2a40c886603a2e2ccc883179cc2d196280e1 (patch) | |
| tree | 88b4b32748e8d4f931414371f3b93011315d27f3 /html/template.html | |
| parent | ec2741ae85303309253cb790d8d0554cd358d919 (diff) | |
| download | muhqs-game-1cbb2a40c886603a2e2ccc883179cc2d196280e1.tar.gz muhqs-game-1cbb2a40c886603a2e2ccc883179cc2d196280e1.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)$ |
