forked from Geertvdc/faker.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
browser_test.html
40 lines (35 loc) · 1.23 KB
/
browser_test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<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>