mirror of
https://github.com/ankitects/anki.git
synced 2025-11-14 00:27:13 -05:00
Simplify some reviewer code
This commit is contained in:
parent
ee1a1c35fb
commit
c016f0c8d0
1 changed files with 8 additions and 32 deletions
|
|
@ -140,6 +140,10 @@ export function _showQuestion(q: string, a: string, bodyclass: string): void {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function scrollToAnswer(): void {
|
||||||
|
document.getElementById("answer")?.scrollIntoView();
|
||||||
|
}
|
||||||
|
|
||||||
export function _showAnswer(a: string, bodyclass: string): void {
|
export function _showAnswer(a: string, bodyclass: string): void {
|
||||||
_queueAction(() =>
|
_queueAction(() =>
|
||||||
_updateQA(
|
_updateQA(
|
||||||
|
|
@ -159,33 +163,14 @@ export function _showAnswer(a: string, bodyclass: string): void {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const _flagColours = {
|
|
||||||
1: "#e25252",
|
|
||||||
2: "#ffb347",
|
|
||||||
3: "#54c414",
|
|
||||||
4: "#578cff",
|
|
||||||
5: "#ff82ee",
|
|
||||||
6: "#00d1b5",
|
|
||||||
7: "#9649dd",
|
|
||||||
};
|
|
||||||
|
|
||||||
export function _drawFlag(flag: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7): void {
|
export function _drawFlag(flag: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7): void {
|
||||||
const elem = document.getElementById("_flag")!;
|
const elem = document.getElementById("_flag")!;
|
||||||
if (flag === 0) {
|
elem.toggleAttribute("hidden", flag === 0);
|
||||||
elem.setAttribute("hidden", "");
|
elem.style.color = `var(--flag${flag}-fg)`;
|
||||||
return;
|
|
||||||
}
|
|
||||||
elem.removeAttribute("hidden");
|
|
||||||
elem.style.color = _flagColours[flag];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function _drawMark(mark: boolean): void {
|
export function _drawMark(mark: boolean): void {
|
||||||
const elem = document.getElementById("_mark")!;
|
document.getElementById("_mark")!.toggleAttribute("hidden", !mark);
|
||||||
if (!mark) {
|
|
||||||
elem.setAttribute("hidden", "");
|
|
||||||
} else {
|
|
||||||
elem.removeAttribute("hidden");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function _typeAnsPress(): void {
|
export function _typeAnsPress(): void {
|
||||||
|
|
@ -196,14 +181,5 @@ export function _typeAnsPress(): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function _emulateMobile(enabled: boolean): void {
|
export function _emulateMobile(enabled: boolean): void {
|
||||||
const list = document.documentElement.classList;
|
document.documentElement.classList.toggle("mobile", enabled);
|
||||||
if (enabled) {
|
|
||||||
list.add("mobile");
|
|
||||||
} else {
|
|
||||||
list.remove("mobile");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function scrollToAnswer(): void {
|
|
||||||
document.getElementById("answer")?.scrollIntoView();
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue