summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2018-09-19 15:07:33 -0400
committerAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2018-09-19 15:07:33 -0400
commit5515cf27e8ef5ee0e4552d83ce5584f2ec477eb2 (patch)
treec798cec7ef942d790a8e6401e92a6aadc543d4f4
parente9f05a3e394f7f4850a259f6c3784c5e1975fb2d (diff)
downloadyorku-course-query-5515cf27e8ef5ee0e4552d83ce5584f2ec477eb2.tar.xz
yorku-course-query-5515cf27e8ef5ee0e4552d83ce5584f2ec477eb2.zip
add default subject
-rw-r--r--script.js16
1 files changed, 12 insertions, 4 deletions
diff --git a/script.js b/script.js
index 1536c4d..dbece30 100644
--- a/script.js
+++ b/script.js
@@ -34,6 +34,7 @@ if (!ycq_storage)
ycq_storage = {};
ycq_storage.course_creds = ycq_storage.course_creds || {};
ycq_storage.course_subjs = ycq_storage.course_subjs || {};
+ycq_storage.default_subj = ycq_storage.default_subj || "";
let now = new Date();
let month = now.getMonth();
@@ -134,6 +135,11 @@ function ready() {
warn.push(`using saved subject for ${state.crsn}: ${state.subj}`);
}
+ if (!state.subj && ycq_storage.default_subj) {
+ state.subj = ycq_storage.default_subj;
+ warn.push(`using saved default subject: ${state.subj}`);
+ }
+
if (!state.fac && state.subj) {
state.fac = DEPTS.get(state.subj);
if (!state.fac)
@@ -142,7 +148,7 @@ function ready() {
if (state.subj && state.crsn && !state.cred) {
if (ycq_storage.course_creds[state.subj + state.crsn]) {
- state.cred = ycq_storage.course_creds[state.crsn];
+ state.cred = ycq_storage.course_creds[state.subj + state.crsn];
warn.push(`using saved credit number for ${state.subj} ${state.crsn}: ${state.cred}`);
} else {
state.cred = "3.00";
@@ -161,11 +167,11 @@ function ready() {
linkContainer.style.display = "block";
} else if (state.fac && state.subj && state.sess) {
link.href = `https://w2prod.sis.yorku.ca/Apps/WebObjects/cdm.woa/wa/crsq1?faculty=${state.fac}&subject=${state.subj}&academicyear=${state.year}&studysession=${state.sess}`;
- link.textContent = `York University: ${state.fac}/${state.subj} Courses (${sessions.selectedOptions[0]. textContent})`;
+ link.textContent = `York University: ${state.fac}/${state.subj} Courses (${sessions.selectedOptions[0].textContent})`;
linkContainer.style.display = "block";
} else {
linkContainer.style.display = "none";
- error.push("insufficient search parameters. need at least subject. see examples above");
+ error.push("need at least subject. see examples above");
}
if (multiple.size)
@@ -177,9 +183,9 @@ function ready() {
ycq_storage.sess = r_sess;
localStorage.ycq = JSON.stringify(ycq_storage);
};
-
input.addEventListener("input", apply);
sessions.addEventListener("change", apply);
+
document.getElementById("sample-queries").addEventListener("click", function (e) {
if (e.target.tagName == "A") {
e.preventDefault();
@@ -191,6 +197,7 @@ function ready() {
input.focus();
}
});
+
let save_crsn = function () {
let modified = false;
if (state.crsn) {
@@ -200,6 +207,7 @@ function ready() {
}
if (state.subj) {
ycq_storage.course_subjs[state.crsn] = state.subj;
+ ycq_storage.default_subj = state.subj;
modified = true;
}
}