function getHR() { var grade = $('#sel-grade').val(); $('#sel-room').html(''); if (grade === "") { $('#sel-room').attr('disabled', 'disabled') return } homerooms[grade].forEach(element => { $('#sel-room').append(``) }); $('#sel-room').removeAttr('disabled') } function redirAdmin() { if ($("#sel-room").val() == "") { alert("請選擇年級 / 班級!"); return; } var url = "/manage/admin/" + $('#sel-grade').val() + "/" + $('#sel-room').val() + "/" + $('#date').val(); var new_form = document.createElement('form'); new_form.method = 'GET'; new_form.action = url; document.body.appendChild(new_form); new_form.submit(); $('.container').hide(); $('#loading').show(); } function edit(string) { $('.view-' + string).each(function (i, obj) { var num = $(this.firstElementChild).attr('class').split(' ')[2].replace('view-n-', ''); if ($(this.firstElementChild).attr('class').split(' ')[1] == "n-1") { $(this).html("") $(this).append(""); $(this).append("\n"); } else if ($(this.firstElementChild).attr('class').split(' ')[1] == "n-2") { $(this).html("") $(this).append(""); $(this).append("\n"); } else if ($(this.firstElementChild).attr('class').split(' ')[1] == "n-3") { $(this).html("") $(this).append(""); $(this).append("\n"); } }); $('#btns-' + string).html("") $('.afterSelButton').attr('disabled', 'disabled'); $('#btns-' + string).append(""); } function unCheckLate(string) { document.getElementById('late^' + string).checked = false; } function unCheckAbs(string) { document.getElementById('absent^' + string).checked = false; } function afterSelAbs(period) { $('#postHomeroomAbs #HR-period').attr('value', period); $('.tobeform').attr('disabled', 'disabled'); $('.afterSelButton').attr('disabled', 'disabled'); $('.tobeform').each(function (i, obj) { if ($(this).attr('class').split(' ')[1].split('^')[1] == period && $(this).is(":checked")) { $('#postHomeroomAbs').append(''); } }); $('#finalCheck').modal('show'); } function submitForm() { $('#HR-notes').attr('value', $('#subjectNotes').val()); $('#postHomeroomAbs').submit(); $('#finalCheck').modal('hide'); $('.container').hide(); $('#loading').show(); } function refresh_homeroom() { var grade = $('#grade').val(); $('#class').html(''); $('span#name').html = "" if (grade === "") { $('#class').attr('disabled', 'disabled') return } // get keys in dict var keys = Object.keys(students[grade]); keys.forEach(element => { $('#class').append(``) }); $('#class').removeAttr('disabled') } function refresh_numbers() { var grade = $('#grade').val(); var class_ = $('#class').val(); $('span#name').html = "" $('#number').html(''); if (grade === "") { $('#class').attr('disabled', 'disabled') if (clas_ !== "") return } if (class_ === "") { $('#number').attr('disabled', 'disabled') return } // get keys in dict var keys = Object.keys(students[grade][class_]); keys.forEach(element => { $('#number').append(``) }); $('#number').removeAttr('disabled') } function showName() { var grade = $('#grade').val(); var class_ = $('#class').val(); var number = $('#number').val(); $('#name').html(students[grade][class_][number]); } function clearForm() { document.getElementById('newabs').reset(); $('#class').attr('disabled', 'disabled') $('#number').attr('disabled', 'disabled') $('span#name').html = "" }