Skip to content

Commit

Permalink
Target relative URL <a> except dropdown menus
Browse files Browse the repository at this point in the history
  • Loading branch information
unode committed Feb 4, 2021
1 parent fc6e41c commit c687842
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions assets/js/lesson.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,12 @@ $(function() {
// and without relying on cookies (avoiding Cookie Law implications)
// when a visitor clicks on any <a> 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;
Expand Down

0 comments on commit c687842

Please sign in to comment.