44 lines
1.4 KiB
JavaScript
44 lines
1.4 KiB
JavaScript
function convertStringToArray(inputString) {
|
|
// Split the string by the delimiter '/'
|
|
const stringArray = inputString.split(",");
|
|
|
|
// Convert each element to a number
|
|
const numberArray = stringArray.map(Number);
|
|
|
|
return numberArray;
|
|
}
|
|
|
|
function filterAndSortMeasurementsByIds(measurements, ids) {
|
|
return measurements
|
|
.filter((measurement) => ids.includes(measurement.id))
|
|
.sort((a, b) => new Date(a.timestamp) - new Date(b.timestamp));
|
|
}
|
|
|
|
function checkVideoPath(videos, name) {
|
|
let res = true;
|
|
videos.forEach(video => {
|
|
const videoName = video.name;
|
|
if(videoName==name)
|
|
res=false;
|
|
});
|
|
return res;
|
|
}
|
|
|
|
function getMeasurermentsIdsFromForm(choice, firstInput,lastInput) {
|
|
if (choice === 'oneByOne') {
|
|
const highlightedButtons = document.querySelectorAll('.number-button.highlight');
|
|
return Array.from(highlightedButtons).map(button => parseInt(button.textContent));
|
|
} else {
|
|
const first = parseInt(firstInput.value);
|
|
const last = parseInt(lastInput.value);
|
|
const numerator = parseInt(document.getElementById('numerator').value);
|
|
const denominator = parseInt(document.getElementById('denominator').value);
|
|
const fraction = numerator / denominator;
|
|
|
|
const measurementIds = [];
|
|
for (let i = first; i <= last; i += fraction) {
|
|
measurementIds.push(Math.round(i));
|
|
}
|
|
return measurementIds;
|
|
}
|
|
} |