33 lines
1,012 B
JavaScript
33 lines
1,012 B
JavaScript
|
const nameLabel = document.getElementById("namelabel");
|
||
|
const nameBox = document.getElementById("name");
|
||
|
|
||
|
nameBox.addEventListener("input", function() {
|
||
|
nameLabel.innerText = `Name (${64 - nameBox.value.length} characters left):`;
|
||
|
})
|
||
|
|
||
|
const msgLabel = document.getElementById("msglabel");
|
||
|
const msgBox = document.getElementById("message");
|
||
|
|
||
|
msgBox.addEventListener("input", function() {
|
||
|
msgLabel.innerText = `Message (${600 - msgBox.value.length} characters left):`;
|
||
|
})
|
||
|
|
||
|
document.getElementById("submitForm").reset();
|
||
|
|
||
|
document.getElementById("submitForm").addEventListener("submit", function(event) {
|
||
|
event.preventDefault();
|
||
|
const formData = new FormData(event.target);
|
||
|
|
||
|
document.getElementById("submitButton").disabled = true;
|
||
|
|
||
|
fetch(macroURL, {
|
||
|
method:"POST",
|
||
|
body: new URLSearchParams(formData)
|
||
|
})
|
||
|
.then(response => response.json())
|
||
|
.then(data => {
|
||
|
event.target.reset();
|
||
|
window.location.reload()
|
||
|
});
|
||
|
|
||
|
});
|