Files
FOFTickets/views/settings.ejs
2025-03-09 22:13:57 -04:00

57 lines
2.3 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" <%= settings["enable-email"] ? "checked" : "" %> >Enable Email<br>
<input type="checkbox" class="setting" name="enable-ticket-use" <%= settings["enable-ticket-use"] ? "checked" : "" %> >Enable Ticket Use<br>
<input type="checkbox" class="setting" name="enable-credit-cards" <%= settings["enable-credit-cards"] ? "checked" : "" %> >Enable Credit Cards<br>
<input type="checkbox" class="setting" name="enable-transfer" <%= settings["enable-transfer"] ? "checked" : "" %> >Enable Transfer<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>
<form action='/killmagiclink' method='post'>
Deactivate Magic Links for:
<input type="email" name="email">
<button type="submit">Deactivate</button>
</form>
<form action="/importfb" method="post" enctype="multipart/form-data">
Import Tickets (Frostburn Format):
<input type="file" name="file">
<input type="submit" value="Upload">
</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>