Hong-Phuc Bui
2025-11-20 9ba573284ccde687b4c190c0f44032eef846410a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import {calculateRadius} from "./kreis.js";
 
const runBnt = document.getElementById("run");
runBnt.addEventListener("click", () => {
    try {
        const fsInput = document.querySelector("#Fs");
        const sInput = document.querySelector("#s");
        const [fs, s] = convertInput(fsInput, sInput);
        console.log({fs, s});
        const [radius,alpha] = calculateRadius(fs, s);
        console.log({radius, alpha});
        const radiusSpan = document.getElementById("radius");
        radiusSpan.innerText = `${radius}`;
        const alphaSpan = document.getElementById("alpha");
        alphaSpan.innerText = `${alpha}`;
    }catch (e) {
        showError(e);
    }
});
 
const convertInput = (fsInput, sInput) => {
    const fs = fsInput.value;
    const nFs = Number(fs);
    if(isNaN(nFs)) {
        //TODO: set styling von fsInput to error
        throw new Error("Fläche-eingabe ist keine Zahl")
    }
    const s = sInput.value;
    const nS = Number(s);
    if(isNaN(s)) {
        //TODO: set styling von sInput to error
        throw new Error("Sehnenlänge-eingabe ist keine Zahl");
    }
    return[nFs, nS];
}
 
const showError = (error) => {
    console.error(error);
}