Hacking Gmail

(Grace) #1

Chapter 6 — Gmail and Greasemonkey 97


}


a.appendChild(document.createTextNode(txt));
li.appendChild(a);
ul.appendChild(li);
}
function getsub(e){
id=e.target.id;

GM_xmlhttpRequest({‘method’:’GET’,’url’:”http://rpc.bloglines.
com/getitems?n=0&s=”+id,’onload’:gotsub});


}
function gotsub(r){
var d=parsesub(r[‘responseText’]);
for(var i=0; i<d.length; i++){
item=d[i];

items[getText(item.getElementsByTagName(‘guid’)[0])]=item;
}
for(i=0; i<d.length; i++){
item=d[i];
displaysubhtml(item);
}
}
function displaysubhtml(item){
li=document.createElement(‘li’);
b=document.getElementById(‘items’);


a=document.createElement(‘a’);
a.id=getText(item.getElementsByTagName(‘guid’)[0]);
a.addEventListener(‘click’,displayitem,false);

a.appendChild(document.createTextNode(getText(item.getElements
ByTagName(‘title’)[0])));
li.appendChild(a);
b.appendChild(li);
}
function displayitem(e){
id=e.target.id;
var item=__items[id];
displayitemhtml(item);
}
function displayitemhtml(item){
i=document.getElementById(‘item’);


i.innerHTML=getText(item.getElementsByTagName(‘description’)[0
]);


Continued
Free download pdf