// Copyright (c) 2011 Benjamin Schweizer.
//

function show_recent_activity() {
    $.getJSON("http://pipes.yahoo.com/pipes/pipe.run?Age=30+days+ago&_id=a553b0d4a4bd356750a348f609fb6ee5&_render=json", function(json) {
        $('#content').prepend('<div class="post"><div class="entry" id="activity"></div></div>')
        $('#activity').append('<h2 style="margin-bottom: 10px;">Recent Activity</h2>');
        $.each(json.value.items, function(idx, item) {
            try {
            //year = parseInt(item.pubDate.substr(0,4), 10);
            month = parseInt(item.pubDate.substr(5,2), 10);
            month = ["null", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"][month];
            day = parseInt(item.pubDate.substr(8,2), 10);
            day = [null, '1st', '2nd', '3rd', '4th', '5th', '6th', '7th', '8th', '9th',
                '10th', '11th', '12th', '13th', '14th', '15th', '16th', '17th', '18th',
                '19th', '20th', '21st', '22nd', '23rd', '24th', '25th', '26th', '27th',
                '28th', '29th', '30th', '31st'][day];
            } catch(err) { day="today"; month=''; };

            /*
            icon = {
                'github.com': '/inc/icons/github.png',
                'twitter.com': '/inc/icons/twitter.png',
                'disqus.com': '/inc/icons/disqus.png'
                }[item.link.split('/')[2]];
            if (typeof icon === 'undefined')
                icon = '/inc/icons/bookmarks.png';
            */

            $('#activity').append('<img src="http://tools.sickos.org/favpng/?' + item.link + '" class="icon" style="float: left;"/>'); 
            $('#activity').append('<div style="padding-left: 20px;"><a href="' + item.link + '" style="color: #333;">' + item.title + '</a>' +
                    ' <span style="color: #888; font-size: 12px;"> ' + month + ' ' + day + '</span></div>');
        });
    });
};

// eof.

