fix empty regulation input

This commit is contained in:
Wolfgang 2024-06-03 22:11:20 +02:00
parent 1dbc4de5ed
commit 65ff1d1105

View file

@ -378,22 +378,30 @@ div>label {
}
function update_inputs() {
Promise.all([
let urls = [
fetch(document.getElementById("base_input").value, { mode: "cors" }),
fetch(document.getElementById("regulation_input").value, { mode: "cors" }),
]).then((res) => {
];
let reg = document.getElementById("regulation_input").value;
if (reg !== "") {
urls.push(fetch(reg, { mode: "cors" }));
}
Promise.all(urls).then((res) => {
res.forEach((r) => {
if (!r.ok) {
throw new Error(r.status);
}
});
Promise.all([res[0].text(), res[1].text()]).then((d) => {
try {
let reg = d[1];
if (reg === "") {
reg = "- header: true\n columns: []\n titles: []\n frequency_unit: GHz\n- frequency: 0-" + 9007199254740991;
let ymls = [res[0].text()];
if (reg !== "") {
ymls.push(res[1].text());
} else {
// make dummy yml file with one big frequency range
ymls.push("- header: true\n columns: []\n titles: []\n frequency_unit: GHz\n- frequency: 0-" + 9007199254740991);
}
update_table(yaml.load(d[0]), yaml.load(reg));
Promise.all(ymls).then((d) => {
try {
update_table(yaml.load(d[0]), yaml.load(d[1]));
} catch (e) {
display_error(e);
}