Skip to content

Commit a4d43fd

Browse files
committed
Merge branch 'master' of github.com:YSL-hack-roll/Module-Planner
2 parents dd4b233 + 27654a6 commit a4d43fd

6 files changed

Lines changed: 116 additions & 8 deletions

File tree

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# CAP/SU
22

3+
34
CAP/SU is a **browser extension for managing SUs, CAP alongside with NUSMOD Module Planner**
45
Targeted at NUS students, CAP/SU can help you plan you college study plans conveniently and keep your academic record.
56

6-
* Table of Contents
7-
{:toc}
7+
8+
#### Welcome to our website: [CAP/SU Website](https://ysl-hack-roll.github.io/Module-Planner/UserGuide.html) and watch our brief [video demo](https://www.youtube.com/watch?v=AGxk2605byM&feature=emb_logo)
9+
810

911
--------------------------------------------------------------------------------------------------------------------
1012

@@ -17,13 +19,13 @@ Targeted at NUS students, CAP/SU can help you plan you college study plans conve
1719
3. Deploy it to your chrome browser.
1820

1921
4. Open [NUSMOD](https://nusmods.com/), access Settings > NUSMods Beta > Turn it ON, then access [NUSMOD-Planner](https://nusmods.com/planner).
20-
![Ui](images/Ui.png)
22+
![Ui](docs/images/Ui.png)
2123

2224
5. Click `Add Modules` to add new modules to the planner.
2325

2426
6. Click `Edit MC and Title` to Enter/Modify Module Credits, Title, Grade, and SU or not.
2527

26-
7. Double Click the colored box of a module to change its SU option.
28+
7. Double Click the colored module card to change its SU option.
2729

2830
8. CAP is shown on the top right corner and Remaining SUs is shown at the bottom right corner.
2931

@@ -38,7 +40,7 @@ Targeted at NUS students, CAP/SU can help you plan you college study plans conve
3840
Records student's respective grades of the modules that they have taken.
3941

4042

41-
![grade seletion](images/selectGrade.png)
43+
![grade seletion](docs/images/selectGrade.png)
4244

4345
Usage:
4446

@@ -58,7 +60,7 @@ Automatically calculates the CAP of a student based on the module information th
5860

5961
Usage:
6062

61-
1. Add module(s) and they respective grade & SU option.
63+
1. Add module(s) and their respective grade & SU option.
6264

6365
2. The calculated CAP is shown at the top right corner. The default CAP is 0.0 when graded MCs is 0.
6466

docs/UserGuide.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
CAP/SU is a **Google Chrome browser extension for managing SUs, CAP alongside with NUSMOD Module Planner**
22
Targeted at NUS students, CAP/SU can help you plan you college study plans conveniently and keep your academic record.
33

4+
#### You are welcomed to watch our brief [video demo](https://www.youtube.com/watch?v=AGxk2605byM&feature=emb_logo) :)
5+
46
--------------------------------------------------------------------------------------------------------------------
57

68
## Quick start

docs/_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
theme: jekyll-theme-cayman
1+
theme: jekyll-theme-slate

docs/index.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
layout: page
3+
title: CAP/SU
4+
---
5+
6+
![Ui](docs/images/Ui.png)
7+
8+
CAP/SU is a **Google Chrome browser extension for managing SUs, CAP alongside with NUSMOD Module Planner**
9+
Targeted at NUS students, CAP/SU can help you plan you college study plans conveniently and keep your academic record.
10+
11+
* If you are interested in using IntelliBrary, head over to the [the **User Guide**](UserGuide.html).

manifest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
"src/check_exist.js",
2626
"src/main.js",
2727
"src/grade.js",
28-
"src/cap.js"
28+
"src/cap.js",
29+
"src/import_export.js"
2930
]
3031
}
3132
]

src/import_export.js

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
$(document).ready(function () {
2+
add_button();
3+
const url_string = window.location.href;
4+
const url = new URL(url_string);
5+
const planner = url.searchParams.get("planner");
6+
const ysl = url.searchParams.get("ysl");
7+
if (planner && ysl) {
8+
let import_mah = confirm('Import data?');
9+
if (import_mah) {
10+
importData();
11+
}
12+
}
13+
});
14+
15+
function exportData() {
16+
const export_url = (`https://nusmods.com/planner?planner=${encodeURIComponent(localStorage.getItem('persist:planner'))}&ysl=${encodeURIComponent(localStorage.getItem('YSL:data'))}`);
17+
// setTimeout(() => {
18+
// navigator.clipboard.writeText(export_url).then(function () {
19+
// console.log('succeeded');
20+
// confirm('URL copied to clipboard!');
21+
// }, function () {
22+
// console.log('failed');
23+
// });
24+
// }, 1000);
25+
navigator.clipboard.writeText(export_url).then(function () {
26+
console.log('succeeded');
27+
confirm('URL copied to clipboard!');
28+
}, function () {
29+
console.log('failed');
30+
});
31+
}
32+
33+
function populateModuleBank(mod) {
34+
let moduleBank = localStorage.getItem('persist:moduleBank');
35+
if (moduleBank) {
36+
moduleBank = JSON.parse(moduleBank);
37+
} else {
38+
moduleBank = {};
39+
}
40+
let modules = moduleBank['modules'];
41+
if (modules) {
42+
modules = JSON.parse(modules);
43+
} else {
44+
modules = {};
45+
}
46+
if (modules[mod]) {
47+
return;
48+
}
49+
const yr = new Date().getFullYear()
50+
const mth = new Date().getMonth();
51+
let ay;
52+
if (mth < 6) {
53+
ay = '' + (yr - 1) + '-' + yr;
54+
} else {
55+
ay = '' + yr + '-' + (yr + 1);
56+
}
57+
fetch(`https://api.nusmods.com/v2/${ay}/modules/${mod}.json`)
58+
.then(res => res.json())
59+
.then(data => {
60+
modules[mod] = data;
61+
moduleBank['modules'] = JSON.stringify(modules);
62+
moduleBank = JSON.stringify(moduleBank);
63+
localStorage.setItem('persist:moduleBank', moduleBank);
64+
});
65+
}
66+
67+
function importData() {
68+
const url_string = (window.location.href);
69+
const url = new URL(url_string);
70+
const planner = decodeURIComponent(url.searchParams.get("planner"));
71+
const ysl = decodeURIComponent(url.searchParams.get("ysl"));
72+
localStorage.setItem('persist:planner', planner);
73+
localStorage.setItem('YSL:data', ysl);
74+
const planner_obj = JSON.parse(planner);
75+
const modules = Object.values(JSON.parse(planner_obj['modules'])).map(x => x['moduleCode']);
76+
modules.forEach(x => {
77+
populateModuleBank(x);
78+
});
79+
window.location.href = '/planner';
80+
}
81+
82+
function add_button() {
83+
var export_btn = $(`<button class="btn btn-svg btn-outline-primary" style="margin-left:8px" type="button">
84+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="svg svg-small"><polyline points="17 1 21 5 17 9"></polyline><path d="M3 11V9a4 4 0 0 1 4-4h14"></path><polyline points="7 23 3 19 7 15"></polyline><path d="M21 13v2a4 4 0 0 1-4 4H3"></path></svg>
85+
Export</button>`);
86+
var space = $('<div class="divider"/>');
87+
checkExist(".main-content > div > header > div", function () {
88+
space.appendTo($(".main-content > div > header > div"));
89+
export_btn.appendTo($(".main-content > div > header > div"));
90+
export_btn.click(exportData);
91+
});
92+
}

0 commit comments

Comments
 (0)