aboutsummaryrefslogtreecommitdiff
path: root/html/template.html
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2025-05-11 21:38:22 -0600
committerFlorian Fischer <florian.fischer@muhq.space>2025-08-20 15:57:16 +0200
commit1cbb2a40c886603a2e2ccc883179cc2d196280e1 (patch)
tree88b4b32748e8d4f931414371f3b93011315d27f3 /html/template.html
parentec2741ae85303309253cb790d8d0554cd358d919 (diff)
downloadmuhqs-game-1cbb2a40c886603a2e2ccc883179cc2d196280e1.tar.gz
muhqs-game-1cbb2a40c886603a2e2ccc883179cc2d196280e1.zip
make rules in html linkable
Diffstat (limited to 'html/template.html')
-rw-r--r--html/template.html25
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)$