worker-time-control/js/index.js

54 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-10-19 08:52:45 +00:00
var pin = "";
var datoUsuario = "";
$(document).ready(function () {
FastClick.attach(document.body);
setEvents();
});
function setEvents() {
2023-01-27 07:45:56 +00:00
const heartEl = document.querySelector('body > h1 > span');
2022-12-12 09:21:02 +00:00
heartEl.addEventListener('click', function() {
const key = prompt('Introduce la clave');
localStorage.setItem('vnKey', key);
});
2021-10-19 08:52:45 +00:00
$(".btnnum").on("click", function () {
pin += parseInt($(this).children().html());
$("#txtPin").text(pin);
});
$(".btnCancel").on("click", function () {
pin = "";
$("#txtPin").text("USUARIO");
});
$(".btnOk").on("click", login);
$(".btnconfirmar").on("click", function () {
localStorage.setItem("userData", JSON.stringify(datoUsuario));
setTimeout(function () {
window.location = "clockIn.html";
}, 200);
$(".loading").fadeOut(200);
});
}
function login() {
2021-10-20 13:13:30 +00:00
$(".loading").fadeIn(200);
2021-10-19 08:52:45 +00:00
$.post({
urlPath: 'login',
jsonData: [pin],
processData: false,
success: function (data) {
localStorage.setItem("userData", JSON.stringify(data));
window.location = "clockIn.html";
2021-10-20 13:13:30 +00:00
},
error: function() {
2021-10-19 08:52:45 +00:00
$(".loading").fadeOut(200);
2021-10-20 13:13:30 +00:00
$("#txtPin").text("USUARIO");
pin = "";
2021-10-19 08:52:45 +00:00
}
});
}