correct syntax error

This commit is contained in:
Ryan Mwangi 2024-10-21 19:41:41 +03:00
parent 707e085fe7
commit 3ffd34190f

View file

@ -29,22 +29,23 @@ const form = document.getElementById('merge-form');
const linkGroupName = document.getElementById('link-group-name').value; const linkGroupName = document.getElementById('link-group-name').value;
const calendarsData = []; const calendarsData = [];
let valid = true; // Flag to track URL validity let valid = true; // Flag to track URL validity
for (let i = 0; i < calendarIndex; i++) { for (let i = 0; i < calendarIndex; i++) {
const prefix = document.getElementById(`prefix-${i}`); const prefix = document.getElementById(`prefix-${i}`);
const override = document.getElementById(`override-${i}`); const override = document.getElementById(`override-${i}`);
const url = document.getElementById(`url-${i}`); const url = document.getElementById(`url-${i}`);
if (prefix && override && url) { if (prefix && override && url) {
// Validate the URL // Validate the URL
if (!isValidUrl(url.value)) { if (!isValidUrl(url.value)) {
valid = false; // Set flag to false if any URL is invalid valid = false; // Set flag to false if any URL is invalid
alert(`Invalid URL format for calendar ${i + 1}: ${url.value}`); alert(`Invalid URL format for calendar ${i + 1}: ${url.value}`);
} else { } else {
calendarsData.push({ calendarsData.push({
prefix: prefix.value, prefix: prefix.value,
override: override.checked, override: override.checked,
url: url.value url: url.value
}); });
}
} }
} }
fetch('/merge', { fetch('/merge', {