-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.min.js
1 lines (1 loc) · 1.05 KB
/
app.min.js
1
(function(s,objectName){setupLinks = function(){if( s.admin ){var sl = document.getElementsByClassName("student-link");for (i = 0; i < sl.length; i++) {let name = sl[i].innerHTML;sl[i].style.cursor='pointer';sl[i].addEventListener("click", function(){window.location = '/update-' + objectName + '/' + this.dataset.id;});}}};updateForm = function(){ var submitButton = document.getElementsByClassName("update-record"); if( submitButton.length === 1 ){ submitButton[0].addEventListener("click", function(){var english = document.getElementById("english");english = english.options[english.selectedIndex].value;var science = document.getElementById("science");science = science.options[science.selectedIndex].value;var maths = document.getElementById("maths");maths = maths.options[maths.selectedIndex].value;var grades = new Set(["A","B","C","D","E","F"]);if (grades.has(english) && grades.has(science) && grades.has(maths) ) {document.getElementById('student-form').submit();}else{ alert('Grades should only be between A - F');}});}};setupLinks();updateForm();})(staff,'student');