Skip to content

Commit

Permalink
Fix offset issue for unapproved students (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
therealsujitk committed Nov 14, 2023
1 parent 2e9aaa3 commit cc9013b
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,6 @@ private void downloadCourses() {
" }" +
" var table = doc.getElementById('studentDetailsList').getElementsByTagName('table')[0];" +
" var headings = table.getElementsByTagName('th');" +
" var offset = headings[0].innerText.toLowerCase().includes('invoice') ? -1 : 0;" +
" var courseIndex, creditsIndex, slotVenueIndex, facultyIndex;" +
" for(var i = 0; i < headings.length; ++i) {" +
" var heading = headings[i].innerText.toLowerCase();" +
Expand All @@ -816,6 +815,9 @@ private void downloadCourses() {
" }" +
" }" +
" var cells = table.getElementsByTagName('td');" +
" var headingOffset = headings[0].innerText.toLowerCase().includes('invoice') ? -1 : 0;" +
" var cellOffset = cells[0].innerText.toLowerCase().includes('invoice') ? 1 : 0;" +
" var offset = headingOffset + cellOffset;" +
" while (courseIndex < cells.length && creditsIndex < cells.length && slotVenueIndex < cells.length && facultyIndex < cells.length) {" +
" var course = {};" +
" var rawCourse = cells[courseIndex + offset].innerText.replace(/\\t/g,'').replace(/\\n/g,' ');" +
Expand All @@ -831,10 +833,10 @@ private void downloadCourses() {
" course.venue = rawSlotVenue.slice(1, rawSlotVenue.length).join(' - ').trim();" +
" course.faculty = rawFaculty[0].trim();" +
" response.courses.push(course);" +
" courseIndex += headings.length + offset;" +
" creditsIndex += headings.length + offset;" +
" slotVenueIndex += headings.length + offset;" +
" facultyIndex += headings.length + offset;" +
" courseIndex += headings.length + headingOffset;" +
" creditsIndex += headings.length + headingOffset;" +
" slotVenueIndex += headings.length + headingOffset;" +
" facultyIndex += headings.length + headingOffset;" +
" }" +
" }" +
"});" +
Expand Down

0 comments on commit cc9013b

Please sign in to comment.