(error => {
console.error(error);
});
});
// Function to send message data to server
function postMessage(username, message) {
return fetch("/api/messages", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
username: username,
message: message
})
}).then(response => {
if (!response.ok) {
throw new Error("Failed to post message");
}
return response.json();
});
}
// Function to add message to message list
function addMessage(id, username, message) {
const messageElem = document.createElement("div");
messageElem.classList.add("message");
messageElem.innerHTML =
${username}
${message}
;
messageList.appendChild(messageElem);
}
// Function to load existing messages from server
function loadMessages() {
fetch("/api/messages")
.then(response => {
if (!response.ok) {
throw new Error("Failed to load messages");
}
return response.json();
})
.then(messages => {
messages.forEach(message => {
addMessage(message.id, message.username, message.message);
});
})
.catch(error => {
console.error(error);
});
}
Product List Welcome! Please confirm that you are 21+ years of age to proceed. Yes No Name: Email: Product Quantity Price Total Product 1 - + $10.00 Shipping fee Standard Expedited Overnight Gift wrapping Total Place Order
Select the Tier: Bronze 1 Bronze 2 Bronze 3 Silver 1 Silver 2 Silver 3 Gold 1 Gold 2 Gold 3 Odds of winning a block: Chances of winning a block: Number of attempts required to win a block:
Comments
Post a Comment