Last active
February 20, 2016 16:15
-
-
Save zarino/8774c74d4595354cf9dd to your computer and use it in GitHub Desktop.
A simple JavaScript function that doubles every character on a web page – useful when testing layouts for i18n issues
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Paste this function to your browser’s JavaScript console, | |
// and then run it, passing in a CSS selector, eg: | |
// > pseudolocalize('body') | |
var pseudolocalize = function pseudolocalize(arg){ | |
if(typeof arg === 'string'){ | |
var elements = document.querySelectorAll(arg); | |
for(var i=0, len=elements.length; i<len; i++){ | |
pseudolocalize(elements[i]); | |
} | |
} else if(arg.nodeType === 1){ | |
for(var i=0, len=arg.childNodes.length; i<len; i++){ | |
pseudolocalize(arg.childNodes[i]); | |
} | |
} else if(arg.nodeType === 3){ | |
arg.nodeValue = arg.nodeValue.replace(/(.)/g, '$1$1'); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pseudolocalize=function e(l){if("string"==typeof l)for(var o=document.querySelectorAll(l),d=0,n=o.length;n>d;d++)e(o[d]);else if(1===l.nodeType)for(var d=0,n=l.childNodes.length;n>d;d++)e(l.childNodes[d]);else 3===l.nodeType&&(l.nodeValue=l.nodeValue.replace(/(.)/g,"$1$1"))}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment