2021-10-19 08:52:45 +00:00
|
|
|
var urlBase = config.urlBase;
|
|
|
|
|
2021-10-20 13:13:30 +00:00
|
|
|
function confirmReset() {
|
|
|
|
$(".confirm").removeClass('confirmKO');
|
|
|
|
$(".txtConfirm").empty();
|
|
|
|
}
|
2021-10-19 08:52:45 +00:00
|
|
|
|
|
|
|
function printError(msg){
|
2021-10-20 13:13:30 +00:00
|
|
|
confirmReset();
|
2021-10-19 08:52:45 +00:00
|
|
|
$(".txtConfirm").append(msg);
|
|
|
|
$(".confirm").addClass('confirmKO');
|
2021-10-20 13:13:30 +00:00
|
|
|
$(".confirm").fadeIn(200);
|
2021-10-19 08:52:45 +00:00
|
|
|
setTimeout(function() {
|
2021-10-20 13:13:30 +00:00
|
|
|
$(".confirm").fadeOut(200);
|
|
|
|
setTimeout(confirmReset, 200);
|
2021-10-19 08:52:45 +00:00
|
|
|
}, 1500);
|
|
|
|
}
|
|
|
|
|
|
|
|
$.ajaxPrefilter(function(xhr) {
|
2021-10-20 13:13:30 +00:00
|
|
|
var orgErrorHandler = xhr.error;
|
|
|
|
|
2022-12-12 09:21:02 +00:00
|
|
|
var key = localStorage.getItem('vnKey');
|
|
|
|
if(key){
|
|
|
|
xhr.jsonData.push(key)
|
|
|
|
}
|
|
|
|
|
2021-10-19 08:52:45 +00:00
|
|
|
Object.assign(xhr, {
|
|
|
|
url: `${urlBase}/workerTimeControl/${xhr.urlPath}`,
|
|
|
|
headers: {
|
|
|
|
'version': '1',
|
|
|
|
'aplicacion': 'workerTimeControl'
|
|
|
|
},
|
|
|
|
timeout: 1000,
|
|
|
|
contentType: 'application/json; charset=utf-8',
|
|
|
|
dataType: 'json',
|
|
|
|
processData: false,
|
|
|
|
data: JSON.stringify(xhr.jsonData),
|
2021-10-20 13:13:30 +00:00
|
|
|
error: function(xhr, textStatus, err) {
|
|
|
|
if (orgErrorHandler) {
|
|
|
|
try {
|
|
|
|
orgErrorHandler(xhr, textStatus, err);
|
|
|
|
} catch (e) {
|
|
|
|
err = e;
|
|
|
|
}
|
|
|
|
}
|
2021-10-19 08:52:45 +00:00
|
|
|
|
|
|
|
switch (textStatus){
|
|
|
|
case 'parsererror':
|
|
|
|
mensaje = 'Requested JSON parse failed';
|
|
|
|
break;
|
|
|
|
case 'timeout':
|
|
|
|
mensaje = 'Time out error';
|
|
|
|
break;
|
|
|
|
case 'abort':
|
|
|
|
mensaje = 'Ajax request aborted';
|
|
|
|
break;
|
|
|
|
case 'error':
|
|
|
|
switch (xhr.status){
|
|
|
|
case 0:
|
|
|
|
mensaje = 'Not connect: Verify Network';
|
|
|
|
break;
|
|
|
|
case 555:
|
|
|
|
mensaje = JSON.parse(xhr.statusText).Message;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (xhr.status >= 400 && xhr.status < 500)
|
|
|
|
mensaje = xhr.statusText;
|
|
|
|
else
|
|
|
|
mensaje = 'Ha ocurrido un error, consulta con informática';
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
mensaje = 'Ha ocurrido un error, consulta con informática';
|
|
|
|
}
|
|
|
|
printError(mensaje);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|