summaryrefslogtreecommitdiff
path: root/script.js
diff options
context:
space:
mode:
Diffstat (limited to 'script.js')
-rw-r--r--script.js17
1 files changed, 9 insertions, 8 deletions
diff --git a/script.js b/script.js
index c9ad800..7fa77db 100644
--- a/script.js
+++ b/script.js
@@ -342,7 +342,7 @@ function ready() {
if (compat_facs) {
let other_facs = compat_facs
.filter(f => f != state["fac"])
- .map(f => `<a href="#" class="prepend-query">${f}/${state["subj"]}</a>`)
+ .map(f => `<a href="#" class="prepend-query" data-query="${f}">${f}/${state["subj"]}</a>`)
.join(", ");
if (other_facs.length)
return "other options: " + other_facs;
@@ -353,11 +353,11 @@ function ready() {
// 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"]];
- add_li(warn, `assuming ${state["subj"]} ${state["crsn"]} is ${state["fac"]}/${state["subj"]}, because you last used ${state["fac"]} for ${state["subj"]} ${state["crsn"]}. ${other_options()}`);
+ add_li(warn, `assuming ${state["subj"]} ${state["crsn"]} is ${state["fac"]}/${state["subj"]} because you last used ${state["fac"]} for ${state["subj"]} ${state["crsn"]}. ${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"]];
- add_li(warn, `assuming ${state["subj"]} means ${state["fac"]}/${state["subj"]}, because you last used ${state["fac"]} for ${state["subj"]}. ${other_options()}`);
+ add_li(warn, `assuming ${state["subj"]} means ${state["fac"]}/${state["subj"]} because you last used ${state["fac"]} for ${state["subj"]}. ${other_options()}`);
} else if (compat_facs) {
// 3. most recent compatible faculty
if (cached_ycq_s.default_facs)
@@ -366,14 +366,14 @@ function ready() {
state["fac"] = cached_ycq_s.default_facs[i];
if (state["fac"]) {
- add_li(warn, `assuming ${state["subj"]} means ${state["fac"]}/${state["subj"]}, because you recently used ${state["fac"]}. ${other_options()}`);
+ add_li(warn, `assuming ${state["subj"]} means ${state["fac"]}/${state["subj"]} because you recently used ${state["fac"]}. ${other_options()}`);
} else {
// 4. first compatible faculty
state["fac"] = compat_facs[0];
if (compat_facs.length > 1)
- add_li(warn, `assuming ${state["subj"]} means ${state["fac"]}/${state["subj"]}, because we set that as the default for ${state["subj"]}. ${other_options()}`);
+ add_li(warn, `assuming ${state["subj"]} means ${state["fac"]}/${state["subj"]}. ${other_options()}`);
else
- add_li(warn, `assuming ${state["subj"]} means ${state["fac"]}/${state["subj"]}, because we only know ${state["fac"]} for ${state["subj"]}.`);
+ add_li(warn, `assuming ${state["subj"]} means ${state["fac"]}/${state["subj"]}`);
}
} else {
add_li(error, "no faculty provided and unknown subject");
@@ -430,12 +430,13 @@ function ready() {
} else if (e.target.closest(".prepend-query")) {
e.preventDefault();
let r = false;
+ let t = e.target.hasAttribute("data-query") ? e.target.getAttribute("data-query") : e.target.textContent;
if (document.execCommand) {
input.setSelectionRange(0, 0);
- r = document.execCommand("insertText", false, e.target.textContent + " ");
+ r = document.execCommand("insertText", false, t + " ");
}
if (!r)
- input.value = e.target.textContent + " " + input.value;
+ input.value = t + " " + input.value;
apply();
}
});