mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-24 23:04:00 +08:00
Add quote search command (#2747)
This commit is contained in:
parent
7e30eca23d
commit
76c230315c
4 changed files with 24 additions and 5 deletions
|
@ -3076,6 +3076,16 @@ export const defaultCommands: MonkeyTypes.CommandsGroup = {
|
|||
$("#top #menu .icon-button.view-settings").trigger("click");
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "viewQuoteSearchPopup",
|
||||
display: "Search for quotes",
|
||||
icon: "fa-search",
|
||||
exec: (): void => {
|
||||
UpdateConfig.setMode("quote");
|
||||
$("#quote-search-button").trigger("click");
|
||||
},
|
||||
shouldFocusTestUI: false,
|
||||
},
|
||||
{
|
||||
id: "viewAccount",
|
||||
display: "View Account Page",
|
||||
|
|
|
@ -186,7 +186,7 @@ export let show = (): void => {
|
|||
$("#commandLine input").trigger("focus");
|
||||
};
|
||||
|
||||
function hide(): void {
|
||||
function hide(shouldFocusTestUI = true): void {
|
||||
UpdateConfig.previewFontFamily(Config.fontFamily);
|
||||
// applyCustomThemeColors();
|
||||
if (!ThemeController.randomTheme) {
|
||||
|
@ -203,19 +203,27 @@ function hide(): void {
|
|||
() => {
|
||||
$("#commandLineWrapper").addClass("hidden");
|
||||
$("#commandLine").removeClass("allCommands");
|
||||
TestUI.focusWords();
|
||||
if (shouldFocusTestUI) {
|
||||
TestUI.focusWords();
|
||||
}
|
||||
}
|
||||
);
|
||||
TestUI.focusWords();
|
||||
if (shouldFocusTestUI) {
|
||||
TestUI.focusWords();
|
||||
}
|
||||
}
|
||||
|
||||
function trigger(command: string): void {
|
||||
let subgroup = false;
|
||||
let input = false;
|
||||
let shouldFocusTestUI = true;
|
||||
const list = CommandlineLists.current[CommandlineLists.current.length - 1];
|
||||
let sticky = false;
|
||||
$.each(list.list, (_index, obj) => {
|
||||
if (obj.id == command) {
|
||||
if (obj.shouldFocusTestUI !== undefined) {
|
||||
shouldFocusTestUI = obj.shouldFocusTestUI;
|
||||
}
|
||||
if (obj.input) {
|
||||
input = true;
|
||||
const escaped = obj.display.split("</i>")[1] ?? obj.display;
|
||||
|
@ -239,7 +247,7 @@ function trigger(command: string): void {
|
|||
});
|
||||
if (!subgroup && !input && !sticky) {
|
||||
AnalyticsController.log("usedCommandLine", { command });
|
||||
hide();
|
||||
hide(shouldFocusTestUI);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
1
frontend/src/scripts/types/types.d.ts
vendored
1
frontend/src/scripts/types/types.d.ts
vendored
|
@ -578,6 +578,7 @@ declare namespace MonkeyTypes {
|
|||
hover?: () => void;
|
||||
available?: () => void;
|
||||
beforeSubgroup?: () => void;
|
||||
shouldFocusTestUI?: boolean;
|
||||
}
|
||||
|
||||
interface CommandsGroup {
|
||||
|
|
|
@ -220,7 +220,7 @@
|
|||
<div class="button" quote="1">medium</div>
|
||||
<div class="button" quote="2">long</div>
|
||||
<div class="button" quote="3">thicc</div>
|
||||
<div class="button" quote="-2">search</div>
|
||||
<div id="quote-search-button" class="button" quote="-2">search</div>
|
||||
</div>
|
||||
<div class="group customGroup hidden">
|
||||
<div class="button customChange">change</div>
|
||||
|
|
Loading…
Reference in a new issue