Abort,
}
+interface TagFilter {
+ description: string;
+ include: (task: Element) => boolean;
+}
+
function BrowserUI() {
const viewColors: { [key: string]: string } = {
all: "Gold",
todo: "White",
waiting: "MediumOrchid",
};
- var currentTagFilter: string | null = null;
+ var currentTagFilter: TagFilter | null = null;
var currentViewState = "todo";
var taskFocusedBeforeJumpingToInput: HTMLElement | null = null;
var lastTagNameEntered = "";
return ui.setState(createTimestamp, newState, oldState);
},
- setTagFilter: function (tag: string) {
+ setTagFilter: function (filter: TagFilter) {
if (currentTagFilter !== null) {
this.resetTagView();
}
const tasksWithTag = new Map();
for (const task of document.getElementsByClassName("task")) {
- if (model.hasTag(task, tag)) {
+ if (filter.include(task)) {
tasksWithTag.set(task.getElementsByClassName("desc")[0].textContent, [model.getPriority(task), task]);
}
}
}
for (const task of Array.from(document.getElementsByClassName("task"))) {
- if (model.hasTag(task, tag)) {
+ if (filter.include(task)) {
task.classList.remove("hide");
} else {
const superTask = highestPrioritySuperTask(task);
}
}
- currentTagFilter = tag;
+ currentTagFilter = filter;
this.setTitle();
},
if (!target) return;
tag = target.textContent!;
}
- this.setTagFilter(tag);
+ this.setTagFilter({description: tag, include: task => !!model.hasTag(task, tag!)});
},
setTitle: function () {
- document.title = "Vopamoi: " + currentViewState + (currentTagFilter ? ": " + currentTagFilter : "");
+ document.title = "Vopamoi: " + currentViewState + (currentTagFilter ? ": " + currentTagFilter.description : "");
},
setView: function (state: string) {