messageHandler update

This commit is contained in:
Adam 2024-11-15 18:08:49 +01:00
parent 8ad64ac523
commit 7f39d3dcdd
1 changed files with 10 additions and 5 deletions

View File

@ -22,13 +22,11 @@
$('.toast-info').css("background-color", "#008080");
},
bidNotification: function (data) {
//console.log("Bid product name" + data.productName);
toastr.success(`<div class="item bidToast"><p>${data.bidPrice}</p><p>${data.productName}</p></div>`, "New bid arrived", {
//"timeOut": 150000,
"closeButton": true,
"positionClass": "toast-bottom-right",
"newestOnTop": true,
"progressBar": true,
"progressBar": true,
"preventDuplicates": false,
"onclick": null,
"showDuration": "30000",
@ -39,10 +37,18 @@
"hideEasing": "linear",
"showMethod": animation,
"hideMethod": "fadeOut"
});
$('.toast-success').css("background-color", "#4caf50");
},
auctionUpdate: function (data) {
const widgetPriceElement = document.getElementById("WidgetPrice");
if (widgetPriceElement) {
widgetPriceElement.textContent = data.bidPrice; // Update the price
console.log(`WidgetPrice updated to: ${data.bidPrice}`);
} else {
console.warn("Element with ID 'WidgetPrice' not found in the DOM.");
}
},
// Add more handlers as needed
default: function (data) {
console.warn("Unhandled message type:", data);
@ -53,7 +59,6 @@
function messageRouter(message) {
// Parse the JSON message
try {
/*console.log(message);*/
const parsedMessage = JSON.parse(message);
const messageType = parsedMessage.messageType;
const messageData = parsedMessage.data;