aboutsummaryrefslogtreecommitdiff
path: root/src/student-prod.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/student-prod.ts')
-rw-r--r--src/student-prod.ts35
1 files changed, 17 insertions, 18 deletions
diff --git a/src/student-prod.ts b/src/student-prod.ts
index 24ac869..67379d9 100644
--- a/src/student-prod.ts
+++ b/src/student-prod.ts
@@ -1,20 +1,20 @@
import type { Graduation } from "./graduation-common.ts";
import { Student } from "./student-common.ts";
-import { getUserIconUrl, getCourseParticipantsUrl } from "./utils-prod.js"
+import { getUserIconUrl, getCourseParticipantsUrl } from "./utils-prod.js";
import { fetchGraduation } from "./graduation-prod.ts";
declare module "./student-common.ts" {
- interface Student {
- getGraduation(): Promise<Graduation>;
- getIconUrl(): Promise<string>;
- }
+ interface Student {
+ getGraduation(): Promise<Graduation>;
+ getIconUrl(): Promise<string>;
+ }
}
Student.prototype.getGraduation = function () {
- return fetchGraduation(this);
+ return fetchGraduation(this);
};
Student.prototype.getIconUrl = function () {
- return getUserIconUrl(this.id);
+ return getUserIconUrl(this.id);
};
// Cache the fetched students.
@@ -26,9 +26,8 @@ async function _fetchStudents() {
const doc = new DOMParser().parseFromString(await res.text(), "text/html");
const table = doc.querySelector("tbody")!;
const fetchedStudents: Array<Student> = [];
- table.querySelectorAll("tr").forEach(row => {
- if (row.classList.contains("emptyrow"))
- return;
+ table.querySelectorAll("tr").forEach((row) => {
+ if (row.classList.contains("emptyrow")) return;
const roleCell = row.querySelector(".c4")!;
// TODO(muhq): Is this locale dependent?
@@ -39,10 +38,8 @@ async function _fetchStudents() {
const nameCell = row.querySelector<HTMLElement>(".c1")!;
let name;
const c = nameCell.firstChild!.firstChild! as HTMLElement;
- if (c.tagName == "SPAN")
- name = c.title;
- else
- name = nameCell.innerText;
+ if (c.tagName == "SPAN") name = c.title;
+ else name = nameCell.innerText;
const profileUrl = nameCell.querySelector<HTMLAnchorElement>("a.aabtn")!.href;
const match = idRegex.exec(profileUrl);
@@ -76,10 +73,12 @@ async function fetchStudents(idFilter?: number, nameFilter?: string, groupFilter
}
}
- return students.filter((s) =>
- (typeof idFilter === "undefined" || s.id === idFilter) &&
- (typeof nameFilter === "undefined" || s.name.includes(nameFilter)) &&
- (typeof groupFilter === "undefined" || s.group.includes(groupFilter)));
+ return students.filter(
+ (s) =>
+ (typeof idFilter === "undefined" || s.id === idFilter) &&
+ (typeof nameFilter === "undefined" || s.name.includes(nameFilter)) &&
+ (typeof groupFilter === "undefined" || s.group.includes(groupFilter)),
+ );
}
async function fetchStudent(idFilter: number, nameFilter: string, groupFilter: string) {