anto
This commit is contained in:
@@ -69,18 +69,15 @@ document.addEventListener("DOMContentLoaded", async () => {
|
||||
function setRequiredAttributes() {
|
||||
const firstInput = document.getElementById('first');
|
||||
const lastInput = document.getElementById('last');
|
||||
const numeratorInput = document.getElementById('numerator');
|
||||
const denominatorInput = document.getElementById('denominator');
|
||||
|
||||
if (firstLastContainer.style.display === 'block') {
|
||||
firstInput.required = true;
|
||||
lastInput.required = true;
|
||||
numeratorInput.required = true;
|
||||
denominatorInput.required = true;
|
||||
} else {
|
||||
firstInput.required = false;
|
||||
lastInput.required = false;
|
||||
numeratorInput.required = false;
|
||||
denominatorInput.required = false;
|
||||
}
|
||||
}
|
||||
@@ -128,7 +125,8 @@ document.addEventListener("DOMContentLoaded", async () => {
|
||||
return 0;
|
||||
}
|
||||
const choice = choiceSelect.value
|
||||
const measurementIds = getMeasurermentsIdsFromForm(choice,firstInput,lastInput);
|
||||
const measurementIds = getMeasurementsIdsFromForm(choice,firstInput,lastInput);
|
||||
console.log(measurementIds)
|
||||
postNewVideo(projectId, measurementIds, nameVideo, videoResolution, videoDuration)
|
||||
.then(()=>{
|
||||
alert('Nouvelle vidéo enregistrée :\nNom : ' + nameVideo +
|
||||
|
||||
@@ -24,21 +24,25 @@ function checkVideoPath(videos, name) {
|
||||
return res;
|
||||
}
|
||||
|
||||
function getMeasurermentsIdsFromForm(choice, firstInput,lastInput) {
|
||||
function getMeasurementsIdsFromForm(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));
|
||||
const measurementIds = new Set();
|
||||
measurementIds.add(first); // Always include the first image
|
||||
// Iterate through the range, adding the step size
|
||||
for (let i = first + denominator; i <= last; i += denominator) {
|
||||
measurementIds.add(i);
|
||||
}
|
||||
return measurementIds;
|
||||
|
||||
measurementIds.add(last); // Always include the last image
|
||||
|
||||
// Convert the Set back to an array and sort it
|
||||
return Array.from(measurementIds).sort((a, b) => a - b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user