5 function add_webjump(key, loc)
10 function add_delicious_webjumps (username)
12 add_webjump("delicious", " http://del.icio.us/" + username);
13 add_webjump("adelicious", "javascript:location.href='http://del.icio.us/" + username + "?v=2&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title);");
14 add_webjump("sdelicious", " http://del.icio.us/search/?search=%s");
15 add_webjump("sadelicious", " http://del.icio.us/search/all?search=%s");
18 // Some built in web jumps
19 function init_webjumps()
21 add_webjump("conkerorwiki",
22 "http://conkeror.org/?action=fullsearch&context=60&value=%s&fullsearch=Text");
23 add_webjump("google", "http://www.google.com/search?q=%s");
24 add_webjump("lucky", "http://www.google.com/search?q=%s&btnI=I'm Feeling Lucky");
25 add_webjump("maps", "http://maps.google.com/?q=%s");
26 add_webjump("scholar", "http://scholar.google.com/scholar?q=%s");
27 add_webjump("clusty", "http://www.clusty.com/search?query=%s");
28 add_webjump("wikipedia", "http://en.wikipedia.org/wiki/Special:Search?search=%s");
29 add_webjump("slang", "http://www.urbandictionary.com/define.php?term=%s");
30 add_webjump("dictionary", "http://dictionary.reference.com/search?q=%s");
31 add_webjump("xulplanet", "http://www.google.com/custom?q=%s&cof=S%3A"+
32 "http%3A%2F%2Fwww.xulplanet.com%3BAH%3Aleft%3BLH%3A65%3BLC"+
33 "%3A4682B4%3BL%3Ahttp%3A%2F%2Fwww.xulplanet.com%2Fimages%2F"+
34 "xulplanet.png%3BALC%3Ablue%3BLW%3A215%3BAWFID%3A0979f384d5"+
35 "181409%3B&domains=xulplanet.com&sitesearch=xulplanet.com&sa=Go");
36 add_webjump("image", "http://images.google.com/images?q=%s");
37 add_webjump("bugzilla", "https://bugzilla.mozilla.org/show_bug.cgi?id=%s");
38 add_webjump("clhs", "http://www.xach.com/clhs?q=%s");
39 add_webjump("emacswiki", "http://www.emacswiki.org/cgi-bin/wiki?search=%s");
40 add_webjump("cliki", "http://www.cliki.net/admin/search?words=%s");
41 add_webjump("ratpoisonwiki", "http://ratpoison.elektrubadur.se/?search=%s");
42 add_webjump("stumpwmwiki", "http://stumpwm.elektrubadur.se/?search=%s");
43 add_webjump("savannah", "http://savannah.gnu.org/search/?words=%s&type_of_search=soft&Search=Search&exact=1");
44 add_webjump("sourceforge", "http://sourceforge.net/search/?words=%s");
45 add_webjump("freshmeat", "http://freshmeat.net/search/?q=%s");
46 add_webjump("slashdot", "http://slashdot.org/search.pl?query=%s");
47 add_webjump("kuro5hin", "http://www.kuro5hin.org/?op=search&string=%s");
48 add_webjump("sheldonbrown", "http://www.google.com/search?q=site:sheldonbrown.com %s");
51 function webjump_build_url(template, subs)
53 var b = template.indexOf('%s');
55 // Just return the same string if it doesn't contain a %s
59 return template.substr(0,b) + encodeURIComponent(subs) + template.substring(a);
62 function get_partial_match(hash, part)
66 if (part == x.substr(0, part.length))
69 if (matches.length == 1)
75 function getWebJump(value)
78 var start = value.indexOf(' ');
81 jump = webjumps[value];
83 jump = webjumps[value.substr(0,start)];
84 // Try to find a web jump match
86 var match = get_partial_match(webjumps, value.substr(0,start));
88 jump = webjumps[match];
92 return webjump_build_url(jump, value.substring(start + 1));
93 } catch(e) {/* FIXME: figure out why we need this */ dump_error(e); return null;}
96 function get_url_or_webjump(input)
98 var url = getWebJump(input);