Skip to content

Commit c3cc33a

Browse files
committed
rough syntax sweel
1 parent 4d520ca commit c3cc33a

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

annotate.js

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function deselectAllExcept(selector) {
2-
var allSelected = document.getElementsByClassName('selected');
3-
for (var i = 0; i < allSelected.length; i++) {
2+
const allSelected = document.querySelectorAll('.selected');
3+
for (let i = 0; i < allSelected.length; i++) {
44
if (
55
allSelected[i].id !== selector &&
66
allSelected[i].getAttribute('aria-details') !== selector
@@ -12,7 +12,7 @@ function deselectAllExcept(selector) {
1212

1313
function makeClickHandler(isHighlight) {
1414
return function onClick(event) {
15-
var targetElement, selector, corresponding;
15+
let targetElement, selector, corresponding;
1616
if (isHighlight) {
1717
selector = event.target.getAttribute('aria-details');
1818
targetElement = event.target;
@@ -22,14 +22,14 @@ function makeClickHandler(isHighlight) {
2222
targetElement = event.target;
2323
} else {
2424
// Depending on where they click, they may have targeted a child element
25-
var annotation = event.target.closest('[role="comment"]');
25+
const annotation = event.target.closest('[role="comment"]');
2626
targetElement = annotation;
2727
selector = annotation.id;
2828
}
2929
}
3030

3131
if (isHighlight) {
32-
corresponding = document.getElementById(selector);
32+
corresponding = document.querySelector(`#${selector}`);
3333
} else {
3434
corresponding = document.querySelector(`[aria-details="${selector}"]`);
3535
}
@@ -39,8 +39,8 @@ function makeClickHandler(isHighlight) {
3939
const isSelected = targetElement.classList.toggle('selected');
4040
corresponding.classList.toggle('selected');
4141
if (isSelected) {
42-
var prefersReducedMotionQuery = window.matchMedia('(prefers-reduced-motion: reduce)');
43-
var prefersReducedMotion = !prefersReducedMotionQuery || prefersReducedMotionQuery.matches;
42+
const prefersReducedMotionQuery = window.matchMedia('(prefers-reduced-motion: reduce)');
43+
const prefersReducedMotion = !prefersReducedMotionQuery || prefersReducedMotionQuery.matches;
4444
corresponding.scrollIntoView({
4545
behavior: prefersReducedMotion ? 'auto' : 'smooth',
4646
block: 'nearest',
@@ -56,24 +56,24 @@ function makeClickHandler(isHighlight) {
5656
}
5757

5858
function deselectAll() {
59-
var selectedComments = document.querySelectorAll('.selected');
60-
for (var i = 0; i < selectedComments.length; i++) {
59+
const selectedComments = document.querySelectorAll('.selected');
60+
for (let i = 0; i < selectedComments.length; i++) {
6161
selectedComments[i].classList.remove('selected');
6262
}
6363
}
6464

6565
function onInitialLoad() {
6666
document.documentElement.className = document.documentElement.className.replace(
67-
/\bno-js\b/,
68-
'js',
67+
`no-js`,
68+
`js`,
6969
);
7070

71-
var highlights = document.getElementsByTagName('mark');
72-
for (var i = 0; i < highlights.length; i++) {
71+
const highlights = document.querySelectorAll('mark');
72+
for (let i = 0; i < highlights.length; i++) {
7373
highlights[i].addEventListener('click', makeClickHandler(true));
7474
}
75-
var comments = document.getElementsByClassName('annotation');
76-
for (var j = 0; j < comments.length; j++) {
75+
const comments = document.querySelectorAll('.annotation');
76+
for (let j = 0; j < comments.length; j++) {
7777
comments[j].addEventListener('click', makeClickHandler(false));
7878
}
7979

0 commit comments

Comments
 (0)