Files
FOFTickets/views/settings.ejs
2024-12-29 18:31:06 -05:00

46 lines
1.6 KiB
Plaintext

<!DOCTYPE html>
<html>
<head>
<title>Settings</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<%- include('partials/nav') %>
<div class="content">
<input type="checkbox" class="setting" name="enable-email">Enable Email<br>
<input type="checkbox" class="setting" name="enable-ticket-use">Enable Ticket Use<br>
<input type="checkbox" class="setting" name="enable-credit-cards">Enable Credit Cards<br>
<form action='/purge' method='post'>
<button type="submit" >Purge Revoked Tickets</button>
</form>
<form action='/wipedb' method='post'>
<button type="submit" >Wipe the Database</button>
</form>
<form action='/serialize' method='post'>
<button type="submit" >Serialize</button>
</form>
<form action='/deserialize' method='post'>
<button type="submit" >Deserialize</button>
</form>
</div>
</body>
<script>
const MessageArea=document.getElementById("message");
const checkboxes = document.getElementsByClassName("setting");
for (let i=0; i<checkboxes.length; i++) checkboxes[i].addEventListener('change',(event) => {
console.log(event);
fetch('/update-setting',{ method:"POST", headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ name:event.target.name, checked:event.target.checked }) })
.then(response => {
if (!response.ok) throw new Error("Network Error: Server did not respond.");
MessageArea.textContent="Updated "+event.target.name;
return response.json();
})
.catch(error => console.error('Error updating checkbox state:', error));
})
</script>
</html>