-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
34 lines (30 loc) · 1.41 KB
/
index.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
<!Doctype html>
<head>
<script type="text/javascript" src="./vcard.js"></script>
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/1.3.8/FileSaver.js"></script>
<script type="application/json" src="./data.json"></script>
<script type="text/javascript">
var mydata =
fetch('./data.json')
.then((response) => { return response.json() })
.then((data) => {
console.log(data.Name);
mydata = data;
var johnDoe = vCard.create(vCard.Version.THREE)
johnDoe.add(vCard.Entry.NAME, mydata.First_Name +";"+mydata.Last_Name+";;")
johnDoe.add(vCard.Entry.FORMATTEDNAME, mydata.Name)
johnDoe.add(vCard.Entry.NICKNAME, mydata.Nick_Name)
johnDoe.add(vCard.Entry.TITLE, mydata.Title)
johnDoe.add(vCard.Entry.PHONE, mydata.Phone, vCard.Type.CELL)
johnDoe.add(vCard.Entry.EMAIL, mydata.Email, vCard.Type.WORK)
johnDoe.add(vCard.Entry.ORGANIZATION, mydata.Organization)
johnDoe.add(vCard.Entry.ADDRESS, ";;" + mydata.Street + ";" + mydata.City + ";" + mydata.State + ";" + mydata.Zip_Code + ";" + mydata.Country, vCard.Type.HOME)
johnDoe.add(vCard.Entry.URL, mydata.website)
var link = vCard.export(johnDoe, mydata.Name, true) // use parameter true to force download
document.body.appendChild(link)
});
</script>
</body>
</!Doctype>