aboutsummaryrefslogtreecommitdiff
path: root/examples/browser_test.html
diff options
context:
space:
mode:
authorMatthew Bergman <[email protected]>2013-01-08 09:35:00 -0800
committerMatthew Bergman <[email protected]>2013-01-08 09:35:00 -0800
commitfd79022a8cb6d0d3adc50e8af96a5e2ae93d8e53 (patch)
tree28c0bd9453cf4e6d273b97bfe2ce53cab11d3330 /examples/browser_test.html
parent1e4fcf794181b8d8c9286ee1890a903199f81847 (diff)
parent19d0e99ebec18bab6047bf944c07fc472fd9773a (diff)
downloadfaker-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.html40
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>
+
+
+
+
+