top 10 boilerplate ever

This commit is contained in:
biglyderv 2024-11-25 14:12:43 -05:00
commit 153c74bd22
17 changed files with 567 additions and 0 deletions

0
static/main.css Normal file
View file

24
static/main.js Normal file
View file

@ -0,0 +1,24 @@
async function formClick(ev) {
ev.preventDefault();
let { target } = ev;
let fetched = await fetch(target.action, {
'method': 'POST',
'body': new FormData(target)
});
let json = await fetched.json();
document.querySelector('.form-message').textContent = json.message;
if (json.redirect) {
setTimeout(function () {
window.location.href = json.redirect;
}, 2000);
}
}
window.onload = function () {
document.addEventListener('submit', formClick);
}