worker-time-control/js/index.js

52 lines
1.3 KiB
JavaScript

var pin = "";
var datoUsuario = "";
$(document).ready(function () {
FastClick.attach(document.body);
setEvents();
});
function setEvents() {
const heartEl = document.querySelector('body > h1 > span');
heartEl.addEventListener('click', function() {
const key = prompt('Introduce la clave');
if (key === null) return
localStorage.setItem('vnKey', key);
});
$(".btnnum").on("click", function () {
pin += parseInt($(this).children().html());
$("#txtPin").text(pin);
});
$(".btnCancel").on("click", function () {
pin = "";
$("#txtPin").text("ID USUARIO");
});
$(".btnOk").on("click", login);
$(".btnconfirmar").on("click", function () {
localStorage.setItem("userData", JSON.stringify(datoUsuario));
setTimeout(function () {
window.location = "clockIn.html";
}, 200);
});
}
function login() {
$.post({
urlPath: 'login',
jsonData: [pin],
processData: false,
success: function (data) {
localStorage.setItem("userData", JSON.stringify(data));
window.location = "clockIn.html";
},
error: function() {
$("#txtPin").text("ID USUARIO");
pin = "";
}
});
}