Skip to content

Commit

Permalink
Merge pull request #276 from sas-fossdev/fix-missing-indicator
Browse files Browse the repository at this point in the history
fixes powerschool showing icons next to every assignment
  • Loading branch information
Suhas Hariharan authored Apr 28, 2021
2 parents 2cf6ea1 + 2c65104 commit efc87fa
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/js/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,18 @@ function extractAssignmentList () {
const assignments = [];
[...table.querySelectorAll('tr')].slice(1, -1).forEach((e, i) => {
const curr = e.querySelectorAll('td');
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));
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));
});
return assignments;
}

/**
* Return whether the given row contains an indicator of any kind(i.e missing, late)
* @param {Element} node Node representing individual row of each assignment
* @returns {boolean} boolean representing whether input has child nodes and are set to visible.
*/
function isIndicatorPresent (node) {
return node.hasChildNodes() && node.childNodes[0].style.display !== 'none';
}
/**
* Return Assignment instances for the given class page.
* @param {Element} node Root node element of the class page.
Expand All @@ -203,7 +210,8 @@ function assignments (node) {
[...node.querySelector('table[align=center').querySelectorAll('tr')].slice(1, -1).forEach((e, i) => {
const curr = e.querySelectorAll('td');
const assignment = new Assignment(curr[2]?.innerText || "", curr[curr.length - 1]?.innerText || "", i);
if (e.querySelector('img[src="/images/icon_missing.gif"]')) {
const missingIcon = e.querySelector('img[src="/images/icon_missing.gif"]');
if (missingIcon && missingIcon?.style.display !== 'none') {
assignment.addStatus(Assignment.statuses.MISSING);
}
tr.push(assignment);
Expand Down

0 comments on commit efc87fa

Please sign in to comment.