{"size": 1714, "ext": "js", "max_stars_repo_path": "staff/src/registra_visita.js", "max_stars_repo_name": "tetochannel/TAMPONITIS", "max_stars_repo_stars_event_min_datetime": "2021-04-22T08:23:30.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-23T15:51:17.000Z", "max_issues_repo_path": "staff/src/registra_visita.js", "max_issues_repo_name": "tetochannel/TAMPONITIS", "max_issues_repo_issues_event_min_datetime": "2021-04-17T09:21:09.000Z", "max_issues_repo_issues_event_max_datetime": "2021-04-17T09:26:49.000Z", "max_forks_repo_path": "staff/src/registra_visita.js", "max_forks_repo_name": "tetochannel/Tamponitis", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": 2, "max_forks_count": null, "avg_line_length": 41.8048780488, "max_line_length": 104, "alphanum_fraction": 0.6446907818}
this.addEventListener('keypress', event => {
    if (event.keyCode == 13) {
        document.getElementById('registrazione').click()
    }
})


function registra_visita() {
    const xhr = new XMLHttpRequest()
    const codice_prenotazione = document.getElementById("codice_prenotazione").value
    const effettuata = document.getElementById("effettuata").checked
    const note = document.getElementById("note").value
    const errors = document.getElementById("errors")
    const success = document.getElementById("success")
    const errors_row = document.getElementById("errors_row")
    const success_row = document.getElementById("success_row")
    xhr.open("POST", "./registra_visita.php", false)
    xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
    xhr.send(`codice_prenotazione=${codice_prenotazione}&effettuata=${Number(effettuata)}&note=${note}`)
    switch (xhr.status) {
        case 200:
            document.getElementById("form").reset()
            errors.innerText = ""
            errors_row.setAttribute("hidden", "true")
            success_row.removeAttribute("hidden")
            success.innerText = xhr.responseText
            setTimeout(() => {success.innerText = "", success_row.setAttribute("hidden", "true")}, 5000)
            break
        case 403:
            success.innerText = ""
            success_row.setAttribute("hidden", "true")
            errors_row.removeAttribute("hidden")
            errors.innerText = xhr.responseText
            setTimeout(() => {errors.innerText = "", errors_row.setAttribute("hidden", "true")}, 5000)
            break
        default:
            console.log(xhr.status)
            break
    }
    return false
}