Export VCard from JS and open in contacts

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Export VCard from JS and open in contacts



I have been trying to figure this out for a little while now. I modified a javascript code to create a VCard. The script currently generates a QR code when the submit button is pressed. If I scan the code with my phone it opens up my contacts with everything filled out. What I want to do is bypass the QR code process and have the script open it automatically when the submit button is pressed. Is there an easy way to take this code and simply export it and open it instead of saving and generating a QR code?



Here's the button code.


<input type="button" name="submit" value="Generate">



And here is the javascript


<script type="text/javascript">
var vcard=
str_start:'BEGIN:VCARDnVERSION:3.0n',
str_vcard:'BEGIN:VCARDnVERSION:3.0n',
str_end:'nEND:VCARD',
goog_chart:'http://chart.googleapis.com/chart?cht=qr&chs=200x200&chl=',
form:,
get_field: function(field)
for(var i in vcard.form)
if(vcard.form[i].name === field)s+$/g,"");


,
add_you: function()
var first_name = "MARC",
last_name = "MATTEO",
birthday = vcard.get_field('birthday'),
gender = vcard.get_field('gender');

vcard.str_vcard += 'N:'+last_name+';'+first_name+'n'+
'FN:'+first_name+' '+last_name;
if(birthday !== '') vcard.str_vcard += 'nBDAY:'+birthday;

if(gender !== '') vcard.str_vcard += 'nX-GENDER:'+gender;
,
add_address: function()
var
org_street = "org_street",
org_city = "org_city",
org_region = "org_region",
org_post = "org_post",
org_country = "org_country";


if(org_street+org_city+org_region+org_post+org_country !== '')
vcard.str_vcard += 'nADR;TYPE=work:;;'+org_street+';'+org_city+';'+org_region+
';'+org_post+';'+org_country;

,
add_tel: function()
var
work = "8005551212";
if(work !== '') vcard.str_vcard += 'nTEL;TYPE=work:'+work;
,
add_email: function()
var work = "testemail@email.com";
if(work !== '') vcard.str_vcard += 'nEMAIL;TYPE=internet,work:'+work;
,
add_url: function()
var
work = "http://www.mywebsite.com";
if(work !== '') vcard.str_vcard += 'nURL;TYPE=work:'+work;
,
add_work: function()
var name = "My Business Name",
title = "CEO";
if(name !== '') vcard.str_vcard += 'nORG:'+name;
if(title !== '') vcard.str_vcard +='nTITLE:'+title;
,

add_note: function()
var name = "My custom note can be anything";
if(name !== '') vcard.str_vcard += 'nNOTE:'+name;
,


add_social: function()
var facebook = "https://www.facebook.com/myaccount",
twitter = "https://www.twitter.com/testaccount",
instagram = "https://www.instagram.com/marcanthonyphoto",
linkedin = "https://www.linkedin.com/marcanthonyphoto";

if(facebook !== 'https://www.facebook.com/') vcard.str_vcard += 'nX-SOCIALPROFILE;type=facebook:'+facebook;

if(twitter !== 'https://www.twitter.com/') vcard.str_vcard +='nX-SOCIALPROFILE;type=twitter:'+twitter;

if(instagram !== 'https://www.instagram.com/') vcard.str_vcard +='nX-SOCIALPROFILE;type=Instagram:'+ instagram;

if(linkedin !== 'https://www.linkedin.com/')vcard.str_vcard +='nX-SOCIALPROFILE;type=linkedin:'+ 'https://www.linkedin.com/marcanthonyphoto';

,

save: function()
vcard.form = $('form').serializeArray();

vcard.add_you();

vcard.add_address();

vcard.add_tel();

vcard.add_email();

vcard.add_url();

vcard.add_work();

vcard.add_note();

vcard.add_social();

vcard.str_vcard += vcard.str_end;

$('textarea[name="vcard"]').val(vcard.str_vcard);

$('#qr').attr('src',vcard.goog_chart+vcard.str_vcard.replace(/n/g,'%0A'));

vcard.str_vcard = vcard.str_start;

;

//input click function
$(function()
$('input[name="submit"]').click(vcard.save);
);


</script>









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard