@@ -48,7 +48,7 @@ const grade_gpa = {
4848 * @param {string } grade The grade to convert.
4949 * @returns {number } The corresponding grade point average.
5050 */
51- function gradeToGPA ( grade ) {
51+ function gradeToGPA ( grade ) {
5252 if ( grade in grade_gpa ) {
5353 return grade_gpa [ grade ] ;
5454 }
@@ -72,7 +72,7 @@ const grade_fp = {
7272 * @param {string } grade The grade to convert.
7373 * @returns {number } The corresponding final percent.
7474 */
75- function gradeToFP ( grade ) {
75+ function gradeToFP ( grade ) {
7676 if ( grade in grade_fp ) {
7777 return grade_fp [ grade ] ;
7878 }
@@ -93,7 +93,7 @@ const fprange = {
9393 '0-15' : 'F' ,
9494} ;
9595
96- function fpToGrade ( finalPercent ) {
96+ function fpToGrade ( finalPercent ) {
9797 return getKeyRange ( fprange , parseFloat ( parseFloat ( finalPercent ) . toFixed ( 2 ) ) ) ;
9898}
9999
@@ -102,7 +102,7 @@ function fpToGrade(finalPercent) {
102102 * @param {Course[] } courses The courses for which the overall grade point average should be calculated.
103103 * @returns {string } The grade point average to the hundredth place.
104104 */
105- function calculate_gpa ( courses ) {
105+ function calculate_gpa ( courses ) {
106106 let courses_with_grades = 0 ;
107107 let sum = 0 ;
108108 for ( var i = 0 ; i < courses . length ; i ++ ) {
@@ -117,7 +117,7 @@ function calculate_gpa(courses) {
117117 }
118118 return ( sum / courses_with_grades ) . toFixed ( 2 ) ;
119119
120- function course_boost ( course_name , grade ) {
120+ function course_boost ( course_name , grade ) {
121121 if ( gradeToGPA ( grade ) < 1.8 ) {
122122 return 0 ;
123123 }
@@ -128,7 +128,7 @@ function calculate_gpa(courses) {
128128 }
129129}
130130
131- function calculate_credit_hours ( course_name ) {
131+ function calculate_credit_hours ( course_name ) {
132132 const double_effect_courses = [ `English 10/American History` , `English 9/World History` ] ;
133133 if ( double_effect_courses . includes ( course_name ) ) {
134134 return 2 ;
@@ -144,7 +144,7 @@ function calculate_credit_hours(course_name) {
144144 * @param {String } html course page html
145145 * @returns {Number|undefined } The final percent
146146 */
147- function extractFinalPercent ( html ) {
147+ function extractFinalPercent ( html ) {
148148 let number ;
149149 try {
150150 let current_string = html . match ( / (? = d o c u m e n t \. w r i t e ) .* / g) [ 1 ] ;
@@ -166,7 +166,7 @@ function extractFinalPercent(html) {
166166 * @param {String } semester string representing semester that the request is for
167167 * @returns {Number|undefined } The final percent
168168 */
169- async function getFinalPercent ( frn , semester ) {
169+ async function getFinalPercent ( frn , semester ) {
170170 let number ;
171171 try {
172172 await fetch ( `https://powerschool.sas.edu.sg/guardian/scores_ms_guardian.html?frn=${ frn } &fg=${ semester } ` , { credentials : "same-origin" } ) . then ( response => response . text ( ) ) . then ( response => {
@@ -188,7 +188,7 @@ async function getFinalPercent(frn, semester) {
188188 * @param {Node } table node representing table
189189 * @returns {String[] } List of all categories
190190 */
191- function extractGradeCategories ( table ) {
191+ function extractGradeCategories ( table ) {
192192 const table_rows = table . getElementsByTagName ( "tr" ) ;
193193 const category_set = new Set ( ) ;
194194 for ( let i = 1 ; i < table_rows . length - 1 ; i ++ ) {
@@ -201,7 +201,7 @@ function extractGradeCategories(table) {
201201 * Extract all assignments from a class.
202202 * @returns {ClassAssignment[] } List of all assignments
203203 */
204- function extractAssignmentList ( ) {
204+ function extractAssignmentList ( ) {
205205 const table = document . querySelector ( "table.zebra.grid > tbody" ) ;
206206 const assignments = [ ] ;
207207 [ ...table . querySelectorAll ( 'tr' ) ] . slice ( 1 , - 1 ) . forEach ( ( e , i ) => {
@@ -215,19 +215,19 @@ function extractAssignmentList() {
215215 return assignments ;
216216}
217217/**
218- * Return whether the given row contains an indicator of any kind(i.e missing, late)
218+ * Return whether the given row contains an indicator of any kind(i.e missing, late)
219219 * @param {Element } node Node representing individual row of each assignment
220220 * @returns {boolean } boolean representing whether input has child nodes and are set to visible.
221221 */
222- function isIndicatorPresent ( node ) {
222+ function isIndicatorPresent ( node ) {
223223 return node . hasChildNodes ( ) && node . querySelector ( "div.ps-icon" ) ;
224224}
225225/**
226226 * Return Assignment instances for the given class page.
227227 * @param {Element } node Root node element of the class page.
228228 * @returns {Assignment[] } Assignments in this course
229229 */
230- function assignmentsFromNode ( node ) {
230+ function assignmentsFromNode ( node ) {
231231 const tr = [ ] ;
232232 // Find assignments table, get it's rows, take out the header and legend rows.
233233 [ ...node . querySelector ( 'table.zebra.grid' ) . querySelectorAll ( 'tr' ) ] . slice ( 1 , - 1 ) . forEach ( ( e , i ) => {
@@ -250,19 +250,21 @@ function assignmentsFromNode(node) {
250250 * @param {String } end_date end date in YYYY-MM-DD format
251251 * @returns {Assignment[] } Assignments in this course
252252 */
253- function assignmentsFromAPI ( studentId , sectionId , startDate , endDate ) {
253+ function assignmentsFromAPI ( studentId , sectionId , startDate , endDate ) {
254254 const assignmentList = [ ] ;
255255 try {
256256 fetch ( 'https://powerschool.sas.edu.sg/ws/xte/assignment/lookup' , {
257- method : "POST" , headers : {
258- 'Content-Type' : 'application/json'
257+ method : "POST" ,
258+ headers : {
259+ 'Content-Type' : 'application/json' ,
259260 } ,
260261 body : JSON . stringify ( {
261262 "student_ids" : [ studentId ] ,
262263 "section_ids" : [ sectionId ] ,
263264 "start_date" : startDate ,
264- "end_date" : endDate
265- } ) , credentials : "same-origin"
265+ "end_date" : endDate ,
266+ } ) ,
267+ credentials : "same-origin" ,
266268 } ) . then ( response => response . json ( ) ) . then ( response => {
267269 for ( let i = 0 ; i < response . length ; i ++ ) {
268270 if ( response [ i ] . _assignmentsections ?. length ) {
@@ -285,15 +287,15 @@ function assignmentsFromAPI(studentId, sectionId, startDate, endDate) {
285287 * Return course title of active class page
286288 * @returns {String } Course title
287289 */
288- function extractCourseTitle ( ) {
289- return document . querySelector ( "tbody:nth-child(1) > tr:nth-child(2) > td:nth-child(1)" ) . innerText
290+ function extractCourseTitle ( ) {
291+ return document . querySelector ( "tbody:nth-child(1) > tr:nth-child(2) > td:nth-child(1)" ) . innerText ;
290292}
291293
292294/**
293295 * Retrieve category weighting for class from local storage
294296 * @returns {Map<String, Object> } Map of weighting assigned to each category for course
295297 */
296- async function getSavedCategoryWeighting ( ) {
298+ async function getSavedCategoryWeighting ( ) {
297299 const courseName = extractCourseTitle ( ) + "-catmap" ;
298300 const catmap = await browser . storage . local . get ( courseName ) ;
299301 if ( catmap === undefined || ( Object . keys ( catmap ) . length === 0 && catmap . constructor === Object ) || catmap [ courseName ] === undefined ) return false ;
@@ -304,7 +306,7 @@ async function getSavedCategoryWeighting() {
304306 * Save category weighting for class to local storage
305307 * @param {Map<String, Object> } catmap Map of weighting assigned to each category for course
306308 */
307- async function saveCategoryWeighting ( catmap ) {
309+ async function saveCategoryWeighting ( catmap ) {
308310 const courseName = extractCourseTitle ( ) ;
309311 const data = { } ;
310312 data [ courseName + "-catmap" ] = catmap ;
@@ -317,7 +319,7 @@ async function saveCategoryWeighting(catmap) {
317319 * @param {String } username users full name
318320 * @returns {Promise<Course[]> } list of courses objects for that user
319321 */
320- async function getSavedGrades ( username ) {
322+ async function getSavedGrades ( username ) {
321323 const courses = [ ] ;
322324 const user_data = ( await browser . storage . local . get ( "user_data" ) ) . user_data ;
323325 if ( user_data !== undefined ) {
@@ -346,7 +348,7 @@ async function getSavedGrades(username) {
346348 * @param {String } username users full name
347349 * @param {Course[] } courses list of course objects to save
348350 */
349- async function saveGradesLocally ( username , courses ) {
351+ async function saveGradesLocally ( username , courses ) {
350352 const data = await getLocalConfig ( ) || { } ;
351353
352354 if ( data . opted_in === undefined ) {
@@ -381,7 +383,7 @@ async function saveGradesLocally(username, courses) {
381383 * @async
382384 * @returns {Config } an object representing the user's config from the browser's local storage
383385 */
384- async function getLocalConfig ( ) {
386+ async function getLocalConfig ( ) {
385387 const data = await browser . storage . local . get ( null ) ;
386388 return data ;
387389}
@@ -390,7 +392,7 @@ async function getLocalConfig() {
390392 * Retrieves the default extension config for new users.
391393 * @returns {Config } an object representing the default config.
392394 */
393- function getDefaultConfig ( ) {
395+ function getDefaultConfig ( ) {
394396 const data = { opted_in : { changed : false , value : false } , percent_main_page : { changed : false , value : true } } ;
395397 return data ;
396398}
0 commit comments