Hacking Gmail

(Grace) #1

104 Part II — Getting Inside Gmail


Listing 6-2(continued)

s+=’ ‘+e.name+’: ‘+e.message+’\n’;
dump(s);
}

function _gd_element(id) {
try {
var el=window.document.getElementById(id);
} catch (e) {
gd_dumpErr(e);
return false;
}
if (el) return el;
return false;
}

function _gd_gmail_delete(e) {
dump(‘Called _gd_gmail_delete()...\n’);
//find the command box
var delete_button=e.target;
var
command_box=delete_button.parentNode.getElementsByTagName(‘sel
ect’)[0];
command_box.onfocus();

//find the command index for ‘move to trash’
var delete_index=-1;
for (var i=0; i<command_box.options.length; i++) {
if (‘tr’==command_box.options[i].value &&
!command_box.options[i].disabled ) {
delete_index=i;
break;
}
}

//don’t try to continue if we can’t move to trash now
if (-1==delete_index) {
var box=_gd_element(‘nt1’);
if (box) {
try {
//if we find the box put an error message in
it
box.firstChild.style.visibility=’visible’;

box.getElementsByTagName(‘td’)[1].innerHTML=’Could not delete.
Make sure at least one conversation is selected.’;
Free download pdf