Revert 34f90d
This commit is contained in:
588
index.html
588
index.html
@@ -375,8 +375,7 @@
|
|||||||
</footer> -->
|
</footer> -->
|
||||||
<img id="connectStatus" style="bottom: 15px; right: 15px; position: fixed; width: 50px;">
|
<img id="connectStatus" style="bottom: 15px; right: 15px; position: fixed; width: 50px;">
|
||||||
</main>
|
</main>
|
||||||
<img id="actionStatus" src="static/ico/statusok.png"
|
<img id="actionStatus" src="static/ico/statusok.png" style="z-index: 2048;margin: 0px;position: fixed;top: 50%;left: 50%;transform: translate(-50%, -50%);width: 100px;height: 100px;display: none;">
|
||||||
style="z-index: 2048;margin: 0px;position: fixed;top: 50%;left: 50%;transform: translate(-50%, -50%);width: 100px;height: 100px;display: none;">
|
|
||||||
<script src="static/showdown.min.js"></script>
|
<script src="static/showdown.min.js"></script>
|
||||||
<script src="static/jquery.js"></script>
|
<script src="static/jquery.js"></script>
|
||||||
<script src="static/gun.js"></script>
|
<script src="static/gun.js"></script>
|
||||||
@@ -467,7 +466,7 @@
|
|||||||
// const PUBLIC_KEY = "~cppGiuA4UFUPGTDoC-4r2izVC3F7MfpaCmF3iZdESN4.vntmjgbAVUpF_zfinYY6EKVFuuTYxh5xOrL4KmtdTmc"
|
// const PUBLIC_KEY = "~cppGiuA4UFUPGTDoC-4r2izVC3F7MfpaCmF3iZdESN4.vntmjgbAVUpF_zfinYY6EKVFuuTYxh5xOrL4KmtdTmc"
|
||||||
var TABLE = GROUPID + ":telesec.tech.eus";
|
var TABLE = GROUPID + ":telesec.tech.eus";
|
||||||
const RELAYS = [
|
const RELAYS = [
|
||||||
// "https://gun-es01.tech.eus/gun",
|
"https://gun-es01.tech.eus/gun",
|
||||||
"https://gun-es02.tech.eus/gun",
|
"https://gun-es02.tech.eus/gun",
|
||||||
"https://gun-es03.tech.eus/gun",
|
"https://gun-es03.tech.eus/gun",
|
||||||
"https://gun-es04.tech.eus/gun",
|
"https://gun-es04.tech.eus/gun",
|
||||||
@@ -529,9 +528,9 @@
|
|||||||
});
|
});
|
||||||
peerListEl.innerHTML = list.innerHTML;
|
peerListEl.innerHTML = list.innerHTML;
|
||||||
peerCountEl.innerText = peerCount;
|
peerCountEl.innerText = peerCount;
|
||||||
if (peerCount < 2) {
|
if (peerCount < 2){
|
||||||
document.getElementById("connectStatus").src = "static/ico/connect_ko.svg"
|
document.getElementById("connectStatus").src = "static/ico/connect_ko.svg"
|
||||||
gun.opt({ peers: RELAYS });
|
gun.opt({peers: RELAYS});
|
||||||
} else {
|
} else {
|
||||||
document.getElementById("connectStatus").src = "static/ico/connect_ok.svg"
|
document.getElementById("connectStatus").src = "static/ico/connect_ok.svg"
|
||||||
|
|
||||||
@@ -2102,334 +2101,289 @@
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
index: function () {
|
index: function () {
|
||||||
function setLayeredImages(comanda, key) {
|
|
||||||
// Base paths for each layer type (adjust paths as needed)
|
|
||||||
const basePaths = {
|
|
||||||
Selección: "static/ico/layered1/",
|
|
||||||
Café: "static/ico/layered1/",
|
|
||||||
Endulzante: "static/ico/layered1/",
|
|
||||||
Cafeina: "static/ico/layered1/",
|
|
||||||
Leche: "static/ico/layered1/",
|
|
||||||
};
|
|
||||||
|
|
||||||
// Map for Selección to filenames
|
|
||||||
const selectionMap = {
|
|
||||||
"ColaCao con leche": "Selección-ColaCao.png",
|
|
||||||
"Infusión": "Selección-Infusion.png",
|
|
||||||
"Café con leche": "Selección-CaféLeche.png",
|
|
||||||
"Solo Leche": "Selección-Leche.png",
|
|
||||||
"Solo café (sin leche)": "Selección-CaféSolo.png",
|
|
||||||
};
|
|
||||||
|
|
||||||
// Start div with relative positioning for layering
|
|
||||||
let html = `<div style="position: relative; width: 200px; height: 200px; background: white; display: inline-block;">`;
|
|
||||||
|
|
||||||
// Layer 1: Selección image
|
|
||||||
const selection = comanda["Selección"];
|
|
||||||
console.log(selection)
|
|
||||||
if (selectionMap[selection]) {
|
|
||||||
html += `<img id="img1-${key}" src="${basePaths.Selección + selectionMap[selection]}" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;">`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Layer 2: Café
|
|
||||||
if (comanda.Café) {
|
|
||||||
html += `<img id="img2-${key}" src="${basePaths.Café}Café-${comanda.Café}.png" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;">`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Layer 3: Endulzante
|
|
||||||
if (comanda.Endulzante) {
|
|
||||||
html += `<img id="img3-${key}" src="${basePaths.Endulzante}Azucar-${comanda.Endulzante}.png" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;">`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Layer 4: Cafeina
|
|
||||||
if (comanda.Cafeina) {
|
|
||||||
html += `<img id="img4-${key}" src="${basePaths.Cafeina}Cafeina-${comanda.Cafeina}.png" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;">`;
|
|
||||||
}
|
|
||||||
// Layer 5: Leche
|
|
||||||
if (comanda.Leche) {
|
|
||||||
html += `<img id="img5-${key}" src="${basePaths.Leche}Leche-${comanda.Leche}.png" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;">`;
|
|
||||||
}
|
|
||||||
// Layer 6: Temperatura
|
|
||||||
if (comanda.Temperatura) {
|
|
||||||
html += `<img id="img6-${key}" src="${basePaths.Leche}Temperatura-${comanda.Temperatura}.png" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;">`;
|
|
||||||
}
|
|
||||||
// Layer 7: Tamaño
|
|
||||||
if (comanda.Tamaño) {
|
|
||||||
html += `<img id="img7-${key}" src="${basePaths.Leche}Tamaño-${comanda.Tamaño}.png" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;">`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close div
|
|
||||||
html += "</div>";
|
|
||||||
|
|
||||||
return html;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
var tts = false;
|
var tts = false;
|
||||||
var sc_nobtn = "";
|
var sc_nobtn = ""
|
||||||
if (urlParams.get("sc_nobtn") == "yes") {
|
if (urlParams.get("sc_nobtn") == "yes") {
|
||||||
sc_nobtn = "pointer-events: none; opacity: 0.5";
|
sc_nobtn = "pointer-events: none; opacity: 0.5"
|
||||||
}
|
}
|
||||||
setTimeout(() => {
|
setTimeout(() => {tts = true; console.log("TTS Enabled"); toastr.info("Texto a voz disponible")}, 6500)
|
||||||
tts = true;
|
|
||||||
console.log("TTS Enabled");
|
|
||||||
toastr.info("Texto a voz disponible");
|
|
||||||
}, 6500);
|
|
||||||
|
|
||||||
const tablebody = safeuuid();
|
const tablebody = safeuuid();
|
||||||
var btn_new = safeuuid();
|
var btn_new = safeuuid();
|
||||||
var tts_check = safeuuid();
|
var tts_check = safeuuid();
|
||||||
container.innerHTML = `
|
container.innerHTML = `
|
||||||
<h1>SuperCafé</h1>
|
<h1>SuperCafé</h1>
|
||||||
<button id="${btn_new}" style="${sc_nobtn};">Nueva comanda</button>
|
<button id="${btn_new}" style="${sc_nobtn};">Nueva comanda</button>
|
||||||
<br>
|
<br>
|
||||||
<label>
|
<label>
|
||||||
<b>Habilitar avisos:</b>
|
<b>Habilitar avisos:</b>
|
||||||
<input type="checkbox" id="${tts_check}" style="height: 25px;width: 25px;">
|
<input type="checkbox" id="${tts_check}" style="height: 25px;width: 25px;">
|
||||||
</label>
|
</label>
|
||||||
<div id="scrolltable"><table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Zona</th>
|
|
||||||
<th>Persona</th>
|
|
||||||
<th style="${sc_nobtn};">Estado</th>
|
|
||||||
<th>Comanda</th>
|
|
||||||
<th>Precio</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody id="${tablebody}"></tbody>
|
|
||||||
</table></div>
|
|
||||||
`;
|
|
||||||
|
|
||||||
tableScroll("#scrolltable");
|
<div id="scrolltable"><table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Zona</th>
|
||||||
|
<th>Persona</th>
|
||||||
|
<th style="${sc_nobtn};">Estado</th>
|
||||||
|
<th>Comanda</th>
|
||||||
|
<th>Precio</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="${tablebody}">
|
||||||
|
</tbody>
|
||||||
|
</table></div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
tableScroll("#scrolltable") // id="scrolltable"
|
||||||
var tablebody_EL = document.getElementById(tablebody);
|
var tablebody_EL = document.getElementById(tablebody);
|
||||||
var rows2 = {};
|
var rows2 = {};
|
||||||
var renderedRows = {};
|
function render() {
|
||||||
var old = {};
|
function sorter(a, b) {
|
||||||
var old2 = {};
|
if (
|
||||||
|
SC_Personas[a.Persona].Region.toUpperCase() <
|
||||||
var DefaultPersona = {
|
SC_Personas[b.Persona].Region.toUpperCase()
|
||||||
Foto: "static/ico/user_generic.png",
|
) {
|
||||||
Nombre: "Desconocido??",
|
return -1;
|
||||||
Puntos: "1",
|
}
|
||||||
Region: "SIN AULA",
|
if (
|
||||||
Roles: "Cafe_SiCaf",
|
SC_Personas[a.Persona].Region.toUpperCase() >
|
||||||
SC_Anilla: "#000000",
|
SC_Personas[b.Persona].Region.toUpperCase()
|
||||||
markdown: "Fantasma",
|
) {
|
||||||
_key: "135733281028030249",
|
return 1;
|
||||||
};
|
}
|
||||||
|
return 0;
|
||||||
// Sorting: Fecha desc, then Region, then Nombre
|
|
||||||
function sortRows(a, b) {
|
|
||||||
const fechaA = new Date(a.Fecha);
|
|
||||||
const fechaB = new Date(b.Fecha);
|
|
||||||
if (fechaA < fechaB) return 1;
|
|
||||||
if (fechaA > fechaB) return -1;
|
|
||||||
|
|
||||||
const regionA = (SC_Personas[a.Persona]?.Region || "").toUpperCase();
|
|
||||||
const regionB = (SC_Personas[b.Persona]?.Region || "").toUpperCase();
|
|
||||||
if (regionA < regionB) return -1;
|
|
||||||
if (regionA > regionB) return 1;
|
|
||||||
|
|
||||||
const nombreA = (SC_Personas[a.Persona]?.Nombre || "").toUpperCase();
|
|
||||||
const nombreB = (SC_Personas[b.Persona]?.Nombre || "").toUpperCase();
|
|
||||||
if (nombreA < nombreB) return -1;
|
|
||||||
if (nombreA > nombreB) return 1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
function createRow(data) {
|
|
||||||
var persona = SC_Personas[data.Persona] || DefaultPersona;
|
|
||||||
var pcalc = SC_priceCalc(JSON.parse(data.Comanda));
|
|
||||||
var precio = pcalc[0];
|
|
||||||
var resumen = pcalc[1];
|
|
||||||
|
|
||||||
var new_tr = document.createElement("tr");
|
|
||||||
new_tr.id = "row-" + data._key;
|
|
||||||
if (sc_nobtn != "") {
|
|
||||||
new_tr.style.pointerEvents = "none";
|
|
||||||
new_tr.style.opacity = "0.5";
|
|
||||||
}
|
}
|
||||||
const ESTADOS = ["Pedido", "En preparación", "Listo", "Entregado", "Deuda", "Pagado"];
|
var tablebody_EL = document.getElementById(tablebody);
|
||||||
|
tablebody_EL.innerHTML = "";
|
||||||
function createEstadoButtons(currentEstado, key) {
|
var DefaultPersona = {
|
||||||
return ESTADOS.map(estado => {
|
Foto: "static/ico/user_generic.png",
|
||||||
const active = estado === currentEstado ? 'disabled class="rojo"' : '';
|
Nombre: "Desconocido??",
|
||||||
return `<button ${active} data-key="${key}" data-estado="${estado}" style="margin:2px;">${estado}</button><br>`;
|
Puntos: "1",
|
||||||
}).join(" ");
|
Region: "SIN AULA",
|
||||||
}
|
Roles: "Cafe_SiCaf",
|
||||||
|
SC_Anilla: "#000000",
|
||||||
// Set color for estado buttons and row background (simplified to text here)
|
markdown: "Fantasma",
|
||||||
var estadoClass = "";
|
_key: "135733281028030249",
|
||||||
var bgColor = "";
|
|
||||||
switch (data.Estado) {
|
|
||||||
case "Pedido": estadoClass = "rojo"; break;
|
|
||||||
case "En preparación": estadoClass = "rojo"; bgColor = "#FFCCCB"; break;
|
|
||||||
case "Listo": estadoClass = "rojo"; bgColor = "gold"; break;
|
|
||||||
case "Entregado": estadoClass = "rojo"; bgColor = "lightgreen"; break;
|
|
||||||
case "Deuda": estadoClass = "rojo"; bgColor = "hotpink"; break;
|
|
||||||
case "Pagado": estadoClass = ""; break;
|
|
||||||
}
|
|
||||||
new_tr.style.backgroundColor = bgColor;
|
|
||||||
|
|
||||||
new_tr.innerHTML = `
|
|
||||||
<td>${persona.Region.toUpperCase() || "?"}<br><br>${data.Fecha}</td>
|
|
||||||
<td class="TextBorder" style="background-color: ${persona.SC_Anilla}; text-align: center; font-size: 17px;">
|
|
||||||
<img src="${persona.Foto}" height="50"><br>${persona.Nombre}<br>
|
|
||||||
<span style="font-size: 25px;">${persona.Puntos} pts.</span>
|
|
||||||
</td>
|
|
||||||
<td style="font-size: 17px;">
|
|
||||||
${createEstadoButtons(data.Estado, data._key)}
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
${setLayeredImages(JSON.parse(data.Comanda), data._key)}
|
|
||||||
<pre style="font-size: 17px; display: inline-block;">${SC_parse(JSON.parse(data.Comanda))}<hr>${data.Notas}</pre>
|
|
||||||
</td>
|
|
||||||
<td><pre>${resumen}</pre>${persona.Puntos >= 10 ? "<br><span style='font-size:20px;'>Gratis! Usando puntos</span>" : `<br><span style='font-size:20px;'>Pagando ${precio}c</span>`}</td>
|
|
||||||
`;
|
|
||||||
|
|
||||||
// Add click to set URL hash
|
|
||||||
new_tr.onclick = () => {
|
|
||||||
setUrlHash("supercafe," + data._key);
|
|
||||||
};
|
};
|
||||||
|
Object.values(rows2)
|
||||||
|
.sort(sorter)
|
||||||
|
.forEach((data) => {
|
||||||
|
var btn_Pedido = safeuuid();
|
||||||
|
var btn_Preparacion = safeuuid();
|
||||||
|
var btn_Hecho = safeuuid();
|
||||||
|
var btn_Entregado = safeuuid();
|
||||||
|
var btn_Deuda = safeuuid();
|
||||||
|
var btn_Pagado = safeuuid();
|
||||||
|
var span_precio = safeuuid();
|
||||||
|
var persona = SC_Personas[data.Persona] || DefaultPersona;
|
||||||
|
var new_tr = document.createElement("tr");
|
||||||
|
var pcalc = SC_priceCalc(JSON.parse(data.Comanda));
|
||||||
|
var precio = pcalc[0]
|
||||||
|
var resumen = pcalc[1]
|
||||||
|
if (persona == DefaultPersona) {
|
||||||
|
data.Persona = "135733281028030249";
|
||||||
|
}
|
||||||
|
if (sc_nobtn != "") {new_tr.style.pointerEvents = "none"}
|
||||||
|
|
||||||
return new_tr;
|
new_tr.innerHTML = `
|
||||||
}
|
<td>${persona.Region.toUpperCase() || "?"}<br><br>${data.Fecha}</td>
|
||||||
|
<td class="TextBorder" style="background-color: ${persona.SC_Anilla
|
||||||
function insertSortedRow(tr, data) {
|
}; text-align: center; font-size: 17px;"><img src="${persona.Foto ||
|
||||||
// Insert `tr` into `tablebody_EL` sorted per sortRows
|
"static/ico/user_generic.png"
|
||||||
const rows = Array.from(tablebody_EL.children);
|
}" height="50"><br> ${persona.Nombre || ""
|
||||||
let inserted = false;
|
}<br> <span style="font-size: 25px;">${persona.Puntos || "0"
|
||||||
for (let i = 0; i < rows.length; i++) {
|
} pts.</span></td>
|
||||||
let key = rows[i].id.replace("row-", "");
|
<td style="font-size: 17px; ${sc_nobtn};">
|
||||||
if (!rows2[key]) continue;
|
<button id="${btn_Pedido}" class="">Pedido</button>
|
||||||
if (sortRows(data, rows2[key]) < 0) {
|
<br><button id="${btn_Preparacion}" class="">En preparación</button>
|
||||||
tablebody_EL.insertBefore(tr, rows[i]);
|
<br><button id="${btn_Hecho}" class="">Listo</button>
|
||||||
inserted = true;
|
<br><button id="${btn_Entregado}" class="">Entregado</button>
|
||||||
break;
|
<br><button id="${btn_Deuda}" class="">Deuda</button>
|
||||||
}
|
<br><button id="${btn_Pagado}" class="">Pagado</button></td>
|
||||||
}
|
<td><pre style="font-size: 17px;">${SC_parse(JSON.parse(data.Comanda)) +
|
||||||
if (!inserted) {
|
"<hr>" +
|
||||||
tablebody_EL.appendChild(tr);
|
data.Notas
|
||||||
}
|
}</pre></td>
|
||||||
}
|
<td><pre>${resumen}</pre><span style="font-size: 20px;" id="${span_precio}"></span></td>
|
||||||
|
`;
|
||||||
function renderRow(data) {
|
tablebody_EL.append(new_tr);
|
||||||
// Create and insert sorted row
|
if (data.Estado == "Pedido") {
|
||||||
const tr = createRow(data);
|
document.getElementById(btn_Pedido).classList = "rojo";
|
||||||
insertSortedRow(tr, data);
|
}
|
||||||
renderedRows[data._key] = tr;
|
if (data.Estado == "En preparación") {
|
||||||
}
|
document.getElementById(btn_Preparacion).classList = "rojo";
|
||||||
|
new_tr.style.backgroundColor = "#FFCCCB";
|
||||||
function updateRow(data) {
|
}
|
||||||
const tr = renderedRows[data._key];
|
if (data.Estado == "Listo") {
|
||||||
if (!tr) return;
|
new_tr.style.backgroundColor = "gold";
|
||||||
const ESTADOS = ["Pedido", "En preparación", "Listo", "Entregado", "Deuda", "Pagado"];
|
document.getElementById(btn_Hecho).classList = "rojo";
|
||||||
|
}
|
||||||
function createEstadoButtons(currentEstado, key) {
|
if (data.Estado == "Entregado") {
|
||||||
return ESTADOS.map(estado => {
|
document.getElementById(btn_Entregado).classList = "rojo";
|
||||||
const active = estado === currentEstado ? 'disabled class="rojo"' : '';
|
new_tr.style.backgroundColor = "lightgreen";
|
||||||
return `<button ${active} data-key="${key}" data-estado="${estado}" style="margin:2px;">${estado}</button><br>`;
|
}
|
||||||
}).join(" ");
|
if (data.Estado == "Deuda") {
|
||||||
}
|
document.getElementById(btn_Deuda).classList = "rojo";
|
||||||
|
new_tr.style.backgroundColor = "hotpink";
|
||||||
var persona = SC_Personas[data.Persona] || DefaultPersona;
|
}
|
||||||
var pcalc = SC_priceCalc(JSON.parse(data.Comanda));
|
new_tr.onclick = () => {
|
||||||
var precio = pcalc[0];
|
setUrlHash("supercafe," + data._key);
|
||||||
var resumen = pcalc[1];
|
};
|
||||||
|
if (SC_Personas[data.Persona].Puntos >= 10) {
|
||||||
tr.style.pointerEvents = sc_nobtn ? "none" : "";
|
document.getElementById(span_precio).innerHTML =
|
||||||
tr.style.opacity = sc_nobtn ? "0.5" : "";
|
"Gratis!<br> Usando puntos";
|
||||||
|
} else {
|
||||||
// Update background and estado
|
document.getElementById(span_precio).innerHTML = `Pagando ${precio}c`
|
||||||
var bgColor = "";
|
}
|
||||||
switch (data.Estado) {
|
// Acciónes
|
||||||
case "Pedido": tr.style.backgroundColor = ""; break;
|
document.getElementById(btn_Pedido).onclick = () => {
|
||||||
case "En preparación": bgColor = "#FFCCCB"; break;
|
window.event.cancelBubble = true;
|
||||||
case "Listo": bgColor = "gold"; break;
|
window.event.stopPropagation();
|
||||||
case "Entregado": bgColor = "lightgreen"; break;
|
data.Estado = "Pedido";
|
||||||
case "Deuda": bgColor = "hotpink"; break;
|
var enc = SEA.encrypt(data, SECRET, (encrypted) => {
|
||||||
case "Pagado": bgColor = ""; break;
|
betterGunPut(
|
||||||
}
|
gun.get(TABLE).get("supercafe").get(data._key),
|
||||||
tr.style.backgroundColor = bgColor;
|
encrypted
|
||||||
|
);
|
||||||
// Update cells
|
toastr.success("Guardado!");
|
||||||
tr.cells[0].innerHTML = `<p style="white-space: nowrap;">${persona.Region.toUpperCase() || "?"}<br><br>${data.Fecha}</p>`;
|
});
|
||||||
tr.cells[1].innerHTML = `<img src="${persona.Foto}" height="50"><br>${persona.Nombre}<br><span style="font-size: 25px;">${persona.Puntos} pts.</span>`;
|
};
|
||||||
tr.cells[2].innerHTML = createEstadoButtons(data.Estado, data._key);
|
document.getElementById(btn_Preparacion).onclick = () => {
|
||||||
tr.cells[3].innerHTML = `
|
window.event.cancelBubble = true;
|
||||||
${setLayeredImages(JSON.parse(data.Comanda), data._key)}
|
window.event.stopPropagation();
|
||||||
<pre style="font-size: 17px; display: inline-block;">${SC_parse(JSON.parse(data.Comanda))}<hr>${data.Notas}</pre>`;
|
data.Estado = "En preparación";
|
||||||
tr.cells[4].innerHTML = `<pre>${resumen}</pre>${persona.Puntos >= 10 ? "<br><span style='font-size:20px;'>Gratis! Usando puntos</span>" : `<br><span style='font-size:20px;'>Pagando ${precio}c</span>`}`;
|
var enc = SEA.encrypt(data, SECRET, (encrypted) => {
|
||||||
|
betterGunPut(
|
||||||
// Reposition if necessary (in case sorting keys changed)
|
gun.get(TABLE).get("supercafe").get(data._key),
|
||||||
tablebody_EL.removeChild(tr);
|
encrypted
|
||||||
insertSortedRow(tr, data);
|
);
|
||||||
}
|
toastr.success("Guardado!");
|
||||||
|
});
|
||||||
function speakTTS(data) {
|
};
|
||||||
if (tts && document.getElementById(tts_check).checked) {
|
document.getElementById(btn_Hecho).onclick = () => {
|
||||||
var persona = SC_Personas[data.Persona] || DefaultPersona;
|
window.event.cancelBubble = true;
|
||||||
var comanda = JSON.parse(data.Comanda);
|
window.event.stopPropagation();
|
||||||
var msg = `Comanda de ${persona.Region}. ${comanda["Selección"]}. ${persona.Nombre}. Estado: ${data.Estado}`;
|
data.Estado = "Listo";
|
||||||
var utterance = new SpeechSynthesisUtterance(msg);
|
var enc = SEA.encrypt(data, SECRET, (encrypted) => {
|
||||||
utterance.rate = 0.9;
|
betterGunPut(
|
||||||
speechSynthesis.speak(utterance);
|
gun.get(TABLE).get("supercafe").get(data._key),
|
||||||
}
|
encrypted
|
||||||
}
|
);
|
||||||
|
toastr.success("Guardado!");
|
||||||
function add_row(data, key) {
|
});
|
||||||
if (data != null) {
|
};
|
||||||
data["_key"] = key;
|
document.getElementById(btn_Entregado).onclick = () => {
|
||||||
|
window.event.cancelBubble = true;
|
||||||
if (old2[key] === undefined) old2[key] = "";
|
window.event.stopPropagation();
|
||||||
if (old[key] === undefined) old[key] = "";
|
data.Estado = "Entregado";
|
||||||
|
var enc = SEA.encrypt(data, SECRET, (encrypted) => {
|
||||||
var estadoChanged = old[key] !== data.Estado;
|
betterGunPut(
|
||||||
var comandaChanged = old2[key] !== data.Comanda;
|
gun.get(TABLE).get("supercafe").get(data._key),
|
||||||
|
encrypted
|
||||||
rows2[key] = data;
|
);
|
||||||
|
toastr.success("Guardado!");
|
||||||
if (!renderedRows[key]) {
|
});
|
||||||
renderRow(data);
|
};
|
||||||
} else if (estadoChanged || comandaChanged) {
|
document.getElementById(btn_Deuda).onclick = () => {
|
||||||
updateRow(data);
|
window.event.cancelBubble = true;
|
||||||
}
|
window.event.stopPropagation();
|
||||||
|
data.Estado = "Deuda";
|
||||||
if (estadoChanged) {
|
var enc = SEA.encrypt(data, SECRET, (encrypted) => {
|
||||||
speakTTS(data);
|
betterGunPut(
|
||||||
}
|
gun.get(TABLE).get("supercafe").get(data._key),
|
||||||
|
encrypted
|
||||||
old[key] = data.Estado;
|
);
|
||||||
old2[key] = data.Comanda;
|
toastr.success("Guardado!");
|
||||||
} else {
|
});
|
||||||
// Remove row
|
};
|
||||||
if (renderedRows[key]) {
|
document.getElementById(btn_Pagado).onclick = () => {
|
||||||
renderedRows[key].remove();
|
window.event.cancelBubble = true;
|
||||||
delete renderedRows[key];
|
window.event.stopPropagation();
|
||||||
}
|
if (!confirm("¿Quieres marcar como pagado? - Se borrara la comanda y se actualizarán los puntos.")) {return}
|
||||||
delete rows2[key];
|
data.Estado = "Pagado";
|
||||||
delete old[key];
|
betterGunPut(
|
||||||
delete old2[key];
|
gun.get(TABLE).get("supercafe").get(data._key),
|
||||||
}
|
null
|
||||||
}
|
);
|
||||||
|
//setUrlHash("personas");
|
||||||
gun.get(TABLE).get("supercafe").map().on((data, key, _msg, _ev) => {
|
//setUrlHash("supercafe");
|
||||||
if (typeof data === "string") {
|
toastr.success("Guardado!");
|
||||||
SEA.decrypt(data, SECRET, (decData) => {
|
if (SC_Personas[data.Persona].Puntos >= 10) {
|
||||||
add_row(decData, key);
|
SC_Personas[data.Persona].Puntos -= 10;
|
||||||
|
toastr.success(
|
||||||
|
"¡Comada gratis para " +
|
||||||
|
SC_Personas[data.Persona].Nombre +
|
||||||
|
"!"
|
||||||
|
);
|
||||||
|
toastr.success(
|
||||||
|
"¡Comada gratis para " +
|
||||||
|
SC_Personas[data.Persona].Nombre +
|
||||||
|
"!"
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
SC_Personas[data.Persona].Puntos += 1;
|
||||||
|
toastr.success("¡Comada DE PAGO!");
|
||||||
|
}
|
||||||
|
SEA.encrypt(
|
||||||
|
SC_Personas[data.Persona],
|
||||||
|
SECRET,
|
||||||
|
(encrypted) => {
|
||||||
|
betterGunPut(
|
||||||
|
gun.get(TABLE).get("personas").get(data.Persona),
|
||||||
|
encrypted
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
});
|
});
|
||||||
} else {
|
}
|
||||||
add_row(data, key);
|
var old = {};
|
||||||
}
|
gun
|
||||||
});
|
.get(TABLE)
|
||||||
|
.get("supercafe")
|
||||||
|
.map()
|
||||||
|
.on((data, key, _msg, _ev) => {
|
||||||
|
EVENTLISTENER = _ev;
|
||||||
|
//alert("sc_map_on")
|
||||||
|
function add_row(data, key) {
|
||||||
|
if (data != null) {
|
||||||
|
data["_key"] = key;
|
||||||
|
console.log(old[key], data.Estado)
|
||||||
|
if (old[key] == undefined) {
|
||||||
|
old[key] = "";
|
||||||
|
}
|
||||||
|
if (old[key] != data.Estado) {
|
||||||
|
console.log("SC:Updated:", data)
|
||||||
|
if (tts && document.getElementById(tts_check).checked) {
|
||||||
|
var msg = `Comanda de ${SC_Personas[data.Persona].Region}. - ${JSON.parse(data.Comanda)["Selección"]}. - ${SC_Personas[data.Persona].Nombre}. - ${data.Estado}`
|
||||||
|
console.log("TTS: " + msg)
|
||||||
|
let utterance = new SpeechSynthesisUtterance(msg);
|
||||||
|
utterance.rate = 0.9
|
||||||
|
// utterance.voice = speechSynthesis.getVoices()[7]
|
||||||
|
speechSynthesis.speak(utterance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rows2[key] = data;
|
||||||
|
old[key] = data.Estado;
|
||||||
|
} else {
|
||||||
|
// console.log("delete", key);
|
||||||
|
delete rows2[key];
|
||||||
|
delete old[key];
|
||||||
|
}
|
||||||
|
render();
|
||||||
|
}
|
||||||
|
if (typeof data == "string") {
|
||||||
|
SEA.decrypt(data, SECRET, (data) => {
|
||||||
|
add_row(data, key);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
add_row(data, key);
|
||||||
|
}
|
||||||
|
});
|
||||||
document.getElementById(btn_new).onclick = () => {
|
document.getElementById(btn_new).onclick = () => {
|
||||||
SC_newCommand();
|
setUrlHash("supercafe," + safeuuid(""));
|
||||||
};
|
};
|
||||||
}
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
notificaciones: {
|
notificaciones: {
|
||||||
navcss: "btn6",
|
navcss: "btn6",
|
||||||
|
|||||||
Reference in New Issue
Block a user