This commit is contained in:
naielv
2025-09-07 15:52:00 +02:00
parent fc4170acb8
commit f11760d867
10 changed files with 337 additions and 355 deletions

View File

@@ -67,14 +67,6 @@ String.prototype.toHex = function() {
return wheelcolors[hash % wheelcolors.length];
};
// Test
console.log("hello".toHex());
console.log("world".toHex());
console.log("foo".toHex());
console.log("bar".toHex());
function stringToColour(str) {
return str.toHex();
}
@@ -1038,7 +1030,6 @@ function TS_IndexElement(
}
function BuildQR(mid, label) {
console.warn("BARCODE " + mid + " LABEL " + label)
return `
<span style="border: 2px dashed black; padding: 10px; display: inline-block; background: white; border-radius: 7px; text-align: center; margin: 10px;">
<b>TeleSec AztecQR</b>

View File

@@ -95,21 +95,6 @@
<script src="static/toastr.min.js"></script>
<script src="static/doublescroll.js"></script>
<!--<script src="static/simplemde.min.js"></script>-->
<script>
let totalSize = 0;
for (let key in localStorage) {
if (localStorage.hasOwnProperty(key)) {
let keySize = new Blob([key]).size; // Size of the key
let valueSize = new Blob([localStorage[key]]).size; // Size of the value
totalSize += keySize + valueSize;
}
}
console.log(`Total localStorage size: ${totalSize} bytes`);
console.log(`Total size in KB: ${(totalSize / 1024).toFixed(2)} KB`);
console.log(`Total size in MB: ${(totalSize / (1024 * 1024)).toFixed(2)} MB`);
</script>
<script src="pwa.js"></script>
<script src="config.js"></script>
<script src="gun_init.js"></script>

View File

@@ -141,7 +141,7 @@ PAGES.aulas = {
load_data(data, "%E");
});
} else {
load_data(data);
load_data(data || {});
}
});
document.getElementById(btn_guardar).onclick = () => {
@@ -276,7 +276,7 @@ PAGES.aulas = {
load_data(data, "%E");
});
} else {
load_data(data);
load_data(data || {});
}
});
document.getElementById(btn_guardar).onclick = () => {

View File

@@ -124,7 +124,7 @@ PAGES.avisos = {
load_data(data, "%E");
});
} else {
load_data(data);
load_data(data || {});
}
});
document.getElementById(btn_guardar).onclick = () => {

View File

@@ -44,7 +44,7 @@ PAGES.comedor = {
load_data(data, "%E");
});
} else {
load_data(data);
load_data(data || {});
}
});
document.getElementById(btn_guardar).onclick = () => {

View File

@@ -5,17 +5,17 @@ PAGES.dataman = {
Title: "Ajustes",
edit: function (mid) {
switch (mid) {
case 'export':
PAGES.dataman.__export()
case "export":
PAGES.dataman.__export();
break;
case 'import':
PAGES.dataman.__import()
case "import":
PAGES.dataman.__import();
break;
case 'config':
PAGES.dataman.__config()
case "config":
PAGES.dataman.__config();
break;
case 'labels':
PAGES.dataman.__labels()
case "labels":
PAGES.dataman.__labels();
break;
default:
// Tab to edit
@@ -33,14 +33,14 @@ PAGES.dataman = {
</label>
<button type="submit">Aplicar ajustes</button>
</form>
`
`;
document.getElementById(form).onsubmit = (ev) => {
ev.preventDefault()
var ford = new FormData(document.getElementById(form))
ev.preventDefault();
var ford = new FormData(document.getElementById(form));
if (ford.get("block_add_account") == "yes") {
config["block_add_account"] = true
}
config["block_add_account"] = true;
}
};
},
__export: function () {
var select_type = safeuuid();
@@ -84,7 +84,6 @@ PAGES.dataman = {
}
});
toastr.success("Exportado todo, descargando!");
console.error(output);
download(
`Export TeleSec ${GROUPID}.json.txt`,
JSON.stringify(output)
@@ -97,7 +96,6 @@ PAGES.dataman = {
document.getElementById(button_export_safe).onclick = () => {
var download_data = (DATA) => {
toastr.success("Exportado todo, descargado!");
console.error(DATA);
download(
`Export TeleSec Encriptado ${GROUPID}.json.txt`,
JSON.stringify(DATA)
@@ -109,7 +107,6 @@ PAGES.dataman = {
document.getElementById(button_export_safe_cloud).onclick = () => {
var download_data = (DATA) => {
toastr.info("Exportado todo, subiendo!");
console.error(DATA);
fetch(
"https://telesec-sync.tech.eus/upload_backup.php?table=" + GROUPID,
{
@@ -178,18 +175,25 @@ PAGES.dataman = {
};
},
__labels: function (mid) {
var div_materiales = safeuuid()
var div_materiales = safeuuid();
container.innerHTML = `
<h1>Imprimir Etiquetas AztecQR</h1>
<button onclick="print()">Imprimir</button>
<h2>Materiales</h2>
<div id="${div_materiales}"></div>
<br><br>`;
div_materiales = document.getElementById(div_materiales)
gun.get(TABLE).get("materiales").map().once((data, key) => {
div_materiales = document.getElementById(div_materiales);
gun
.get(TABLE)
.get("materiales")
.map()
.once((data, key) => {
function add_row(data, key) {
if (data != null) {
div_materiales.innerHTML += BuildQR("materiales," + key, data["Nombre"] || key)
div_materiales.innerHTML += BuildQR(
"materiales," + key,
data["Nombre"] || key
);
}
}
if (typeof data == "string") {
@@ -199,7 +203,7 @@ PAGES.dataman = {
} else {
add_row(data, key);
}
})
});
},
index: function () {
container.innerHTML = `
@@ -208,6 +212,6 @@ PAGES.dataman = {
<a class="button" href="#dataman,export">Exportar datos</a>
<a class="button" href="#dataman,labels">Imprimir etiquetas</a>
<a class="button" href="#dataman,config">Ajustes</a>
`
}
`;
},
};

View File

@@ -78,7 +78,7 @@ PAGES.materiales = {
load_data(data, "%E");
});
} else {
load_data(data);
load_data(data || {});
}
});
document.getElementById(btn_guardar).onclick = () => {
@@ -176,7 +176,6 @@ PAGES.materiales = {
document.getElementById("tableContainer"),
undefined,
function(data) {
console.log(data.Ubicacion, filtroUbicacion);
if (data.Ubicacion == filtroUbicacion) {return false}
if (filtroUbicacion == "") {return false}
return true

View File

@@ -74,7 +74,7 @@ PAGES.notas = {
load_data(data, "%E");
});
} else {
load_data(data);
load_data(data || {});
}
});
document.getElementById(btn_guardar).onclick = () => {

View File

@@ -98,7 +98,7 @@ PAGES.personas = {
load_data(data, "%E");
});
} else {
load_data(data);
load_data(data || {});
}
});
document

View File

@@ -1,12 +1,15 @@
PERMS["supercafe"] = "SuperCafé"
PERMS["supercafe:edit"] = "&gt; Editar"
PERMS["supercafe"] = "SuperCafé";
PERMS["supercafe:edit"] = "&gt; Editar";
PAGES.supercafe = {
navcss: "btn4",
icon: "static/appico/Coffee.svg",
AccessControl: true,
Title: "SuperCafé",
edit: function (mid) {
if (!checkRole("supercafe:edit")) {setUrlHash("supercafe");return}
if (!checkRole("supercafe:edit")) {
setUrlHash("supercafe");
return;
}
var nameh1 = safeuuid();
var field_fecha = safeuuid();
var field_persona = safeuuid();
@@ -84,8 +87,7 @@ PAGES.supercafe = {
function load_data(data, ENC = "") {
document.getElementById(nameh1).innerText = key;
document.getElementById(field_fecha).value = data["Fecha"];
document.getElementById(field_persona).value =
data["Persona"] || "";
document.getElementById(field_persona).value = data["Persona"] || "";
currentPersonaID = data["Persona"] || "";
document.getElementById(field_comanda).value =
SC_parse(JSON.parse(data["Comanda"] || "{}")) || "";
@@ -100,7 +102,7 @@ PAGES.supercafe = {
load_data(data, "%E");
});
} else {
load_data(data);
load_data(data || {});
}
});
document.getElementById(btn_guardar).onclick = () => {
@@ -141,7 +143,10 @@ PAGES.supercafe = {
};
},
index: function () {
if (!checkRole("supercafe")) {setUrlHash("index");return}
if (!checkRole("supercafe")) {
setUrlHash("index");
return;
}
var tts = false;
var sc_nobtn = "";
if (urlParams.get("sc_nobtn") == "yes") {
@@ -152,7 +157,7 @@ PAGES.supercafe = {
console.log("TTS Enabled");
toastr.info("Texto a voz disponible");
}, 6500);
EventListeners.Timeout.push(ev)
EventListeners.Timeout.push(ev);
const tablebody = safeuuid();
const tablebody2 = safeuuid();
var btn_new = safeuuid();
@@ -197,7 +202,7 @@ PAGES.supercafe = {
default: "",
label: "Comanda",
},
]
];
if (!checkRole("supercafe:edit")) {
config = [
{
@@ -212,17 +217,17 @@ PAGES.supercafe = {
default: "",
label: "Comanda",
},
]
];
}
//Todas las comandas
var comandasTot = {}
var comandasTot = {};
function calcPrecio() {
var tot = 0
Object.values(comandasTot).forEach(precio => {
tot += precio
var tot = 0;
Object.values(comandasTot).forEach((precio) => {
tot += precio;
});
document.getElementById(totalprecio).innerText = tot
return tot
document.getElementById(totalprecio).innerText = tot;
return tot;
}
TS_IndexElement(
"supercafe",
@@ -231,8 +236,8 @@ PAGES.supercafe = {
document.querySelector("#cont1"),
(data, new_tr) => {
// new_tr.style.backgroundColor = "#FFCCCB";
comandasTot[data._key] = SC_priceCalc(JSON.parse(data.Comanda))[0]
calcPrecio()
comandasTot[data._key] = SC_priceCalc(JSON.parse(data.Comanda))[0];
calcPrecio();
if (data.Estado == "Pedido") {
new_tr.style.backgroundColor = "#FFFFFF";
}
@@ -262,7 +267,6 @@ PAGES.supercafe = {
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]
@@ -281,8 +285,8 @@ PAGES.supercafe = {
document.querySelector("#cont2"),
(data, new_tr) => {
// new_tr.style.backgroundColor = "#FFCCCB";
comandasTot[data._key] = 0 // No mostrar comandas en deuda.
calcPrecio()
comandasTot[data._key] = 0; // No mostrar comandas en deuda.
calcPrecio();
if (data.Estado == "Pedido") {
new_tr.style.backgroundColor = "#FFFFFF";
@@ -313,7 +317,6 @@ PAGES.supercafe = {
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]
@@ -324,11 +327,11 @@ PAGES.supercafe = {
}
);
if (!checkRole("supercafe:edit")) {
document.getElementById(btn_new).style.display = "none"
document.getElementById(btn_new).style.display = "none";
} else {
document.getElementById(btn_new).onclick = () => {
setUrlHash("supercafe," + safeuuid(""));
};
}
},
}
};