I’m trying to put together a script that will add @today to anything tagged @due with today’s date (ex: @due(2016-03-02).)
Below is a modified version of Jesse’s script for replacing @tomorrow with @today. With this script, a @today tag is only added to items that are tagged with both @due and @q (a random test tag).
function TaskPaperContextScript(editor, options) {
var today = DateTime.format(‘today’);
var outline = editor.outline;
outline.groupUndoAndChanges(function() {
outline.evaluateItemPath(‘//@due’).forEach(function (each) {
each.setAttribute(‘data-today’, each.getAttribute(‘data-q’));
});
});
}
Okay, that’s what I thought it was doing, but I was confused since removing it made the script not work at all. Then I took a look at another script you posted and realized in order to add the today tag with no parentheses, I had to do
each.setAttribute('data-tomorrow', '');
Thanks for holding my hand through this! I really appreciate the time you’ve taken to explain everything.
Hi. I belong to those who when it comes to javascript can’t hope for anything better than to copy/paste something that works. Thank you for the script! I have used it to create overdue and available tags as well. Three different scripts. Now, I was wondering if one could merge them into one script that would make sure that the item only has one of these tags. Any help is greatly appreciated
You might have to spell out the logic of which tag(s) get thrown out of the balloon when multiples are found.
For example an ordering like:
@available -> @due -> @today -> @overdue ?
in which any predecessors of the latest type of tag are considered redundant and get pruned out ?
Or something with a few more special cases ? (Is @available, for example, incompatible with @due, or can those two co-exist in your scheme ?)
PS if its essentially a 3 or 4 colour traffic light scheme, in which each type of tag has a higher temperature than its predecessor, then perhaps you could have a pair of key strokes:
add heat (switch to next (hotter) tag type)
reduce heat (switch back to previous (cooler) tag type).
Ah yes, of course. I’m thinking, for now, that only those three tags are incompatible with one another, with @overdue at the top (hottest, >@due date), followed by @today (= @due date), and @available (>= @start date) last. As you put it, but without the @due:
@available -> @today -> @overdue
where the predecessors get pruned out.
The @due and @start tags, together with @flag can live beside any other tag. But perhaps @start could be added to list above, as the coldest tag, before @available…
(Actually, I’m not sure about this scheme, and should have perhaps thought it over more thoroughly before asking for help.)
You could experiment, if you like, with the following settings:
{
// OPTIONS:
// Rank tags and values cool -> hot (left -> right)
tagOrder: ['available', 'today', 'overdue'],
valueOrder: [], // value list can be empty, for simple tags
forward: true, // create another copy of the script for moving back (edit to `forward: false`)
cycle: true // Extremes cycle back to start ? (edit to `cycle: false` to stop at extremes)
}