Last active
May 2, 2018 13:26
-
-
Save Tinram/0209d3c38e1bdfa36cd6aaeedb25ee20 to your computer and use it in GitHub Desktop.
Text garbage generator. Creates junk text for HTML prototypes etc.
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 Garbage = { | |
/** | |
* Garbage text filler generator. | |
* @author Tinram | |
*/ | |
/** | |
* Generate the junk text. | |
* | |
* @param object oID, element ID to populate | |
* @param integer iNum, number of text repetitions | |
* @param string sText, custom text instead of 'lorem ipsum ' default | |
*/ | |
generate: function(oID, iNum, sText) { | |
"use strict"; | |
var | |
aHolder = [], | |
n = iNum || 40, | |
sGarbage = sText || "lorem ipsum "; | |
if (oID === undefined) { | |
alert("Garbage {} : a DOM ID is required!"); | |
} | |
if ( ! document.getElementById(oID)) { | |
alert("Garbage {} : DOM ID '" + oID + "' does not exist!"); | |
return; | |
} | |
while (n--) { | |
aHolder[aHolder.length] = sGarbage; | |
} | |
document.getElementById(oID).innerHTML = aHolder.join(""); | |
} | |
}; | |
/* | |
examples: | |
Garbage.generate("id_1", 20); | |
Garbage.generate("id_2", 40, "junk text "); | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment