task.appendChild(desc);
task.classList.add("task");
task.setAttribute("tabindex", "0");
- task.setAttribute("data-created", timestamp);
+ task.setAttribute("id", timestamp);
task.setAttribute("data-state", "todo");
const tasks = document.getElementById("tasks")!;
tasks.insertBefore(task, tasks.firstElementChild);
if (task.hasAttribute("data-priority")) {
return parseFloat(task.getAttribute("data-priority")!);
}
- return parseFloat(task.getAttribute("data-created")!);
+ return parseFloat(task.getAttribute("id")!);
},
getTask: function (createTimestamp: string) {
- for (const task of document.getElementsByClassName("task")) {
- if (task.getAttribute("data-created") === createTimestamp) {
- return task;
- }
- }
+ return document.getElementById(createTimestamp);
},
insertInPriorityOrder: function (task: Element, dest: Element) {
if (resolution === CommitOrAbort.Abort || newDescription.match(/^ *$/) || newDescription === oldDescription) {
desc.textContent = oldDescription;
} else {
- ui.edit(task.getAttribute("data-created")!, newDescription, oldDescription);
+ ui.edit(task.getAttribute("id")!, newDescription, oldDescription);
}
},
task.removeChild(input);
task.focus();
if (resolution === CommitOrAbort.Commit && !newTagName.match(/^ *$/) && !model.hasTag(task, newTagName)) {
- ui.addTag(task.getAttribute("data-created")!, newTagName);
+ ui.addTag(task.getAttribute("id")!, newTagName);
lastTagNameEntered = newTagName;
}
},
makeTopPriority: function (task: Element | null = null) {
if (!task) task = this.currentTask();
if (!task) return;
- ui.setPriority(task.getAttribute("data-created")!, clock.now(), model.getPriority(task));
+ ui.setPriority(task.getAttribute("id")!, clock.now(), model.getPriority(task));
task instanceof HTMLElement && task.focus();
},
removeTag: function () {
const target = this.currentTag();
if (!target) return;
- ui.removeTag(target.parentElement!.getAttribute("data-created")!, target.textContent!);
+ ui.removeTag(target.parentElement!.getAttribute("id")!, target.textContent!);
},
resetTagView: function () {
console.assert(aPriority > newPriority && newPriority > bPriority, aPriority, ">", newPriority, ">", bPriority);
const newPriorityRounded = Math.round(newPriority);
const okToRound = aPriority > newPriorityRounded && newPriorityRounded > bPriority;
- ui.setPriority(task.getAttribute("data-created")!, okToRound ? newPriorityRounded : newPriority, model.getPriority(task));
+ ui.setPriority(task.getAttribute("id")!, okToRound ? newPriorityRounded : newPriority, model.getPriority(task));
task instanceof HTMLElement && task.focus();
},
if (!task) return;
const oldState = task.getAttribute("data-state")!;
if (newState === oldState) return;
- const createTimestamp = task.getAttribute("data-created")!;
+ const createTimestamp = task.getAttribute("id")!;
if (currentViewState !== "all" || newState == "deleted") {
this.moveCursorVertically(1) || this.moveCursorVertically(-1);
}