Chapter 6 — Gmail and Greasemonkey 95
}
function parsesubs(r){
parser=new DOMParser();
dom=parser.parseFromString(r,’text/xml’);
outlines=dom.getElementsByTagName(‘outline’);
subs=new Array();
for(i=0; i<outlines.length; i++){
if (outlines[i].getAttribute(‘type’) != undefined
){
d={ ‘title’:outlines[i].getAttribute(‘title’),
‘htmlUrl’:outlines[i].getAttribute(‘htmlUrl’),
‘type’:outlines[i].getAttribute(‘type’),
‘xmlUrl’:outlines[i].getAttribute(‘xmlUrl’),
‘BloglinesSubId’:outlines[i].getAttribute(‘BloglinesSubId’),
‘BloglinesUnread’:outlines[i].getAttribute(‘BloglinesUnread’)
};
subs[subs.length]=d;
}
}
return subs;
}
function gotsubs(response){
if (typeof(response)==’object’){
data=response[‘responseText’];
}else{
data=response;
}
r=parsesubs(data);
r.sort(function(a,b){; var r=a[‘BloglinesUnread’] >
b[‘BloglinesUnread’]; if(r){return -1}else{return 1} });
addsubhtml_init();
for(i=0; i<r.length; i++){
addsubhtml(r[i]);
}
addsubhtml_end();
}
function addsubhtml_end(){
ul=document.getElementById(‘bloglines_subs’);
if (ul){
GM_setValue(‘subs_cached_html’,ul.innerHTML);
}
}
function createbutton(str){
a=document.createElement(‘div’);
a.appendChild(document.createTextNode(str))
a.style.backgroundColor=’#dddddd’;
a.style.borderStyle=’outset’;
a.style.borderColor=’#eeeeee’;
Continued