summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
a1aa43d)
Making "high" priorities low numbers was a mistake.
1. Things that come freshly to attention are much more often among the
highest priority things and are very rarely lower priority that
everything else being tracked.
2. Logging the completion of an already-done task, a task that was *so*
high-priority that it was completed before even being tracked here,
feels bad when it ends up initially marked as lowest-priority-ever
unless some additional action is taken.
3. Marking a new task highest-ever-priority is fairly common and
oughtn't cost two log entries.
4. All the high priority tasks ever tracked oughtn't be fighting over
the smallest-representable IEEE floating point values, as they all
try to get slightly closer to zero. When highest-priority is now(),
these tasks get nicely spread out over the keyspace. This helps with
* keeping priority values integer-rounded, which helps with
* serialized log size
* log parsing simplicity (clients needn't support scientific notation)
* preventing underflow
* making the priority-sorted 'done' views be not-completely-useless
as all the tasks that have ever been high-priority get haphazardly
interleaved near zero. Instead, it becomes almost chronological.
This change does rather a lot of violence to current users of this tool,
inverting their displayed task list order & making no provision
whatsoever for gentle migration across this change of an implementation
detail. This is fine, because there's still only one user of this tool:
the author. Breaking changes like this will not be tolerated after
deployment.
task.setAttribute("tabindex", "0");
task.setAttribute("data-created", timestamp);
task.setAttribute("data-state", "todo");
task.setAttribute("tabindex", "0");
task.setAttribute("data-created", timestamp);
task.setAttribute("data-state", "todo");
- document.getElementById("tasks")!.appendChild(task);
+ const tasks = document.getElementById("tasks")!;
+ tasks.insertBefore(task, tasks.firstElementChild);
if (!target) return null;
target.setAttribute("data-priority", `${priority}`);
for (const task of document.getElementsByClassName("task")) {
if (!target) return null;
target.setAttribute("data-priority", `${priority}`);
for (const task of document.getElementsByClassName("task")) {
- if (task !== target && this.getPriority(task) > priority) {
+ if (task !== target && this.getPriority(task) < priority) {
task.parentElement!.insertBefore(target, task);
return target;
}
task.parentElement!.insertBefore(target, task);
return target;
}
}
input.value = "";
if (event.getModifierState("Control")) {
}
input.value = "";
if (event.getModifierState("Control")) {
- this.makeTopPriority(task);
+ this.makeBottomPriority(task);
if (dest instanceof HTMLElement) dest.focus();
},
if (dest instanceof HTMLElement) dest.focus();
},
+ makeBottomPriority: function (task: Element | null = null) {
+ if (!task) task = document.activeElement;
+ if (!task) return;
+ this.setPriority(task, document.getElementById("tasks")!.lastElementChild, null);
+ },
+
makeTopPriority: function (task: Element | null = null) {
if (!task) task = document.activeElement;
if (!task) return;
makeTopPriority: function (task: Element | null = null) {
if (!task) task = document.activeElement;
if (!task) return;
- this.setPriority(task, null, document.getElementsByClassName("task")[0]);
+ ui.setPriority(task.getAttribute("data-created")!, clock.now(), Model.getPriority(task));
+ task instanceof HTMLElement && task.focus();
},
moveCursor: function (offset: number): boolean {
},
moveCursor: function (offset: number): boolean {
// Change task's priority to be between other tasks a and b.
setPriority: function (task: Element, a: Element | null, b: Element | null) {
// Change task's priority to be between other tasks a and b.
setPriority: function (task: Element, a: Element | null, b: Element | null) {
- const aPriority = a === null ? 0 : Model.getPriority(a);
- const bPriority = b === null ? clock.now() : Model.getPriority(b);
- console.assert(aPriority < bPriority, aPriority, "<", bPriority);
- const span = bPriority - aPriority;
- const newPriority = aPriority + 0.1 * span + 0.8 * span * Math.random();
- console.assert(aPriority < newPriority && newPriority < bPriority, aPriority, "<", newPriority, "<", bPriority);
+ const aPriority = a === null ? clock.now() : Model.getPriority(a);
+ const bPriority = b === null ? 0 : Model.getPriority(b);
+ console.assert(aPriority > bPriority, aPriority, ">", bPriority);
+ const span = aPriority - bPriority;
+ const newPriority = bPriority + 0.1 * span + 0.8 * span * Math.random();
+ console.assert(aPriority > newPriority && newPriority > bPriority, aPriority, ">", newPriority, ">", bPriority);
const newPriorityRounded = Math.round(newPriority);
const newPriorityRounded = Math.round(newPriority);
- const okToRound = aPriority < newPriorityRounded && newPriorityRounded < bPriority;
+ const okToRound = aPriority > newPriorityRounded && newPriorityRounded > bPriority;
ui.setPriority(task.getAttribute("data-created")!, okToRound ? newPriorityRounded : newPriority, Model.getPriority(task));
task instanceof HTMLElement && task.focus();
},
ui.setPriority(task.getAttribute("data-created")!, okToRound ? newPriorityRounded : newPriority, Model.getPriority(task));
task instanceof HTMLElement && task.focus();
},