Yet another Yubnub bookmarklet (URIComponent)

2 views
Skip to first unread message

HopfZ

unread,
Sep 20, 2006, 4:37:29 PM9/20/06
to YubNub
Usage: Highlight a text (ex: extraordinary) and click the bookmarklet
and type command (ex: dict). Or don't highlight a text and click the
bookmarklet and type query (ex: dict extraordinary).

The bookmarklets can be found at the following webnote page. one is for
new window, another is for current window:
http://www.aypwip.org/webnote/load.py?name=yubnub.bookmarklet&time=2006-09-20+16%3A20%3A39

The difference from Brian Armknecht's bookmarklet is that it uses
URIComponent instead of escape. it should have less encoding problem
for foreign language query.
ref: "yubnub search tools & korean encoding issue"
http://groups.google.com/group/YubNub/browse_thread/thread/a203578f62165b48/e143d98a075ceece

tested in Opera 9, IE 6, Firefox 1.5.

bookmarklet codes

yubnub bookmarklet (URIComponent)(open in new window)
javascript:(function(){
var w=window,d=document,gS='getSelection',r;
// cross-browser way to get selection
var
se=''+(w[gS]?w[gS]():d[gS]?d[gS]():d.selection.createRange().text);
// trim selection
se=se.replace(/(^\s+|\s+$)/g,'');
// yub('ls google') will return a yubnub url that parses 'ls google'.
function yub(s){
return('http://yubnub.org/parser/parse?command='+
encodeURIComponent(s).replace(/\%20/g,'+'))
}
if(r=prompt('search-word: '+se+'\ntype yubnub command:'))
open(yub(se.length?(r+' '+se):r));
})();

yubnub bookmarklet (URIComponent)(open in current window)
replace the last line (open...) with
location=yub(se.length?(r+' '+se):r);

Brian

unread,
Sep 21, 2006, 9:04:16 PM9/21/06
to YubNub
Good idea, Hopf.

I added a comment to the original YubNub blog post to mention your
bookmarklets:
http://yubnub.blogspot.com/2005/11/yubnub-bookmarklet-by-brian-armknecht.html#comments

Brian

Reply all
Reply to author
Forward
0 new messages