Skip navigation

I was playing with Abdallah El Guindy’s “very useful” Ubiquity mashup. Its objective is to fetch the every week Todo list from the G-OSC Wiki. There were few glitches however in his script that I managed to fix.

The best thing about this script and Ubiquity is the preview function. Just popout Ubiquity, type gosc-watsup and the preview should get you the information immediately. However, preview didn’t work.

I Fixed it by adding the missing parameter pblock to the preview function gosc_watsup_preview_page, so it finally appeared.(took me some time to reach that btw)

Then I noticed the previewed items were not complete. I examined the code a little. Abdallah traverses the tags using JQuery.  He greps the To do List anchor with the find function, jumps twice to the next  siblings (siblings are other tags at the same level) and fetches the content using next(). The problem with that is sometimes the To do list is not just one block. There may be a list, then a block of text, another list ..etc. So the last next() invoke may sometimes bring only part of the Todo list.

I managed to solve that too, by calling next() repeatedly in a loop until there are no more siblings. This however brought another problem as the References, Feedback and other items at the same level are brought into preview. I solved that too by added a condition to check we are not leaving the To Do List section.

Okay preview is working and nothing is missing. But it doesn’t look very nice, even though the items are in an Unordered List.

Apparently this is a bug in Firefox. This is what happens:

div.innerHTML=”<ul>”;

div.innerHTML=”<li>Item</li>;”

div.innerHTML=”</ul>”;

is treated differently than

div.innerHTML=”<ul><li>Item<li><ul>”;

So I had to switch to the second one as the in the first, the <ul> is totally ignored.

So, is that all? No! There is one last problem (hopefully), but I’ll just leave that to another post 🙂

This is my updated version of gosc-watsup.

var GOSC_WATSUP_BASE_URL = ‘http://se.bigbuddysociety.net&#8217;;
var GOSC_WATSUP_TODO_PAGE = “http://se.bigbuddysociety.net/wiki/index.php?title=To-Do&#8221;;

function gosc_watsup_go_to_page() {
jQuery.get(GOSC_WATSUP_TODO_PAGE, {}, function(html) {
var url = jQuery(html).find(‘#bodyContent’).children(‘ul’).children(‘li:last’).children(‘:first’).attr(‘href’);
Utils.focusUrlInBrowser(GOSC_WATSUP_BASE_URL + url);
});
}

function gosc_watsup_preview_page(pblock) {
jQuery.get(GOSC_WATSUP_TODO_PAGE, {}, function(html) {
var url = jQuery(html).find(‘#bodyContent’).children(‘ul’).children(‘li:last’).children(‘:first’).attr(‘href’);
jQuery.get(GOSC_WATSUP_BASE_URL + url, {}, function(html2) {
pblock.innerHTML = ‘<h2>Latest TODO list</h2>’;
var innerHtml=””;
temp=jQuery(html2).find(‘a’).filter(function(index){
return jQuery(this).attr(‘name’) == ‘To_Do_List’;
}).next().next();

innerHtml+=”<ul>”;

do
{
innerHtml+=jQuery(temp).html();
temp=jQuery(temp).next();
if(jQuery(temp).attr(‘name’)!=null)break;
//alert(todo);
}
while((jQuery(temp).next().html())!=null)

innerHtml+=”</ul>”;
pblock.innerHTML=innerHtml;

});

});
}

CmdUtils.CreateCommand({
names: [“gosc-watsup”],
author: { name: “Abdallah El Guindy and Tarek Galal”, email: “abdallah.elguindy@gmail.com”},
contributors: [“Tarek Galal”],
description: “Go to the latest TODO list page.”,
execute: gosc_watsup_go_to_page,
preview: gosc_watsup_preview_page
})

CmdUtils.CreateCommand({
	names: ["gosc-watsup"],
	author: { name: "Abdallah El Guindy and Tarek Galal", email: "abdallah [dot] elguindy [at] gmail [dot] com"},
	contributors: ["Tarek Galal"],
	description: "Go to the latest TODO list page.",
	execute: gosc_watsup_go_to_page,
	preview: gosc_watsup_preview_page
})
Advertisements

2 Comments

    • Abdallah El Guindy
    • Posted October 22, 2009 at 5:02 pm
    • Permalink
    • Reply

    Very nice work!

    Please DO ADD yourself to the authors as we agreed earlier!

  1. I did add myself to the contributors on the wiki version, I just forgot to update this one. Thanks.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: