From c6878424bc01d41c02a261890e5762d932b5457b Mon Sep 17 00:00:00 2001 From: unode Date: Thu, 4 Feb 2021 21:59:15 +0000 Subject: [PATCH] Target relative URL except dropdown menus --- assets/js/lesson.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/assets/js/lesson.js b/assets/js/lesson.js index 1d47d875..17ba2d78 100644 --- a/assets/js/lesson.js +++ b/assets/js/lesson.js @@ -82,9 +82,12 @@ $(function() { // and without relying on cookies (avoiding Cookie Law implications) // when a visitor clicks on any the github/gitlab value // is added as a URL parameter - // FIXME Only add the parameter if the URL is local - // i.e. if it lacks a hostname or the hostname matches the current URL - $("a").click(function(e) { + // Note, only consider relative URLs that start with ./ or ../ + let anchors = $("a[href^='./'],a[href^='../']"); + // exclude anchors with dropdown behavior + anchors = anchors.not("[data-toggle='dropdown']") + + anchors.click(function(e) { e.preventDefault(); let ghgl_value = ghgl_selector.filter(":checked").val(); let href = this.href;