-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path10.js
More file actions
26 lines (24 loc) · 738 Bytes
/
10.js
File metadata and controls
26 lines (24 loc) · 738 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
function shiftSelect() {
const checkboxes = document.querySelectorAll(
".inbox input[type = 'checkbox"
);
let lastChecked;
let inBetween = false;
function handleCheck(e) {
if (e.shiftKey && this.checked) {
checkboxes.forEach((checkbox) => {
if (checkbox === this || checkbox === lastChecked) {
inBetween = !inBetween;
}
if (inBetween) {
checkbox.checked = true;
}
});
}
lastChecked = this;
}
checkboxes.forEach((checkbox) =>
checkbox.addEventListener("click", handleCheck)
);
}
window.addEventListener("DOMContentLoaded", shiftSelect);