Skip to content

Commit

Permalink
Restyled by prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
restyled-commits committed Aug 21, 2023
1 parent b511c94 commit ec6a093
Show file tree
Hide file tree
Showing 3 changed files with 1,011 additions and 901 deletions.
54 changes: 31 additions & 23 deletions coverage/lcov-report/block-navigation.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
/* eslint-disable */
var jumpToCode = (function init() {
// Classes of code we would like to highlight in the file view
var missingCoverageClasses = [ '.cbranch-no', '.cstat-no', '.fstat-no' ];
var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no'];

// Elements to highlight in the file listing view
var fileListingElements = [ 'td.pct.low' ];
var fileListingElements = ['td.pct.low'];

// We don't want to select elements that are direct descendants of another
// match
var notSelector = ':not(' + missingCoverageClasses.join('):not(') +
') > '; // becomes `:not(a):not(b) > `
var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > `

// Selecter that finds elements on the page to which we can jump
var selector =
fileListingElements.join(', ') + ', ' + notSelector +
missingCoverageClasses.join(
', ' +
notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b`
fileListingElements.join(', ') +
', ' +
notSelector +
missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b`

// The NodeList of matching elements
var missingCoverageElements = document.querySelectorAll(selector);
Expand All @@ -31,8 +30,13 @@ var jumpToCode = (function init() {
function makeCurrent(index) {
toggleClass(index);
currentIndex = index;
missingCoverageElements.item(index).scrollIntoView(
{behavior : 'smooth', block : 'center', inline : 'center'});
missingCoverageElements
.item(index)
.scrollIntoView({
behavior: 'smooth',
block: 'center',
inline: 'center',
});
}

function goToPrevious() {
Expand All @@ -49,32 +53,36 @@ var jumpToCode = (function init() {
function goToNext() {
var nextIndex = 0;

if (typeof currentIndex === 'number' &&
currentIndex < missingCoverageElements.length - 1) {
if (
typeof currentIndex === 'number' &&
currentIndex < missingCoverageElements.length - 1
) {
nextIndex = currentIndex + 1;
}

makeCurrent(nextIndex);
}

return function jump(event) {
if (document.getElementById('fileSearch') === document.activeElement &&
document.activeElement != null) {
if (
document.getElementById('fileSearch') === document.activeElement &&
document.activeElement != null
) {
// if we're currently focused on the search input, we don't want to
// navigate
return;
}

switch (event.which) {
case 78: // n
case 74: // j
goToNext();
break;
case 66: // b
case 75: // k
case 80: // p
goToPrevious();
break;
case 78: // n
case 74: // j
goToNext();
break;
case 66: // b
case 75: // k
case 80: // p
goToPrevious();
break;
}
};
})();
Expand Down
Loading

0 comments on commit ec6a093

Please sign in to comment.