uploaded base code

This commit is contained in:
2025-03-15 18:28:52 +02:00
parent dd379a6f5c
commit 4066abb255
10 changed files with 302 additions and 0 deletions

53
static/script.js Normal file
View File

@@ -0,0 +1,53 @@
const socket = io();
document.addEventListener("DOMContentLoaded", function () {
const storeForm = document.getElementById("store-form");
const phoneInput = document.getElementById("phone-input");
const retrieveButton = document.getElementById("retrieve-button");
const configForm = document.getElementById("config-form");
if (storeForm) {
storeForm.addEventListener("submit", function (event) {
event.preventDefault();
const formData = new FormData(storeForm);
fetch("/store", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(Object.fromEntries(formData))
})
.then(response => response.json())
.then(data => alert(data.message || "Error"));
});
}
if (retrieveButton) {
retrieveButton.addEventListener("click", function () {
const phone = phoneInput.value;
fetch(`/retrieve?phone=${encodeURIComponent(phone)}`)
.then(response => response.json())
.then(data => {
console.log(data);
alert(JSON.stringify(data));
});
});
}
if (configForm) {
configForm.addEventListener("submit", function (event) {
event.preventDefault();
const formData = new FormData(configForm);
fetch("/config", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(Object.fromEntries(formData))
})
.then(response => response.json())
.then(data => alert(data.message || "Error"));
});
}
socket.on("update", function (data) {
console.log("Live update:", data);
alert(data.message);
});
});

41
static/styles.css Normal file
View File

@@ -0,0 +1,41 @@
body {
font-family: Arial, sans-serif;
direction: ltr;
text-align: left;
margin: 20px;
background-color: #f4f4f4;
}
.container {
max-width: 600px;
margin: auto;
background: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
}
input, button {
display: block;
width: 100%;
margin-bottom: 10px;
padding: 10px;
border-radius: 5px;
border: 1px solid #ccc;
}
button {
background-color: #007BFF;
color: white;
border: none;
cursor: pointer;
}
button:hover {
background-color: #0056b3;
}
.rtl {
direction: rtl;
text-align: right;
}