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 9, 2024
1 parent 1198b24 commit 9595c26
Showing 1 changed file with 0 additions and 38 deletions.
38 changes: 0 additions & 38 deletions js/rt-html-abs.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,44 +276,6 @@ function openChat(element) {
App.callActionButton(json);
}

// rt-html-abs.js
(function(global) {
'use strict';

// Create namespace
global.rtlib = global.rtlib || {};

// Add function to namespace
global.rtlib.downloadVCard = function() {
try {
const vCardContent = document.getElementById('vcardTemplate')?.textContent;
if (!vCardContent) {
throw new Error('VCard template not found');
}

const fnMatch = vCardContent.match(/FN;CHARSET=utf-8:(.*)/);
const filename = fnMatch ? fnMatch[1].trim() : 'contact';

const blob = new Blob([vCardContent], {
type: 'text/vcard;charset=utf-8'
});

const downloadUrl = URL.createObjectURL(blob);
const downloadLink = document.createElement('a');
downloadLink.href = downloadUrl;
downloadLink.download = `${filename}.vcf`;

document.body.appendChild(downloadLink);
downloadLink.click();
document.body.removeChild(downloadLink);

URL.revokeObjectURL(downloadUrl);
} catch (error) {
console.error('Error downloading VCard:', error);
}
};
})(typeof window !== 'undefined' ? window : global);

document.addEventListener('DOMContentLoaded', () => {
const buttons = document.querySelectorAll('.btn');
buttons.forEach(button => {
Expand Down

0 comments on commit 9595c26

Please sign in to comment.