@@ -159,7 +159,7 @@ function highlightFilter(s) {
159159 }
160160 var r = "" ;
161161 var pos = 0 ;
162- for ( i in parts ) {
162+ for ( var i in parts ) {
163163 if ( i > 0 ) {
164164 r += '<mark class="highlight">' +
165165 s . substring ( pos , pos + filter . length ) +
@@ -219,7 +219,7 @@ function populateBomBody() {
219219 bomtable = pcbdata . bom . B ;
220220 break ;
221221 }
222- for ( i in bomtable ) {
222+ for ( var i in bomtable ) {
223223 var bomentry = bomtable [ i ] ;
224224 if ( filter && ! entryMatches ( bomentry ) ) {
225225 continue ;
@@ -267,8 +267,11 @@ function populateBomBody() {
267267 tr . appendChild ( td ) ;
268268 bom . appendChild ( tr ) ;
269269 var handler = createRowHighlightHandler ( tr . id , references ) ;
270- tr . onmouseenter = handler ;
271- highlightHandlers . push ( { id : tr . id , handler : handler } ) ;
270+ tr . onmousemove = handler ;
271+ highlightHandlers . push ( {
272+ id : tr . id ,
273+ handler : handler
274+ } ) ;
272275 if ( ( filter || reflookup ) && first ) {
273276 highlightedRefs = references ;
274277 drawHighlights ( ) ;
@@ -277,6 +280,46 @@ function populateBomBody() {
277280 }
278281}
279282
283+ function highlightPreviousRow ( ) {
284+ if ( ! currentHighlightedRowId ) {
285+ highlightHandlers [ highlightHandlers . length - 1 ] . handler ( ) ;
286+ return ;
287+ }
288+ for ( var i = 0 ; i < highlightHandlers . length - 1 ; i ++ ) {
289+ if ( highlightHandlers [ i + 1 ] . id == currentHighlightedRowId ) {
290+ highlightHandlers [ i ] . handler ( ) ;
291+ break ;
292+ }
293+ }
294+ if ( highlightHandlers . length > 1 &&
295+ highlightHandlers [ 0 ] . id == currentHighlightedRowId ) {
296+ highlightHandlers [ highlightHandlers . length - 1 ] . handler ( ) ;
297+ }
298+ document . getElementById ( currentHighlightedRowId ) . scrollIntoView (
299+ { behavior : "smooth" , block : "center" , inline : "nearest" }
300+ ) ;
301+ }
302+
303+ function highlightNextRow ( ) {
304+ if ( ! currentHighlightedRowId ) {
305+ highlightHandlers [ 0 ] . handler ( ) ;
306+ return ;
307+ }
308+ for ( var i = 1 ; i < highlightHandlers . length ; i ++ ) {
309+ if ( highlightHandlers [ i - 1 ] . id == currentHighlightedRowId ) {
310+ highlightHandlers [ i ] . handler ( ) ;
311+ break ;
312+ }
313+ }
314+ if ( highlightHandlers . length > 1 &&
315+ highlightHandlers [ highlightHandlers . length - 1 ] . id == currentHighlightedRowId ) {
316+ highlightHandlers [ 0 ] . handler ( ) ;
317+ }
318+ document . getElementById ( currentHighlightedRowId ) . scrollIntoView (
319+ { behavior : "smooth" , block : "center" , inline : "nearest" }
320+ ) ;
321+ }
322+
280323function populateBomTable ( ) {
281324 while ( bom . firstChild ) {
282325 bom . removeChild ( bom . firstChild ) ;
@@ -426,7 +469,7 @@ function changeBomLayout(layout) {
426469}
427470
428471function removeGutterNode ( node ) {
429- for ( i = 0 ; i < node . childNodes . length ; i ++ ) {
472+ for ( var i = 0 ; i < node . childNodes . length ; i ++ ) {
430473 if ( node . childNodes [ i ] . classList &&
431474 node . childNodes [ i ] . classList . contains ( "gutter" ) ) {
432475 node . removeChild ( node . childNodes [ i ] ) ;
@@ -446,6 +489,21 @@ function setBomCheckboxes(value) {
446489 populateBomTable ( ) ;
447490}
448491
492+ document . onkeydown = function ( e ) {
493+ switch ( e . key ) {
494+ case "ArrowUp" :
495+ highlightPreviousRow ( ) ;
496+ e . preventDefault ( ) ;
497+ break ;
498+ case "ArrowDown" :
499+ highlightNextRow ( ) ;
500+ e . preventDefault ( ) ;
501+ break ;
502+ default :
503+ break ;
504+ }
505+ }
506+
449507window . onload = function ( e ) {
450508 initStorage ( ) ;
451509 cleanGutters ( ) ;
0 commit comments