phone contacts .vcf export file explorer
phone contacts export file explorer; parses a PIM00001.vcf file and prints a table.
by Laurens Maneschijn
March 25, 2017
HTML
paste your phone contacts export file below:<br>
e.g. <code>PIM00001.vcf</code><br>
<textarea id="ta"></textarea><br>
<button onclick="window.read();window.draw();">read and draw</button>
<hr>
<button id="button_newwin">open in new window</button>
</button>
<div id="result"></div>
CSS
body{
background: #111;
color: #888;
line-height:1;
font-size:12px;
}
table{
border-collapse: collapse;
}
table thead tr th,
table tbody tr td{
padding:0 0 0 0;
}
table tbody tr:hover td{
background-color: rgba(128,128,128,0.2);
}
/* allow breaking url: */
table tbody tr td:nth-child(8){
word-break: break-all;
}
JavaScript
var vcards = [];
var vcard_known_keys = [];
var vcard_known_keys_obj = {};
function init(){
vcards = [];
vcard_known_keys = [];
vcard_known_keys_obj = {};
}
////////////////////////////////////////
// VCARD
////////////////////////////////////////
function VCARD(){
this.vcardlines = [];
this.vcardlines_by_key = {};
}
VCARD.prototype.addVCARDLine = function(vcardline){
key = vcardline.getKey();
this.addKnownKey(key);
this.vcardlines.push(vcardline);
if(typeof this.vcardlines_by_key['___'+key] === 'undefined'){
this.vcardlines_by_key['___'+key] = [];
}
this.vcardlines_by_key['___'+key].push(vcardline);
}
VCARD.prototype.getVCARDLinesByKey = function(key){
return this.vcardlines_by_key['___'+key];
}
VCARD.prototype.addKnownKey = function(key){
if(typeof vcard_known_keys_obj['___' + key] === 'undefined'){
vcard_known_keys_obj['___' + key] = 1;
vcard_known_keys.push(key);
}else{
vcard_known_keys_obj['___' + key] ++;
}
}
////////////////////////////////////////
// VCARDLine
////////////////////////////////////////
function VCARDLine(str){
this.str = str;
this.header = null;
this.body = null;
this.key = null;
this.html = null;
}
VCARDLine.prototype.isVcardBegin = function(){
return this.str == 'BEGIN:VCARD';
}
VCARDLine.prototype.isVcardEnd = function(){
return this.str == 'END:VCARD';
}
VCARDLine.prototype.getBody = function(){
if(this.body === null){
var str = (''+this.str);
this.body = str.substr(str.indexOf(':') + 1);
}
return this.body;
}
VCARDLine.prototype.getBodyParts = function(){
return this.getBody().split(';');
}
VCARDLine.prototype.getHeader = function(){
if(this.header === null){
var str = (''+this.str);
this.header = str.substr(0, str.indexOf(':'));
}
return this.header;
}
VCARDLine.prototype.getHeaderParts = function(){
return this.getHeader().split(';');
}
VCARDLine.prototype.getHeaderByKey = function(key){
if(this.headerbykey === undefined || this.headerbykey === null){
this.headerbykey =...