Skip to content

Commit 9de7bb1

Browse files
authored
Populate TA seat code finder grid
2 parents 7ce63fe + dbbfbf0 commit 9de7bb1

File tree

2 files changed

+50
-12
lines changed

2 files changed

+50
-12
lines changed

src/checker/ta.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@ import * as ui from "/src/modules/ui.js";
33
import storage from "/src/modules/storage.js";
44
import * as auth from "/src/modules/auth.js";
55
import island from "/src/modules/island.js";
6+
import Element from "/src/modules/element.js";
67

78
const domain = ((window.location.hostname.search('check') != -1) || (window.location.hostname.search('127') != -1)) ? 'https://api.check.vssfalcons.com' : `http://${document.domain}:5000`;
89
if (window.location.pathname.split('?')[0].endsWith('/admin')) window.location.pathname = '/admin/';
910

11+
var period = document.getElementById("period-input")?.value;
12+
1013
var courses = [];
1114
var segments = [];
1215
var questions = [];
@@ -20,6 +23,39 @@ try {
2023
async function init() {
2124
if (!storage.get("code")) return window.location.href = '/';
2225
if (!storage.get("pwd")) return auth.ta(init);
26+
// Populate seat code finder grid
27+
document.getElementById("seat-grid").innerHTML = "";
28+
for (let col = 1; col <= 5; col++) {
29+
for (let row = 6; row > 0; row--) {
30+
period = document.getElementById("period-input").value;
31+
const code = period + row.toString() + col.toString();
32+
const button = new Element("button", "", {
33+
click: () => {
34+
document.getElementById("code-input").value = code;
35+
ui.view("settings/code");
36+
},
37+
}).element;
38+
document.getElementById("seat-grid").append(button);
39+
ui.addTooltip(button, code);
40+
}
41+
}
42+
document.getElementById("period-input").addEventListener("change", () => {
43+
document.getElementById("seat-grid").innerHTML = "";
44+
for (let col = 1; col <= 5; col++) {
45+
for (let row = 6; row > 0; row--) {
46+
period = document.getElementById("period-input").value;
47+
const code = period + row.toString() + col.toString();
48+
const button = new Element("button", "", {
49+
click: () => {
50+
document.getElementById("code-input").value = code;
51+
ui.view("settings/code");
52+
},
53+
}).element;
54+
document.getElementById("seat-grid").append(button);
55+
ui.addTooltip(button, code);
56+
}
57+
}
58+
});
2359
if (document.querySelector('[data-logout]')) document.querySelector('[data-logout]').addEventListener('click', () => auth.logout(init));
2460

2561
// Show clear data fix guide

src/modules/island.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -226,19 +226,21 @@ export function renderExtras() {
226226
if (!island) return;
227227
if (island.classList.contains('rendered')) return;
228228
var textarea = island.querySelector('.description .textarea');
229-
var textareaContent = textarea.getAttribute('content');
230-
var quill = new Quill(textarea, {
231-
readOnly: true,
232-
modules: {
233-
syntax: true,
234-
toolbar: false,
235-
fazEmoji: {
236-
collection: 'fluent-emoji',
229+
if (textarea) {
230+
var textareaContent = textarea.getAttribute('content');
231+
var quill = new Quill(textarea, {
232+
readOnly: true,
233+
modules: {
234+
syntax: true,
235+
toolbar: false,
236+
fazEmoji: {
237+
collection: 'fluent-emoji',
238+
},
237239
},
238-
},
239-
theme: 'snow'
240-
});
241-
quill.setContents(JSON.parse(textareaContent));
240+
theme: 'snow'
241+
});
242+
quill.setContents(JSON.parse(textareaContent));
243+
}
242244
island.querySelectorAll('img[data-src]:not([src])').forEach(img => img.src = img.getAttribute('data-src'));
243245
mediumZoom(".island .attachments img", {
244246
background: "transparent"

0 commit comments

Comments
 (0)