mirror of
https://github.com/welton89/RRBEC.git
synced 2026-04-05 21:45:41 +00:00
style: toast ao add product na comanda
This commit is contained in:
@@ -19,115 +19,86 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
|
||||
|
||||
function verificarCookieNotificacao() {
|
||||
var iconNotify = document.getElementById('icon-notify');
|
||||
if (document.cookie.indexOf('notificacao=') === -1) {
|
||||
document.cookie = 'notificacao=true; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/';
|
||||
iconNotify.style.backgroundColor = 'green';
|
||||
iconNotify.textContent = '🔊';
|
||||
}else{
|
||||
let valorAtual = document.cookie.replace(/(?:(?:^|.*;\s*)notificacao\s*\=\s*([^;]*).*$)|^.*$/, "$1");
|
||||
iconNotify.style.backgroundColor = valorAtual === 'true' ? 'green' : 'red';
|
||||
iconNotify.textContent = valorAtual === 'true' ? '🔊' : '🔇';
|
||||
}
|
||||
}
|
||||
verificarCookieNotificacao();
|
||||
|
||||
function cookieNotificacao() {
|
||||
if (document.cookie.indexOf('notificacao=') !== -1) {
|
||||
let valorAtual = document.cookie.replace(/(?:(?:^|.*;\s*)notificacao\s*\=\s*([^;]*).*$)|^.*$/, "$1");
|
||||
var iconNotify = document.getElementById('icon-notify');
|
||||
let novoValor = valorAtual === 'true' ? 'false' : 'true';
|
||||
if (novoValor === 'true') {
|
||||
iconNotify.style.backgroundColor = 'green';
|
||||
iconNotify.textContent = '🔊';
|
||||
}else{
|
||||
iconNotify.style.backgroundColor = 'red';
|
||||
iconNotify.textContent = '🔇';
|
||||
}
|
||||
document.cookie = 'notificacao=' + novoValor + '; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/';
|
||||
} else {
|
||||
document.cookie = 'notificacao=true; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/';
|
||||
}
|
||||
}
|
||||
|
||||
const websocket = new WebSocket('ws://192.168.0.150:8765');
|
||||
const nomeUsuario = document.getElementById('user-info').textContent;
|
||||
|
||||
websocket.addEventListener('open', (event) => {
|
||||
console.log('Conectado ao servidor WebSocket');
|
||||
});
|
||||
|
||||
websocket.addEventListener('message', (event) => {
|
||||
const data = JSON.parse(event.data);
|
||||
|
||||
switch (data.local) {
|
||||
case 'cozinha':
|
||||
|
||||
if (document.getElementById('Fila') !== null && data.tipo === 'add'){
|
||||
|
||||
|
||||
var novoElemento = document.createElement('div');
|
||||
novoElemento.innerHTML = data.message;
|
||||
document.getElementById('Fila').appendChild(novoElemento);
|
||||
let valorAtual = document.cookie.replace(/(?:(?:^|.*;\s*)notificacao\s*\=\s*([^;]*).*$)|^.*$/, "$1");
|
||||
if (valorAtual === 'true') {
|
||||
texto = new SpeechSynthesisUtterance(data.speak);
|
||||
window.speechSynthesis.speak(texto);
|
||||
// setTimeout(function() {
|
||||
// location.reload();
|
||||
// }, 6000);
|
||||
}
|
||||
}
|
||||
else if (document.getElementById('obs-'+data.id) !== null && data.tipo === 'edit'){
|
||||
const obs = document.getElementById('obs-'+data.id)
|
||||
const card = obs.parentNode;
|
||||
card.style.backgroundColor = 'rgb(243, 165, 75)';
|
||||
obs.innerHTML = data.message;
|
||||
let valorAtual = document.cookie.replace(/(?:(?:^|.*;\s*)notificacao\s*\=\s*([^;]*).*$)|^.*$/, "$1");
|
||||
|
||||
if (valorAtual === 'true') {
|
||||
texto = new SpeechSynthesisUtterance(data.speak);
|
||||
window.speechSynthesis.speak(texto);
|
||||
// setTimeout(function() {
|
||||
// location.reload();
|
||||
// }, 6000);
|
||||
}
|
||||
}
|
||||
else if (document.getElementById('m-card-'+data.id) !== null && data.tipo === 'delete'){
|
||||
// const card = document.getElementById('m-card-'+data.id)
|
||||
// card.style.backgroundColor = 'rgb(253, 69, 69)';
|
||||
let valorAtual = document.cookie.replace(/(?:(?:^|.*;\s*)notificacao\s*\=\s*([^;]*).*$)|^.*$/, "$1");
|
||||
if (valorAtual === 'true') {
|
||||
texto = new SpeechSynthesisUtterance(data.speak);
|
||||
window.speechSynthesis.speak(texto);
|
||||
setTimeout(function() {
|
||||
location.reload();
|
||||
}, 6000);
|
||||
}
|
||||
}
|
||||
// const websocket = new WebSocket('ws://192.168.0.150:8765');
|
||||
// const nomeUsuario = document.getElementById('user-info').textContent;
|
||||
|
||||
// websocket.addEventListener('open', (event) => {
|
||||
// console.log('Conectado ao servidor WebSocket');
|
||||
// });
|
||||
|
||||
// websocket.addEventListener('message', (event) => {
|
||||
// const data = JSON.parse(event.data);
|
||||
|
||||
// switch (data.local) {
|
||||
// case 'cozinha':
|
||||
|
||||
// if (document.getElementById('Fila') !== null && data.tipo === 'add'){
|
||||
|
||||
|
||||
// var novoElemento = document.createElement('div');
|
||||
// novoElemento.innerHTML = data.message;
|
||||
// document.getElementById('Fila').appendChild(novoElemento);
|
||||
// let valorAtual = document.cookie.replace(/(?:(?:^|.*;\s*)notificacao\s*\=\s*([^;]*).*$)|^.*$/, "$1");
|
||||
// if (valorAtual === 'true') {
|
||||
// texto = new SpeechSynthesisUtterance(data.speak);
|
||||
// window.speechSynthesis.speak(texto);
|
||||
// // setTimeout(function() {
|
||||
// // location.reload();
|
||||
// // }, 6000);
|
||||
// }
|
||||
// }
|
||||
// else if (document.getElementById('obs-'+data.id) !== null && data.tipo === 'edit'){
|
||||
// const obs = document.getElementById('obs-'+data.id)
|
||||
// const card = obs.parentNode;
|
||||
// card.style.backgroundColor = 'rgb(243, 165, 75)';
|
||||
// obs.innerHTML = data.message;
|
||||
// let valorAtual = document.cookie.replace(/(?:(?:^|.*;\s*)notificacao\s*\=\s*([^;]*).*$)|^.*$/, "$1");
|
||||
|
||||
// if (valorAtual === 'true') {
|
||||
// texto = new SpeechSynthesisUtterance(data.speak);
|
||||
// window.speechSynthesis.speak(texto);
|
||||
// // setTimeout(function() {
|
||||
// // location.reload();
|
||||
// // }, 6000);
|
||||
// }
|
||||
// }
|
||||
// else if (document.getElementById('m-card-'+data.id) !== null && data.tipo === 'delete'){
|
||||
// // const card = document.getElementById('m-card-'+data.id)
|
||||
// // card.style.backgroundColor = 'rgb(253, 69, 69)';
|
||||
// let valorAtual = document.cookie.replace(/(?:(?:^|.*;\s*)notificacao\s*\=\s*([^;]*).*$)|^.*$/, "$1");
|
||||
// if (valorAtual === 'true') {
|
||||
// texto = new SpeechSynthesisUtterance(data.speak);
|
||||
// window.speechSynthesis.speak(texto);
|
||||
// setTimeout(function() {
|
||||
// location.reload();
|
||||
// }, 6000);
|
||||
// }
|
||||
// }
|
||||
|
||||
break;
|
||||
case 'praca':
|
||||
console.log('Mensagem para a praca:', data);
|
||||
break;
|
||||
case 'guarita':
|
||||
console.log('Mensagem para a guarita:', data);
|
||||
break;
|
||||
case 'balcao':
|
||||
console.log('Mensagem para a balcao:', data);
|
||||
break;
|
||||
default:
|
||||
console.log('Local desconhecido:', data);
|
||||
}
|
||||
// break;
|
||||
// case 'praca':
|
||||
// console.log('Mensagem para a praca:', data);
|
||||
// break;
|
||||
// case 'guarita':
|
||||
// console.log('Mensagem para a guarita:', data);
|
||||
// break;
|
||||
// case 'balcao':
|
||||
// console.log('Mensagem para a balcao:', data);
|
||||
// break;
|
||||
// default:
|
||||
// console.log('Local desconhecido:', data);
|
||||
// }
|
||||
|
||||
});
|
||||
websocket.addEventListener('error', (event) => {
|
||||
console.error('Erro no WebSocket:', event);
|
||||
});
|
||||
websocket.addEventListener('close', (event) => {
|
||||
console.log("conexão fechada");
|
||||
});
|
||||
// });
|
||||
// websocket.addEventListener('error', (event) => {
|
||||
// console.error('Erro no WebSocket:', event);
|
||||
// });
|
||||
// websocket.addEventListener('close', (event) => {
|
||||
// console.log("conexão fechada");
|
||||
// });
|
||||
|
||||
|
||||
|
||||
@@ -154,7 +125,7 @@ function openFullscreen() {
|
||||
}
|
||||
}
|
||||
|
||||
function showToast(message, type ,duration = 3000) {
|
||||
function showToast(message, type ,duration = 2500) {
|
||||
const toast = document.getElementById('toast');
|
||||
|
||||
if (type === 'success') {
|
||||
|
||||
Reference in New Issue
Block a user