Skip to content

Commit 90e3293

Browse files
romain145qu1ck
authored andcommitted
Add shortcut 'n' to tick "Placed" checkbox and highlight next row
1 parent 3be7469 commit 90e3293

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

InteractiveHtmlBom/ibom.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ function populateBomHeader() {
186186
var td = document.createElement("TH");
187187
td.classList.add("numCol");
188188
tr.appendChild(td);
189-
checkboxes = bomCheckboxes.split(",");
189+
checkboxes = bomCheckboxes.split(",").filter((e) => e);
190190
for (var checkbox of checkboxes) {
191191
if (checkbox) {
192192
td = document.createElement("TH");
@@ -522,6 +522,23 @@ function toggleBomCheckbox(bomrowid, checkboxnum) {
522522
checkbox.onchange();
523523
}
524524

525+
function checkBomCheckbox(bomrowid, checkboxname) {
526+
var checkboxnum = 0;
527+
while (checkboxnum < checkboxes.length &&
528+
checkboxes[checkboxnum].toLowerCase() != checkboxname.toLowerCase()) {
529+
checkboxnum++;
530+
}
531+
if (!bomrowid || checkboxnum > checkboxes.length) {
532+
return;
533+
}
534+
var bomrow = document.getElementById(bomrowid);
535+
var checkbox = bomrow.childNodes[checkboxnum + 1].childNodes[0];
536+
checkbox.checked = true;
537+
checkbox.indeterminate = false;
538+
checkbox.onchange();
539+
}
540+
541+
525542
function removeGutterNode(node) {
526543
for (var i = 0; i < node.childNodes.length; i++) {
527544
if (node.childNodes[i].classList &&
@@ -545,6 +562,13 @@ function setBomCheckboxes(value) {
545562

546563
document.onkeydown = function(e) {
547564
switch (e.key) {
565+
case "n":
566+
if (currentHighlightedRowId !== null) {
567+
checkBomCheckbox(currentHighlightedRowId, "placed");
568+
highlightNextRow();
569+
e.preventDefault();
570+
}
571+
break;
548572
case "ArrowUp":
549573
highlightPreviousRow();
550574
e.preventDefault();

0 commit comments

Comments
 (0)