diff --git a/web/_js/infoblock.js b/web/_js/infoblock.js index 3cfe7d5c..3ee3065c 100644 --- a/web/_js/infoblock.js +++ b/web/_js/infoblock.js @@ -31,7 +31,7 @@ function createInfoBlock(entry) { let headerElement = document.createElement("h2"); let linkElement = document.createElement("a"); - linkElement.href = "#id=" + entry.id; + linkElement.href = "#" + entry.id; linkElement.innerText = entry.name; headerElement.appendChild(linkElement); diff --git a/web/_js/main.js b/web/_js/main.js index 199684fd..92acbcc7 100644 --- a/web/_js/main.js +++ b/web/_js/main.js @@ -113,9 +113,9 @@ async function init(){ // Backwards compatibility for old links using "search" id arg if(args.includes("id=")){ - let idHash = "id=" + args.split("id=")[1].split("&")[0]; + let idHash = args.split("id=")[1].split("&")[0]; window.location.hash = idHash; - let idArgMatch = new RegExp(`${idHash}&?`); // Patten for the id plus a following & if present + let idArgMatch = new RegExp(`id=${idHash}&?`); // Patten for the id plus a following & if present window.location.search = window.location.search.substring(1).replace(idArgMatch, ""); } } diff --git a/web/_js/view.js b/web/_js/view.js index 2d626622..54e3b2bb 100644 --- a/web/_js/view.js +++ b/web/_js/view.js @@ -53,7 +53,6 @@ var defaultSort = "shuffle"; document.getElementById("sort").value = defaultSort; var lastPos = [0, 0]; -var idLastHighlight; // track the last id to prevent highlighting from different hash arg updates var fixed = false; // Fix hovered items in place, so that clicking on links is possible @@ -679,20 +678,7 @@ function highlightEntryFromUrl(){ var objectsContainer = document.getElementById("objectsList"); - var id = 0; - - var args = window.location.hash; - if(args){ - id = args.split("id=")[1]; - if(id){ - id = id.split("&")[0]; - } - } - - if(id === idLastHighlight){ - return; - } - idLastHighlight = id; + var id = window.location.hash.substring(1); //Remove hash prefix var entries = atlas.filter(function(e){ return e.id === id; @@ -759,11 +745,8 @@ function initView(){ updateLines(); var args = window.location.hash; - if(args){ - id = args.split("id=")[1]; - if(id){ - highlightEntryFromUrl(); - } + if(args){ // both "/" and just "/#" will be an empty hash string + highlightEntryFromUrl(); } }