Signed-off-by: ale <ale@manalejandro.com>
Este commit está contenido en:
ale
2026-02-09 00:16:51 +01:00
padre 4b66a91750
commit 728e8a3de7
Se han modificado 8 ficheros con 274 adiciones y 274 borrados

Ver fichero

@@ -166,6 +166,10 @@ const DB = {
div.appendChild(document.createTextNode(msg));
const page = document.getElementById("page");
if (page) {
// Limpiar solo contenido dinámico, mantener cabecera
Array.from(page.children).forEach(child => {
if (!child.classList.contains('amo-header')) child.remove();
});
page.appendChild(div);
}
},
@@ -211,31 +215,55 @@ const DB = {
// Crear un objeto que emule la API de mozIStorageStatement
const stmt = this.db.prepare(sql);
let currentRow = null;
const columnNames = stmt.getColumnNames();
const paramsObj = {};
let paramsBound = false;
return {
params: {},
params: paramsObj,
executeStep() {
return stmt.step();
// Bind parameters only once before first execution
if (!paramsBound && Object.keys(paramsObj).length > 0) {
// Convert params object to sql.js format (add ':' prefix to keys)
const boundParams = {};
for (const key in paramsObj) {
boundParams[':' + key] = paramsObj[key];
}
stmt.bind(boundParams);
paramsBound = true;
}
const hasRow = stmt.step();
if (hasRow) {
const values = stmt.get();
currentRow = {};
columnNames.forEach((name, index) => {
currentRow[name] = values[index];
});
}
return hasRow;
},
reset() {
stmt.reset();
currentRow = null;
paramsBound = false;
},
finalize() {
stmt.free();
currentRow = null;
},
get row() {
return currentRow || {};
},
row: new Proxy({}, {
get(target, prop) {
return stmt.get()[stmt.getColumnNames().indexOf(prop)];
}
}),
getString(index) {
return stmt.get()[index];
return currentRow ? Object.values(currentRow)[index] : null;
},
getInt32(index) {
return stmt.get()[index];
return currentRow ? Object.values(currentRow)[index] : 0;
},
getDouble(index) {
return stmt.get()[index];
return currentRow ? Object.values(currentRow)[index] : 0.0;
}
};
}