update app_logic.js
This commit is contained in:
@@ -4,14 +4,15 @@ function tableScroll(query) {
|
||||
//var secretTokenEl = document.getElementById("secretToken");
|
||||
var groupIdEl = document.getElementById("groupId");
|
||||
var container = document.getElementById("container");
|
||||
|
||||
function LinkAccount(LinkAccount_group, LinkAccount_secret, refresh = false) {
|
||||
GROUPID = LinkAccount_group.toUpperCase();
|
||||
SECRET = LinkAccount_secret.toUpperCase();
|
||||
|
||||
|
||||
localStorage.setItem("TELESEC_AUTO", "YES");
|
||||
localStorage.setItem("TELESEC_groupid", GROUPID);
|
||||
localStorage.setItem("TELESEC_secret", SECRET);
|
||||
|
||||
|
||||
TABLE = GROUPID + ":telesec.tech.eus";
|
||||
//secretTokenEl.innerText = SECRET;
|
||||
groupIdEl.innerText = GROUPID;
|
||||
@@ -33,26 +34,8 @@ if (urlParams.get("login") != null) {
|
||||
);
|
||||
//location.search = "";
|
||||
}
|
||||
|
||||
function open_page(params) {
|
||||
if (SUB_LOGGED_IN != true) {
|
||||
PAGES["login"].index();
|
||||
return;
|
||||
}
|
||||
if (params == "") {
|
||||
params = "index";
|
||||
}
|
||||
var path = params.split(",");
|
||||
var app = path[0];
|
||||
if (path[1] == undefined) {
|
||||
PAGES[app].index();
|
||||
return;
|
||||
}
|
||||
PAGES[app].edit(path[1]);
|
||||
}
|
||||
function setUrlHash(hash) {
|
||||
location.hash = "#" + hash;
|
||||
}
|
||||
window.onhashchange = () => {
|
||||
try {
|
||||
if (EVENTLISTENER != null) {
|
||||
try {
|
||||
@@ -70,9 +53,31 @@ window.onhashchange = () => {
|
||||
} catch (e) {
|
||||
console.debug("EVENTLISTENER onhashchange", e);
|
||||
}
|
||||
if (SUB_LOGGED_IN != true) {
|
||||
PAGES["login"].index();
|
||||
return;
|
||||
}
|
||||
if (params == "") {
|
||||
params = "index";
|
||||
}
|
||||
var path = params.split(",");
|
||||
var app = path[0];
|
||||
if (path[1] == undefined) {
|
||||
PAGES[app].index();
|
||||
return;
|
||||
}
|
||||
PAGES[app].edit(path[1]);
|
||||
}
|
||||
|
||||
function setUrlHash(hash) {
|
||||
location.hash = "#" + hash;
|
||||
|
||||
|
||||
}
|
||||
window.onhashchange = () => {
|
||||
open_page(location.hash.replace("#", ""));
|
||||
};
|
||||
|
||||
function download(filename, text) {
|
||||
var element = document.createElement("a");
|
||||
element.setAttribute(
|
||||
@@ -80,14 +85,15 @@ function download(filename, text) {
|
||||
"data:application/octet-stream;charset=utf-8," + encodeURIComponent(text)
|
||||
);
|
||||
element.setAttribute("download", filename);
|
||||
|
||||
|
||||
element.style.display = "none";
|
||||
document.body.appendChild(element);
|
||||
|
||||
|
||||
element.click();
|
||||
|
||||
|
||||
document.body.removeChild(element);
|
||||
}
|
||||
|
||||
function resizeInputImage(
|
||||
file,
|
||||
callback,
|
||||
@@ -95,51 +101,54 @@ function resizeInputImage(
|
||||
targetQuality = 0.75
|
||||
) {
|
||||
const reader = new FileReader();
|
||||
|
||||
reader.onload = function (event) {
|
||||
|
||||
reader.onload = function(event) {
|
||||
const img = new Image();
|
||||
img.onload = function () {
|
||||
img.onload = function() {
|
||||
const aspectRatio = img.width / img.height;
|
||||
const targetWidth = targetHeight * aspectRatio;
|
||||
|
||||
|
||||
const canvas = document.createElement("canvas");
|
||||
canvas.width = targetWidth;
|
||||
canvas.height = targetHeight;
|
||||
|
||||
|
||||
const ctx = canvas.getContext("2d");
|
||||
|
||||
|
||||
ctx.fillStyle = "#ffffff";
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
|
||||
ctx.drawImage(img, 0, 0, targetWidth, targetHeight);
|
||||
|
||||
|
||||
// Get resized image as Blob
|
||||
const dataURL = canvas.toDataURL("image/jpeg", targetQuality);
|
||||
callback(dataURL);
|
||||
};
|
||||
img.src = event.target.result;
|
||||
};
|
||||
|
||||
|
||||
reader.readAsDataURL(file);
|
||||
}
|
||||
|
||||
function CurrentISODate() {
|
||||
return new Date().toISOString().split("T")[0].replace("T", " ");
|
||||
}
|
||||
|
||||
function CurrentISOTime() {
|
||||
return new Date().toISOString();
|
||||
}
|
||||
|
||||
function fixGunLocalStorage() {
|
||||
localStorage.removeItem("radata");
|
||||
removeCache();
|
||||
location.reload();
|
||||
}
|
||||
|
||||
function betterGunPut(ref, data) {
|
||||
ref.put(data, (ack) => {
|
||||
if (ack.err) {
|
||||
toastr.error(
|
||||
ack.err + "<br>Pulsa aqui para reiniciar la app",
|
||||
"Error al guardar",
|
||||
{ onclick: () => fixGunLocalStorage() }
|
||||
"Error al guardar", { onclick: () => fixGunLocalStorage() }
|
||||
);
|
||||
} else {
|
||||
console.debug("Guardado correctamente");
|
||||
@@ -161,4 +170,4 @@ setInterval(() => {
|
||||
}, 5000);
|
||||
gun.get(TABLE).on((data) => {
|
||||
var e = true;
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user