Skip to content

Commit efc87fa

Browse files
author
Suhas Hariharan
authored
Merge pull request #276 from sas-fossdev/fix-missing-indicator
fixes powerschool showing icons next to every assignment
2 parents 2cf6ea1 + 2c65104 commit efc87fa

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/js/helpers.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,18 @@ function extractAssignmentList () {
187187
const assignments = [];
188188
[...table.querySelectorAll('tr')].slice(1, -1).forEach((e, i) => {
189189
const curr = e.querySelectorAll('td');
190-
assignments.push(new ClassAssignment(i, curr[0].innerHTML, curr[1].innerHTML, curr[2].innerHTML, curr[3].hasChildNodes(), curr[4].hasChildNodes(), curr[5].hasChildNodes(), curr[6].hasChildNodes(), curr[7].hasChildNodes(), curr[8].innerHTML, curr[10].innerHTML));
190+
assignments.push(new ClassAssignment(i, curr[0].innerHTML, curr[1].innerHTML, curr[2].innerHTML, isIndicatorPresent(curr[3]), isIndicatorPresent(curr[4]), isIndicatorPresent(curr[5]), isIndicatorPresent(curr[6]), isIndicatorPresent(curr[7]), curr[8].innerHTML, curr[10].innerHTML));
191191
});
192192
return assignments;
193193
}
194-
194+
/**
195+
* Return whether the given row contains an indicator of any kind(i.e missing, late)
196+
* @param {Element} node Node representing individual row of each assignment
197+
* @returns {boolean} boolean representing whether input has child nodes and are set to visible.
198+
*/
199+
function isIndicatorPresent (node) {
200+
return node.hasChildNodes() && node.childNodes[0].style.display !== 'none';
201+
}
195202
/**
196203
* Return Assignment instances for the given class page.
197204
* @param {Element} node Root node element of the class page.
@@ -203,7 +210,8 @@ function assignments (node) {
203210
[...node.querySelector('table[align=center').querySelectorAll('tr')].slice(1, -1).forEach((e, i) => {
204211
const curr = e.querySelectorAll('td');
205212
const assignment = new Assignment(curr[2]?.innerText || "", curr[curr.length - 1]?.innerText || "", i);
206-
if (e.querySelector('img[src="/images/icon_missing.gif"]')) {
213+
const missingIcon = e.querySelector('img[src="/images/icon_missing.gif"]');
214+
if (missingIcon && missingIcon?.style.display !== 'none') {
207215
assignment.addStatus(Assignment.statuses.MISSING);
208216
}
209217
tr.push(assignment);

0 commit comments

Comments
 (0)