Skip to content

Instantly share code, notes, and snippets.

@ronsims2
Forked from anonymous/index.html
Last active August 29, 2015 14:25
Show Gist options
  • Save ronsims2/8a4b70503a7557bc69d0 to your computer and use it in GitHub Desktop.
Save ronsims2/8a4b70503a7557bc69d0 to your computer and use it in GitHub Desktop.
Simple Lorem Ipsum Tool for Web Designers (Needs jQuery)
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-1.11.0.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<div class="foo" style="background:red;">123
</div>
<div class="foo" style="background:orange;">456
</div>
<div class="foo" style="background:yellow;">789
</div>
<script id="jsbin-javascript">
(function(){
var lipsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit." +
"Fusce sit amet nunc eu purus bibendum pharetra non non mi. Ut tincidunt vulputate neque." +
"Vestibulum condimentum lacus eget egestas rutrum.";
window.printLipsum = function(lines, paragraphs, className) {
var text = '';
var paragraph = '<p>';
for (var i = 0; i < lines; i++) {
paragraph += lipsum;
}
paragraph += '</p>';
for (var j = 0; j < lines; j++) {
text += paragraph;
}
if(jQuery) {
if (className[0] !== '.') {
className = '.' + className;
}
jQuery(className).html(text);
}
};
})();
$(document).ready(function(){
// params 1 : sentences per paragraph
// param 2 : the number of paragraphs
//param 3 : the name of the class to fill with text (fills all elements with the class name)
printLipsum(4, 3, 'foo');
});
</script>
<script id="jsbin-source-javascript" type="text/javascript">(function(){
var lipsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit." +
"Fusce sit amet nunc eu purus bibendum pharetra non non mi. Ut tincidunt vulputate neque." +
"Vestibulum condimentum lacus eget egestas rutrum.";
window.printLipsum = function(lines, paragraphs, className) {
var text = '';
var paragraph = '<p>';
for (var i = 0; i < lines; i++) {
paragraph += lipsum;
}
paragraph += '</p>';
for (var j = 0; j < lines; j++) {
text += paragraph;
}
if(jQuery) {
if (className[0] !== '.') {
className = '.' + className;
}
jQuery(className).html(text);
}
};
})();
$(document).ready(function(){
// params 1 : sentences per paragraph
// param 2 : the number of paragraphs
//param 3 : the name of the class to fill with text (fills all elements with the class name)
printLipsum(4, 3, 'foo');
});</script></body>
</html>
(function(){
var lipsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit." +
"Fusce sit amet nunc eu purus bibendum pharetra non non mi. Ut tincidunt vulputate neque." +
"Vestibulum condimentum lacus eget egestas rutrum.";
window.printLipsum = function(lines, paragraphs, className) {
var text = '';
var paragraph = '<p>';
for (var i = 0; i < lines; i++) {
paragraph += lipsum;
}
paragraph += '</p>';
for (var j = 0; j < lines; j++) {
text += paragraph;
}
if(jQuery) {
if (className[0] !== '.') {
className = '.' + className;
}
jQuery(className).html(text);
}
};
})();
$(document).ready(function(){
// params 1 : sentences per paragraph
// param 2 : the number of paragraphs
//param 3 : the name of the class to fill with text (fills all elements with the class name)
printLipsum(4, 3, 'foo');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment