From 986a3daed3a51fa5c7bd97e4fe3a75e61040a1fd Mon Sep 17 00:00:00 2001 From: liquidev Date: Tue, 3 Oct 2023 15:13:28 +0200 Subject: [PATCH] expand the linked branch by default --- static/js/tree.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/static/js/tree.js b/static/js/tree.js index 4920761..53ba261 100644 --- a/static/js/tree.js +++ b/static/js/tree.js @@ -192,3 +192,17 @@ async function navigateToCurrentBranch() { // expand the
recursively. window.addEventListener("popstate", navigateToCurrentBranch); addEventListener("DOMContentLoaded", navigateToCurrentBranch); + +// When you enter the website through a link someone sent you, it would be nice if the linked branch +// got expanded by default. +async function expandLinkedBranch() { + let hash = window.location.hash; + if (hash.length > 0) { + let linkedBranch = document.getElementById(hash.substring(1)); + if (linkedBranch.children.length > 0 && linkedBranch.children[0].tagName == "DETAILS") { + expandDetailsRecursively(linkedBranch.children[0]); + } + } +} + +addEventListener("DOMContentLoaded", expandLinkedBranch);