From 7d8f3cf6a9943fb91443491a8cbe1ac0ae309e82 Mon Sep 17 00:00:00 2001 From: cl0ne Date: Sun, 1 Nov 2020 05:39:50 +0200 Subject: [PATCH 1/2] Handle percent-escaped hash in target URL fragment --- pgidocgen/gen/data/index/index.html | 33 ++++++++++++++++------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/pgidocgen/gen/data/index/index.html b/pgidocgen/gen/data/index/index.html index 9d815241..291b0b03 100644 --- a/pgidocgen/gen/data/index/index.html +++ b/pgidocgen/gen/data/index/index.html @@ -12,26 +12,29 @@ function applyHash() { // takes the current hash loads the path into the content frame - var hash = window.location.hash; - var elm = document.getElementById('Content'); - var new_src; - - if(hash) { - // needed for webkit - if(!endsWith(hash, ".html") && !endsWith(hash, "/") && hash.indexOf("#", 1) < 0) - hash += "/"; - - new_src = hash.substring(1); - } else { - new_src= main_page; + var hash = window.location.hash.substring(1); + var contentFrame = document.getElementById("Content"); + var newSrc = main_page; + + if (hash) { + if (hash.indexOf("#") < 0) { + if (hash.indexOf("%23") > 0) { + // unescape first percent-escaped hash + hash = hash.replace("%23", "#"); + } else if (!endsWith(hash, ".html") && !endsWith(hash, "/")) { + hash += "/"; // needed for webkit + } + } + newSrc = hash; } // create a dummy element so we can compare the URLs; prevents // flashing on chrome when the same url is set twice on start var dummy = document.createElement("a"); - dummy.href = new_src; - if(dummy.href != elm.src) - elm.src = new_src; + dummy.href = newSrc; + if(dummy.href != contentFrame.src) { + contentFrame.src = newSrc; + } } From 9ba6c356c424106c87282a87506395b6bc347149 Mon Sep 17 00:00:00 2001 From: cl0ne Date: Thu, 24 Dec 2020 23:59:35 +0200 Subject: [PATCH 2/2] Revert style-related changes --- pgidocgen/gen/data/index/index.html | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/pgidocgen/gen/data/index/index.html b/pgidocgen/gen/data/index/index.html index 291b0b03..8cbf2a46 100644 --- a/pgidocgen/gen/data/index/index.html +++ b/pgidocgen/gen/data/index/index.html @@ -13,28 +13,26 @@ // takes the current hash loads the path into the content frame var hash = window.location.hash.substring(1); - var contentFrame = document.getElementById("Content"); - var newSrc = main_page; + var elm = document.getElementById('Content'); + var new_src = main_page; if (hash) { if (hash.indexOf("#") < 0) { - if (hash.indexOf("%23") > 0) { - // unescape first percent-escaped hash + if (hash.indexOf("%23") > 0) + // unescape only first percent-escaped hash hash = hash.replace("%23", "#"); - } else if (!endsWith(hash, ".html") && !endsWith(hash, "/")) { + else if (!endsWith(hash, ".html") && !endsWith(hash, "/")) hash += "/"; // needed for webkit - } } - newSrc = hash; + new_src = hash; } // create a dummy element so we can compare the URLs; prevents // flashing on chrome when the same url is set twice on start var dummy = document.createElement("a"); - dummy.href = newSrc; - if(dummy.href != contentFrame.src) { - contentFrame.src = newSrc; - } + dummy.href = new_src; + if(dummy.href != elm.src) + elm.src = new_src; }