Skip to content

Instantly share code, notes, and snippets.

@karbassi
Created November 17, 2009 16:56
Show Gist options
  • Save karbassi/237055 to your computer and use it in GitHub Desktop.
Save karbassi/237055 to your computer and use it in GitHub Desktop.
Here's how I edited it.
It should work, but I haven't really ran it through the browser.
Also, if you WANT it to work for IE5, you can include the 'map' function as shown in:
https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Objects/Array/Map#Compatibility
// JavaScript Document
function flip() {
var b = {
a: "\u0250",
b: "q",
c: "\u0254",
d: "p",
e: "\u01dd",
f: "\u025f",
g: "b",
h: "\u0265",
i: "\u0131",
j: "\u0638",
k: "\u029e",
l: "1",
m: "\u026f",
n: "u",
p: "d",
q: "b",
r: "\u0279",
t: "\u0287",
u: "n",
v: "\u028c",
w: "\u028d",
y: "\u028e",
"[": "]",
"]": "[",
"(": ")",
")": "(",
"{": "}",
"}": "{",
"?": "\u00bf",
"\u00bf": "?",
"!": "\u00a1",
"'": ",",
",": "'"
};
document.getElementById('flipped').value = document.getElementById('original')
.value
.toLowerCase()
.split('')
.map(function(a){return b[a] ? b[a] ? a;})
.join('');
}
<!--
This is the only relevant part of the html. It's only a snippet.
-->
<style type="text/css">
form#flipForm { width: 470px; }
#flipForm input, #flipForm textarea { float: left; clear: left; }
#flipForm textarea { width: 468px; height: 100px; }
</style>
<form name="flipForm" id="flipForm">
<textarea rows="5" cols="50" id="original" name="original"></textarea>
<input type="button" value="Flip Text" onClick="flip()">
<textarea rows="5" cols="50" id="flipped" name="flipped"></textarea>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment