remove evals (#2624)

This commit is contained in:
Evan 2022-03-04 05:42:09 -06:00 committed by GitHub
parent c27caa68af
commit 8da243ecfe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 7 deletions

View file

@ -3215,8 +3215,28 @@ export function pushCurrent(val: MonkeyTypes.CommandsGroup): void {
current.push(val);
}
export function getList(list: string): MonkeyTypes.CommandsGroup {
return eval(list);
const listsObject = {
commandsChallenges,
commandsLanguages,
commandsDifficulty,
commandsLazyMode,
commandsPaceCaret,
commandsShowAvg,
commandsMinWpm,
commandsMinAcc,
commandsMinBurst,
commandsFunbox,
commandsConfidenceMode,
commandsStopOnError,
commandsLayouts,
commandsOppositeShiftMode,
commandsTags,
};
export type ListsObjectKeys = keyof typeof listsObject;
export function getList(list: ListsObjectKeys): MonkeyTypes.CommandsGroup {
return listsObject[list];
}
ConfigEvent.subscribe((eventKey, eventValue) => {

View file

@ -668,17 +668,14 @@ $(document).on("click", "#keymap .r5 .key-space", () => {
$(document).on("click", "#testModesNotice .text-button", (event) => {
const commands = CommandlineLists.getList(
$(event.currentTarget).attr("commands") as string
$(event.currentTarget).attr("commands") as CommandlineLists.ListsObjectKeys
);
const func = $(event.currentTarget).attr("function");
if (commands !== undefined) {
if ($(event.currentTarget).attr("commands") === "commandsTags") {
CommandlineLists.updateTagCommands();
}
CommandlineLists.pushCurrent(commands);
show();
} else if (func != undefined) {
eval(func);
}
});

View file

@ -566,7 +566,6 @@ list["clearTagPb"] = new SimplePopup(
} else {
Notifications.add("Something went wrong: " + response.message, -1);
}
// console.log(`clearing for ${eval("this.parameters[0]")} ${eval("this.parameters[1]")}`);
},
(thisPopup) => {
thisPopup.text = `Are you sure you want to clear PB for tag ${thisPopup.parameters[1]}?`;