diff options
| author | Matthew Bergman <[email protected]> | 2013-01-08 09:35:00 -0800 |
|---|---|---|
| committer | Matthew Bergman <[email protected]> | 2013-01-08 09:35:00 -0800 |
| commit | fd79022a8cb6d0d3adc50e8af96a5e2ae93d8e53 (patch) | |
| tree | 28c0bd9453cf4e6d273b97bfe2ce53cab11d3330 /examples/browser_test.html | |
| parent | 1e4fcf794181b8d8c9286ee1890a903199f81847 (diff) | |
| parent | 19d0e99ebec18bab6047bf944c07fc472fd9773a (diff) | |
| download | faker-fd79022a8cb6d0d3adc50e8af96a5e2ae93d8e53.tar.xz faker-fd79022a8cb6d0d3adc50e8af96a5e2ae93d8e53.zip | |
Merge pull request #37 from BryanDonovan/main
Refactored with 100% test coverage
Diffstat (limited to 'examples/browser_test.html')
| -rw-r--r-- | examples/browser_test.html | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/examples/browser_test.html b/examples/browser_test.html new file mode 100644 index 00000000..91511cdf --- /dev/null +++ b/examples/browser_test.html @@ -0,0 +1,40 @@ +<html> + <head> + <script src = "../Faker.js" type = "text/javascript"></script> + <script> + var card = Faker.Helpers.createCard(); + 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.write(JSON.stringify(card)); + </script> + </head> + <body> + </body> +</html> + + + + + |
