From mboxrd@z Thu Jan 1 00:00:00 1970 From: andy at warmcat.com (Andy Green) Date: Sat, 23 Jun 2018 15:45:06 +0800 Subject: [PATCH v2] cgit.js: line range highlight: always hook hashchange in case hash added In-Reply-To: <152957329993.21285.2517119299142660486.stgit@mail.warmcat.com> References: <152957329993.21285.2517119299142660486.stgit@mail.warmcat.com> Message-ID: <152973990674.1595.16867624676272040380.stgit@mail.warmcat.com> Since the user might add a # to a URL that didn't initially have one, eg by clicking the line numbers, always register the hashchange listener. Signed-off-by: Andy Green --- cgit.js | 4 ---- ui-shared.c | 5 ++++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/cgit.js b/cgit.js index d905634..a3ddf81 100644 --- a/cgit.js +++ b/cgit.js @@ -61,10 +61,6 @@ function cgit_line_range_highlight(depth) e1.style.backgroundColor = "yellow"; } - window.addEventListener("hashchange", function() { - cgit_line_range_highlight(cgit_line_range_depth); - }, false); - hl = (window.innerHeight / (e.offsetHeight + 1)); v = (l1 + ((l2 - l1) / 2)) - (hl / 2); if (v > l1) diff --git a/ui-shared.c b/ui-shared.c index 7fd6bad..3417919 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -1245,9 +1245,12 @@ void cgit_set_title_from_path(const char *path) void cgit_emit_line_range_highlight_script(int parent_level) { htmlf("\n", parent_level); }