Changeset 97

Show
Ignore:
Timestamp:
05/14/06 19:27:39 (3 years ago)
Author:
t-bone
Message:

cleanup, msn works about as well as it will

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • extension/resurrect/content/resurrect.js

    r96 r97  
    1 /* 
    2 Enumerating: document.location 
    3 document.location.hash = #x 
    4 document.location.host = www.google.com 
    5 document.location.hostname = www.google.com 
    6 document.location.href = http://www.google.com/search?q=foo&start=0&ie=utf-8&oe=utf-8&client=firefox-a&rls=org.mozilla:en-US:official#x 
    7 document.location.pathname = /search 
    8 document.location.port = 
    9 document.location.protocol = http: 
    10 document.location.search = ?q=foo&start=0&ie=utf-8&oe=utf-8&client=firefox-a&rls=org.mozilla:en-US:official 
    11 document.location.replace = function replace() { [native code] } 
    12 document.location.assign = function assign() { [native code] } 
    13 document.location.reload = function reload() { [native code] } 
    14 */ 
    15  
    161var resurrect={ 
    172 
     
    194        {name:'CoralCDN', id:'coralcdn'}, 
    205        {name:'Google Cache', id:'google'}, 
    21         {name:'The Internet Archive', id:'archive'} 
     6        {name:'The Internet Archive', id:'archive'}, 
    227        {name:'MSN Cache', id:'msn'}, 
    23         {name:'Yahoo! Cache', id:'yahoo'}, 
     8        {name:'Yahoo! Cache', id:'yahoo'} 
    249    ], 
    2510 
     
    5237// // // // // // // // // // // // // // // // // // // // // // // // // // // 
    5338 
    54     dumpProps:function(obj, withFuncs) { 
    55         dump('--------------------------------------------\n'); 
    56         dump(obj+'\n\n'); 
    57         var s=''; 
    58         for (i in obj) { 
    59             try { 
    60                 if (!withFuncs && 'function'==typeof obj[i]) continue; 
    61                 s=i+': '+obj[i]; 
    62                 s=s.replace(/\n\s*./, 'n'); 
    63                 dump( s.substring(0, 79)+'\n' ); 
    64             } catch (e) { } 
    65         } 
    66         dump('\n'); 
    67     }, 
    68  
    69     findTag:function(tagName) { 
    70         var el=document.popupNode; 
    71  
    72         try { 
    73             while (el && el.tagName && tagName!=el.tagName) { 
    74                 el=el.parentNode; 
    75             } 
    76             return el; 
    77         } catch (e) { } 
    78         return null; 
    79     }, 
    80  
    81 // // // // // // // // // // // // // // // // // // // // // // // // // // // 
    82  
    8339    page:function(event) { 
    8440        var doc=getBrowser().contentWindow.document; 
     
    8743 
    8844    link:function(event) { 
    89         var a=resurrect.findTag('A'); 
    90         resurrect.showDialog(a.href); 
     45        var el=document.popupNode; 
     46 
     47        try { 
     48            while (el && el.tagName && 'A'!=el.tagName) { 
     49                el=el.parentNode; 
     50            } 
     51            resurrect.showDialog(el.href); 
     52        } catch (e) { } 
     53        return null; 
    9154    }, 
    9255 
     
    13598            break; 
    13699        case 'yahoo': 
    137             //opener.resurrect.yahooApi(encUrl); 
    138100            var xhr=new XMLHttpRequest(); 
    139101            xhr.open('GET', 
     
    149111            } catch (e ) { 
    150112                gotoUrl='http://search.yahoo.com/search?p='+encUrl; 
     113            } 
     114 
     115            break; 
     116        case 'msn': 
     117            //FD382E93B5ABC456C5E34C238A906CAB2DEEB5D6 
     118            //ugh, they've got an API but .. SOAP?  blech too complicated 
     119 
     120            var searchUrl='http://search.msn.com/results.aspx?q='+encUrl; 
     121 
     122            var xhr=new XMLHttpRequest(); 
     123            xhr.open('GET', searchUrl, false); 
     124            xhr.send(null); 
     125 
     126            try { 
     127                var m=xhr.responseText.match(/<a href=\"([^\"]+)\">Cached page/); 
     128                gotoUrl=m[1]; 
     129                gotoUrl=gotoUrl.replace('&amp;', '&'); 
     130            } catch (e ) { 
     131                gotoUrl=searchUrl; 
    151132            } 
    152133