Return to Snippet

Revision: 12906
at April 1, 2009 03:27 by spraitas


Initial Code
function watchFlip() {
	var elements = document.body.getElementsByTagName("*");
	for (var x = 0; x < elements.length; ++x) {
		if ((elements[x].innerText || elements[x].textContent) && elements[x].innerHTML.indexOf('<') == -1 &&
				(elements[x].nodeName == "DIV" || elements[x].nodeName == "SPAN" || elements[x].nodeName == "A" || elements[x].nodeName == "H1" || elements[x].nodeName == "H2"
					|| elements[x].nodeName == "LABEL" || elements[x].nodeName == "B" || elements[x].nodeName == "OPTION" || elements[x].nodeName == "TH")) {
			var result2 = flipStr((elements[x].innerText || elements[x].textContent).toLowerCase());
			if (elements[x].innerText) {
				elements[x].innerText = result2;
			} else {
				elements[x].textContent = result2;
			}
		}
	}

	onLoadFunctionList.push(function() {
		if (document.comment_formmain_comment) {
			document.comment_formmain_comment.preview_comment_button.value = flipStr(document.comment_formmain_comment.preview_comment_button.value.toLowerCase());
			document.comment_formmain_comment.add_comment_button.value = flipStr(document.comment_formmain_comment.add_comment_button.value.toLowerCase());
		}
	});
}

function flipStr(str) {
	var result = "";
	for (var x = str.length - 1; x >= 0; --x){
		var c = str.charAt(x);
		var r = watchFlipCharset[c];
		result += r != undefined ? r : c;
	}

	return result;
}


var watchFlipCharset = {
a : '\u0250',
b : 'q',
c : '\u0254',
d : 'p',
e : '\u01DD',
f : '\u025F',
g : '\u0183',
h : '\u0265',
i : '\u0131',
j : '\u027E',
k : '\u029E',
l : 'l',
m : '\u026F',
n : 'u',
o : 'o',
p : 'd',
q : 'b',
r : '\u0279',
s : 's',
t : '\u0287',
u : 'n',
v : '\u028C',
w : '\u028D',
y : '\u028E',
z : 'z',
1 : '\u21C2',
2 : '\u1105',
3 : '\u1110',
4 : '\u3123',
5 : '\u078E',  /* or u03DB */
6 : '9',
7 : '\u3125',
8 : '8',
9 : '6',
0 : '0',
'.' : '\u02D9',
',' : "\'",
"\'" : ',',
"\"" : ',,',
"´" : ',',
"`" : ',',
';' : '\u061B',
'!' : '\u00A1',
'\u00A1' : '!',
'?' : '\u00BF',
'\u00BF' : '?',
'[' : ']',
']' : '[',
'(' : ')',
')' : '(',
'{' : '}',
'}' : '{',
'<' : '>',
'>' : '<',
'_' : '\u203E',
'\r' : '\n'
};

Initial URL

                                

Initial Description
April 1, 2009, youtube.com

Initial Title
Flip text in page

Initial Tags
text

Initial Language
JavaScript