Skip to content

Commit 06a4bec

Browse files
committed
Migrate options to Vue and go more community driven
This commit makes several improvements. It migrates the options page to Vue, changes the author field and copyrights to include The SAS PES Authors, deduplicates some code, and adds some missing information/fixes to the README. Signed-off-by: Gary Kim <[email protected]>
1 parent 4fa206d commit 06a4bec

File tree

8 files changed

+128
-77
lines changed

8 files changed

+128
-77
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ Regardless of what the extension calculates, teachers are able to override the f
2828

2929
### Main Page
3030
* View final percent for each course
31-
* View current semester GPA
31+
* View semester GPA for both S1 and S2
3232
* Recalculate semester GPA with custom hypothetical grades.
33+
* Calculate cumulative GPA
3334

3435
### Class Page
3536
* View final percent and cutoffs for grades
@@ -41,14 +42,14 @@ Regardless of what the extension calculates, teachers are able to override the f
4142

4243
## Browser Support
4344

44-
### Offically Supported
45+
### Officially Supported
4546

4647
* Firefox
4748
* Chromium
4849

4950
Please be aware that the extension is mainly designed for use in Firefox.
5051

51-
### Unoffical Support
52+
### Unofficial Support
5253

5354
People have gotten the extension to work on the following browsers
5455

@@ -69,7 +70,8 @@ Refer to the [libraries.txt](/libraries.txt).
6970

7071
## License
7172

72-
Copyright &copy; 2018-2019 Gary Kim &lt;<[email protected]>&gt;
73+
Copyright &copy; 2020 The SAS PES Authors
74+
Copyright &copy; 2018-2020 Gary Kim &lt;<[email protected]>&gt;
7375

7476
Source code licensed under [AGPL-3.0-only](LICENSE)
7577

src/js/helpers.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
import Assignment from "./models/Assignment";
2828

29+
import browser from 'webextension-polyfill';
2930
const getKeyRange = require('get-key-range');
3031

3132
const grade_gpa = {
@@ -176,6 +177,16 @@ function assignments (node) {
176177
return tr;
177178
}
178179

180+
/**
181+
* Send Analytics ping
182+
* @param {String} action_input the action being taken
183+
* @param {String} [url] Url to report
184+
*/
185+
async function analytics_message (action_input, url) {
186+
const href = url || window.location.href.split("?")[0];
187+
browser.runtime.sendMessage({ action: "analytics_send", args: { url: href, action: action_input } });
188+
}
189+
179190
export {
180191
gradeToFP,
181192
grade_fp,
@@ -187,4 +198,5 @@ export {
187198
extractFinalPercent,
188199
assignments,
189200
calculate_credit_hours,
201+
analytics_message,
190202
};

src/js/saspowerschoolff.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import $ from 'jquery';
3030
const browser = require('webextension-polyfill');
3131

32-
import { calculate_gpa, extractFinalPercent, gradeToGPA } from './helpers';
32+
import { calculate_gpa, extractFinalPercent, gradeToGPA, analytics_message } from './helpers';
3333

3434
// Vue Components
3535
import Vue from 'vue';
@@ -68,10 +68,6 @@ function main () {
6868
analytics_message("default");
6969
}
7070
}
71-
function analytics_message (action_input) {
72-
const href = window.location.href.split("?")[0];
73-
browser.runtime.sendMessage({ action: "analytics_send", args: { url: href, action: action_input } });
74-
}
7571

7672
function main_page () {
7773
const student_name = document.querySelector('#userName').querySelector('span').innerText;

src/js/views/Options.vue

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<template>
2+
<div>
3+
<h3>Version: {{ version }}</h3>
4+
<form>
5+
<label><input
6+
v-model="options.analytics"
7+
type="checkbox"
8+
>Enable Analytics</label>
9+
<br>
10+
<label><input
11+
v-model="options.percent_main_page"
12+
type="checkbox"
13+
>Load final percent and missing assignments on overall grade page (More network intensive)</label>
14+
<br>
15+
<!--<label><input type="checkbox" id="save-grades" />Save last seen grades (requires previous option to work)</label>-->
16+
</form>
17+
<br>
18+
19+
<footer>
20+
<br>
21+
Last Seen Grades has been temporarily removed to be improved upon.<br>
22+
<br>
23+
For any suggestions or feedback/inquiries regarding downloading or deleting collected analytics data, please email <a href="mailto:[email protected]">[email protected]</a>.<br>
24+
<br>
25+
Analytics ID: {{ options.id }}<span style="white-space: nowrap; padding-left: 5px;" /><button @click="copyId">
26+
<span v-if="copiedRecently">Copied!</span>
27+
<span v-else>Copy</span>
28+
</button><br>
29+
<br>
30+
SAS Powerschool Enhancement Suite is the collective work of many different people working together publicly. Visit our <a href="https://github.com/gary-kim/saspes">GitHub page</a> if you'd like to participate as well.<br>
31+
<br>
32+
More info and source code (Anyone and everyone is welcome to contribute): <br>
33+
<a href="https://github.com/gary-kim/saspes">https://github.com/gary-kim/saspes</a><br>
34+
<br>
35+
Credits: <br>
36+
Special thanks to Alan Chang for the idea. <br>
37+
<a
38+
:href="thirdPartyLibraries"
39+
target="_blank"
40+
>Third-Party Libraries</a>
41+
</footer>
42+
</div>
43+
</template>
44+
45+
<script>
46+
import { analytics_message } from '../helpers';
47+
import browser from 'webextension-polyfill';
48+
49+
function defaultOptions () {
50+
return {
51+
id: "Not set yet",
52+
percent_main_page: true,
53+
analytics: true,
54+
save_grades_temp: true,
55+
};
56+
}
57+
58+
export default {
59+
name: "Options",
60+
data () {
61+
return {
62+
options: defaultOptions(),
63+
ignoreNextReset: false,
64+
copiedRecently: false,
65+
thirdPartyLibraries: browser.extension.getURL('web_accessible_resources/libraries.txt'),
66+
version: SASPES_VERSION_NAME,
67+
};
68+
},
69+
watch: {
70+
options: {
71+
deep: true,
72+
handler (val) {
73+
if (this.ignoreNextReset) {
74+
this.ignoreNextReset = false;
75+
return;
76+
}
77+
browser.storage.local.set(JSON.parse(JSON.stringify(val)));
78+
},
79+
},
80+
},
81+
async mounted () {
82+
analytics_message("Options Page", "saspes://options");
83+
await this.resetData();
84+
browser.storage.onChanged.addListener(this.resetData);
85+
},
86+
methods: {
87+
async resetData () {
88+
const options = await browser.storage.local.get(defaultOptions());
89+
this.ignoreNextReset = true;
90+
this.options = Object.assign({}, this.options, options);
91+
},
92+
copyId () {
93+
this.copiedRecently = true;
94+
navigator.clipboard.writeText(this.options.id);
95+
setTimeout(() => { this.copiedRecently = false; }, 1500);
96+
},
97+
},
98+
};
99+
</script>
100+
101+
<style scoped>
102+
103+
</style>

src/manifest - chromium.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"short_name": "SAS PES",
55
"version": "SET_DURING_BUILD",
66
"version_name": "SET_DURING_BUILD",
7-
"author": "Gary Kim",
7+
"author": "Gary Kim & The SAS PES Authors",
88
"homepage_url": "https://github.com/gary-kim/saspes/",
99
"description": "Provides various enhancements for SAS Powerschool",
1010
"permissions": [

src/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "SAS Powerschool Enhancement Suite",
44
"short_name": "SAS PES",
55
"version": "SET_DURING_BUILD",
6-
"author": "Gary Kim",
6+
"author": "Gary Kim & The SAS PES Authors",
77
"homepage_url":"https://github.com/gary-kim/saspes/",
88
"description": "Provides various enhancements for SAS Powerschool",
99
"permissions": [

src/ui/options.html

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,7 @@
44

55
</head>
66
<body>
7-
<h3>Version: <span id="version"></span></h3>
8-
<form>
9-
<label><input type="checkbox" id="analytics" />Enable Analytics</label>
10-
<br />
11-
<label><input type="checkbox" id="percent-mp" />Load final percent and missing assignments on overall grade page (More network intensive)</label>
12-
<br />
13-
<!--<label><input type="checkbox" id="save-grades" />Save last seen grades (requires previous option to work)</label>-->
14-
</form>
15-
<br />
16-
17-
<footer>
18-
<br />
19-
Last Seen Grades has been temporarily removed to be improved upon.<br />
20-
<br />
21-
For any suggestions or feedback/inquiries regarding downloading or deleting collected analytics data, please email <a href="mailto:[email protected]">[email protected]</a>.<br />
22-
<br />
23-
Analytics ID: <span id="analytics-id"></span><span style="white-space: nowrap; padding-left: 5px;"></span><button id="copy-analytics-id">Copy</button><br />
24-
<br />
25-
More info and Source Code (Anyone and everyone is welcome to contribute): <br />
26-
<a href="https://github.com/gary-kim/saspes" id="source-code-link">https://github.com/gary-kim/saspes</a><br />
27-
<br />
28-
Credits: <br />
29-
Special thanks to Alan Chang for the idea. <br />
30-
<a id="third-party-libraries" target="_blank">Third-Party Libraries</a>
31-
</footer>
7+
<div id="options"></div>
328
<script src="options.js"></script>
339
</body>
3410
</html>

src/ui/options.js

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -24,48 +24,10 @@
2424

2525
'use strict';
2626

27-
const browser = require('webextension-polyfill');
28-
29-
var analyticsid = "";
27+
import Vue from 'vue';
28+
import Options from '../js/views/Options';
3029

3130
window.addEventListener("load", main, false);
3231
function main () {
33-
browser.runtime.sendMessage({ action: "analytics_send", args: { url: "saspes://options", action: "Options Page" } });
34-
35-
browser.storage.local.get({ analytics: true, percent_main_page: true, id: "Not set yet", save_grades_temp: true }).then(function (returned) {
36-
document.getElementById("analytics").checked = returned.analytics;
37-
document.getElementById("percent-mp").checked = returned.percent_main_page;
38-
document.getElementById("analytics-id").innerText = returned.id;
39-
analyticsid = returned.id;
40-
});
41-
document.getElementById("third-party-libraries").href = browser.extension.getURL("web_accessible_resources/libraries.txt");
42-
document.getElementById("version").innerText = SASPES_VERSION_NAME;
43-
document.getElementById("analytics").addEventListener("click", function () {
44-
const value = document.getElementById("analytics").checked;
45-
if (!value) {
46-
browser.runtime.sendMessage({ action: "analytics_send", args: { url: "saspes://disableanalytics.options", action: "Options Page: Disable Analytics" } });
47-
}
48-
browser.storage.local.set({ analytics: value });
49-
});
50-
document.getElementById("percent-mp").addEventListener("click", function () {
51-
const value = document.getElementById("percent-mp").checked;
52-
browser.storage.local.set({ percent_main_page: value });
53-
});
54-
document.getElementById("source-code-link").addEventListener("click", (event) => {
55-
const href = event.currentTarget.getAttribute('href');
56-
browser.runtime.sendMessage({ action: "analytics_send", args: { url: href, extra: { link: href } } });
57-
});
58-
document.getElementById("copy-analytics-id").addEventListener("click", (event) => {
59-
const target = event.currentTarget;
60-
if (target.getAttribute("attr-pressed")) {
61-
return;
62-
}
63-
navigator.clipboard.writeText(analyticsid);
64-
target.innerText = "Copied!";
65-
target.setAttribute("attr-pressed", "true");
66-
setTimeout(() => {
67-
target.innerText = "Copy";
68-
target.removeAttribute("attr-pressed");
69-
}, 1500);
70-
});
32+
new (Vue.extend(Options))().$mount('#options');
7133
}

0 commit comments

Comments
 (0)