Skip to content

Commit

Permalink
ability to add a personal dictionary for the lipsum generator
Browse files Browse the repository at this point in the history
  • Loading branch information
mistergraphx committed Oct 28, 2018
1 parent 401c49e commit 7814d19
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
8 changes: 8 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ Fixie inserts the right type of content based on the tag name. Here are some maj

## Tips

### Change the default dictionary

```
var words= ["Je", "france", "sport", "aurait mieux fait", "super", "voir", "plus", "Mister-graphX"];
fixie.setWordLibrary(words).init();
```

### Change the default image placeholder service

<http://tinyfinch.com/top-12-image-placeholder-services/>
Expand Down
19 changes: 10 additions & 9 deletions fixie.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
var fixie = (function () {

var selector;
var fixie_wordlibrary = ["8-bit", "ethical", "reprehenderit", "delectus", "non", "latte", "fixie", "mollit", "authentic", "1982", "moon", "helvetica", "dreamcatcher", "esse", "vinyl", "nulla", "Carles", "bushwick", "bronson", "clothesline", "fin", "frado", "jug", "kale", "organic", "local", "fresh", "tassel", "liberal", "art", "the", "of", "bennie", "chowder", "daisy", "gluten", "hog", "capitalism", "is", "vegan", "ut", "farm-to-table", "etsy", "incididunt", "sunt", "twee", "yr", "before", "gentrify", "whatever", "wes", "Anderson", "chillwave", "dubstep", "sriracha", "voluptate", "pour-over", "esse", "trust-fund", "Pinterest", "Instagram", "DSLR", "vintage", "dumpster", "totally", "selvage", "gluten-free", "brooklyn", "placeat", "delectus", "sint", "magna", "brony", "pony", "party", "beer", "shot", "narwhal", "salvia", "letterpress", "art", "party", "street-art", "seitan", "anime", "wayfarers", "non-ethical", "viral", "iphone", "anim", "polaroid", "gastropub", "city", "classy", "original", "brew"];
var imagePlaceHolder = "https://placehold.it/${w}x${h}&text=${text}";



if (typeof document.getElementsByClassName !== "function") {
document.getElementsByClassName = function (cl) {
var retnode = [];
Expand Down Expand Up @@ -78,7 +81,7 @@ var fixie = (function () {
case "s":
case "u":
case "small":
case "span":
// case "span":
case "code":
case "pre":
case "li":
Expand Down Expand Up @@ -162,9 +165,7 @@ var fixie = (function () {
}


// Begin generator
var fixie_wordlibrary = ["I", "8-bit", "ethical", "reprehenderit", "delectus", "non", "latte", "fixie", "mollit", "authentic", "1982", "moon", "helvetica", "dreamcatcher", "esse", "vinyl", "nulla", "Carles", "bushwick", "bronson", "clothesline", "fin", "frado", "jug", "kale", "organic", "local", "fresh", "tassel", "liberal", "art", "the", "of", "bennie", "chowder", "daisy", "gluten", "hog", "capitalism", "is", "vegan", "ut", "farm-to-table", "etsy", "incididunt", "sunt", "twee", "yr", "before", "gentrify", "whatever", "wes", "Anderson", "chillwave", "dubstep", "sriracha", "voluptate", "pour-over", "esse", "trust-fund", "Pinterest", "Instagram", "DSLR", "vintage", "dumpster", "totally", "selvage", "gluten-free", "brooklyn", "placeat", "delectus", "sint", "magna", "brony", "pony", "party", "beer", "shot", "narwhal", "salvia", "letterpress", "art", "party", "street-art", "seitan", "anime", "wayfarers", "non-ethical", "viral", "iphone", "anim", "polaroid", "gastropub", "city", "classy", "original", "brew"]

// Generator functions
function fixie_capitalize(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
Expand Down Expand Up @@ -218,17 +219,13 @@ var fixie = (function () {
for (var i = 0, l = constrain(3,5); i < l; i++) {
html += fetch_suroundWithTag(1, 1, fixie_fetchPhrase, "dt") + fetch_suroundWithTag(1, 1, fixie_fetchPhrase, "dd");
}
console.log(html)
return html;
}


// Handle all elements with class "fixie"
fixie_handle_elements(document.getElementsByClassName("fixie"));
// fixie_handle_elements(document.getElementsByClassName("fixie"));

// Handle elements which match give css selectors


function init_str(selector_str) {
if (!document.querySelectorAll) {
return false;
Expand Down Expand Up @@ -262,6 +259,10 @@ var fixie = (function () {
selector = sl;
}
return this;
},
"setWordLibrary": function(dic){
fixie_wordlibrary = dic;
return this;
}
};

Expand Down
7 changes: 5 additions & 2 deletions sample.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ <h2 class="fixie"></h2>

<script type="text/javascript" src="fixie.js"></script>
<script>
// Changes default image source to Flickr
fixie.setImagePlaceholder('http://flickholdr.com/${w}/${h}/fixie').init();
// Change default dictionary
var words= ["Je", "france", "sport", "aurait mieux fait", "super", "voir", "plus", "Mister-graphX"];
fixie.setWordLibrary(words).init();
// Changes default image source to Picsum
// fixie.setImagePlaceholder('https://picsum.photos/${w}/${h}/${text}').init();
</script>
</body>
</html>

0 comments on commit 7814d19

Please sign in to comment.