INNER CODE UNIT · JavaScript
high
sirius-ms/sirius · lcms2/viewer/viewer.js:34
high = mid - 1; // Target is in the left half
}
// Update the closest index if needed
if (closestIndex === -1 || Math.abs(functor(arr[mid]) - target) < Math.abs(functor(arr[closestIndex]) - target)) {
closestIndex = mid;
}
}
return closestIndex; // Target not found, return the closest index
}
function updateSlider(evt) {
let value = d3.select("#mzslider").node().value;
d3.select("#mznum").node().value = value;
let index = binarySearchClosest(document.lcdata, parseFloat(value), (x)=>x.mz);
document.currentIndex = index;
refreshPlot();
}