To load this file without formatting, visit http://www.ewanmellor.org.uk/javascript/rot13.js. This is a spam-protection measure; sorry for the inconvenience.
· rot13.js ·
1/* rot13.js. Version 1.3. 5Rot13 functions by Valentin Hilbig, who has placed them in the public domain. <http://tools.geht.net/rot13.html>. Improvements have been made by Ewan Mellor <ebg13 at rjnazryybe.bet.hx>, who has also placed his code in the public domain. 10 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20This file may be obtained from <http://www.ewanmellor.org.uk/javascript/>. */ 25/** * @return The rot13 of the given string. The &#nn;, <, >, and & * entities are also expanded, as entities are sometimes left unprocessed by * browsers when performing Element.innerText or * Element.childNodes[0].nodeValue. Other characters not in [A-Za-z] are 30 * placed in the output without change. */ function rot13(a) { if (!rot13map) 35 { rot13map = rot13init(); } var s = ""; 40 var i; var entity = ""; for (i = 0; i < a.length; i++) { var b = a.charAt(i); 45 if (entity) { entity += b; 50 if (b == ';') { if (entity == "<") { s += "<"; 55 } else if (entity == ">") { s += ">"; } 60 else if (entity == "&") { s += "&"; } else 65 { var matches = entity.match(rot13numericEntityRE); if (matches[1]) { 70 s+= String.fromCharCode(matches[1]); } } entity = ""; 75 } } else if (b == '&') { entity = "&"; 80 } else { s += (b >= 'A' && b <= 'Z' || b >= 'a' && b <= 'z' ? rot13map[b] : b); } 85 } return s; } 90 rot13map = null; rot13numericEntityRE = /&#(.*);/; 95/** * Initialise this module. This is called by rot13 if necessary -- there is * no need to call it explicitly yourself. */ function rot13init() 100{ var map = new Array(); var s = "abcdefghijklmnopqrstuvwxyz"; var i; 105 for (i = 0; i < s.length; i++) { map[s.charAt(i)] = s.charAt((i + 13) % 26); } for (i = 0; i < s.length; i++) 110 { map[s.charAt(i).toUpperCase()] = s.charAt((i + 13) % 26).toUpperCase(); } return map; 115}
· rot13.js ends ·
To load this file without formatting, visit http://www.ewanmellor.org.uk/javascript/rot13.js. This is a spam-protection measure; sorry for the inconvenience.