2021-10-19 07:30:49 -07:00
|
|
|
var signaturePad, selPeriod, canvas, width = $(window).width(), modal;
|
2021-12-12 02:38:10 -08:00
|
|
|
var indDS = {};
|
2021-10-19 07:30:49 -07:00
|
|
|
function submitForm() {
|
|
|
|
if (!signaturePad.isEmpty()) {
|
|
|
|
$('#' + modal).modal('hide');
|
|
|
|
loadingAnimation();
|
|
|
|
signaturePad.off();
|
|
|
|
var data = signaturePad.toDataURL('image/png');
|
|
|
|
document.getElementById("attendanceData^" + selPeriod).getElementsByClassName("signatureData")[0].value = data;
|
|
|
|
document.getElementById("attendanceData^" + selPeriod).submit();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
alert("Please sign first");
|
|
|
|
}
|
|
|
|
}
|
2021-12-26 05:08:50 -08:00
|
|
|
function submitDSForm() {
|
|
|
|
for (var i in indDS) {
|
|
|
|
var tmp = document.createElement('input');
|
|
|
|
tmp.type = 'hidden';
|
|
|
|
tmp.name = 'ds^' + i;
|
|
|
|
tmp.value = indDS[i];
|
|
|
|
document.getElementById('attendanceData^' + selPeriod).appendChild(tmp);
|
|
|
|
}
|
|
|
|
$('#' + modal).modal('hide');
|
|
|
|
loadingAnimation();
|
|
|
|
document.getElementById("attendanceData^" + selPeriod).submit();
|
|
|
|
}
|
2021-10-19 07:30:49 -07:00
|
|
|
function resizeCanvas() {
|
|
|
|
var ratio = Math.max(window.devicePixelRatio || 1, 1);
|
|
|
|
canvas.width = canvas.offsetWidth * ratio;
|
|
|
|
canvas.height = canvas.offsetHeight * ratio;
|
|
|
|
canvas.getContext("2d").scale(ratio, ratio);
|
|
|
|
signaturePad.clear(); // otherwise isEmpty() might return incorrect value
|
|
|
|
}
|
|
|
|
function viewSignature(period) {
|
|
|
|
selPeriod = period
|
2021-12-26 05:08:50 -08:00
|
|
|
document.getElementById("attendanceData^" + selPeriod).getElementsByClassName("submissionType")[0].value = "newAbsent";
|
2021-10-19 07:30:49 -07:00
|
|
|
modal = 'sign-' + period;
|
|
|
|
$('#' + modal).modal('show');
|
|
|
|
var cnt = 0;
|
|
|
|
$('.tobeform').each(function (i, obj) {
|
|
|
|
if ($(this).is(":checked")) {
|
|
|
|
cnt++;
|
|
|
|
$('#postHomeroomAbs').append('<input type="checkbox" name="' + $(this).attr('class').split(' ')[1].split('^')[1]
|
|
|
|
+ '" checked="checked">');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (cnt == 0) {
|
|
|
|
$('#allPresentWarning-' + period).removeAttr('hidden');
|
|
|
|
}
|
|
|
|
canvas = document.getElementById("signature_pad^" + period);
|
|
|
|
signaturePad = new SignaturePad(canvas);
|
|
|
|
width = $(window).width();
|
|
|
|
window.addEventListener("resize", () => {
|
|
|
|
if (width != $(window).width()) {
|
|
|
|
resizeCanvas();
|
|
|
|
width = $(window).width();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
document.getElementById(modal).addEventListener("shown.bs.modal", function (e) {
|
|
|
|
resizeCanvas();
|
|
|
|
});
|
|
|
|
resizeCanvas();
|
|
|
|
}
|
2021-12-26 05:08:50 -08:00
|
|
|
function signDS(period) {
|
|
|
|
selPeriod = period
|
|
|
|
document.getElementById("attendanceData^" + selPeriod).getElementsByClassName("submissionType")[0].value = "dsSubmit";
|
|
|
|
modal = 'ds-' + period;
|
|
|
|
$('#' + modal).modal('show');
|
|
|
|
}
|
2021-10-19 07:30:49 -07:00
|
|
|
function unCheckLate(string) {
|
|
|
|
document.getElementById('late^' + string).checked = false;
|
2021-12-12 02:38:10 -08:00
|
|
|
strForNote = string.substring(string.indexOf("^") + 1);
|
|
|
|
if (document.getElementById("absent^" + string).checked == true && !!!document.getElementById("note^"+strForNote)) {
|
|
|
|
var tmp = document.createElement('input')
|
|
|
|
tmp.type = 'text'
|
|
|
|
tmp.id = 'note^'+strForNote
|
|
|
|
tmp.name = 'note^'+strForNote
|
|
|
|
tmp.className = 'form-control'
|
|
|
|
document.getElementById('input^' + string).appendChild(tmp)
|
|
|
|
} else if (document.getElementById("absent^" + string).checked == false) {
|
|
|
|
document.getElementById('note^' + strForNote).remove();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
function unCheckAbs(string) {
|
|
|
|
document.getElementById('absent^' + string).checked = false;
|
|
|
|
strForNote = string.substring(string.indexOf("^") + 1);
|
|
|
|
if (document.getElementById("late^" + string).checked == true && !!!document.getElementById("note^"+strForNote)) {
|
|
|
|
var tmp = document.createElement('input')
|
|
|
|
tmp.type = 'text'
|
|
|
|
tmp.id = 'note^'+strForNote
|
|
|
|
tmp.name = 'note^'+strForNote
|
|
|
|
tmp.className = 'form-control'
|
|
|
|
document.getElementById('input^' + string).appendChild(tmp)
|
|
|
|
} else if (document.getElementById("late^" + string).checked == false) {
|
|
|
|
document.getElementById('note^' + strForNote).remove();
|
|
|
|
}
|
2021-10-19 07:30:49 -07:00
|
|
|
}
|
|
|
|
|
2021-12-12 02:38:10 -08:00
|
|
|
|
2021-10-19 07:30:49 -07:00
|
|
|
function loadingAnimation() {
|
|
|
|
$("div.container").hide();
|
|
|
|
$('#loading').show();
|
|
|
|
}
|
|
|
|
function chgDate(sel) {
|
|
|
|
loadingAnimation();
|
|
|
|
var url = '/manage/date/' + $('#date').val()
|
|
|
|
var new_form = document.createElement('form');
|
|
|
|
new_form.method = 'GET';
|
|
|
|
new_form.action = url;
|
|
|
|
document.body.appendChild(new_form);
|
|
|
|
new_form.submit();
|
|
|
|
}
|
2021-12-12 02:38:10 -08:00
|
|
|
function addDS() {
|
|
|
|
if ($('#dsnumbersel').val() == "" || $('#dsoffensesel').val() == "") {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var text = $('#dsoffensesel').val()
|
|
|
|
if ($('#dsoffenseother').val() != "") {
|
|
|
|
text = text.concat(": ", $('#dsoffenseother').val());
|
|
|
|
}
|
|
|
|
indDS[$("#dsnumbersel").val()] = text;
|
|
|
|
$('#inddsview>.col').append('<div class="row"><div class="col">'+$("#dsnumbersel").val()+'</div><div class="col">'+text+'</div></div>')
|
|
|
|
$('#dsnumbersel option[value="'+$("#dsnumbersel").val()+'"]').remove();
|
|
|
|
$('#dsoffenseother').val("");
|
|
|
|
$('#dsoffensesel').val("");
|
|
|
|
$('#dsnumbersel').val("");
|
|
|
|
}
|