The HTML below, placed in your notelet nodelet, will give you a button that displays the ROT-13 transformation of whatever text you have selected in an alert box.

The code is largely inspired by tongpoo's nifty bookmarklet here. (Thanks tongpoo! Love those XORs.)

Note that in all versions you can save precious notelet space by altering the button text from 'ROT-13' to something shorter of your choosing. Also you can delete any spaces that appear between the quotes (") - these have been inserted to prevent this writeup breaking browser windows.

Internet Explorer & Mozilla & Netscape

If you're not pushed for space in your notelet nodelet, this version will work in IE and Mozilla and Netscape:

<button onclick="p=document.all?document.selection.createRange().text: document.getSelection();q='';for(i=0;i<p.length;){c=p.charCodeAt(i++); q+=String.fromCharCode(c+(c<65^c<91^c<97^c<123?(c-1)%32<13?13:-13:0))} alert(q)">ROT-13</button>

Platform specific

To save a few more precious characters, use one of these:

Internet Explorer

<button onclick="p=document.selection.createRange().text;q='';for(i=0;i<p.length;){c= p.charCodeAt(i++);q+=String.fromCharCode(c+(c<65^c<91^c<97^c<123?(c-1)%32<13?13: -13:0))}alert(q)">ROT-13</button>

Mozilla & Netscape

<button onclick="p=document.getSelection();q='';for(i=0;i<p.length;){c=p.charCodeAt(i++) ;q+=String.fromCharCode(c+(c<65^c<91^c<97^c<123?(c-1)%32<13?13:-13:0))}alert(q) ">ROT-13</button>

Updates for other browsers are most welcome.

Log in or register to write something here or to contact authors.