Being an eleetist.
Ever wanted to know how the geek speak was done. Great for tweeting and or blogging.
[code]
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
// Create the Phrase translations arrays
var PhrasesEnglish =
new Array('crap', 'dude', 'hacker',
'hacks', 'you', 'cool', 'oh my god',
'fear', 'power', 'own',
'what the hell', 'elite', 'for the win',
'oh really', 'good game');
var PhrasesLeet =
new Array('carp', 'dood', 'haxor', 'hax', 'joo',
'kewl', 'omg', 'ph43', 'powwah', 'pwn',
'wth', 'leet', 'ftw', 'o rly', 'gg');
// Create the Letter translations arrays
var LettersEnglish =
new Array('n', 'b', 'k', 'd', 'e', 'f', 'g', 'h',
'p', 'm', 'r', 'l', 'o', 'q', 's', 't',
'u', 'x', 'w', 'y', 'z', 'c', 'a', 'j',
'i', 'v', ' ');
var LettersLeet =
new Array('/\\/', '|}', '|X', '[)', '3', '|=', 'gee', '|-|',
'|*', '(\\/)', '|2', '1', '()', '0', '$', '+',
'|_|', '><', '\\X/', '\'/', '2', '<', '/\\', '_|',
'|', '\\/', ' ');
// Translates text in input area to/from leet speak
function translateText() {
var inputString = document.getElementById('input').value;
if (document.getElementById('conversionType').value == "e") {
for (i = 0; i < PhrasesEnglish.length; ++i)
inputString = inputString.replace(
new RegExp(PhrasesEnglish[i], "gi"),
PhrasesLeet[i]
);
for (i = 0; i < LettersEnglish.length; ++i)
inputString = inputString.replace(
new RegExp(LettersEnglish[i], "gi"),
LettersLeet[i]
);
}
else {
for (i = 0; i < LettersLeet.length; ++i)
inputString = inputString.replace(
new RegExp(RegExp.escape(LettersLeet[i]), "g"),
LettersEnglish[i]
);
for (i = 0; i < PhrasesLeet.length; ++i)
inputString = inputString.replace(
new RegExp(RegExp.escape(PhrasesLeet[i]), "g"),
PhrasesEnglish[i]
);
}
document.getElementById('input').value = inputString;
}
// This function is used to escape any special regular expression
// characters in the search strings used to convert from leet to
// english. Taken from: http://simonwillison.net/2006/Jan/20/escape/
RegExp.escape = function(text) {
if (!arguments.callee.sRE) {
var specials = [
'/', '.', '*', '+', '?', '|', '$',
'(', ')', '[', ']', '{', '}', '\\'
];
arguments.callee.sRE = new RegExp(
'(\\' + specials.join('|\\') + ')', 'g'
);
}
return text.replace(arguments.callee.sRE, '\\$1');
}
style="font-weight: bold;
background-image: url('leetBG.png');
background-attachment: fixed;
background-position: 160px 165px;
background-repeat: no-repeat;">
onclick="translateText();" />
[/code]
[code]
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
// Create the Phrase translations arrays
var PhrasesEnglish =
new Array('crap', 'dude', 'hacker',
'hacks', 'you', 'cool', 'oh my god',
'fear', 'power', 'own',
'what the hell', 'elite', 'for the win',
'oh really', 'good game');
var PhrasesLeet =
new Array('carp', 'dood', 'haxor', 'hax', 'joo',
'kewl', 'omg', 'ph43', 'powwah', 'pwn',
'wth', 'leet', 'ftw', 'o rly', 'gg');
// Create the Letter translations arrays
var LettersEnglish =
new Array('n', 'b', 'k', 'd', 'e', 'f', 'g', 'h',
'p', 'm', 'r', 'l', 'o', 'q', 's', 't',
'u', 'x', 'w', 'y', 'z', 'c', 'a', 'j',
'i', 'v', ' ');
var LettersLeet =
new Array('/\\/', '|}', '|X', '[)', '3', '|=', 'gee', '|-|',
'|*', '(\\/)', '|2', '1', '()', '0', '$', '+',
'|_|', '><', '\\X/', '\'/', '2', '<', '/\\', '_|',
'|', '\\/', ' ');
// Translates text in input area to/from leet speak
function translateText() {
var inputString = document.getElementById('input').value;
if (document.getElementById('conversionType').value == "e") {
for (i = 0; i < PhrasesEnglish.length; ++i)
inputString = inputString.replace(
new RegExp(PhrasesEnglish[i], "gi"),
PhrasesLeet[i]
);
for (i = 0; i < LettersEnglish.length; ++i)
inputString = inputString.replace(
new RegExp(LettersEnglish[i], "gi"),
LettersLeet[i]
);
}
else {
for (i = 0; i < LettersLeet.length; ++i)
inputString = inputString.replace(
new RegExp(RegExp.escape(LettersLeet[i]), "g"),
LettersEnglish[i]
);
for (i = 0; i < PhrasesLeet.length; ++i)
inputString = inputString.replace(
new RegExp(RegExp.escape(PhrasesLeet[i]), "g"),
PhrasesEnglish[i]
);
}
document.getElementById('input').value = inputString;
}
// This function is used to escape any special regular expression
// characters in the search strings used to convert from leet to
// english. Taken from: http://simonwillison.net/2006/Jan/20/escape/
RegExp.escape = function(text) {
if (!arguments.callee.sRE) {
var specials = [
'/', '.', '*', '+', '?', '|', '$',
'(', ')', '[', ']', '{', '}', '\\'
];
arguments.callee.sRE = new RegExp(
'(\\' + specials.join('|\\') + ')', 'g'
);
}
return text.replace(arguments.callee.sRE, '\\$1');
}
background-image: url('leetBG.png');
background-attachment: fixed;
background-position: 160px 165px;
background-repeat: no-repeat;">
onclick="translateText();" />
Comments
Post a Comment