worker-time-control/js/index.js

48 lines
1.1 KiB
JavaScript

var pin = "";
var datoUsuario = "";
$(document).ready(function () {
FastClick.attach(document.body);
setEvents();
});
function setEvents() {
$(".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() {
$(".loading").fadeIn(200);
$.post({
urlPath: 'login',
jsonData: [pin],
processData: false,
success: function (data) {
localStorage.setItem("userData", JSON.stringify(data));
window.location = "clockIn.html";
},
error: function() {
$(".loading").fadeOut(200);
$("#txtPin").text("USUARIO");
pin = "";
}
});
}