Forums

Discuss all things Remember The Milk.

Custom list sorting with greasemonkey. Here you go..

dziamid says:
There has been a number of requests to enable all sorts of sorting of lists. In fact, it is quite easy to implement yourself. Personally, it needed my list to be sorted by tag name. Here's what you do (for noobs):
1. Install apache and set up localhost to store custom files for greasemonkey
2. Install greasemonkey plugin in firefox
3. Download jQuery (http://code.jquery.com/jquery-1.4.2.min.js)
and tinysort plugin (http://code.google.com/p/tinysort/downloads/detail?name=tinysort.1.0.4.zip&can=2&q=), extract and save somewhere under apache web directory. Check the files are accessible on your machine via localhost.
4. Finally, here's a greasemonkey script that sorts your tasks list when you load (reload) a page in browser.
--------


// Add jQuery
var jquery = document.createElement('script');
jquery.src = 'http://localhost/path/to/jquery.js';
jquery.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(jquery);
// Add tinysort plugin
var tinysort = document.createElement('script');
tinysort.src = 'http://localhost/path/to/jquery.tinysort.min.js';
tinysort.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(tinysort);

// Check if jQuery's loaded
function jqery_loader() {
if(typeof unsafeWindow.jQuery == 'undefined')
{ window.setTimeout(jqery_loader,100); }
else { $ = unsafeWindow.jQuery; letsJQuery(); }
}
jqery_loader();

// All your GM code must be inside this function

function letsJQuery() {
//make sure there is no conflict between jQuery and other libraries
$.noConflict();
$('#tasks table tr').tsort();
}

-------

Set up your paths to jquery and sort plugin. Read here how to customize tsort for your needs: http://blog.pengoworks.com/index.cfm/2008/9/11/Sorting-DOM-elements-using-jQuery
Good luck!
Posted at 12:56pm on August 26, 2010
Log in to post a reply.