uploaded base code
This commit is contained in:
53
static/script.js
Normal file
53
static/script.js
Normal 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
41
static/styles.css
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user