2006-05-14 23:48:10 +02:00
|
|
|
var resurrect={
|
2006-05-15 00:37:23 +02:00
|
|
|
|
|
|
|
mirrors:[
|
|
|
|
{name:'CoralCDN', id:'coralcdn'},
|
|
|
|
{name:'Google Cache', id:'google'},
|
2006-05-15 01:27:39 +02:00
|
|
|
{name:'The Internet Archive', id:'archive'},
|
2006-05-15 01:09:01 +02:00
|
|
|
{name:'MSN Cache', id:'msn'},
|
2006-05-15 01:27:39 +02:00
|
|
|
{name:'Yahoo! Cache', id:'yahoo'}
|
2006-05-15 00:37:23 +02:00
|
|
|
],
|
|
|
|
|
|
|
|
originalDoc:null,
|
|
|
|
gotoUrl:null,
|
2006-05-14 23:48:10 +02:00
|
|
|
|
|
|
|
// // // // // // // // // // // // // // // // // // // // // // // // // // //
|
|
|
|
|
|
|
|
onLoad:function() {
|
|
|
|
window.removeEventListener('load', resurrect.onLoad, false);
|
|
|
|
|
|
|
|
document.getElementById('contentAreaContextMenu')
|
|
|
|
.addEventListener('popupshowing', resurrect.toggleContextItems, false);
|
|
|
|
},
|
|
|
|
|
|
|
|
toggleContextItems:function(event) {
|
|
|
|
resurrect.clickTarget=event.target;
|
|
|
|
|
2006-05-15 01:09:01 +02:00
|
|
|
var onDocument=!(
|
|
|
|
gContextMenu.isContentSelected || gContextMenu.onTextInput ||
|
|
|
|
gContextMenu.onLink || gContextMenu.onImage
|
2006-05-14 23:48:10 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
document.getElementById('resurrect-page-context')
|
|
|
|
.setAttribute('hidden', !onDocument);
|
|
|
|
document.getElementById('resurrect-link-context')
|
|
|
|
.setAttribute('hidden', !gContextMenu.onLink);
|
|
|
|
},
|
|
|
|
|
|
|
|
// // // // // // // // // // // // // // // // // // // // // // // // // // //
|
|
|
|
|
2006-05-15 01:27:39 +02:00
|
|
|
page:function(event) {
|
|
|
|
var doc=getBrowser().contentWindow.document;
|
|
|
|
resurrect.showDialog(doc.location.href);
|
2006-05-14 23:48:10 +02:00
|
|
|
},
|
|
|
|
|
2006-05-15 01:27:39 +02:00
|
|
|
link:function(event) {
|
2006-05-14 23:48:10 +02:00
|
|
|
var el=document.popupNode;
|
|
|
|
|
|
|
|
try {
|
2006-05-15 01:27:39 +02:00
|
|
|
while (el && el.tagName && 'A'!=el.tagName) {
|
2006-05-14 23:48:10 +02:00
|
|
|
el=el.parentNode;
|
|
|
|
}
|
2006-05-15 01:27:39 +02:00
|
|
|
resurrect.showDialog(el.href);
|
2006-05-14 23:48:10 +02:00
|
|
|
} catch (e) { }
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
|
|
|
|
// // // // // // // // // // // // // // // // // // // // // // // // // // //
|
|
|
|
|
|
|
|
showDialog:function(url) {
|
2006-05-15 00:37:23 +02:00
|
|
|
resurrect.originalDoc=getBrowser().contentWindow.document;
|
|
|
|
resurrect.gotoUrl=url;
|
|
|
|
|
|
|
|
window.openDialog(
|
|
|
|
'chrome://resurrect/content/resurrect-select-mirror.xul',
|
|
|
|
'_blank',
|
|
|
|
'modal,centerscreen,resizable=no,chrome,dependent'
|
|
|
|
);
|
|
|
|
},
|
|
|
|
|
|
|
|
selectMirror:function(event) {
|
|
|
|
var listbox=document.getElementById('mirror');
|
|
|
|
|
|
|
|
var gotoUrl=null;
|
|
|
|
|
|
|
|
var rawUrl=opener.resurrect.gotoUrl;
|
|
|
|
var encUrl=encodeURIComponent(rawUrl);
|
|
|
|
|
|
|
|
switch (listbox.value) {
|
|
|
|
case 'coralcdn':
|
|
|
|
gotoUrl=rawUrl.substring(0, 8)+
|
|
|
|
rawUrl.substring(8).replace(/\//, '.nyud.net:8080/');
|
|
|
|
break;
|
2006-05-15 00:38:47 +02:00
|
|
|
case 'google':
|
|
|
|
gotoUrl='http://www.google.com/search?q=cache:'+encUrl
|
|
|
|
break;
|
2006-05-15 00:41:06 +02:00
|
|
|
case 'archive':
|
|
|
|
gotoUrl='http://web.archive.org/web/*/'+rawUrl
|
2006-05-15 01:09:01 +02:00
|
|
|
break;
|
|
|
|
case 'yahoo':
|
|
|
|
var xhr=new XMLHttpRequest();
|
|
|
|
xhr.open('GET',
|
|
|
|
'http://api.search.yahoo.com/WebSearchService/V1/'+
|
|
|
|
'webSearch?appid=firefox-resurrect&query='+encUrl+'&results=1',
|
|
|
|
false
|
|
|
|
);
|
|
|
|
xhr.send(null);
|
|
|
|
|
|
|
|
try {
|
|
|
|
var c=xhr.responseXML.getElementsByTagName('Cache');
|
|
|
|
gotoUrl=c[0].firstChild.textContent;
|
|
|
|
} catch (e ) {
|
|
|
|
gotoUrl='http://search.yahoo.com/search?p='+encUrl;
|
|
|
|
}
|
|
|
|
|
2006-05-15 01:27:39 +02:00
|
|
|
break;
|
|
|
|
case 'msn':
|
|
|
|
//FD382E93B5ABC456C5E34C238A906CAB2DEEB5D6
|
|
|
|
//ugh, they've got an API but .. SOAP? blech too complicated
|
|
|
|
|
|
|
|
var searchUrl='http://search.msn.com/results.aspx?q='+encUrl;
|
|
|
|
|
|
|
|
var xhr=new XMLHttpRequest();
|
|
|
|
xhr.open('GET', searchUrl, false);
|
|
|
|
xhr.send(null);
|
|
|
|
|
|
|
|
try {
|
|
|
|
var m=xhr.responseText.match(/<a href=\"([^\"]+)\">Cached page/);
|
|
|
|
gotoUrl=m[1];
|
|
|
|
gotoUrl=gotoUrl.replace('&', '&');
|
|
|
|
} catch (e ) {
|
|
|
|
gotoUrl=searchUrl;
|
|
|
|
}
|
|
|
|
|
2006-05-15 00:41:06 +02:00
|
|
|
break;
|
2006-05-15 00:37:23 +02:00
|
|
|
}
|
|
|
|
if (gotoUrl) {
|
|
|
|
opener.resurrect.originalDoc.location.assign(gotoUrl);
|
|
|
|
}
|
|
|
|
|
|
|
|
//setTimeout avoids error message when selecting in listbox
|
|
|
|
setTimeout(window.close, 0);
|
2006-05-14 23:48:10 +02:00
|
|
|
}
|
|
|
|
|
2006-05-15 00:37:23 +02:00
|
|
|
// // // // // // // // // // // // // // // // // // // // // // // // // // //
|
|
|
|
|
2006-05-14 23:48:10 +02:00
|
|
|
}//end var resurrect
|
|
|
|
|
2006-05-15 00:37:23 +02:00
|
|
|
if ('undefined'!=typeof gBrowser) {
|
|
|
|
window.addEventListener('load', resurrect.onLoad, false);
|
|
|
|
}
|