Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separating lines between different semesters #19

Merged
merged 2 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 3,
"name": "Karaktersnitt for Studentweb",
"short_name": "Karaktersnitt",
"version": "1.0.4",
"version": "1.0.5",
"description": "Regner automatisk ut karaktersnitt på Studentweb.",
"homepage_url": "https://github.com/runarmod/Karaktersnitt",

Expand Down
32 changes: 31 additions & 1 deletion src/karaktersnitt_kalkulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
* The script is only executed on the "Mine resultater" page.
*/

const allRows = document.getElementsByTagName("tr");
const allRows = document
.querySelector(".table-standard.reflow.ui-panel-content")
.getElementsByTagName("tr");

let checkedSubjects = [];

Expand Down Expand Up @@ -41,8 +43,36 @@ for (const changeButton of changeButtonsLabels) {
});
}

createBoldLines();
createAllCheckboxes();

/**
* Creates bold lines between rows with different semesters, to easier distinguish between them.
*/
function createBoldLines() {
let previousRow = null;
for (const row of allRows) {
if (
!(row.classList.contains("none") || row.classList.contains("resultatTop"))
)
continue;

if (!previousRow) {
previousRow = row;
continue;
}

const previousSemester = previousRow.children[0].children[1].innerText;
const currentSemester = row.children[0].children[1].innerText;

if (previousSemester != currentSemester) {
row.style.borderTop = "3px solid black";
}

previousRow = row;
}
}

/**
* Creates checkboxes for each relevant row and attaches event
* listener to update the average when checkbox is changed.
Expand Down
Loading