Fix editor

This commit is contained in:
Christopher Cookman 2024-12-21 02:25:57 -07:00
parent a28f672516
commit 023e4da2f9

View file

@ -6,10 +6,11 @@ const alertBox = (type, message) => {
};
// Set expiresTimestamp to the time in const ban.expiresTimestamp (convert from js date number to local time string that conforms with html form values)
const expiresTimestamp = document.getElementById('expiresTimestamp').value;
const expiresDate = new Date(ban.expiresTimestamp)
document.getElementById('expiresTimestamp').value = new Date(expiresDate.getTime() - (expiresDate.getTimezoneOffset() * 60000)).toISOString().slice(0, 16);
if (ban.expiresTimestamp !== null) {
const expiresTimestamp = document.getElementById('expiresTimestamp').value;
const expiresDate = new Date(ban.expiresTimestamp)
document.getElementById('expiresTimestamp').value = new Date(expiresDate.getTime() - (expiresDate.getTimezoneOffset() * 60000)).toISOString().slice(0, 16);
}
var reasonFlags = {};
@ -24,7 +25,7 @@ fetch('/api/v1/info')
document.getElementById('banForm').addEventListener('submit', function (event) {
event.preventDefault();
// Combine flag values
const checkboxes = document.querySelectorAll('.flag-checkbox');
let combinedFlags = 0;
@ -53,20 +54,20 @@ document.getElementById('banForm').addEventListener('submit', function (event) {
},
body: JSON.stringify(data)
})
.then(response => response.json())
.then(result => {
if (result.success) {
console.log('Success:', result);
// Handle success (e.g., show a success message, redirect, etc.)
window.location.href = '/admin';
} else {
console.error('Error:', result.message);
alertBox('alert-danger', 'An error has occurred: ' + result.message);
}
})
.catch(error => {
console.error('Error:', error);
alertBox('alert-danger', 'An error has occurred. Please contact support.\n' + error);
// Handle error (e.g., show an error message)
});
.then(response => response.json())
.then(result => {
if (result.success) {
console.log('Success:', result);
// Handle success (e.g., show a success message, redirect, etc.)
window.location.href = '/admin';
} else {
console.error('Error:', result.message);
alertBox('alert-danger', 'An error has occurred: ' + result.message);
}
})
.catch(error => {
console.error('Error:', error);
alertBox('alert-danger', 'An error has occurred. Please contact support.\n' + error);
// Handle error (e.g., show an error message)
});
});