mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-03-12 23:20:25 +08:00
moved global stats to a new module
This commit is contained in:
parent
d69c424a21
commit
806846e55b
5 changed files with 36 additions and 34 deletions
|
@ -107,6 +107,8 @@ const refactoredSrc = [
|
|||
"./src/js/simple-popups.js",
|
||||
"./src/js/settings.js",
|
||||
|
||||
"./src/js/account/all-time-stats.js",
|
||||
|
||||
"./src/js/elements/monkey.js",
|
||||
"./src/js/elements/notifications.js",
|
||||
"./src/js/elements/leaderboards.js",
|
||||
|
|
|
@ -102,9 +102,9 @@ export function signOut() {
|
|||
|
||||
//TODO Bring this back when possible
|
||||
|
||||
// clearGlobalStats();
|
||||
// AllTimeStats.clear();
|
||||
// Settings.hideAccountSection();
|
||||
// updateAccountLoginButton();
|
||||
// AccountIcon.update();
|
||||
// changePage("login");
|
||||
// DB.setSnapshot(null);
|
||||
})
|
||||
|
|
|
@ -55,7 +55,7 @@ function signUp() {
|
|||
}
|
||||
);
|
||||
usr.sendEmailVerification();
|
||||
clearGlobalStats();
|
||||
AllTimeStats.clear();
|
||||
Notifications.add("Account created", 1, 3);
|
||||
$("#menu .icon-button.account .text").text(nname);
|
||||
try {
|
||||
|
@ -1021,36 +1021,6 @@ function loadMoreLines() {
|
|||
}
|
||||
}
|
||||
|
||||
function clearGlobalStats() {
|
||||
$(".pageAccount .globalTimeTyping .val").text(`-`);
|
||||
$(".pageAccount .globalTestsStarted .val").text(`-`);
|
||||
$(".pageAccount .globalTestsCompleted .val").text(`-`);
|
||||
}
|
||||
|
||||
function refreshGlobalStats() {
|
||||
if (DB.getSnapshot().globalStats.time != undefined) {
|
||||
let th = Math.floor(DB.getSnapshot().globalStats.time / 3600);
|
||||
let tm = Math.floor((DB.getSnapshot().globalStats.time % 3600) / 60);
|
||||
let ts = Math.floor((DB.getSnapshot().globalStats.time % 3600) % 60);
|
||||
$(".pageAccount .globalTimeTyping .val").text(`
|
||||
|
||||
${th < 10 ? "0" + th : th}:${tm < 10 ? "0" + tm : tm}:${
|
||||
ts < 10 ? "0" + ts : ts
|
||||
}
|
||||
`);
|
||||
}
|
||||
if (DB.getSnapshot().globalStats.started != undefined) {
|
||||
$(".pageAccount .globalTestsStarted .val").text(
|
||||
DB.getSnapshot().globalStats.started
|
||||
);
|
||||
}
|
||||
if (DB.getSnapshot().globalStats.completed != undefined) {
|
||||
$(".pageAccount .globalTestsCompleted .val").text(
|
||||
DB.getSnapshot().globalStats.completed
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let totalSecondsFiltered = 0;
|
||||
|
||||
function refreshAccountPage() {
|
||||
|
@ -1058,7 +1028,7 @@ function refreshAccountPage() {
|
|||
ThemeColors.update();
|
||||
ChartController.accountHistory.updateColors();
|
||||
ChartController.accountActivity.updateColors();
|
||||
refreshGlobalStats();
|
||||
AllTimeStats.update();
|
||||
fillPbTables();
|
||||
|
||||
let chartData = [];
|
||||
|
|
29
src/js/account/all-time-stats.js
Normal file
29
src/js/account/all-time-stats.js
Normal file
|
@ -0,0 +1,29 @@
|
|||
export function clear() {
|
||||
$(".pageAccount .globalTimeTyping .val").text(`-`);
|
||||
$(".pageAccount .globalTestsStarted .val").text(`-`);
|
||||
$(".pageAccount .globalTestsCompleted .val").text(`-`);
|
||||
}
|
||||
|
||||
export function update() {
|
||||
if (DB.getSnapshot().globalStats.time != undefined) {
|
||||
let th = Math.floor(DB.getSnapshot().globalStats.time / 3600);
|
||||
let tm = Math.floor((DB.getSnapshot().globalStats.time % 3600) / 60);
|
||||
let ts = Math.floor((DB.getSnapshot().globalStats.time % 3600) % 60);
|
||||
$(".pageAccount .globalTimeTyping .val").text(`
|
||||
|
||||
${th < 10 ? "0" + th : th}:${tm < 10 ? "0" + tm : tm}:${
|
||||
ts < 10 ? "0" + ts : ts
|
||||
}
|
||||
`);
|
||||
}
|
||||
if (DB.getSnapshot().globalStats.started != undefined) {
|
||||
$(".pageAccount .globalTestsStarted .val").text(
|
||||
DB.getSnapshot().globalStats.started
|
||||
);
|
||||
}
|
||||
if (DB.getSnapshot().globalStats.completed != undefined) {
|
||||
$(".pageAccount .globalTestsCompleted .val").text(
|
||||
DB.getSnapshot().globalStats.completed
|
||||
);
|
||||
}
|
||||
}
|
|
@ -51,3 +51,4 @@ import * as SimplePopups from "./simple-popups";
|
|||
import * as ThemePicker from "./theme-picker";
|
||||
import "./custom-theme-popup";
|
||||
import "./import-settings-popup";
|
||||
import * as AllTimeStats from "./all-time-stats";
|
||||
|
|
Loading…
Reference in a new issue