[Ajax] Hacking Rojo - Ajaxize 'Mark as Read' function
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);
}
}
}
