Skip to content

Commit

Permalink
js: fix @imkiva's reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
ice1000 committed Nov 26, 2023
1 parent 6be83e9 commit 5510313
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions pretty/src/main/resources/aya-html/highlight-fn.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
// Copyright 2023, Andreas Abel.
// Falls under the Agda license at https://github.com/agda/agda/blob/master/LICENSE
/*
* Copyright (c) 2020-2023 Tesla (Yinsen) Zhang.
* Use of this source code is governed by the MIT license that can be found in the LICENSE.md file.
*/

// When we hover over an Agda identifier, we highlight all occurrences of this identifier on the page.
// To this end, we create a map from identifier to all of its occurrences in the beginning.

// A dictionary from hrefs to 'a'-elements that have this href.
const dict = new Map();

function highlightFn() {
function highlightFn(root) {
// Get all 'a' tags with an 'href' attribute.
// We call those "objects".
const objs = document.querySelectorAll('a[href]');
const objs = root.querySelectorAll('a[href]');

// Build a dictionary mapping a href to a set of objects that have this href.
for (const obj of objs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
* Use of this source code is governed by the MIT license that can be found in the LICENSE.md file.
*/

highlightFn();
highlightFn(document);
2 changes: 1 addition & 1 deletion pretty/src/main/resources/aya-html/show-tooltip-fn.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class HoverStack {
newHover.classList.add("AyaTooltipPopup");
// Hover to highlight occurrences is done by adding mouse event listeners to the elements in the tooltip.
// The inserted tooltip is not a child of `document` when the page was loaded, so a manual setup is needed.
setupHighlight(newHover);
highlightFn(newHover);

// Auto-dismissal setup
let self = this;
Expand Down

0 comments on commit 5510313

Please sign in to comment.