diff options
| author | Josef Salyer <[email protected]> | 2013-07-28 12:15:49 -0400 |
|---|---|---|
| committer | Josef Salyer <[email protected]> | 2013-07-28 12:15:49 -0400 |
| commit | d21bb4156b44b619c8d207714ea42727441e88b4 (patch) | |
| tree | e5fd534adb6355e90795509d07d3483569d287a4 /examples/browser_test.html | |
| parent | 12807aea877d80d39c06fbf89f81cb09d63a40d6 (diff) | |
| parent | 1bd1d73d29222c4e2f52d63a4282345b63a324df (diff) | |
| download | faker-d21bb4156b44b619c8d207714ea42727441e88b4.tar.xz faker-d21bb4156b44b619c8d207714ea42727441e88b4.zip | |
added a bunch of test, changed format of many files to match the newer style
Diffstat (limited to 'examples/browser_test.html')
| -rw-r--r-- | examples/browser_test.html | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/examples/browser_test.html b/examples/browser_test.html new file mode 100644 index 00000000..afe81bec --- /dev/null +++ b/examples/browser_test.html @@ -0,0 +1,41 @@ +<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> + + + + + |
