-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
all-time-stats.ts
36 lines (32 loc) · 1.18 KB
/
all-time-stats.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import * as DB from "../db";
import * as DateTime from "../utils/date-and-time";
export function clear(): void {
$(".pageAccount .globalTimeTyping .val").text(`-`);
$(".pageAccount .globalTestsStarted .val").text(`-`);
$(".pageAccount .globalTestsCompleted .val").text(`-`);
}
export function update(): void {
const snapshot = DB.getSnapshot();
if (!snapshot) return;
if (snapshot.typingStats !== undefined) {
// let th = Math.floor(DB.getSnapshot().typingStats.time / 3600);
// let tm = Math.floor((DB.getSnapshot().typingStats.time % 3600) / 60);
// let ts = Math.floor((DB.getSnapshot().typingStats.time % 3600) % 60);
const seconds = snapshot?.typingStats?.timeTyping ?? 0;
let string = "";
if (seconds === 0) {
string = "-";
} else {
string = DateTime.secondsToString(Math.round(seconds), true, true);
}
$(".pageAccount .globalTimeTyping .val").text(string);
}
if (snapshot.typingStats !== undefined) {
$(".pageAccount .globalTestsStarted .val").text(
snapshot.typingStats.startedTests as number
);
$(".pageAccount .globalTestsCompleted .val").text(
snapshot.typingStats.completedTests as number
);
}
}