Skip to content

Commit

Permalink
refactor: rename simple popup to simple modal
Browse files Browse the repository at this point in the history
  • Loading branch information
Miodec committed Apr 2, 2024
1 parent 7635d37 commit 82b9323
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion frontend/src/ts/index.ts
Expand Up @@ -25,7 +25,7 @@ import * as Result from "./test/result";
import "./controllers/account-controller";
import { enable } from "./states/glarses-mode";
import "./test/caps-warning";
import "./popups/simple-popups";
import "./modals/simple-modals";
import "./controllers/input-controller";
import "./ready";
import "./controllers/route-controller";
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/ts/modals/ape-keys.ts
Expand Up @@ -4,7 +4,7 @@ import * as Notifications from "../elements/notifications";
import format from "date-fns/format";
import * as ConnectionState from "../states/connection";
import AnimatedModal, { ShowOptions } from "../utils/animated-modal";
import { showPopup } from "../popups/simple-popups";
import { showPopup } from "./simple-modals";

let apeKeys: Ape.ApeKeys.GetApeKeys | null = {};

Expand Down
Expand Up @@ -7,7 +7,7 @@ import * as Notifications from "../elements/notifications";
import * as Settings from "../pages/settings";
import * as ThemePicker from "../settings/theme-picker";
import * as CustomText from "../test/custom-text";
import * as SavedTextsPopup from "./saved-texts-popup";
import * as SavedTextsPopup from "../popups/saved-texts-popup";
import * as AccountButton from "../elements/account-button";
import { FirebaseError } from "firebase/app";
import { Auth, isAuthenticated, getAuthenticatedUser } from "../firebase";
Expand Down Expand Up @@ -43,7 +43,7 @@ type Input = {
label?: string;
};

let activePopup: SimplePopup | null = null;
let activePopup: SimpleModal | null = null;

type ExecReturn = {
status: 1 | 0 | -1;
Expand Down Expand Up @@ -82,7 +82,7 @@ type PopupKey =
| "deleteCustomTheme"
| "forgotPassword";

const list: Record<PopupKey, SimplePopup | undefined> = {
const list: Record<PopupKey, SimpleModal | undefined> = {
updateEmail: undefined,
updateName: undefined,
updatePassword: undefined,
Expand Down Expand Up @@ -110,16 +110,16 @@ const list: Record<PopupKey, SimplePopup | undefined> = {
forgotPassword: undefined,
};

type SimplePopupOptions = {
type SimpleModalOptions = {
id: string;
type: string;
title: string;
inputs?: Input[];
text?: string;
buttonText: string;
execFn: (thisPopup: SimplePopup, ...params: string[]) => Promise<ExecReturn>;
beforeInitFn?: (thisPopup: SimplePopup) => void;
beforeShowFn?: (thisPopup: SimplePopup) => void;
execFn: (thisPopup: SimpleModal, ...params: string[]) => Promise<ExecReturn>;
beforeInitFn?: (thisPopup: SimpleModal) => void;
beforeShowFn?: (thisPopup: SimpleModal) => void;
canClose?: boolean;
onlineOnly?: boolean;
hideCallsExec?: boolean;
Expand All @@ -141,7 +141,7 @@ const modal = new AnimatedModal({
},
});

class SimplePopup {
class SimpleModal {
parameters: string[];
wrapper: HTMLElement;
element: HTMLElement;
Expand All @@ -151,13 +151,13 @@ class SimplePopup {
inputs: Input[];
text?: string;
buttonText: string;
execFn: (thisPopup: SimplePopup, ...params: string[]) => Promise<ExecReturn>;
beforeInitFn: ((thisPopup: SimplePopup) => void) | undefined;
beforeShowFn: ((thisPopup: SimplePopup) => void) | undefined;
execFn: (thisPopup: SimpleModal, ...params: string[]) => Promise<ExecReturn>;
beforeInitFn: ((thisPopup: SimpleModal) => void) | undefined;
beforeShowFn: ((thisPopup: SimpleModal) => void) | undefined;
canClose: boolean;
onlineOnly: boolean;
hideCallsExec: boolean;
constructor(options: SimplePopupOptions) {
constructor(options: SimpleModalOptions) {
this.parameters = [];
this.id = options.id;
this.type = options.type;
Expand Down Expand Up @@ -494,7 +494,7 @@ async function reauthenticate(
}
}

list.updateEmail = new SimplePopup({
list.updateEmail = new SimpleModal({
id: "updateEmail",
type: "text",
title: "Update email",
Expand Down Expand Up @@ -565,7 +565,7 @@ list.updateEmail = new SimplePopup({
},
});

list.removeGoogleAuth = new SimplePopup({
list.removeGoogleAuth = new SimpleModal({
id: "removeGoogleAuth",
type: "text",
title: "Remove Google authentication",
Expand Down Expand Up @@ -620,7 +620,7 @@ list.removeGoogleAuth = new SimplePopup({
},
});

list.removeGithubAuth = new SimplePopup({
list.removeGithubAuth = new SimpleModal({
id: "removeGithubAuth",
type: "text",
title: "Remove GitHub authentication",
Expand Down Expand Up @@ -675,7 +675,7 @@ list.removeGithubAuth = new SimplePopup({
},
});

list.updateName = new SimplePopup({
list.updateName = new SimpleModal({
id: "updateName",
type: "text",
title: "Update name",
Expand Down Expand Up @@ -753,7 +753,7 @@ list.updateName = new SimplePopup({
},
});

list.updatePassword = new SimplePopup({
list.updatePassword = new SimpleModal({
id: "updatePassword",
type: "text",
title: "Update password",
Expand Down Expand Up @@ -839,7 +839,7 @@ list.updatePassword = new SimplePopup({
},
});

list.addPasswordAuth = new SimplePopup({
list.addPasswordAuth = new SimpleModal({
id: "addPasswordAuth",
type: "text",
title: "Add password authentication",
Expand Down Expand Up @@ -931,7 +931,7 @@ list.addPasswordAuth = new SimplePopup({
},
});

list.deleteAccount = new SimplePopup({
list.deleteAccount = new SimpleModal({
id: "deleteAccount",
type: "text",
title: "Delete account",
Expand Down Expand Up @@ -980,7 +980,7 @@ list.deleteAccount = new SimplePopup({
},
});

list.resetAccount = new SimplePopup({
list.resetAccount = new SimpleModal({
id: "resetAccount",
type: "text",
title: "Reset account",
Expand Down Expand Up @@ -1031,7 +1031,7 @@ list.resetAccount = new SimplePopup({
},
});

list.optOutOfLeaderboards = new SimplePopup({
list.optOutOfLeaderboards = new SimpleModal({
id: "optOutOfLeaderboards",
type: "text",
title: "Opt out of leaderboards",
Expand Down Expand Up @@ -1078,7 +1078,7 @@ list.optOutOfLeaderboards = new SimplePopup({
},
});

list.clearTagPb = new SimplePopup({
list.clearTagPb = new SimpleModal({
id: "clearTagPb",
type: "text",
title: "Clear tag PB",
Expand Down Expand Up @@ -1122,7 +1122,7 @@ list.clearTagPb = new SimplePopup({
},
});

list.applyCustomFont = new SimplePopup({
list.applyCustomFont = new SimpleModal({
id: "applyCustomFont",
type: "text",
title: "Custom font",
Expand All @@ -1139,7 +1139,7 @@ list.applyCustomFont = new SimplePopup({
},
});

list.resetPersonalBests = new SimplePopup({
list.resetPersonalBests = new SimpleModal({
id: "resetPersonalBests",
type: "text",
title: "Reset personal bests",
Expand Down Expand Up @@ -1199,7 +1199,7 @@ list.resetPersonalBests = new SimplePopup({
},
});

list.resetSettings = new SimplePopup({
list.resetSettings = new SimpleModal({
id: "resetSettings",
type: "text",
title: "Reset settings",
Expand All @@ -1215,7 +1215,7 @@ list.resetSettings = new SimplePopup({
},
});

list.revokeAllTokens = new SimplePopup({
list.revokeAllTokens = new SimpleModal({
id: "revokeAllTokens",
type: "text",
title: "Revoke all tokens",
Expand Down Expand Up @@ -1264,7 +1264,7 @@ list.revokeAllTokens = new SimplePopup({
},
});

list.unlinkDiscord = new SimplePopup({
list.unlinkDiscord = new SimpleModal({
id: "unlinkDiscord",
type: "text",
title: "Unlink Discord",
Expand Down Expand Up @@ -1301,7 +1301,7 @@ list.unlinkDiscord = new SimplePopup({
},
});

list.generateApeKey = new SimplePopup({
list.generateApeKey = new SimpleModal({
id: "generateApeKey",
type: "text",
title: "Generate new Ape key",
Expand Down Expand Up @@ -1343,7 +1343,7 @@ list.generateApeKey = new SimplePopup({
},
});

list.viewApeKey = new SimplePopup({
list.viewApeKey = new SimpleModal({
id: "viewApeKey",
type: "text",
title: "Ape key",
Expand Down Expand Up @@ -1383,7 +1383,7 @@ list.viewApeKey = new SimplePopup({
},
});

list.deleteApeKey = new SimplePopup({
list.deleteApeKey = new SimpleModal({
id: "deleteApeKey",
type: "text",
title: "Delete Ape key",
Expand All @@ -1409,7 +1409,7 @@ list.deleteApeKey = new SimplePopup({
},
});

list.editApeKey = new SimplePopup({
list.editApeKey = new SimpleModal({
id: "editApeKey",
type: "text",
title: "Edit Ape key",
Expand Down Expand Up @@ -1441,7 +1441,7 @@ list.editApeKey = new SimplePopup({
},
});

list.deleteCustomText = new SimplePopup({
list.deleteCustomText = new SimpleModal({
id: "deleteCustomText",
type: "text",
title: "Delete custom text",
Expand All @@ -1462,7 +1462,7 @@ list.deleteCustomText = new SimplePopup({
},
});

list.deleteCustomTextLong = new SimplePopup({
list.deleteCustomTextLong = new SimpleModal({
id: "deleteCustomTextLong",
type: "text",
title: "Delete custom text",
Expand All @@ -1483,7 +1483,7 @@ list.deleteCustomTextLong = new SimplePopup({
},
});

list.resetProgressCustomTextLong = new SimplePopup({
list.resetProgressCustomTextLong = new SimpleModal({
id: "resetProgressCustomTextLong",
type: "text",
title: "Reset progress for custom text",
Expand All @@ -1507,7 +1507,7 @@ list.resetProgressCustomTextLong = new SimplePopup({
},
});

list.updateCustomTheme = new SimplePopup({
list.updateCustomTheme = new SimpleModal({
id: "updateCustomTheme",
type: "text",
title: "Update custom theme",
Expand Down Expand Up @@ -1588,7 +1588,7 @@ list.updateCustomTheme = new SimplePopup({
},
});

list.deleteCustomTheme = new SimplePopup({
list.deleteCustomTheme = new SimpleModal({
id: "deleteCustomTheme",
type: "text",
title: "Delete custom theme",
Expand All @@ -1606,7 +1606,7 @@ list.deleteCustomTheme = new SimplePopup({
},
});

list.forgotPassword = new SimplePopup({
list.forgotPassword = new SimpleModal({
id: "forgotPassword",
type: "text",
title: "Forgot password",
Expand Down

0 comments on commit 82b9323

Please sign in to comment.