Skip to content

Commit

Permalink
added role, title, and multi dates
Browse files Browse the repository at this point in the history
  • Loading branch information
Zakher Masri authored and Zakher Masri committed Mar 12, 2022
1 parent 51814f0 commit 283ff73
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
29 changes: 10 additions & 19 deletions index.js
Expand Up @@ -13,6 +13,10 @@
// TEL;TYPE=WORK,VOICE:966WORKPHONE0623655
// TEL;TYPE=HOME,FAX:966FAX34289
// TEL;TYPE=WORK,FAX:966WORKFAX234322
// BDAY:20191111
// ANNIVERSARY:20221010
// LOGO;ENCODING=b;TYPE=PNG:IMAGEDATA..
// PHOTO;ENCODING=b;TYPE=PNG:IMAGEDATA..
// LABEL;CHARSET=UTF-8;TYPE=HOME:MyHomeLabel
// ADR;CHARSET=UTF-8;TYPE=HOME:;;3798;Dammam;Eastern;32333;Saudi Arabia
// LABEL;CHARSET=UTF-8;TYPE=WORK:MyWorkLabel
Expand Down Expand Up @@ -69,39 +73,23 @@ exports.createVCard = function (contactObject) {
.map((address) => `ADR;CHARSET=UTF-8;type=${address.label}:${address.address_text}\r\n`)
.join("");
}

if (vc.dates) {
allDates = vc.dates
.map((date, i) => {
return `
item${i + 1}.X-ABDATE:${date.date_text}
item${i + 1}.X-ABLabel:${date.date_label}`;
})
.map((date, i) => `item${i + 1}.X-ABDATE:${date.label}${nl}item${i + 1}.X-ABLabel:${date.text}${nl}`)
.join("");
}

if (vc.socials) {
allSocials = vc.socials
.map((social, i) => {
return `X-SOCIALPROFILE;TYPE=${social.label}:${social.link}\r\n`;
})
.map((social, i) => `X-SOCIALPROFILE;TYPE=${social.label}:${social.link}\r\n`)
.join("");
}

// let lastUpdated = dayjs(parseInt(onecardObject?.updatedAt))
// .format("YYYYMMDD_HHMMss")
// .split("_");
// let lastUpdatedISO = lastUpdated[0] + "T" + lastUpdated[1] + "Z";
// let vs1 = `
// BEGIN:VCARD
// VERSION:3.0
// N:${vc.last_name};${vc.first_name};${vc.middle_name};${vc.prefix};${vc.suffix}
// NICKNAME:${vc.nickname}
// ${allAddresses}BDAY:${vc.birthday.split("-").join("")}
// FN:${vc.first_name}
// LN:${vc.last_name}
// TITLE:${vc.job_title}${allDates}
// NOTE:${vc.notes}

// ${allSocials}${allNumbers}${allEmails}ORG:${vc.company};${vc.department}
// SOURCE:https://link.onecard.zone/${onecardObject?.onecard_shortid}
// REV:${lastUpdatedISO}
Expand All @@ -126,10 +114,13 @@ exports.createVCard = function (contactObject) {
isEmpty("NICKNAME;CHARSET=UTF-8:", vc.nickname, nl) +
isEmpty("NOTE;CHARSET=UTF-8:", vc.notes, nl) +
isEmpty("ORG;CHARSET=UTF-8:", vc.organization, nl) +
isEmpty("TITLE;CHARSET=UTF-8:", vc.title, nl) +
isEmpty("ROLE;CHARSET=UTF-8:", vc.role, nl) +
(allEmails ? allEmails : "") +
(allNumbers ? allNumbers : '') +
(allSocials ? allSocials : '') +
(allAddresses ? allAddresses : '') +
(allDates ? allDates : '') +
vcEnd;

return vCardString;
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"homepage": "https://sikka-software.github.io/vcardi",
"name": "@sikka/vcardi",
"version": "1.1.5",
"version": "1.1.6",
"description": "vCard Generator",
"main": "index.js",
"scripts": {
Expand Down
11 changes: 11 additions & 0 deletions test.js
Expand Up @@ -12,6 +12,17 @@ let mycard = stuff.createVCard({
role: "Chief Executive Officer",
title: "CEO",
notes: "here are the notes",
dates: [{
label: 'Birthday',
text: '19930118'
},{
label: 'Birthday',
text: '19930118'
},
{
label: 'Anniversary',
text: '20220101'
}],
numbers: [
{
label: "Work",
Expand Down

0 comments on commit 283ff73

Please sign in to comment.