diff options
| author | Bryan Donovan <[email protected]> | 2013-01-05 18:14:28 -0800 |
|---|---|---|
| committer | Bryan Donovan <[email protected]> | 2013-01-05 18:14:28 -0800 |
| commit | 72a36253b1d4f42a0630b6dfcff47e5d98c8ff2a (patch) | |
| tree | 698ca1356b0c7cc5c0b33a890876aae5a36c1a61 /test/browser_test.html | |
| parent | 306c77c9971bdf6dc6c23fef7aeb9964323cd95f (diff) | |
| download | faker-72a36253b1d4f42a0630b6dfcff47e5d98c8ff2a.tar.xz faker-72a36253b1d4f42a0630b6dfcff47e5d98c8ff2a.zip | |
renaming tests dir to test
Diffstat (limited to 'test/browser_test.html')
| -rw-r--r-- | test/browser_test.html | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/browser_test.html b/test/browser_test.html new file mode 100644 index 00000000..91511cdf --- /dev/null +++ b/test/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> + + + + + |
