diff options
| author | Marak <[email protected]> | 2014-09-22 11:27:08 +0200 |
|---|---|---|
| committer | Marak <[email protected]> | 2014-09-22 11:27:08 +0200 |
| commit | 2aa00986923a4eee359b7a21520956f436fa8917 (patch) | |
| tree | 733f4eebe3021b8c35f3928cc0e4a9192e417f7c /examples/index.html | |
| parent | dfd9774fbe229a3f30b8fdc348a84671da210b6e (diff) | |
| download | faker-2aa00986923a4eee359b7a21520956f436fa8917.tar.xz faker-2aa00986923a4eee359b7a21520956f436fa8917.zip | |
[dist] Updated browser example. Moved browser example into new directory.
Diffstat (limited to 'examples/index.html')
| -rw-r--r-- | examples/index.html | 91 |
1 files changed, 0 insertions, 91 deletions
diff --git a/examples/index.html b/examples/index.html deleted file mode 100644 index 08a21691..00000000 --- a/examples/index.html +++ /dev/null @@ -1,91 +0,0 @@ -<html> - <head> - <title>faker.js - generate massive amounts of fake data in Node.js and the browser</title> - <script src = "js/jquery.js" type = "text/javascript"></script> - <script src = "js/prettyPrint.js" type = "text/javascript"></script> - <script src = "js/faker.js" type = "text/javascript"></script> - - <script> - - if(typeof JSON == 'undefined'){ - document.write('get a real browser that has JSON.stringify and JSON.parse built in <br/>'); - - // implement JSON.stringify serialization - var JSON = {}; - JSON.stringify = function (obj) { - var t = typeof (obj); - if (t != "object" || obj === null) { - // simple data type - if (t == "string") obj = '"'+obj+'"'; - return String(obj); - } - else { - // recurse array or object - var n, v, json = [], arr = (obj && obj.constructor == Array); - for (n in obj) { - v = obj[n]; t = typeof(v); - if (t == "string") v = '"'+v+'"'; - else if (t == "object" && v !== null) v = JSON.stringify(v); - json.push((arr ? "" : '"' + n + '":') + String(v)); - } - return (arr ? "[" : "{") + String(json) + (arr ? "]" : "}"); - } - }; - } - - $(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)); - - $('#generate').click(function(){ - var card = faker.helpers.createCard(); - $('#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(){ - var cards = []; - for(var i = 0; i < $('#cardCount').val(); i++){ - var card = faker.helpers.createCard(); - cards.push(card); - } - $('#output').html('<textarea cols = "100" rows = "100">'+JSON.stringify(cards)+'</textarea>'); - }, 10); - - }); - - }); - - </script> - </head> - <body> - <h1>faker.js - generate massive amounts of fake data in Node.js and the browser</h1> - <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> - </body> -</html> |
