}
function BrowserUI() {
+ const viewColors: { [key: string]: string } = {
+ all: "Gold",
+ cancelled: "Red",
+ deleted: "Black",
+ done: "LawnGreen",
+ "someday-maybe": "DeepSkyBlue",
+ todo: "White",
+ waiting: "MediumOrchid",
+ };
var currentViewState = "todo";
var taskFocusedBeforeJumpingToInput: HTMLElement | null = null;
var lastTagNameEntered = "";
return ui.setState(createTimestamp, newState, oldState);
},
- setView: function (state: string, color: string) {
+ setView: function (state: string) {
const sheet = (document.getElementById("viewStyle") as HTMLStyleElement).sheet!;
if (state === "all") {
sheet.insertRule(`.task[data-state=deleted] { display: none }`);
} else {
sheet.insertRule(`.task:not([data-state=${state}]) { display: none }`);
}
- sheet.insertRule(`:root { --view-state-indicator-color: ${color}; }`);
+ sheet.insertRule(`:root { --view-state-indicator-color: ${viewColors[state]}; }`);
sheet.removeRule(2);
sheet.removeRule(2);
currentViewState = state;
if (event.key == "m") return browserUI.setState("someday-maybe");
} else if (inputState === InputState.V) {
inputState = InputState.Root;
- if (event.key == "a") return browserUI.setView("all", "Gold");
- if (event.key == "c") return browserUI.setView("cancelled", "Red");
- if (event.key == "d") return browserUI.setView("done", "LawnGreen");
- if (event.key == "q") return browserUI.setView("todo", "White");
+ if (event.key == "a") return browserUI.setView("all");
+ if (event.key == "c") return browserUI.setView("cancelled");
+ if (event.key == "d") return browserUI.setView("done");
+ if (event.key == "q") return browserUI.setView("todo");
if (event.key == "s") return (inputState = InputState.VS);
- if (event.key == "v") return browserUI.setView("todo", "White");
- if (event.key == "w") return browserUI.setView("waiting", "MediumOrchid");
- if (event.key == "x") return browserUI.setView("deleted", "Black");
+ if (event.key == "v") return browserUI.setView("todo");
+ if (event.key == "w") return browserUI.setView("waiting");
+ if (event.key == "x") return browserUI.setView("deleted");
} else if (inputState === InputState.VS) {
inputState = InputState.Root;
- if (event.key == "m") return browserUI.setView("someday-maybe", "DeepSkyBlue");
+ if (event.key == "m") return browserUI.setView("someday-maybe");
}
}
}