You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@age.apache.org by ey...@apache.org on 2022/04/20 18:29:03 UTC
[incubator-age-website] branch asf-site updated: Adding url param on load (#37)
This is an automated email from the ASF dual-hosted git repository.
eya pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/incubator-age-website.git
The following commit(s) were added to refs/heads/asf-site by this push:
new 425b8ba Adding url param on load (#37)
425b8ba is described below
commit 425b8ba9668b4dee03a73d72a0a22caa802e4c0f
Author: Nick Sorrell <ni...@cint.io>
AuthorDate: Wed Apr 20 14:28:01 2022 -0400
Adding url param on load (#37)
* Adding url param on load
* Handles updating url in window on click
---
assets/scripts/index.js | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/assets/scripts/index.js b/assets/scripts/index.js
index 1af5b34..5ecf5db 100644
--- a/assets/scripts/index.js
+++ b/assets/scripts/index.js
@@ -1,9 +1,17 @@
var handleClick = function (el) {
decorateSidebar(el);
showMainContent(el);
+ updateLocation(el);
if (menuIsVisible()) handleMenuClick();
}
+var updateLocation = function (el) {
+ let loc = el.parentElement.id.split("-")[1];
+ if (loc) {
+ window.history.pushState(loc, '', `?l=${loc}`);
+ }
+}
+
var decorateSidebar = function (el) {
let items = document.getElementsByClassName("sidebar-item");
for (let i = 0; i < items.length; i++) {
@@ -44,4 +52,13 @@ var handleMenuClick = function (el) {
var handleJiraSearch = function () {
let searchTerms = document.getElementById("jira-search").value;
window.open(`https://issues.apache.org/jira/browse/AGE-1?jql=(project%3DAGE)%20and%20text%20~%20%22${searchTerms}%22`, "_blank");
-}
\ No newline at end of file
+}
+
+window.onload = function() {
+ let url = new URL(location.href);
+ let goto = url.searchParams.get("l");
+ let el = document.getElementById(`sidebar-${goto}`);
+ if (el) {
+ handleClick(el.firstChild);
+ }
+}