Skip to content

Commit

Permalink
fixed table navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
domonik committed Nov 30, 2023
1 parent 2497089 commit 792cde6
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions assets/js/smithwaterman.js
Original file line number Diff line number Diff line change
Expand Up @@ -536,5 +536,38 @@ function buildAlignmentCorrect(seq1, seq2, alignmentPath) {
return [alignSeq1, alignSeq2];
}

document.addEventListener('DOMContentLoaded', function () {
const table = document.getElementById('tableD');

table.addEventListener('keydown', function (event) {
const currentCell = event.target.parentElement;
const currentRow = currentCell.parentElement;
const currentRowIndex = currentRow.rowIndex;
const currentCellIndex = currentCell.cellIndex;

let nextCell;

switch (event.key) {
case 'ArrowUp':
nextCell = table.rows[currentRowIndex - 1]?.cells[currentCellIndex];
break;
case 'ArrowDown':
nextCell = table.rows[currentRowIndex + 1]?.cells[currentCellIndex];
break;
case 'ArrowLeft':
nextCell = currentCellIndex > 0 ? currentRow.cells[currentCellIndex - 1] : null;
break;
case 'ArrowRight':
nextCell = currentRow.cells[currentCellIndex + 1];
break;
default:
break;
}

if (nextCell && nextCell.querySelector('input')) {
nextCell.querySelector('input').focus();
event.preventDefault();
}
});
});

0 comments on commit 792cde6

Please sign in to comment.