Skip to content

Commit f1e6d5f

Browse files
committed
Version 0.1.6
1 parent c2c8138 commit f1e6d5f

File tree

11 files changed

+190
-16
lines changed

11 files changed

+190
-16
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Open Beta 0.1.6
2+
3+
## 2019-04-24
4+
5+
### Features
6+
7+
* **Hypo Assignment Calculator:** Check how your class grade will be effected by a new assignment!
8+
* **Login Page:** The login page now contains information about SAS Powerschool Enhancement Suite
9+
10+
### Miscellaneous
11+
12+
* **Options Page:** Repo link has been changed to GitHub.
13+
* **Copyright Header:** A copyright header has been added to many files.
14+
115
# Open Beta 0.1.5.7
216

317
## 2019-01-15

src/chromium/ui/options.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<a href="https://gschool.ydgkim.com/saspowerschool/?pk_campaign=SASPES&pk_kwd=options-page" id="website-link">https://gschool.ydgkim.com/saspowerschool/</a><br />
2525
<br />
2626
Source Code: <br />
27-
<a href="https://gitlab.com/garykim/saspes" id="source-code-link">https://gitlab.com/garykim/saspes</a><br />
27+
<a href="https://github.com/gary-kim/saspes" id="source-code-link">https://github.com/gary-kim/saspes</a><br />
2828
<br />
2929
Credits: <br />
3030
Special thanks to Alan Chang for the idea.

src/css/spse.css

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ div.hypo-grade-div {
6969
left: 100vw;
7070
/* transition: left,right 1s; */
7171
}
72+
div.hypo-grade-div select {
73+
border-radius: 5px 5px 5px 5px;
74+
}
7275
div.hypo-grade-div-fixed {
7376
position: fixed;
7477
right: 0;
@@ -96,13 +99,45 @@ div.hypo-grade-div-fixed {
9699
position: relative;
97100
display: inline-block;
98101
}
99-
#update-info {
102+
#saspes-info {
100103
background-color: #FFF;
101104
box-shadow: 0 10px 20px rgba(0,0,0,0.4);
102105
position: relative;
103106
padding-bottom: 1px;
104-
margin: 0;
107+
margin-top: 50px;
105108
padding: 0;
106109
font-size: inherit;
107110
color: #444444;
111+
}
112+
.saspes-content {
113+
padding: 20px;
114+
}
115+
.saspes-section {
116+
border: 1px solid #CCCCCC;
117+
border-radius: 4px;
118+
margin: 10px 20px;
119+
padding: 0;
120+
}
121+
.saspes-section h3 {
122+
font-size: 110%;
123+
margin: 0 10px 10px 10px;
124+
padding: 0;
125+
border-top-right-radius: 3px;
126+
border-top-left-radius: 3px;
127+
}
128+
.saspes-section select {
129+
margin: 0 auto 0 auto;
130+
border-radius: 5px 5px 5px 5px;
131+
}
132+
.saspes-section label {
133+
vertical-align: initial;
134+
padding-left: 20px;
135+
}
136+
.saspes-section input {
137+
border-radius: 5px 5px 5px 5px;
138+
padding: 5px;
139+
}
140+
.saspes-logo {
141+
height: 2em;
142+
padding-right: 0.7em;
108143
}

src/js/background.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
SAS Powerschool Enhancement Suite - A browser extension to improve the experience of using SAS Powerschool.
33
4-
Copyright (C) 2018-2019 Gary Kim (gary@ydgkim.com)
4+
Copyright (C) 2018-2019 Gary Kim <gary@garykim.dev>
55
66
This program is free software: you can redistribute it and/or modify
77
it under the terms of the GNU General Public License as published by

src/js/saspowerschoolff.js

Lines changed: 96 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
SAS Powerschool Enhancement Suite - A browser extension to improve the experience of SAS Powerschool.
33
4-
Copyright (C) 2018-2019 Gary Kim (gary@ydgkim.com)
4+
Copyright (C) 2018-2019 Gary Kim <gary@garykim.dev>
55
66
This program is free software: you can redistribute it and/or modify
77
it under the terms of the GNU General Public License as published by
@@ -20,6 +20,18 @@
2020

2121
'use strict';
2222

23+
const fprange = {
24+
'0-15': 'F',
25+
'15-25': 'D',
26+
'25-35': 'D+',
27+
'35-45': 'C',
28+
'45-55': 'C+',
29+
'55-65': 'B',
30+
'65-75': 'B+',
31+
'75-85': 'A',
32+
'85-90': 'A+'
33+
}
34+
2335
let percent_main_page = true;
2436
browser.storage.local.get({percent_main_page: true}).then(
2537
function( returned ) {
@@ -41,7 +53,7 @@ function main( jQuery ) {
4153
});
4254

4355

44-
let page_url = window.location.href;
56+
let page_url = window.location.href.split('#')[0];
4557
if(page_url == "https://powerschool.sas.edu.sg/guardian/homeHS.html") {
4658
main_page();
4759
analytics_message("Main Page");
@@ -188,6 +200,8 @@ function main_page() {
188200
*/
189201
}
190202
function class_page() {
203+
204+
// Show final percent
191205
let current_string = $("table.linkDescList").html();
192206
current_string = current_string.match(/(?=document\.write).*/g)[1];
193207
current_string = /\[.*\]/g.exec(current_string)[0].slice(1,-1);
@@ -198,6 +212,42 @@ function class_page() {
198212
return;
199213
}
200214
document.querySelector("table.linkDescList").append(html2node(`<tr><td><strong>Final Percent: </strong></td><td>` + parseFloat(number).toFixed(2) + ` <div class="tooltip saspe">&#9432;<span class="tooltiptext saspe">85: A+ | 75: A <br />65: B+ | 55: B <br />45: C+ | 35: C <br/>25: D+ | 15: D</span></div></td></tr>`));
215+
216+
217+
// Hypo Assignment
218+
let $hypo_assignment = $('<div></div>').addClass('saspes-section');
219+
let hypo_assignment_info = {
220+
weight: 0,
221+
grade: 'B'
222+
};
223+
224+
$hypo_assignment.html('<h3>Hypothetical Assignment</h3> <label for="saspes-assignment-effect" >Effect of new assignment (currently): </label>');
225+
226+
227+
$('<input type="number" min="0" max="100" value="0" id="saspes-assignment-effect" />').on('input', (e) => {
228+
hypo_assignment_info.weight = parseInt(e.currentTarget.value);
229+
showHypoGrade();
230+
}).appendTo($hypo_assignment);
231+
$hypo_assignment.append($('<text>% </text>'))
232+
$hypo_assignment.append($('<label for="hypo-grade-select">Grade of new assignment: </label>'));
233+
$('<select id="hypo-grade-select"><option value="A+">A+</option><option value="A">A</option><option value="B+">B+</option><option value="B" selected="">B</option><option value="C+">C+</option><option value="C">C</option><option value="D+">D+</option><option value="D">D</option><option value="F">F</option></select>').on('change', (e) => {
234+
hypo_assignment_info.grade = e.currentTarget.value;
235+
showHypoGrade();
236+
}).appendTo($hypo_assignment);
237+
$hypo_assignment.append(`<br /><h4>Your grade with the selected assignment would be <text id="new-hypo-grade"></text> with a final percent of <text id="new-hypo-fp"></text>.</h4>`);
238+
239+
$hypo_assignment.insertAfter('div.box-round');
240+
241+
showHypoGrade();
242+
function showHypoGrade() {
243+
let new_fp = hypo_assignment_info.weight * 0.01 * grade_fp(hypo_assignment_info.grade) + ((100 - (hypo_assignment_info.weight)) * 0.01 * parseFloat(number));
244+
console.log(new_fp);
245+
console.log(getKeyRange(fprange, new_fp))
246+
document.querySelector('div.saspes-section text#new-hypo-grade').innerText = getKeyRange(fprange, new_fp);
247+
document.querySelector('div.saspes-section text#new-hypo-fp').innerText = new_fp.toFixed(2);
248+
}
249+
250+
201251
}
202252
function login_page() {
203253
/*
@@ -222,6 +272,16 @@ function login_page() {
222272
let insert_location = document.querySelector('#content');
223273
insert_location.parentNode.insertBefore(document.createElement('a'), insert_location);
224274
*/
275+
$('<div id="saspes-info"></div>').insertAfter('div#content');
276+
$('#saspes-info').html(`<h3> <img src="${browser.runtime.getURL('icons/128.png')}" class="saspes-logo">SAS Powerschool Enhancement Suite</h3> <div class="saspes-content"><p style="font-size: 1.5em;">Version: ${browser.runtime.getManifest().version}</p><p><a class="saspes-link" href="https://gschool.ydgkim.com/saspowerschool/" target="_blank" >Project Website<a> | <a href="https://github.com/gary-kim/saspes/blob/master/CHANGELOG.md" class="saspes-link" target="_blank" >Changelog</a> | <a class="saspes-link" href="https://github.com/gary-kim/saspes" target="_blank" >Source Code</a> | <a id="login-extension-settings" href="#" >Extension Options</a></div></p>`);
277+
$('#login-extension-settings').on('click', () => {
278+
browser.runtime.sendMessage({action: "open_settings"});
279+
});
280+
$('.saspes-link').on('click', (e) => {
281+
let href = e.currentTarget.href;
282+
browser.runtime.sendMessage({action: "analytics_send", args: {url: href, extra: {link: href}}});
283+
});
284+
225285
}
226286
function fill_percent($fill_location,url_link,percents, pos_in_arr) {
227287
if(!percent_main_page) {
@@ -318,6 +378,40 @@ function grade_gpa(grade) {
318378
break;
319379
}
320380
}
381+
function grade_fp(grade) {
382+
switch(grade){
383+
case "A+":
384+
return 90;
385+
break;
386+
case "A":
387+
return 80;
388+
break;
389+
case "B+":
390+
return 70;
391+
break;
392+
case "B":
393+
return 60;
394+
break;
395+
case "C+":
396+
return 50;
397+
break;
398+
case "C":
399+
return 40;
400+
break;
401+
case "D+":
402+
return 30;
403+
break;
404+
case "D":
405+
return 20;
406+
break;
407+
case "F":
408+
return 10;
409+
break;
410+
default:
411+
return -1;
412+
break;
413+
}
414+
}
321415
function html2node(html_string) {
322416
return html2nodelist(html_string)[0];
323417
}

src/lib/range.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
This is a slightly modified version of rahatarmanahmed's get-key-range npm package. You can see the package at
3+
https://www.npmjs.com/package/get-key-range
4+
*/
5+
6+
function getKeyRange(obj, key) {
7+
let ranges = Object.keys(obj);
8+
for (let i = ranges.length - 1; i >= 0; i--) {
9+
if (isInRange(ranges[i], key)) return obj[ranges[i]]
10+
}
11+
}
12+
function isInRange(ranges, n) {
13+
ranges = ranges.split(/\s*,\s*/);
14+
return ranges.some(inRange.bind(null, n));
15+
16+
function inRange(n, range) {
17+
var limits = range.split(/\s*-\s*/);
18+
19+
if (limits.length === 1) return range == n;
20+
if (limits.length !== 2) throw new Error('Invalid range:' + range);
21+
22+
var max = Math.max(limits[0], limits[1]);
23+
var min = Math.min(limits[0], limits[1]);
24+
25+
return min <= n && n <= max;
26+
}
27+
}
28+
29+
window.getKeyRange = getKeyRange;

src/manifest - chromium.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"manifest_version": 2,
33
"name": "SAS Powerschool Enhancement Suite",
44
"short_name": "SAS PES",
5-
"version": "0.1.5.7",
6-
"version_name": "Public Beta 0.1.5.7",
5+
"version": "0.1.6",
6+
"version_name": "Public Beta 0.1.6",
77
"author": "Gary Kim",
88
"homepage_url": "https://gschool.ydgkim.com/saspowerschool/",
99
"description": "Provides various enhancements for SAS Powerschool",
@@ -20,15 +20,16 @@
2020
},
2121
"web_accessible_resources": [
2222
"/ui/historygrades.*",
23-
"/chromium/ui/historygrades.html"
23+
"/chromium/ui/historygrades.html",
24+
"/icons/*"
2425
],
2526
"background": {
2627
"scripts": ["chromium/background-fix.js","chromium/browser-polyfill.js","lib/jquery-3.3.1.js","js/background.js"]
2728
},
2829
"content_scripts": [
2930
{
3031
"matches": ["https://powerschool.sas.edu.sg/*"],
31-
"js": ["chromium/background-fix.js","chromium/browser-polyfill.js","lib/jquery-3.3.1.js","js/saspowerschoolff.js"],
32+
"js": ["chromium/background-fix.js","chromium/browser-polyfill.js","lib/jquery-3.3.1.js","lib/range.js","js/saspowerschoolff.js"],
3233
"css": ["css/spse.css"],
3334
"run_at": "document_start"
3435
}

src/manifest.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 2,
33
"name": "SAS Powerschool Enhancement Suite",
44
"short_name": "SAS PES",
5-
"version": "0.1.5.7",
5+
"version": "0.1.6",
66
"author": "Gary Kim",
77
"homepage_url":"https://gschool.ydgkim.com/saspowerschool/",
88
"description": "Provides various enhancements for SAS Powerschool",
@@ -25,15 +25,16 @@
2525
"browser_style": true
2626
},
2727
"web_accessible_resources": [
28-
"/ui/historygrades.*"
28+
"/ui/historygrades.*",
29+
"/icons/*"
2930
],
3031
"background": {
3132
"scripts": ["lib/jquery-3.3.1.js","js/background.js"]
3233
},
3334
"content_scripts": [
3435
{
3536
"matches": ["https://powerschool.sas.edu.sg/*"],
36-
"js": ["lib/jquery-3.3.1.js","js/saspowerschoolff.js"],
37+
"js": ["lib/jquery-3.3.1.js","lib/range.js","js/saspowerschoolff.js"],
3738
"css": ["css/spse.css"],
3839
"run_at": "document_start"
3940
}

src/ui/historygrades.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
SAS Powerschool Enhancement Suite - A browser extension to improve the experience of SAS Powerschool.
33
4-
Copyright (C) 2018-2019 Gary Kim (gary@ydgkim.com)
4+
Copyright (C) 2018-2019 Gary Kim <gary@garykim.dev>
55
66
This program is free software: you can redistribute it and/or modify
77
it under the terms of the GNU General Public License as published by

src/ui/options.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<a href="https://gschool.ydgkim.com/saspowerschool/?pk_campaign=SASPES&pk_kwd=options-page" id ="website-link">https://gschool.ydgkim.com/saspowerschool/</a><br />
2626
<br />
2727
Source Code: <br />
28-
<a href="https://gitlab.com/garykim/saspes" id="source-code-link">https://gitlab.com/garykim/saspes</a><br />
28+
<a href="https://github.com/gary-kim/saspes" id="source-code-link">https://github.com/gary-kim/saspes</a><br />
2929
<br />
3030
Credits: <br />
3131
Special thanks to Alan Chang for the idea.

0 commit comments

Comments
 (0)