}
},
+ insertInPriorityOrder: function (task: Element, dest: Element) {
+ const priority = this.getPriority(task);
+ for (const t of dest.children) {
+ if (t !== task && this.getPriority(t) < priority) {
+ dest.insertBefore(task, t);
+ return;
+ }
+ }
+ dest.appendChild(task);
+ },
+
removeTag: function (createTimestamp: string, tagName: string) {
const task = this.getTask(createTimestamp);
if (!task) return null;
const target = this.getTask(createTimestamp);
if (!target) return null;
target.setAttribute("data-priority", `${priority}`);
- for (const task of document.getElementsByClassName("task")) {
- if (task !== target && this.getPriority(task) < priority) {
- task.parentElement!.insertBefore(target, task);
- return target;
- }
- }
- document.getElementById("tasks")!.appendChild(target);
+ this.insertInPriorityOrder(target, target.parentElement!);
return target;
},