Station/www/cards/js/qwikclock_punchinout.js

60 lines
1.7 KiB
JavaScript
Raw Normal View History

2017-12-19 04:09:21 -07:00
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
2017-12-26 23:18:02 -07:00
if (largebtns) {
$(".start_btn").addClass("btn-huge");
$(".start_btn .icon svg").addClass("fa-2x");
$(".stop_btn").addClass("btn-huge");
$(".stop_btn .icon svg").addClass("fa-2x");
}
$(".card_qwikclock_punchinout").each(function () {
var card = $(this);
var url = $(this).data("apiurl");
$.post(url, {
username: getuser(),
password: getAPIKey(),
action: "ping"
}, function (resp) {
// We didn't get a 403
}, "json").fail(function () {
card.css("display", "none");
});
});
2017-12-19 04:09:21 -07:00
$(".card_qwikclock_punchinout").on("click", ".start_btn", function () {
var parent = $(this).parents(".card_app");
var url = parent.data("apiurl");
console.log(url + " " + getuser());
$.post(url, {
username: getuser(),
password: getAPIKey(),
action: "punchin"
}, function (resp) {
if (resp.status == "OK") {
2017-12-26 23:20:25 -07:00
showmsg('<i class="fas fa-check"></i> ' + resp.msg, "success");
2017-12-19 04:09:21 -07:00
} else {
2017-12-26 23:20:25 -07:00
showmsg('<i class="fas fa-times"></i> ' + resp.msg, "danger");
2017-12-19 04:09:21 -07:00
}
}, "json");
});
$(".card_qwikclock_punchinout").on("click", ".stop_btn", function () {
var parent = $(this).parents(".card_app");
var url = parent.data("apiurl");
console.log(url + " " + getuser());
$.post(url, {
username: getuser(),
password: getAPIKey(),
action: "punchout"
}, function (resp) {
if (resp.status == "OK") {
2017-12-26 23:20:25 -07:00
showmsg('<i class="fas fa-check"></i> ' + resp.msg, "success");
2017-12-19 04:09:21 -07:00
} else {
2017-12-26 23:20:25 -07:00
showmsg('<i class="fas fa-times"></i> ' + resp.msg, "danger");
2017-12-19 04:09:21 -07:00
}
}, "json");
});