mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-11-10 22:22:21 +08:00
website starts in focus mode and focus is removed once finished loading
This commit is contained in:
parent
9b66d4a67d
commit
b1bf8c3793
8 changed files with 33 additions and 27 deletions
|
|
@ -4,9 +4,11 @@ const { validateConfig } = require("../../handlers/validation");
|
|||
class ConfigController {
|
||||
static async getConfig(req, res, next) {
|
||||
try {
|
||||
const { uid } = req.decodedToken;
|
||||
let config = await ConfigDAO.getConfig(uid);
|
||||
return res.status(200).json(config);
|
||||
return setTimeout(async () => {
|
||||
const { uid } = req.decodedToken;
|
||||
let config = await ConfigDAO.getConfig(uid);
|
||||
return res.status(200).json(config);
|
||||
}, 3000);
|
||||
} catch (e) {
|
||||
return next(e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,9 +34,11 @@ try {
|
|||
class ResultController {
|
||||
static async getResults(req, res, next) {
|
||||
try {
|
||||
const { uid } = req.decodedToken;
|
||||
const results = await ResultDAO.getResults(uid);
|
||||
return res.status(200).json(results);
|
||||
return setTimeout(async () => {
|
||||
const { uid } = req.decodedToken;
|
||||
const results = await ResultDAO.getResults(uid);
|
||||
return res.status(200).json(results);
|
||||
}, 3000);
|
||||
} catch (e) {
|
||||
next(e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import * as TestLogic from "./test-logic";
|
|||
import * as UI from "./ui";
|
||||
import axiosInstance from "./axios-instance";
|
||||
import * as PSA from "./psa";
|
||||
import * as Focus from "./focus";
|
||||
|
||||
export const gmailProvider = new firebase.auth.GoogleAuthProvider();
|
||||
// const githubProvider = new firebase.auth.GithubAuthProvider();
|
||||
|
|
@ -64,6 +65,7 @@ const authListener = firebase.auth().onAuthStateChanged(async function (user) {
|
|||
await loadUser(user);
|
||||
} else {
|
||||
UI.setPageTransition(false);
|
||||
Focus.set(false);
|
||||
if (UI.getActivePage() == "pageLoading") UI.changePage("");
|
||||
}
|
||||
let theme = Misc.findGetParameter("customTheme");
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ import * as AllTimeStats from "./all-time-stats";
|
|||
import * as PbTables from "./pb-tables";
|
||||
import * as AccountController from "./account-controller";
|
||||
import * as LoadingPage from "./loading-page";
|
||||
import * as Focus from "./focus";
|
||||
import * as SignOutButton from "./sign-out-button";
|
||||
import axiosInstance from "./axios-instance";
|
||||
|
||||
let filterDebug = false;
|
||||
|
|
@ -223,6 +225,7 @@ export async function getDataAndInit() {
|
|||
console.log("account loading finished");
|
||||
if (UI.getActivePage() == "pageLoading") {
|
||||
LoadingPage.updateBar(100, true);
|
||||
Focus.set(false);
|
||||
UI.changePage("");
|
||||
}
|
||||
}
|
||||
|
|
@ -1010,6 +1013,8 @@ export function update() {
|
|||
ChartController.accountHistory.update({ duration: 0 });
|
||||
ChartController.accountActivity.update({ duration: 0 });
|
||||
LoadingPage.updateBar(100, true);
|
||||
SignOutButton.show();
|
||||
Focus.set(false);
|
||||
UI.swapElements(
|
||||
$(".pageAccount .preloader"),
|
||||
$(".pageAccount .content"),
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import * as SignOutButton from "./sign-out-button";
|
|||
import * as MonkeyPower from "./monkey-power";
|
||||
import * as NewVersionNotification from "./new-version-notification";
|
||||
import * as Notifications from "./notifications";
|
||||
import * as Focus from "./focus";
|
||||
|
||||
ManualRestart.set();
|
||||
Misc.migrateFromCookies();
|
||||
|
|
@ -22,6 +23,7 @@ if (window.location.hostname === "localhost") {
|
|||
});
|
||||
}
|
||||
|
||||
Focus.set(true, true);
|
||||
RouteController.handleInitialPageClasses(window.location.pathname);
|
||||
$(document).ready(() => {
|
||||
if (window.location.pathname === "/") {
|
||||
|
|
@ -47,9 +49,6 @@ $(document).ready(() => {
|
|||
.removeClass("hidden")
|
||||
.stop(true, true)
|
||||
.animate({ opacity: 1 }, 250, () => {
|
||||
if (window.location.pathname === "/account") {
|
||||
SignOutButton.show();
|
||||
}
|
||||
if (window.location.pathname === "/verify") {
|
||||
const fragment = new URLSearchParams(window.location.hash.slice(1));
|
||||
if (fragment.has("access_token")) {
|
||||
|
|
@ -70,7 +69,7 @@ $(document).ready(() => {
|
|||
// }
|
||||
} else if (window.location.pathname !== "/") {
|
||||
let page = window.location.pathname.replace("/", "");
|
||||
UI.changePage(page);
|
||||
// UI.changePage(page);
|
||||
}
|
||||
});
|
||||
Settings.settingsFillPromise.then(Settings.update);
|
||||
|
|
|
|||
|
|
@ -1,14 +1,15 @@
|
|||
import * as Caret from "./caret";
|
||||
import * as UI from "./ui";
|
||||
|
||||
let state = false;
|
||||
|
||||
export function set(foc) {
|
||||
export function set(foc, withCursor = false) {
|
||||
if (foc && !state) {
|
||||
state = true;
|
||||
Caret.stopAnimation();
|
||||
$("#top").addClass("focus");
|
||||
$("#bottom").addClass("focus");
|
||||
$("body").css("cursor", "none");
|
||||
if (!withCursor) $("body").css("cursor", "none");
|
||||
$("#middle").addClass("focus");
|
||||
} else if (!foc && state) {
|
||||
state = false;
|
||||
|
|
@ -21,6 +22,9 @@ export function set(foc) {
|
|||
}
|
||||
|
||||
$(document).mousemove(function (event) {
|
||||
if (!state) return;
|
||||
if (UI.getActivePage() == "pageLoading") return;
|
||||
if (UI.getActivePage() == "pageAccount" && state == true) return;
|
||||
if (
|
||||
$("#top").hasClass("focus") &&
|
||||
(event.originalEvent.movementX > 0 || event.originalEvent.movementY > 0)
|
||||
|
|
|
|||
|
|
@ -590,7 +590,7 @@ export function restart(
|
|||
},
|
||||
125,
|
||||
async () => {
|
||||
Focus.set(false);
|
||||
if (UI.getActivePage() == "pageTest") Focus.set(false);
|
||||
TestUI.focusWords();
|
||||
$("#monkey .fast").stop(true, true).css("opacity", 0);
|
||||
$("#monkey").stop(true, true).css({ animationDuration: "0s" });
|
||||
|
|
|
|||
20
src/js/ui.js
20
src/js/ui.js
|
|
@ -184,20 +184,12 @@ export function changePage(page, norestart = false) {
|
|||
} else {
|
||||
setPageTransition(true);
|
||||
TestLogic.restart();
|
||||
swapElements(
|
||||
activePageElement,
|
||||
$(".page.pageAccount"),
|
||||
250,
|
||||
() => {
|
||||
setPageTransition(false);
|
||||
history.pushState("account", null, "account");
|
||||
$(".page.pageAccount").addClass("active");
|
||||
activePage = "pageAccount";
|
||||
},
|
||||
() => {
|
||||
SignOutButton.show();
|
||||
}
|
||||
);
|
||||
swapElements(activePageElement, $(".page.pageAccount"), 250, () => {
|
||||
setPageTransition(false);
|
||||
history.pushState("account", null, "account");
|
||||
$(".page.pageAccount").addClass("active");
|
||||
activePage = "pageAccount";
|
||||
});
|
||||
Funbox.activate("none");
|
||||
Account.update();
|
||||
TestConfig.hide();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue