Skip to content

Commit 85a4149

Browse files
committed
fix: add function for calculating hypothetical assignment
Easier to comprehend with a single function name rather than a series of DOM modifications. Signed-off-by: Lucas Sta Maria <[email protected]>
1 parent e72064f commit 85a4149

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

src/js/saspowerschoolff.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,10 @@ function class_page () {
109109
return;
110110
}
111111
document.querySelector("table.linkDescList").append(html2node(`<tr><td><strong>Final Percent: </strong></td><td>` + number.toFixed(2) + ` <div class="tooltip saspes">&#9432;<span class="tooltiptext saspes">85: A+ | 75: A <br />65: B+ | 55: B <br />45: C+ | 35: C <br/>25: D+ | 15: D</span></div></td></tr>`));
112-
113-
document.querySelector('div.box-round').insertAdjacentHTML('afterend', `<div id="saspes-hypo-assignment"></div>`);
114-
new (Vue.extend(HypoAssignment))({
115-
propsData: {
116-
currentFP: number,
117-
},
118-
}).$mount('#saspes-hypo-assignment');
112+
113+
addHypoAssignment();
119114
}
115+
120116
function login_page () {
121117
$('<div id="saspes-info"></div>').insertAfter('div#content');
122118
browser.storage.local.get({ showExtensionInfo: true }).then(result => {
@@ -302,7 +298,7 @@ function getFirstSemCourses () {
302298

303299
/**
304300
* Adds the hypothetical grade calculator.
305-
* @param {courses} The courses of the student
301+
* @param courses The courses of the student
306302
*/
307303
function addHypoGradeCalc (courses) {
308304
const HypoGradesDiv = document.createElement('div');
@@ -315,3 +311,16 @@ function addHypoGradeCalc (courses) {
315311
},
316312
}).$mount(".hypo-grade-div-fixed");
317313
}
314+
315+
/**
316+
* Add a hypothetical assignment calculator widget.
317+
* @param number The current final percent of the student.
318+
*/
319+
function addHypoAssignment (number) {
320+
document.querySelector('div.box-round').insertAdjacentHTML('afterend', `<div id="saspes-hypo-assignment"></div>`);
321+
new (Vue.extend(HypoAssignment))({
322+
propsData: {
323+
currentFP: number,
324+
},
325+
}).$mount('#saspes-hypo-assignment');
326+
}

0 commit comments

Comments
 (0)