https://calculcg.utcluj.ro/

URL inviato:
https://calculcg.utcluj.ro/
Report terminato:

Variabili JavaScript · 3 trovate

NomeTipo
onbeforetoggleobject
documentPictureInPictureobject
onscrollendobject

Messaggi di log della console · 1 trovati

TipoCategoriaLog
errornetwork
URL
https://calculcg.utcluj.ro/favicon.ico
Testo
Failed to load resource: the server responded with a status of 404 ()

HTML

<!DOCTYPE html><html lang="en"><head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- font pentru pagina -->
    <link href="https://fonts.googleapis.com/css?family=Roboto:900" rel="stylesheet">
    <!-- bifa pentru radio button -->
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/line-awesome/css/line-awesome.min.css" rel="stylesheet">
    <!-- importa stylingul pentru pagina -->
    <link rel="stylesheet" type="text/css" href="/static/styles/formular_date.css">
    <title>Calcul Caracteristici Geometrice</title>
</head>

<body>
    <div class="page-wrapper">
        <div class="page-heading">
            <div class="title" data-text="Calcul Caracteristici Geometrice"></div>
            <h2>Alege o forma:</h2>
        </div>

        <form id="inputForm" action="/" method="post">
            <div class="data-form">
                <div class="radio-buttons">
                    <label class="custom-radio">
                        <input type="radio" id="option1" name="option" value="dreptunghi" checked="">
                        <span class="radio-btn"><i class="las la-check"></i>
                            <div class="shape-icon">
                                <img src="/static/images/dreptunghi_simplu.png">
                                <h3>Dreptunghi</h3>
                            </div>
                        </span>
                    </label>
                    <label class="custom-radio">
                        <input type="radio" id="option2" name="option" value="T">
                        <span class="radio-btn"><i class="las la-check"></i>
                            <div class="shape-icon">
                                <img src="/static/images/t_simplu.png">
                                <h3>T</h3>
                            </div>
                        </span>
                    </label>
                    <label class="custom-radio">
                        <input type="radio" id="option3" name="option" value="I">
                        <span class="radio-btn"><i class="las la-check"></i>
                            <div class="shape-icon">
                                <img src="/static/images/i_simplu.png">
                                <h3>I</h3>
                            </div>
                        </span>
                    </label>
                </div>

                <div id="inputs">
                    <div id="input1">
                        <label class="shape-input-label" for="base1">Baza 1</label>
                        <input type="text" id="base1" name="base1" pattern="[0-9]+(?:[.,][0-9]+)?" placeholder="ex: 10 cm"><br>
                        <label class="shape-input-label" for="height1">Inaltime 1</label>
                        <input type="text" id="height1" name="height1" pattern="[0-9]+(?:[.,][0-9]+)?" placeholder="ex: 20 cm"><br>
                    </div>
                    <div id="input2" class="hidden">
                        <label class="shape-input-label" for="base2">Baza 2</label>
                        <input type="text" id="base2" name="base2" pattern="[0-9]+(?:[.,][0-9]+)?" placeholder="ex: 10 cm"><br>
                        <label class="shape-input-label" for="height2">Inaltime 2</label>
                        <input type="text" id="height2" name="height2" pattern="[0-9]+(?:[.,][0-9]+)?" placeholder="ex: 20 cm"><br>
                    </div>
                    <div id="input3" class="hidden">
                        <label class="shape-input-label" for="base3">Baza 3</label>
                        <input type="text" id="base3" name="base3" pattern="[0-9]+(?:[.,][0-9]+)?" placeholder="ex: 10 cm"><br>
                        <label class="shape-input-label" for="height3">Inaltime 3</label>
                        <input type="text" id="height3" name="height3" pattern="[0-9]+(?:[.,][0-9]+)?" placeholder="ex: 20 cm"><br>
                    </div>
                </div>
                <div class="button-wrapper">
                    <button type="button" id="submitButton">Calculeaza</button>
                </div>
            </div>
        </form>
    </div>

    <script>
        function areInputsFilled() {
            var inputs = document.querySelectorAll('#inputs > div:not(.hidden) input[type="text"]');
            for (var i = 0; i < inputs.length; i++) {
                if (inputs[i].value === '') {
                    return false;
                }
            }
            return true;
        }

        function resetInputs() {
            document.querySelectorAll('#inputs > div input[type="text"]').forEach(function (input) {
                input.value = ''; // reseteaza valoarea din pinput de fiecare data cand se schimba valoarea din radio button
            });

            document.querySelectorAll('#inputs > div').forEach(function (div) {
                div.classList.add('hidden');
            });
            document.getElementById('input1').classList.remove('hidden');
        }

        resetInputs();
        document.getElementById('option1').checked = true; // varianta default pentru radio button

        document.querySelectorAll('input[name="option"]').forEach(function (radio) {
            radio.addEventListener('change', function () {
                resetInputs();
                var shape = this.value;
                switch (shape) {
                    case 'dreptunghi':
                        document.querySelector('#input1').classList.remove('hidden');
                        break;
                    case 'T':
                        document.querySelector('#input1').classList.remove('hidden');
                        document.querySelector('#input2').classList.remove('hidden');
                        break;
                    case 'I':
                        document.querySelector('#input1').classList.remove('hidden');
                        document.querySelector('#input2').classList.remove('hidden');
                        document.querySelector('#input3').classList.remove('hidden');
                        break;
                    default:
                        resetInputs();
                        break;
                }
            });
        });

        document.querySelectorAll('input[type="text"]').forEach(function (input) {
            input.addEventListener('input', function () {
                // reformateaza valorea din input, orice nu e cifra, virgula sau punct (1.55 sau 1,77 permis)
                this.value = this.value.replace(/[^\d.,]/g, '');

                // avem valoare pozitiva
                if (parseFloat(this.value) <= 0 || isNaN(parseFloat(this.value))) {
                    this.value = '';
                }
            });
        });


        // trimite datele din formular catre server
        document.getElementById('submitButton').addEventListener('click', async function () {
            if (areInputsFilled()) {
                var shape = document.querySelector('input[name="option"]:checked').value;
                var bases = [];
                var heights = [];

                if (shape === "dreptunghi") {
                    bases.push(document.getElementById('base1').value);
                    heights.push(document.getElementById('height1').value);
                } else if (shape === "T") {
                    bases.push(document.getElementById('base1').value);
                    bases.push(document.getElementById('base2').value);
                    heights.push(document.getElementById('height1').value);
                    heights.push(document.getElementById('height2').value);
                } else if (shape === "I") {
                    bases.push(document.getElementById('base1').value);
                    bases.push(document.getElementById('base2').value);
                    bases.push(document.getElementById('base3').value);
                    heights.push(document.getElementById('height1').value);
                    heights.push(document.getElementById('height2').value);
                    heights.push(document.getElementById('height3').value);
                }

                var formData = new FormData();
                formData.append('shape', shape);
                formData.append('bases', JSON.stringify(bases));
                formData.append('heights', JSON.stringify(heights));

                try {
                    const response = await fetch('https://calculcg.utcluj.ro/', {
                        method: 'POST',
                        body: formData
                    });

                    if (response.status === 200) {
                        const responseData = await response.json();
                        // peristam raspunsul de la server pe sessionStorage pentru pagina de rezultat
                        sessionStorage.setItem('responseData', JSON.stringify(responseData));
                        setTimeout(function () {
                            window.location.href = '/results';
                        }, 1000);
                    } else {
                        throw new Error('Response status was not 200');
                    }
                } catch (error) {
                    console.error('Error fetching data:', error);
                }
            } else {
                alert('Completeaza toate inputurile!');
            }
        });
    </script>


</body></html>