function showRegisterForm() { document.getElementById("text-container").style.top = '2%' document.getElementById("register-button").style.opacity = 0 document.getElementById("participation-buttons").style.display = 'inline-block' document.getElementById("name-form").style.display = 'inherit' document.getElementById("add-calender-event").style.display = 'none' document.getElementById("guest-name").focus() var audio = document.getElementById("audio"); audio.play(); } async function participate(isParticipating) { let value = document.getElementById("guest-name").value if (!value) { return } let name = value.trim() document.getElementById("participation-buttons").style.display = 'none' document.getElementById("name-form").style.display = 'none' console.log("Registering: " + name); if (isParticipating) { let registered = await performRequest(name, "register") if (registered) { document.getElementById("registered-text").style.display = 'inherit' document.getElementById("add-calender-event").style.display = 'inherit' } else { document.getElementById("error-text").style.display = 'inherit' } } else { let declined = await performRequest(name, "decline") if (declined) { document.getElementById("declined-text").style.display = 'inherit' } else { document.getElementById("error-text").style.display = 'inherit' } } } function handleErrors(response) { if (!response.ok) throw new Error(response.status); return response.text(); } function catchErrors(error) { console.log(error); return "Failed"; } async function performRequest(name, path) { let text = await fetch("/festival/api/" + path, { method: 'POST', body: name }).then(handleErrors).catch(catchErrors); if (text == "Success") { console.log("Registered: " + name); return true; } console.log("Failed to register: " + text); return false; } function download(file) { window.location = file }