ready for PR

This commit is contained in:
Russel Yasol
2024-10-02 19:22:00 +08:00
parent 39907e983a
commit b70ada6b9c
227 changed files with 102724 additions and 11540 deletions

36
www/js/handle-at-input.js Normal file
View File

@@ -0,0 +1,36 @@
// Handle form submission via JavaScript
document
.getElementById("commandForm")
.addEventListener("submit", function (e) {
e.preventDefault(); // Prevent default form submission
const commandInput = document.getElementById("command").value;
const outputTextarea = document.getElementById("output");
// Make sure input is not empty
if (commandInput.trim() === "") {
outputTextarea.value = "Please enter a valid AT command.";
return;
}
// Send the AT command to the CGI script via fetch
fetch("/cgi-bin/atinout_handler.sh", {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
body: `command=${encodeURIComponent(commandInput)}`,
})
.then((response) => response.json())
.then((data) => {
// Display the response in the textarea
if (data.output) {
outputTextarea.value = data.output;
} else {
outputTextarea.value = "Error: No output received.";
}
})
.catch((error) => {
outputTextarea.value = `Error fetching data: ${error.message}`;
});
});