This commit is contained in:
2024-04-20 06:32:07 -07:00
parent ae77d20de6
commit 6241826922
22 changed files with 22765 additions and 2063 deletions

View File

@@ -1,39 +1,25 @@

var NotificacionesADS = function () {
var VentanaConConexion = false;
let nointentos = 0;
const maxintentos = 4;
var wNum;
const valueok = "1";
const AdsNotificacionesReconected = "AdsNotificacionesReconected";
const Windownumber = "ADSWindownumber";
const AdsNotificacionesIsConnected = "AdsNotificacionesIsConnected";
function initherramientas() {
const valueok = "1";
function initherramientas() {
if (("Notification" in window)) {
if (Notification.permission !== 'denied') {
Notification.requestPermission(function (permission) {
// If the user accepts, let's create a notification
//if (permission === "granted") {
//}
if (permission === "granted") {
}
});
}
}
}
//-------------------------------------------------------------------- Eventos ----------------------------------------------------------------------
var AlertaVentana = function (Titulo, Mensaje, Tipo, timeoutseconds, Opciones) {
var AlertaVentana = function (Titulo, Mensaje, Tipo, timeoutseconds,Opciones) {
console.log(Mensaje);
let obj = { metodo: "AlertaVentana", titulo: Titulo, mensaje: Mensaje, timeout: timeoutseconds, tipo: Tipo, opciones: Opciones, tick: (new Date()).getTime() };
let obj = { metodo: "AlertaVentana", titulo: Titulo, mensaje: Mensaje, timeout: timeoutseconds, tipo: Tipo, opciones: Opciones, tick: (new Date()).getTime() }
let myjson = JSON.stringify(obj);
localStorage.setItem("ADSNotificaciones", myjson);
execAlertaVentana(obj);
};
function Execstring(script) {
try {
eval(script);
} catch (e) {
console.error('(SignalR) ErrorScript \'' + script + '\'');
}
execAlertaVentana(obj);
}
var execAlertaVentana = function (obj) {
console.log(obj);
@@ -56,7 +42,7 @@ var NotificacionesADS = function () {
//});
let Mensaje = obj.mensaje;
let titulo = obj.titulo;
let timeout = obj.timeout;
let timeout = obj.timeout;
if (timeout) {
timeout = timeout * 1000;//convierto a milisegundos
} else { timeout = 0; }
@@ -74,7 +60,7 @@ var NotificacionesADS = function () {
"showMethod": "fadeIn",
"hideMethod": "fadeOut"
};
}
switch (obj.tipo) {
case 5:
@@ -93,95 +79,70 @@ var NotificacionesADS = function () {
toastr.warning(Mensaje, titulo, opciones);
}
}
};
}
//-------------------------------------------------------------------- EndEventos ----------------------------------------------------------------------
function closeopenConexion() {
if (VentanaConConexion) {
localStorage.removeItem(AdsNotificacionesIsConnected);
let varreconected = localStorage.getItem(AdsNotificacionesReconected);//obtengo la variable para cambiarla y dispara el evento local change
if (varreconected === "1") {
localStorage.removeItem(AdsNotificacionesReconected);
} else { localStorage.setItem(AdsNotificacionesReconected, "1"); }
}
nointentos = maxintentos;
let varreconected = localStorage.getItem("AdsNotificacionesReconected");
localStorage.removeItem("AdsNotificacionesIsConnected");
if (varreconected == "1") {
localStorage.removeItem("AdsNotificacionesReconected");
} else { localStorage.setItem("AdsNotificacionesReconected", "1"); }
}
function beforeunloadcloseopenConexion(e) {
closeopenConexion();
closeopenConexion()
}
function loadConection() {
VentanaConConexion = true;
localStorage.setItem(AdsNotificacionesIsConnected, valueok);
if ($.connection) {
var proxy = $.connection.notificaciones;
/*$.connection.hub.url = '/signalr';*/
$.connection.hub.disconnected(function () {
console.log(' (SignalR) diconnected');
signalrconectionStar(1200);
});
function loadConection() {
// VentanaConConexion = true;
//localStorage.setItem("AdsNotificacionesIsConnected", valueok);
//if ($.connection) {
// let nointentos =0
// var proxy = $.connection.notificaciones;
// /*$.connection.hub.url = '/signalr';*/
// $.connection.hub.disconnected(function () {
// setTimeout(function () { nointentos = nointentos + 1; if (nointentos < 4) { $.connection.hub.start().done(function () { nointentos = 0 }); console.log('Reconected'); } }, 120000);
// });
proxy.client.AlertaVentana = AlertaVentana;
// proxy.client.AlertaVentana = AlertaVentana;
proxy.client.Execstring = Execstring;
signalrconectionStar(1200);
// $.connection.hub.start().done(function () {
// console.log('Bienvenido');
// });
//} else {
// console.error('Signal Error (no se encontro $.connection)');
//}
//window.addEventListener("beforeunload", beforeunloadcloseopenConexion);
}
function initConnection() {
let isconnected = localStorage.getItem("AdsNotificacionesIsConnected");
if (isconnected == valueok) {
} else {
console.error('(SignalR) Error :\'no se encontro $.connection\'');
}
window.addEventListener("beforeunload", beforeunloadcloseopenConexion);
}
function signalrconectionStar(TimeOut) {
setTimeout(function () {
nointentos = nointentos + 1;
if (nointentos < maxintentos) {
$.connection.hub.start().done(function () { console.log('(SignalR)Bienvenido'); nointentos = 0; })
.fail(function () { console.log(' (SignalR) no conectado (Intento:' + nointentos + ')'); signalrconectionStar(12000); });
}
}, TimeOut);
}
function initConnection() {
let isconnected = localStorage.getItem(AdsNotificacionesIsConnected);
if (isconnected !== valueok) {
loadConection();
} else {
console.log('is some there conected (' + wNum+')');
loadConection()
}
}
function handlelocalstorage() {
function handlelocalstorage() {
window.addEventListener('storage', function (evt) {
if (evt.key === "ADSNotificaciones") {
///
x = 1;
if (evt.key == "ADSNotificaciones") {
}
switch (evt.key + "") {
case 'ADSCloseConection':
closeopenConexion();
$.connection.hub.stop().done(function () {
console.log('stopped');
});
break;
case 'AdsNotificacionesReconected':
if (!VentanaConConexion) {
setTimeout(function () { initConnection(); }, (wNum * 200));
setTimeout(function () { initConnection() }, 5000)
} else {
window.removeEventListener("beforeunload", beforeunloadcloseopenConexion);
window.removeEventListener("beforeunload", beforeunloadcloseopenConexion)
}
break;
case 'ADSNotificaciones':
try {
let obj = JSON.parse(evt.newValue);
if (obj && obj.metodo === "AlertaVentana") {
if (obj && obj.metodo == "AlertaVentana") {
execAlertaVentana(obj);
}
} catch (e) {
console.error(e);
console.error(e)
}
break;
}
@@ -191,11 +152,6 @@ var NotificacionesADS = function () {
return {
init: function () {
wNum = parseInt(localStorage.getItem(Windownumber));
if (isNaN(wNum) || (wNum > 50)) { wNum = 12; }
wNum = wNum + 1;
localStorage.setItem(Windownumber, wNum);
initherramientas();
handlelocalstorage();
initConnection();

2670
Scripts/jquery-3.7.1.intellisense.js vendored Normal file

File diff suppressed because it is too large Load Diff

10716
Scripts/jquery-3.7.1.js vendored Normal file

File diff suppressed because it is too large Load Diff

2
Scripts/jquery-3.7.1.min.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

8617
Scripts/jquery-3.7.1.slim.js Normal file

File diff suppressed because it is too large Load Diff

2
Scripts/jquery-3.7.1.slim.min.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long