mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2024-09-20 15:26:15 +08:00
Merge branch 'master' of https://github.com/Miodec/monkey-type
This commit is contained in:
commit
40475b5699
File diff suppressed because it is too large
Load diff
|
@ -27,8 +27,26 @@ function showFound() {
|
|||
let list = CommandlineLists.current[CommandlineLists.current.length - 1];
|
||||
$.each(list.list, (index, obj) => {
|
||||
if (obj.found && (obj.available !== undefined ? obj.available() : true)) {
|
||||
commandsHTML +=
|
||||
'<div class="entry" command="' + obj.id + '">' + obj.display + "</div>";
|
||||
let icon = obj.icon ?? "fa-chevron-right";
|
||||
let faIcon = /^fa-/g.test(icon);
|
||||
if (!faIcon) {
|
||||
icon = `<div class="textIcon">${icon}</div>`;
|
||||
} else {
|
||||
icon = `<i class="fas fa-fw ${icon}"></i>`;
|
||||
}
|
||||
if (list.configKey) {
|
||||
if (
|
||||
(obj.configValueMode &&
|
||||
obj.configValueMode === "include" &&
|
||||
Config[list.configKey].includes(obj.configValue)) ||
|
||||
Config[list.configKey] === obj.configValue
|
||||
) {
|
||||
icon = `<i class="fas fa-fw fa-check"></i>`;
|
||||
} else {
|
||||
icon = `<i class="fas fa-fw"></i>`;
|
||||
}
|
||||
}
|
||||
commandsHTML += `<div class="entry" command="${obj.id}"><div class="icon">${icon}</div><div>${obj.display}</div></div>`;
|
||||
}
|
||||
});
|
||||
$("#commandLine .suggestions").html(commandsHTML);
|
||||
|
@ -149,11 +167,12 @@ function trigger(command) {
|
|||
if (obj.input) {
|
||||
input = true;
|
||||
showInput(obj.id, obj.display, obj.defaultValue);
|
||||
} else if (obj.subgroup) {
|
||||
subgroup = true;
|
||||
CommandlineLists.current.push(obj.subgroup);
|
||||
show();
|
||||
} else {
|
||||
obj.exec();
|
||||
if (obj.subgroup !== null && obj.subgroup !== undefined) {
|
||||
subgroup = obj.subgroup;
|
||||
}
|
||||
if (obj.sticky === true) {
|
||||
sticky = true;
|
||||
}
|
||||
|
@ -196,23 +215,37 @@ export let show = () => {
|
|||
function addChildCommands(
|
||||
unifiedCommands,
|
||||
commandItem,
|
||||
parentCommandDisplay = ""
|
||||
parentCommandDisplay = "",
|
||||
parentCommand = ""
|
||||
) {
|
||||
let commandItemDisplay = commandItem.display.replace(/\s?\.\.\.$/g, "");
|
||||
let icon = `<i class="fas fa-fw"></i>`;
|
||||
if (
|
||||
commandItem.configValue !== undefined &&
|
||||
Config[parentCommand.configKey] === commandItem.configValue
|
||||
) {
|
||||
icon = `<i class="fas fa-fw fa-check"></i>`;
|
||||
}
|
||||
if (parentCommandDisplay)
|
||||
commandItemDisplay = parentCommandDisplay + " > " + commandItemDisplay;
|
||||
commandItemDisplay =
|
||||
parentCommandDisplay + " > " + icon + commandItemDisplay;
|
||||
if (commandItem.subgroup) {
|
||||
try {
|
||||
commandItem.exec();
|
||||
const currentCommandsIndex = CommandlineLists.current.length - 1;
|
||||
CommandlineLists.current[currentCommandsIndex].list.forEach((cmd) => {
|
||||
if (cmd.alias === undefined) cmd.alias = commandItem.alias;
|
||||
addChildCommands(unifiedCommands, cmd, commandItemDisplay);
|
||||
commandItem.subgroup.list.forEach((cmd) => {
|
||||
commandItem.configKey = commandItem.subgroup.configKey;
|
||||
addChildCommands(unifiedCommands, cmd, commandItemDisplay, commandItem);
|
||||
});
|
||||
CommandlineLists.current.pop();
|
||||
// commandItem.exec();
|
||||
// const currentCommandsIndex = CommandlineLists.current.length - 1;
|
||||
// CommandlineLists.current[currentCommandsIndex].list.forEach((cmd) => {
|
||||
// if (cmd.alias === undefined) cmd.alias = commandItem.alias;
|
||||
// addChildCommands(unifiedCommands, cmd, commandItemDisplay);
|
||||
// });
|
||||
// CommandlineLists.current.pop();
|
||||
} catch (e) {}
|
||||
} else {
|
||||
let tempCommandItem = { ...commandItem };
|
||||
tempCommandItem.icon = parentCommand.icon;
|
||||
if (parentCommandDisplay) tempCommandItem.display = commandItemDisplay;
|
||||
unifiedCommands.push(tempCommandItem);
|
||||
}
|
||||
|
@ -359,7 +392,7 @@ $(document).on(
|
|||
|
||||
$("#commandLineWrapper #commandLine .suggestions").on("mouseover", (e) => {
|
||||
if (!commandLineMouseMode) return;
|
||||
console.log("clearing keyboard active");
|
||||
// console.log("clearing keyboard active");
|
||||
$("#commandLineWrapper #commandLine .suggestions .entry").removeClass(
|
||||
"activeKeyboard"
|
||||
);
|
||||
|
@ -381,10 +414,14 @@ $("#commandLineWrapper #commandLine .suggestions").on("mouseover", (e) => {
|
|||
} catch (e) {}
|
||||
});
|
||||
|
||||
$("#commandLineWrapper #commandLine .suggestions").click((e) => {
|
||||
$(".suggestions .entry").removeClass("activeKeyboard");
|
||||
trigger($(e.target).attr("command"));
|
||||
});
|
||||
$(document).on(
|
||||
"click",
|
||||
"#commandLineWrapper #commandLine .suggestions .entry",
|
||||
(e) => {
|
||||
$(".suggestions .entry").removeClass("activeKeyboard");
|
||||
trigger($(e.currentTarget).attr("command"));
|
||||
}
|
||||
);
|
||||
|
||||
$("#commandLineWrapper").click((e) => {
|
||||
if ($(e.target).attr("id") === "commandLineWrapper") {
|
||||
|
@ -398,6 +435,40 @@ $("#commandLineWrapper").click((e) => {
|
|||
}
|
||||
});
|
||||
|
||||
//might come back to it later
|
||||
// function shiftCommand(){
|
||||
// let activeEntries = $("#commandLineWrapper #commandLine .suggestions .entry.activeKeyboard, #commandLineWrapper #commandLine .suggestions .entry.activeMouse");
|
||||
// activeEntries.each((index, activeEntry) => {
|
||||
// let commandId = activeEntry.getAttribute('command');
|
||||
// let foundCommand = null;
|
||||
// CommandlineLists.defaultCommands.list.forEach(command => {
|
||||
// if(foundCommand === null && command.id === commandId){
|
||||
// foundCommand = command;
|
||||
// }
|
||||
// })
|
||||
// if(foundCommand.shift){
|
||||
// $(activeEntry).find('div').text(foundCommand.shift.display);
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
|
||||
// let shiftedCommands = false;
|
||||
// $(document).keydown((e) => {
|
||||
// if (e.key === "Shift") {
|
||||
// if(shiftedCommands === false){
|
||||
// shiftedCommands = true;
|
||||
// shiftCommand();
|
||||
// }
|
||||
|
||||
// }
|
||||
// });
|
||||
|
||||
// $(document).keyup((e) => {
|
||||
// if (e.key === "Shift") {
|
||||
// shiftedCommands = false;
|
||||
// }
|
||||
// });
|
||||
|
||||
$(document).keydown((e) => {
|
||||
// if (isPreviewingTheme) {
|
||||
// console.log("applying theme");
|
||||
|
|
|
@ -1221,12 +1221,29 @@ label.checkbox {
|
|||
overflow-y: scroll;
|
||||
max-height: calc(100vh - 10rem - 3rem);
|
||||
display: grid;
|
||||
cursor: pointer;
|
||||
|
||||
.entry {
|
||||
padding: 0.5rem 1rem;
|
||||
font-size: 0.75rem;
|
||||
line-height: 0.75rem;
|
||||
color: var(--sub-color);
|
||||
display: grid;
|
||||
grid-template-columns: auto 1fr;
|
||||
|
||||
div {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.textIcon {
|
||||
font-weight: 900;
|
||||
/* width: 1.25rem; */
|
||||
display: inline-block;
|
||||
letter-spacing: -0.1rem;
|
||||
margin-right: 0.5rem;
|
||||
text-align: center;
|
||||
width: 1.25em;
|
||||
}
|
||||
|
||||
.fas {
|
||||
margin-right: 0.5rem;
|
||||
|
|
Loading…
Reference in a new issue