« [Ajax] Hacking Rojo - an Ajax Wrapper for Rojo | Main | My scripts in Userscripts.org »

[Ajax] Hacking Rojo - Ajaxize 'Mark as Read' function

Tags: Ajax , Greasemonkey , Rojo

Since my previous work 'an Ajax Wrapper for Rojo' has replaced the iframe remote scripting by XMLHttpRequest, some slow 'loading whole page' transactions of Rojo need remodeling now. Well, I use the term "Ajaxize" which means turning the old-fashioned transactions of cross-pages into Ajax approach. The first one I've done is to make "Mark as Read" as a background transaction.

The script 'rojo.ajax.user.js' is now version 1.1 and has the following features:

1. Override the Remote object(remote scripting) by an Ajax wrapper. 2. Mark as read is now Ajax and reset the unread count on the LHS menu.

Download: rojo.ajax.user.js

The code is simple. Just 'click' the 'Mark as Read' url by XMLHttpRequest, and then reset the counter in LHS menu.

Ajax.Mark_as_Read = function() {

    var markasread = document.getElementById("markReadLink");
    if( markasread ) {
        var url = markasread.href;
        markasread.href = 'javascript:;';
        var callback = function() {
            var li = document.getElementsByTagName('li');
            for(var i=0; i < li.length; i++) {
                if( li[i].className == 'selected subscription unread' ) {
                    li[i].getElementsByTagName('span')[0].innerHTML = '';
                }
            }
        }
        markasread.onclick = function() {
            Remote.execRequest(url, callback, null);
        }
    }
}

TrackBack

Listed below are links to weblogs that reference [Ajax] Hacking Rojo - Ajaxize 'Mark as Read' function:

» [Ajax] Hacking Rojo - Ajaxize more of 'Mark as Read' from Yuan.CC Web Experiments
Last time I have Ajaxized a 'Mark as Read' on a single feed to move the HTTP request to background by calling XMLHttpRequest instead of bringing to a new page. The counters of unread entries are reset on LHS... [Read More]

» [Ajax] Hacking Rojo - Adding bits to feeds in Rojo from Yuan.CC Web Experiments
Rojo is lacking of some designs of user friendly. Why am I saying that? Sometimes we need to make an unnecessary click to get some basic but useful information of a feed. While reading stories of a feed, we... [Read More]

» [Ajax] Hacking Rojo - Quick unsubscribe feeds in Rojo from Yuan.CC Web Experiments
In Rojo, you can unsubscribe feeds only within two pages, the page of managing your feed list or the one of viewing the feed profile. Now the rojo.ajax.user.js script injects quick links to let you unsubscribe feeds any time.... [Read More]

» [Ajax] Hacking Rojo - Clearance of All Additions from Yuan.CC Web Experiments
I have been adding some additions to Rojo and keeping this script updated with Rojo. Lately, Rojo slightly changed its HTML layout, so some features of the script failed. I also fixed the compatible problem with Firefox 1.5RC3. Following... [Read More]