summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2018-09-22 09:07:54 -0400
committerAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2018-09-22 09:07:54 -0400
commit2161c4834ec9098363d36d788f1bf390780a012c (patch)
tree0b7f6bfa43bdfa04133648752615a6bdc6032436
parent763030ff4e2af3c54f869b2749aef167488666b7 (diff)
downloadyorku-course-query-2161c4834ec9098363d36d788f1bf390780a012c.tar.xz
yorku-course-query-2161c4834ec9098363d36d788f1bf390780a012c.zip
fix "other options"
-rw-r--r--script.js26
1 files changed, 15 insertions, 11 deletions
diff --git a/script.js b/script.js
index 9ec7707..0951b5b 100644
--- a/script.js
+++ b/script.js
@@ -320,23 +320,27 @@ function ready() {
// 2. most recent faculty for this subject
// 3. most recent compatible faculty
// 4. first compatible faculty
- if (SUBJS.hasOwnProperty(state["subj"])) {
- var compat_facs = SUBJS[state["subj"]];
- let other_facs = compat_facs
- .filter(f => f != state["fac"])
- .map(f => `<a href="#" class="prepend-query">${f}</a>`)
- .join(", ");
- var other_options = `, other options: ${other_facs}`;
+ let compat_facs = SUBJS[state["subj"]];
+ let other_options = function () {
+ if (compat_facs) {
+ let other_facs = compat_facs
+ .filter(f => f != state["fac"])
+ .map(f => `<a href="#" class="prepend-query">${f}</a>`)
+ .join(", ");
+ if (other_facs.length)
+ return ", other options: " + other_facs;
+ }
+ return "";
}
// 1. most recent faculty for this course
if (state["crsn"] && cached_ycq_s.course_facs[state["subj"] + state["crsn"]]) {
state["fac"] = cached_ycq_s.course_facs[state["subj"] + state["crsn"]];
- warn.push(`using saved faculty for ${state["subj"]} ${state["crsn"]}: ${state["fac"]}${other_options}`);
+ warn.push(`using saved faculty for ${state["subj"]} ${state["crsn"]}: ${state["fac"]}${other_options()}`);
} else if (cached_ycq_s.subj_facs[state["subj"]]) {
// 2. most recent faculty for this subject
state["fac"] = cached_ycq_s.subj_facs[state["subj"]];
- warn.push(`using saved faculty for ${state["subj"]}: ${state["fac"]}${other_options}`);
+ warn.push(`using saved faculty for ${state["subj"]}: ${state["fac"]}${other_options()}`);
} else if (compat_facs) {
// 3. most recent compatible faculty
if (cached_ycq_s.default_facs)
@@ -345,11 +349,11 @@ function ready() {
state["fac"] = cached_ycq_s.default_facs[i];
if (state["fac"]) {
- warn.push(`using saved faculty: ${state["fac"]}${other_options}`);
+ warn.push(`using saved faculty: ${state["fac"]}${other_options()}`);
} else {
// 4. first compatible faculty
state["fac"] = compat_facs[0];
- warn.push(`using default faculty for ${state["subj"]}: ${state["fac"]}${other_options}`);
+ warn.push(`using default faculty for ${state["subj"]}: ${state["fac"]}${other_options()}`);
}
} else {
error.push("no faculty provided and unknown subject");