Created
March 23, 2012 22:14
-
-
Save rocktronica/2175583 to your computer and use it in GitHub Desktop.
Lorem function w/ input and tinyMCE filler
This file contains 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
function lorem(iWords, bPunct) { | |
var s = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", | |
words = s.toLowerCase().replace(/[^a-zA-Z 0-9]+/g,'').split(/\s/), | |
iWords = iWords || 5, | |
sOutput = ""; | |
for (var i = 0; i < iWords; i++) { | |
sOutput += " " + words[Math.ceil(Math.random() * words.length) - 1]; | |
if (bPunct && i < iWords - 1) { | |
if (!Math.round(Math.random() * 15)) { | |
sOutput += "."; | |
} else if (!Math.round(Math.random() * 5)) { | |
sOutput += ","; | |
} | |
} | |
} | |
sOutput = sOutput.trim(); | |
if (bPunct) { sOutput = sOutput.charAt(0).toUpperCase() + sOutput.slice(1) + "."; } | |
return sOutput; | |
} | |
$("input[type='text']:visible").not(".riTextBox").not(".rdfd_").each(function(){ $(this).val(lorem(Math.round(1 + Math.random() * 5))); }); | |
$.each(tinyMCE.editors, function() { this.setContent(lorem(Math.round(1 + Math.random() * 20), true)); }); | |
$("input[name*='Postal']").val(Math.floor(Math.random() * 89999) + 10000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment