Skip to content

Commit

Permalink
Update rt-html-abs.js
Browse files Browse the repository at this point in the history
  • Loading branch information
ledangtrung committed Dec 5, 2024
1 parent 9ac16a0 commit ba0ba79
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions js/rt-html-abs.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,25 @@ async function addToContacts() {
}
}

async function downloadContact() {
try {
const contact = getContactData();
const vcard = generateVCard();
const blob = new Blob([vcard], { type: 'text/vcard' });
const url = window.URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = `${contact.name || 'contact'}.vcf`;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
window.URL.revokeObjectURL(url);
} catch (error) {
console.error('Error downloading contact:', error);
alert('Failed to download contact. Please try again.');
}
}

async function copyContact() {
try {
const vcard = generateVCard();
Expand Down

0 comments on commit ba0ba79

Please sign in to comment.