see comments on Reforming rot13 - Less Wrong

2 Post author: DanielVarga 04 November 2011 11:41PM

You are viewing a comment permalink. View the original post to see all comments and the full post content.

Comments (35)

You are viewing a single comment's thread.

Comment author: see 05 November 2011 01:33:09AM 0 points [-]

I'm personally much happier using a rot13 bookmarklet rather than having to use an external site to decode the spoiler text. If your alternative comes with a bookmarklet I can use to decode, I'm willing to use that; otherwise, I'd rather people stick with rot13 coding.

Comment author: dbaupp 05 November 2011 02:20:51AM *  2 points [-]

I agree that a bookmarklet is preferable to external applications. And in that vein, I've adapted this one so that it does in-place encoding/decoding both of normal text and text inside textboxes (like this: na rknzcyr).

javascript:function%20convert(inText){var%20outText='',t;for(i=0;i<inText.length;i++){t=inText.charCodeAt(i);if((t>64&&t<78)||(t>96&&t<110))t%20+=%2013;else%20if((t>77&&t<91)||(t>109&&t<123))t%20-=%2013;outText%20+=%20String.fromCharCode(t);}return%20outText;}var%20sel=window.getSelection().getRangeAt(0);if(sel==''){var%20act=document.activeElement;if(act.type=="textarea"){var%20start=act.selectionStart,end=act.selectionEnd;if(start!=end){var%20prefix=act.value.substring(0,start);var%20middle=convert(act.value.substring(start,end));var%20suffix=act.value.substring(end);act.value=prefix;act.value%20+=%20middle;void(act.value%20+=%20suffix);}}else{void(inText=prompt('Phrase...',''));if(inText)alert(convert(inText));}}else{out=convert(sel.toString());sel.deleteContents();var%20span=document.createElement("span");span.innerHTML=out;sel.insertNode(span);}

(I've only tested it on newer versions of Firefox and Chrome)

Comment author: see 08 November 2011 09:53:16PM 0 points [-]

Irel hfrshy!

Comment author: dbaupp 09 November 2011 05:41:54AM 1 point [-]

Thanks!

(When I saw this in my inbox, I was very very confused, until I realised its context.)