Skip to content

Commit

Permalink
[examples] Added drop down for locale selection
Browse files Browse the repository at this point in the history
  • Loading branch information
Marak committed Sep 15, 2014
1 parent fbf2615 commit 2e08141
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@

$(document).ready(function(e){

for (var locale in faker.locales) {
$('#locale').append('<option value="' + locale + '">' + locale + '</option>');
}

var card = faker.helpers.createCard();
$('#output').html(prettyPrint(card));

Expand All @@ -43,6 +47,14 @@
$('#output').html(prettyPrint(card));
});


$('#locale').change(function(e){
var locale = $(this).attr('value');
faker.locale = locale;
var card = faker.helpers.createCard();
$('#output').html(prettyPrint(card));
});

$('#generateSet').click(function(){

setTimeout(function(){
Expand All @@ -65,6 +77,13 @@ <h1>faker.js - generate massive amounts of fake data in Node.js and the browser<
<a href="http://github.com/marak/faker.js/"><img style="position:absolute; z-index:10; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png" alt="Fork me on GitHub" /></a>
<input id = "generate" type = "button" value = "generate one random card as HTML" />
<input id = "generateSet" type = "button" value = "generate an assosative array of random cards as JSON" />
<br/>
<br/>
locale <select id = "locale">
<option value="en">en</option>
<option value="es">es</option>
<option value="de">de</option>
</select>
card count : <input id = "cardCount" type = "text" size = "3" value = "5" /><br/><br/>
<strong>protip</strong>: open your console on this page and run: <code>console.log(faker); var randomName = faker.name.findName(); console.log(randomName);</code><hr/>
<div id = "output"></div>
Expand Down

0 comments on commit 2e08141

Please sign in to comment.