summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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");