This commit is contained in:
naielv
2025-07-30 22:38:25 +02:00
parent 970b1dddf7
commit 03c132a6bd
8 changed files with 348 additions and 266 deletions

View File

@@ -34,6 +34,10 @@ if (urlParams.get("login") != null) {
//location.search = ""; //location.search = "";
} }
function open_page(params) { function open_page(params) {
if (SUB_LOGGED_IN != true) {
PAGES["login"].index();
return;
}
if (params == "") { if (params == "") {
params = "index"; params = "index";
} }

View File

@@ -215,7 +215,9 @@ function addCategory_Personas(
options, options,
defaultval, defaultval,
change_cb = () => {}, change_cb = () => {},
label = "Persona" label = "Persona",
open_default = false,
default_empty_text = "- Lista Vacia -"
) { ) {
var details_0 = document.createElement("details"); // children: img_0, summary_0 var details_0 = document.createElement("details"); // children: img_0, summary_0
//details_0.open = true; //details_0.open = true;
@@ -233,6 +235,9 @@ function addCategory_Personas(
span_0.append(p.Nombre || "", " ", img_0); span_0.append(p.Nombre || "", " ", img_0);
summary_0.append(label, span_0); summary_0.append(label, span_0);
details_0.append(summary_0, document.createElement("br")); details_0.append(summary_0, document.createElement("br"));
if (open_default == true) {
details_0.open = true;
}
details_0.style.textAlign = "center"; details_0.style.textAlign = "center";
details_0.style.margin = "5px"; details_0.style.margin = "5px";
details_0.style.padding = "5px"; details_0.style.padding = "5px";
@@ -302,6 +307,11 @@ function addCategory_Personas(
//btn.style.fontSize="17.5px" //btn.style.fontSize="17.5px"
details_0.append(btn); details_0.append(btn);
}); });
if (Object.entries(options).length == 0) {
var btn = document.createElement("b");
btn.append(default_empty_text);
details_0.append(btn);
}
} }
const SC_actions_icons = { const SC_actions_icons = {
Tamaño: "static/ico/sizes.png", Tamaño: "static/ico/sizes.png",
@@ -493,23 +503,21 @@ gun
.get("personas") .get("personas")
.map() .map()
.on((data, key, _msg, _ev) => { .on((data, key, _msg, _ev) => {
if (data != null) { function add_row(data, key) {
function add_row(data, key) { if (data != null) {
if (data != null) { data["_key"] = key;
data["_key"] = key; SC_Personas[key] = data;
SC_Personas[key] = data;
} else {
delete SC_Personas[key];
}
}
if (typeof data == "string") {
SEA.decrypt(data, SECRET, (data) => {
add_row(data, key);
});
} else { } else {
add_row(data, key); delete SC_Personas[key];
} }
} }
if (typeof data == "string") {
SEA.decrypt(data, SECRET, (data) => {
add_row(data, key);
});
} else {
add_row(data, key);
}
}); });
function SC_parse(json) { function SC_parse(json) {
@@ -656,7 +664,6 @@ function TS_IndexElement(
} }
return 0; return 0;
} }
var tablebody_EL = document.getElementById(tablebody);
tablebody_EL.innerHTML = ""; tablebody_EL.innerHTML = "";
Object.values(rows) Object.values(rows)
.sort(sorter) .sort(sorter)
@@ -675,34 +682,39 @@ function TS_IndexElement(
config.forEach((key) => { config.forEach((key) => {
switch (key.type) { switch (key.type) {
case "raw": case "raw":
const tdRaw = document.createElement('td'); const tdRaw = document.createElement("td");
const rawContent = (data[key.key] || key.default || "").replace(/\n/g, '<br>'); const rawContent = (data[key.key] || key.default || "").replace(
/\n/g,
"<br>"
);
tdRaw.innerHTML = rawContent; tdRaw.innerHTML = rawContent;
new_tr.appendChild(tdRaw); new_tr.appendChild(tdRaw);
break; break;
case "comanda": case "comanda":
const tdComanda = document.createElement('td'); const tdComanda = document.createElement("td");
const parsedComanda = JSON.parse(data.Comanda); const parsedComanda = JSON.parse(data.Comanda);
const precio = SC_priceCalc(parsedComanda)[0]; const precio = SC_priceCalc(parsedComanda)[0];
// Create a temporary div to parse the HTML from setLayeredImages // Create a temporary div to parse the HTML from setLayeredImages
const tempDiv = document.createElement('div'); const tempDiv = document.createElement("div");
tempDiv.innerHTML = setLayeredImages(parsedComanda, data._key); tempDiv.innerHTML = setLayeredImages(parsedComanda, data._key);
tdComanda.appendChild(tempDiv.firstChild); tdComanda.appendChild(tempDiv.firstChild);
const pre = document.createElement('pre'); const pre = document.createElement("pre");
pre.style.fontSize = '15px'; pre.style.fontSize = "15px";
pre.style.display = 'inline-block'; pre.style.display = "inline-block";
const spanPrecio = document.createElement('span'); const spanPrecio = document.createElement("span");
spanPrecio.style.fontSize = '20px'; spanPrecio.style.fontSize = "20px";
spanPrecio.innerHTML = SC_Personas[data.Persona].Puntos >= 10 ? spanPrecio.innerHTML =
`Total: Gratis!(${precio}c)` : SC_Personas[data.Persona].Puntos >= 10
`Total: ${precio}c`; ? `Total: Gratis!(${precio}c)`
: `Total: ${precio}c`;
pre.appendChild(spanPrecio); pre.appendChild(spanPrecio);
pre.appendChild(document.createTextNode('\n')); pre.appendChild(document.createTextNode("\n"));
pre.innerHTML += SC_parse_short(parsedComanda) + "<hr>" + data.Notas; pre.innerHTML +=
SC_parse_short(parsedComanda) + "<hr>" + data.Notas;
tdComanda.appendChild(pre); tdComanda.appendChild(pre);
new_tr.appendChild(tdComanda); new_tr.appendChild(tdComanda);
@@ -712,19 +724,19 @@ function TS_IndexElement(
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";
} }
const td = document.createElement('td'); const td = document.createElement("td");
td.style.fontSize = '17px'; td.style.fontSize = "17px";
if (sc_nobtn) { if (sc_nobtn) {
td.style.pointerEvents = 'none'; td.style.pointerEvents = "none";
td.style.opacity = '0.5'; td.style.opacity = "0.5";
} }
// Create buttons // Create buttons
const createButton = (text, state) => { const createButton = (text, state) => {
const button = document.createElement('button'); const button = document.createElement("button");
button.textContent = text; button.textContent = text;
if (data.Estado === state) { if (data.Estado === state) {
button.className = 'rojo'; button.className = "rojo";
} }
button.onclick = (event) => { button.onclick = (event) => {
event.preventDefault(); event.preventDefault();
@@ -741,20 +753,24 @@ function TS_IndexElement(
// Create all buttons // Create all buttons
const buttons = [ const buttons = [
createButton('Pedido', 'Pedido'), createButton("Pedido", "Pedido"),
createButton('En preparación', 'En preparación'), createButton("En preparación", "En preparación"),
createButton('Listo', 'Listo'), createButton("Listo", "Listo"),
createButton('Entregado', 'Entregado'), createButton("Entregado", "Entregado"),
createButton('Deuda', 'Deuda') createButton("Deuda", "Deuda"),
]; ];
// Create paid button separately due to different behavior // Create paid button separately due to different behavior
const paidButton = document.createElement('button'); const paidButton = document.createElement("button");
paidButton.textContent = 'Pagado'; paidButton.textContent = "Pagado";
paidButton.onclick = (event) => { paidButton.onclick = (event) => {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
if (!confirm("¿Quieres marcar como pagado? - Se borrara la comanda y se actualizarán los puntos.")) { if (
!confirm(
"¿Quieres marcar como pagado? - Se borrara la comanda y se actualizarán los puntos."
)
) {
return false; return false;
} }
data.Estado = "Pagado"; data.Estado = "Pagado";
@@ -762,22 +778,33 @@ function TS_IndexElement(
toastr.success("Guardado!"); toastr.success("Guardado!");
if (SC_Personas[data.Persona].Puntos >= 10) { if (SC_Personas[data.Persona].Puntos >= 10) {
SC_Personas[data.Persona].Puntos -= 10; SC_Personas[data.Persona].Puntos -= 10;
toastr.success("¡Comada gratis para " + SC_Personas[data.Persona].Nombre + "!"); toastr.success(
toastr.success("¡Comada gratis para " + SC_Personas[data.Persona].Nombre + "!"); "¡Comada gratis para " +
SC_Personas[data.Persona].Nombre +
"!"
);
toastr.success(
"¡Comada gratis para " +
SC_Personas[data.Persona].Nombre +
"!"
);
} else { } else {
SC_Personas[data.Persona].Puntos += 1; SC_Personas[data.Persona].Puntos += 1;
toastr.success("¡Comada DE PAGO!"); toastr.success("¡Comada DE PAGO!");
} }
SEA.encrypt(SC_Personas[data.Persona], SECRET, (encrypted) => { SEA.encrypt(SC_Personas[data.Persona], SECRET, (encrypted) => {
betterGunPut(gun.get(TABLE).get("personas").get(data.Persona), encrypted); betterGunPut(
gun.get(TABLE).get("personas").get(data.Persona),
encrypted
);
}); });
return false; return false;
}; };
// Add all buttons to td with line breaks between // Add all buttons to td with line breaks between
buttons.forEach(button => { buttons.forEach((button) => {
td.appendChild(button); td.appendChild(button);
td.appendChild(document.createElement('br')); td.appendChild(document.createElement("br"));
}); });
td.appendChild(paidButton); td.appendChild(paidButton);
new_tr.appendChild(td); new_tr.appendChild(td);
@@ -786,41 +813,45 @@ function TS_IndexElement(
break; break;
case "persona": case "persona":
const persona = SC_Personas[data[key.key]]; const persona = SC_Personas[data[key.key]];
const regco = stringToColour((persona.Region || "?").toLowerCase()); const regco = stringToColour(
(persona.Region || "?").toLowerCase()
);
const tdPersona = document.createElement('td'); const tdPersona = document.createElement("td");
tdPersona.style.textAlign = 'center'; tdPersona.style.textAlign = "center";
tdPersona.style.fontSize = '20px'; tdPersona.style.fontSize = "20px";
tdPersona.style.backgroundColor = regco; tdPersona.style.backgroundColor = regco;
tdPersona.style.color = colorIsDarkAdvanced(regco); tdPersona.style.color = colorIsDarkAdvanced(regco);
const regionSpan = document.createElement('span'); const regionSpan = document.createElement("span");
regionSpan.style.fontSize = '40px'; regionSpan.style.fontSize = "40px";
regionSpan.style.textTransform = 'capitalize'; regionSpan.style.textTransform = "capitalize";
regionSpan.textContent = (persona.Region || "?").toLowerCase(); regionSpan.textContent = (persona.Region || "?").toLowerCase();
tdPersona.appendChild(regionSpan); tdPersona.appendChild(regionSpan);
tdPersona.appendChild(document.createElement('br')); tdPersona.appendChild(document.createElement("br"));
const infoSpan = document.createElement('span'); const infoSpan = document.createElement("span");
infoSpan.style.backgroundColor = 'white'; infoSpan.style.backgroundColor = "white";
infoSpan.style.border = '2px solid black'; infoSpan.style.border = "2px solid black";
infoSpan.style.borderRadius = '5px'; infoSpan.style.borderRadius = "5px";
infoSpan.style.display = 'inline-block'; infoSpan.style.display = "inline-block";
infoSpan.style.padding = '5px'; infoSpan.style.padding = "5px";
infoSpan.style.color = 'black'; infoSpan.style.color = "black";
const img = document.createElement('img'); const img = document.createElement("img");
img.src = persona.Foto || "static/ico/user_generic.png"; img.src = persona.Foto || "static/ico/user_generic.png";
img.height = 70; img.height = 70;
infoSpan.appendChild(img); infoSpan.appendChild(img);
infoSpan.appendChild(document.createElement('br')); infoSpan.appendChild(document.createElement("br"));
infoSpan.appendChild(document.createTextNode(persona.Nombre || "")); infoSpan.appendChild(
document.createTextNode(persona.Nombre || "")
);
infoSpan.appendChild(document.createElement('br')); infoSpan.appendChild(document.createElement("br"));
const pointsSpan = document.createElement('span'); const pointsSpan = document.createElement("span");
pointsSpan.style.fontSize = '17px'; pointsSpan.style.fontSize = "17px";
pointsSpan.textContent = (persona.Puntos || "0") + " puntos."; pointsSpan.textContent = (persona.Puntos || "0") + " puntos.";
infoSpan.appendChild(pointsSpan); infoSpan.appendChild(pointsSpan);
@@ -839,23 +870,21 @@ function TS_IndexElement(
} }
ref.map().on((data, key, _msg, _ev) => { ref.map().on((data, key, _msg, _ev) => {
EVENTLISTENER = _ev; EVENTLISTENER = _ev;
if (data != null) { function add_row(data, key) {
function add_row(data, key) { if (data != null) {
if (data != null) { data["_key"] = key;
data["_key"] = key; rows[key] = data;
rows[key] = data;
} else {
delete rows[key];
}
render();
}
if (typeof data == "string") {
SEA.decrypt(data, SECRET, (data) => {
add_row(data, key);
});
} else { } else {
add_row(data, key); delete rows[key];
} }
render();
}
if (typeof data == "string") {
SEA.decrypt(data, SECRET, (data) => {
add_row(data, key);
});
} else {
add_row(data, key);
} }
}); });
} }
@@ -863,6 +892,9 @@ function TS_IndexElement(
const PAGES = {}; const PAGES = {};
document.addEventListener("DOMContentLoaded", () => { document.addEventListener("DOMContentLoaded", () => {
Object.keys(PAGES).forEach((key) => { Object.keys(PAGES).forEach((key) => {
if (PAGES[key].Esconder == true) {
return;
}
var a = document.createElement("a"); var a = document.createElement("a");
a.className = "button " + PAGES[key].navcss; a.className = "button " + PAGES[key].navcss;
a.href = "#" + key; a.href = "#" + key;

View File

@@ -20,3 +20,6 @@ const RELAYS = [
"https://gun.defucc.me/gun", "https://gun.defucc.me/gun",
]; ];
var SECRET = ""; var SECRET = "";
var SUB_LOGGED_IN = false;
var SUB_LOGGED_IN_DETAILS = false;
var SUB_LOGGED_IN_ID = false;

View File

@@ -141,6 +141,7 @@
<script src="gun_init.js"></script> <script src="gun_init.js"></script>
<script src="app_logic.js"></script> <script src="app_logic.js"></script>
<script src="app_modules.js"></script> <script src="app_modules.js"></script>
<script src="page__login.js"></script>
<script src="page__index.js"></script> <script src="page__index.js"></script>
<script src="page__importar.js"></script> <script src="page__importar.js"></script>
<script src="page__exportar.js"></script> <script src="page__exportar.js"></script>

50
src/page__login.js Normal file
View File

@@ -0,0 +1,50 @@
PAGES.login = {
Esconder: true,
Title: "Login",
index: function (mid) {
var field_persona = safeuuid();
var btn_guardar = safeuuid();
var btn_reload = safeuuid();
var div_actions = safeuuid();
container.innerHTML = `
<h1>Iniciar sesión</h1>
<fieldset>
<legend>Valores</legend>
<input type="hidden" id="${field_persona}">
<div id="${div_actions}"></div>
<button class="btn5" id="${btn_guardar}">Acceder</button>
<button class="btn1" id="${btn_reload}">Recargar lista</button>
</fieldset>
<a style="color: rgb(240,240,240)">Acceso sin cuenta</a>
`;
var divact = document.getElementById(div_actions);
addCategory_Personas(
divact,
SC_Personas,
"",
(value) => {
document.getElementById(field_persona).value = value;
},
"¿Quién eres?",
true,
"- Pulsa recargar -"
);
document.getElementById("appendApps").style.display = "none"
document.getElementById(btn_guardar).onclick = () => {
if (document.getElementById(field_persona).value == "") {
alert("Tienes que elegir tu cuenta!");
return;
}
SUB_LOGGED_IN_ID = document.getElementById(field_persona).value
SUB_LOGGED_IN_DETAILS = SC_Personas[SUB_LOGGED_IN_ID]
SUB_LOGGED_IN = true
setUrlHash("index")
document.getElementById("appendApps").style.display = "unset"
};
document.getElementById(btn_reload).onclick = () => {
setUrlHash("login," + safeuuid(""))
};
},
}

View File

@@ -1,19 +1,19 @@
PAGES.materiales = { PAGES.materiales = {
navcss: "btn2", navcss: "btn2",
Title: "Materiales", Title: "Materiales",
edit: function (mid) { edit: function (mid) {
var nameh1 = safeuuid(); var nameh1 = safeuuid();
var field_nombre = safeuuid(); var field_nombre = safeuuid();
var field_cantidad = safeuuid(); var field_cantidad = safeuuid();
var field_unidad = safeuuid(); var field_unidad = safeuuid();
var field_cantidad_min = safeuuid(); var field_cantidad_min = safeuuid();
var field_abierto = safeuuid(); var field_abierto = safeuuid();
var field_ubicacion = safeuuid(); var field_ubicacion = safeuuid();
var field_referencia = safeuuid(); var field_referencia = safeuuid();
var field_notas = safeuuid(); var field_notas = safeuuid();
var btn_guardar = safeuuid(); var btn_guardar = safeuuid();
var btn_borrar = safeuuid(); var btn_borrar = safeuuid();
container.innerHTML = ` container.innerHTML = `
<h1>Material <code id="${nameh1}"></code></h1> <h1>Material <code id="${nameh1}"></code></h1>
<fieldset> <fieldset>
<label> <label>
@@ -48,67 +48,67 @@ PAGES.materiales = {
<button class="rojo" id="${btn_borrar}">Borrar</button> <button class="rojo" id="${btn_borrar}">Borrar</button>
</fieldset> </fieldset>
`; `;
gun gun
.get(TABLE) .get(TABLE)
.get("materiales") .get("materiales")
.get(mid) .get(mid)
.once((data, key) => { .once((data, key) => {
function load_data(data, ENC = "") { function load_data(data, ENC = "") {
document.getElementById(nameh1).innerText = key; document.getElementById(nameh1).innerText = key;
document.getElementById(field_nombre).value = data["Nombre"] || ""; document.getElementById(field_nombre).value = data["Nombre"] || "";
document.getElementById(field_unidad).value = data["Unidad"] || ""; document.getElementById(field_unidad).value = data["Unidad"] || "";
document.getElementById(field_cantidad).value = document.getElementById(field_cantidad).value =
data["Cantidad"] || ""; data["Cantidad"] || "";
document.getElementById(field_cantidad_min).value = document.getElementById(field_cantidad_min).value =
data["Cantidad_Minima"] || ""; data["Cantidad_Minima"] || "";
document.getElementById(field_ubicacion).value = document.getElementById(field_ubicacion).value =
data["Ubicacion"] || "-"; data["Ubicacion"] || "-";
document.getElementById(field_referencia).value = document.getElementById(field_referencia).value =
data["Referencia"] || "?"; data["Referencia"] || "?";
document.getElementById(field_notas).value = data["Notas"] || ""; document.getElementById(field_notas).value = data["Notas"] || "";
}
if (typeof data == "string") {
SEA.decrypt(data, SECRET, (data) => {
load_data(data, "%E");
});
} else {
load_data(data);
}
});
document.getElementById(btn_guardar).onclick = () => {
var data = {
Nombre: document.getElementById(field_nombre).value,
Unidad: document.getElementById(field_unidad).value,
Cantidad: document.getElementById(field_cantidad).value,
Cantidad_Minima: document.getElementById(field_cantidad_min).value,
Ubicacion: document.getElementById(field_ubicacion).value,
Referencia: document.getElementById(field_referencia).value,
Notas: document.getElementById(field_notas).value,
};
var enc = SEA.encrypt(data, SECRET, (encrypted) => {
document.getElementById("actionStatus").style.display = "block";
betterGunPut(gun.get(TABLE).get("materiales").get(mid), encrypted);
toastr.success("Guardado!");
setTimeout(() => {
document.getElementById("actionStatus").style.display = "none";
setUrlHash("materiales");
}, 1500);
});
};
document.getElementById(btn_borrar).onclick = () => {
if (confirm("¿Quieres borrar este material?") == true) {
betterGunPut(gun.get(TABLE).get("materiales").get(mid), null);
toastr.error("Borrado!");
setTimeout(() => {
setUrlHash("materiales");
}, 1500);
} }
if (typeof data == "string") {
SEA.decrypt(data, SECRET, (data) => {
load_data(data, "%E");
});
} else {
load_data(data);
}
});
document.getElementById(btn_guardar).onclick = () => {
var data = {
Nombre: document.getElementById(field_nombre).value,
Unidad: document.getElementById(field_unidad).value,
Cantidad: document.getElementById(field_cantidad).value,
Cantidad_Minima: document.getElementById(field_cantidad_min).value,
Ubicacion: document.getElementById(field_ubicacion).value,
Referencia: document.getElementById(field_referencia).value,
Notas: document.getElementById(field_notas).value,
}; };
}, var enc = SEA.encrypt(data, SECRET, (encrypted) => {
index: function () { document.getElementById("actionStatus").style.display = "block";
const tablebody = safeuuid(); betterGunPut(gun.get(TABLE).get("materiales").get(mid), encrypted);
var btn_new = safeuuid(); toastr.success("Guardado!");
container.innerHTML = ` setTimeout(() => {
document.getElementById("actionStatus").style.display = "none";
setUrlHash("materiales");
}, 1500);
});
};
document.getElementById(btn_borrar).onclick = () => {
if (confirm("¿Quieres borrar este material?") == true) {
betterGunPut(gun.get(TABLE).get("materiales").get(mid), null);
toastr.error("Borrado!");
setTimeout(() => {
setUrlHash("materiales");
}, 1500);
}
};
},
index: function () {
const tablebody = safeuuid();
var btn_new = safeuuid();
container.innerHTML = `
<h1>Materiales</h1> <h1>Materiales</h1>
<button id="${btn_new}">Nuevo Material</button> <button id="${btn_new}">Nuevo Material</button>
<div id="scrolltable"><table> <div id="scrolltable"><table>
@@ -125,70 +125,68 @@ PAGES.materiales = {
</tbody> </tbody>
</table></div> </table></div>
`; `;
tableScroll("#scrolltable"); tableScroll("#scrolltable");
var tablebody_EL = document.getElementById(tablebody); var tablebody_EL = document.getElementById(tablebody);
var rows = {}; var rows = {};
function render() { function render() {
function sorter(a, b) { function sorter(a, b) {
if (a.Nombre < b.Nombre) { if (a.Nombre < b.Nombre) {
return -1; return -1;
}
if (a.Nombre > b.Nombre) {
return 1;
}
return 0;
} }
var tablebody_EL = document.getElementById(tablebody); if (a.Nombre > b.Nombre) {
tablebody_EL.innerHTML = ""; return 1;
Object.values(rows) }
.sort(sorter) return 0;
.forEach((data) => { }
var new_tr = document.createElement("tr"); var tablebody_EL = document.getElementById(tablebody);
new_tr.innerHTML = ` tablebody_EL.innerHTML = "";
Object.values(rows)
.sort(sorter)
.forEach((data) => {
var new_tr = document.createElement("tr");
new_tr.innerHTML = `
<td>${data.Referencia || "?"}</td> <td>${data.Referencia || "?"}</td>
<td>${data.Nombre || "?"}</td> <td>${data.Nombre || "?"}</td>
<td>${data.Ubicacion || "?"}</td> <td>${data.Ubicacion || "?"}</td>
<td>${data.Cantidad || "?"} ${data.Unidad || "?"}</td> <td>${data.Cantidad || "?"} ${data.Unidad || "?"}</td>
<td>${data.Notas || "?"}</td> <td>${data.Notas || "?"}</td>
`; `;
var min = parseFloat(data.Cantidad_Minima); var min = parseFloat(data.Cantidad_Minima);
var act = parseFloat(data.Cantidad); var act = parseFloat(data.Cantidad);
if (act < min) { if (act < min) {
new_tr.style.backgroundColor = "lightcoral"; new_tr.style.backgroundColor = "lightcoral";
}
new_tr.onclick = () => {
setUrlHash("materiales," + data._key);
};
tablebody_EL.append(new_tr);
});
}
gun
.get(TABLE)
.get("materiales")
.map()
.on((data, key, _msg, _ev) => {
EVENTLISTENER = _ev;
if (data != null) {
function add_row(data, key) {
if (data != null) {
data["_key"] = key;
rows[key] = data;
} else {
delete rows[key];
}
render();
}
if (typeof data == "string") {
SEA.decrypt(data, SECRET, (data) => {
add_row(data, key);
});
} else {
add_row(data, key);
}
} }
new_tr.onclick = () => {
setUrlHash("materiales," + data._key);
};
tablebody_EL.append(new_tr);
}); });
document.getElementById(btn_new).onclick = () => { }
setUrlHash("materiales," + safeuuid("")); gun
}; .get(TABLE)
}, .get("materiales")
} .map()
.on((data, key, _msg, _ev) => {
EVENTLISTENER = _ev;
function add_row(data, key) {
if (data != null) {
data["_key"] = key;
rows[key] = data;
} else {
delete rows[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 = () => {
setUrlHash("materiales," + safeuuid(""));
};
},
};

View File

@@ -198,23 +198,21 @@ PAGES.personas = {
.map() .map()
.on((data, key, _msg, _ev) => { .on((data, key, _msg, _ev) => {
EVENTLISTENER = _ev; EVENTLISTENER = _ev;
if (data != null) { function add_row(data, key) {
function add_row(data, key) { if (data != null) {
if (data != null) { data["_key"] = key;
data["_key"] = key; rows[key] = data;
rows[key] = data;
} else {
delete rows[key];
}
render();
}
if (typeof data == "string") {
SEA.decrypt(data, SECRET, (data) => {
add_row(data, key);
});
} else { } else {
add_row(data, key); delete rows[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 = () => {

View File

@@ -58,23 +58,21 @@ PAGES.resumen_diario = {
.map() .map()
.on((data, key, _msg, _ev) => { .on((data, key, _msg, _ev) => {
EVENTLISTENER2 = _ev; EVENTLISTENER2 = _ev;
if (data != null) { function add_row(data, key) {
function add_row(data, key) { if (data != null) {
if (data != null) { data["_key"] = key;
data["_key"] = key; materiales_low[key] = data;
materiales_low[key] = data;
} else {
delete materiales_low[key];
}
render_materialesLow();
}
if (typeof data == "string") {
SEA.decrypt(data, SECRET, (data) => {
add_row(data, key);
});
} else { } else {
add_row(data, key); delete materiales_low[key];
} }
render_materialesLow();
}
if (typeof data == "string") {
SEA.decrypt(data, SECRET, (data) => {
add_row(data, key);
});
} else {
add_row(data, key);
} }
}); });
function render_personasHigh() { function render_personasHigh() {
@@ -123,23 +121,21 @@ PAGES.resumen_diario = {
.map() .map()
.on((data, key, _msg, _ev) => { .on((data, key, _msg, _ev) => {
EVENTLISTENER = _ev; EVENTLISTENER = _ev;
if (data != null) { function add_row(data, key) {
function add_row(data, key) { if (data != null) {
if (data != null) { data["_key"] = key;
data["_key"] = key; personas_high[key] = data;
personas_high[key] = data;
} else {
delete personas_high[key];
}
render_personasHigh();
}
if (typeof data == "string") {
SEA.decrypt(data, SECRET, (data) => {
add_row(data, key);
});
} else { } else {
add_row(data, key); delete personas_high[key];
} }
render_personasHigh();
}
if (typeof data == "string") {
SEA.decrypt(data, SECRET, (data) => {
add_row(data, key);
});
} else {
add_row(data, key);
} }
}); });
}, },