ForumsQuestionsUserscript (or option) to swap Due Date with its tooltip text?


Userscript (or option) to swap Due Date with its tooltip text?
Author Message
pds

Posted: Mar 04, 2010
Score: 0 Reference
Anybody else out there prefer to see how many days are remaining before a task comes due (i.e. "In 23 days (Fri)") rather than a calendar date (i.e. "Mar 26")?

I noticed that Toodledo does provide this information as the hover-over/tooltip text on the Due Date column, but I would like to be able to swap the hover/tooltip text with the current contents of the span tag itself (the calendar date).

I couldn't find a user setting within Toodledo to make this change, so I was wondering if anybody out there had a greasemonkey script (or could give me some pointers in making it myself) that was able to do this? Or at least something similar that I could play with to see if I could modify it to do this?

I am not a javascript programmer, so I don't know how to access the necessary elements from the DOM.
pds

Posted: Mar 04, 2010
Score: 0 Reference
Actually, that wasn't that hard :)

Thanks to Michael Lasevich's examples at http://www.legrig.com/soft/toodledo-addons/ I was able to figure it out (with the jQuery documentation's help as well):


// ==UserScript==
// @name ToodleDo Addons - Swap Due Date With Remaining
// @namespace ToodleDo-Addons
// @include http://www.toodledo.com/views/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js
// ==/UserScript==

function swap_due_and_remaining() {
$("div.col2.dett").each(function(index){
var duedate = $(this).text();
var span = $(this).find("span");
var remaining = span.attr("title");

span.text(remaining);
span.attr("title", duedate);
});
}

$(document).ready(function(){
swap_due_and_remaining();

// A little cheat to handle tab clicks
$("div.tab").click(function(){setTimeout(swap_due_and_remaining, 1000)});
$("div.tabon").click(function(){setTimeout(swap_due_and_remaining, 1000)});
});

// A little cheat to handle key presses
$(document).keypress(function(){setTimeout(swap_due_and_remaining, 1000)});
pds

Posted: Mar 04, 2010
Score: 0 Reference
Improved version that keeps "Today/Tomorrow" as-is, but changes all other dates to the "In XX days" style:

// ==UserScript==
// @name ToodleDo Addons - Swap Due Date With Remaining
// @namespace ToodleDo-Addons
// @include http://www.toodledo.com/views/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js
// ==/UserScript==

function swap_due_and_remaining() {
$("div.col2.dett").each(function(index){
var duedate = $(this).text();
var span = $(this).find("span");
var remaining = span.attr("title");

if (duedate.match(/^T/) == null) {
span.text(remaining);
span.attr("title", duedate);
}
});
}

$(document).ready(function(){
swap_due_and_remaining();

// A little cheat to handle tab clicks
$("div.tab").click(function(){setTimeout(swap_due_and_remaining, 1000)});
$("div.tabon").click(function(){setTimeout(swap_due_and_remaining, 1000)});
});

// A little cheat to handle key presses
$(document).keypress(function(){setTimeout(swap_due_and_remaining, 1000)});
pds

Posted: Mar 04, 2010
Score: 0 Reference
Whoops...posted too soon. The previous version calls the function every time ANY key press is made, anywhere on the page (including for every character you're typing in a new task name, for example).

This updated version prevents that (largely stolen from another one of Mike's scripts -- thanks Mike!)

// ==UserScript==
// @name ToodleDo Addons - Swap Due Date With Remaining
// @namespace ToodleDo-Addons
// @include http://www.toodledo.com/views/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js
// ==/UserScript==

function swap_due_and_remaining() {
$("div.col2.dett").each(function(index){
var duedate = $(this).text();
var span = $(this).find("span");
var remaining = span.attr("title");

if (duedate.match(/^T/) == null) {
span.text(remaining);
span.attr("title", duedate);
}
});
}

$(document).ready(function(){
swap_due_and_remaining();

// A little cheat to handle tab clicks
$("div.tab").click(function(){setTimeout(swap_due_and_remaining, 1000)});
$("div.tabon").click(function(){setTimeout(swap_due_and_remaining, 1000)});
});

// A little cheat to handle key presses
$(document).keypress(function(event){
var obj = event.target.tagName;

if (event.metaKey || event.ctrlKey || event.altKey) return;

if (obj != "HTML" && obj != "BODY" && obj != "DIV") return;

if (event.charCode >= 48 && event.charCode <= 57) {
setTimeout(swap_due_and_remaining, 1000);
}
});
You cannot reply yet

U Back to topic home

R Post a reply

To participate in these forums, you must be signed in.