Commit 6a4970be authored by PhoeniX's avatar PhoeniX

User contacts

parent b4f9d430
No preview for this file type
......@@ -28,11 +28,11 @@ Blocks.page = (function(){
fullname.style.height = '16px';
fullname.style.lineHeight = '16px';
fullname.innerHTML = name.join(' ');
var fullinfo = userinfo.appendChild(document.createElement('div'));
fullinfo.style.cssFloat = 'right';
fullinfo.style.height = '70px';
fullinfo.style.width = '32px';
fullinfo.style.background = 'url("img/info.png") center center no-repeat';
var infoswitch = userinfo.appendChild(document.createElement('div'));
infoswitch.style.cssFloat = 'right';
infoswitch.style.height = '70px';
infoswitch.style.width = '32px';
infoswitch.style.background = 'url("img/info.png") center center no-repeat';
var online = userinfo.appendChild(document.createElement('div'));
online.style.cssFloat = 'left';
online.style.width = '-moz-calc(100% - 112px)';
......@@ -67,20 +67,139 @@ Blocks.page = (function(){
if (user.city) {
var cs = ac.appendChild(document.createElement('span'));
VK.api.call('database.getCitiesById',{"city_ids": user.city}, function(r){
cs.innerHTML = (user.bdate ? ', ' : '') + r.response[0].name;
cs.innerHTML = (agecity.childNodes.length ? ', ' : '') + r.response[0].name;
});
}
agecity.appendChild(ac);
var fullinfo = userinfo.appendChild(document.createElement('div'));
//fullinfo.style.height = 0;
fullinfo.style.width = '100%';
fullinfo.style.cssFloat = 'left';
fullinfo.style.overflow = 'hidden';
if (user.status) {
var status = fullinfo.appendChild(document.createElement('div'));
status.style.borderTop = status.style.borderBottom = '1px solid #ccc';
status.style.backgroundColor = '#fff';
status.style.color = '#000';
status.style.padding = '10px 16px';
status.innerHTML = user.status;
}
var contacts = fullinfo.appendChild(document.createElement('div'));
contacts.style.margin = '10px 0';
contacts.style.borderTop = contacts.style.borderBottom = '1px solid #ccc';
contacts.style.backgroundColor = '#fff';
contacts.style.color = '#000';
var sep = document.createElement('hr');
sep.style.height = '1px';
sep.style.margin = '0 0 0 48px';
sep.style.backgroundColor = '#ddd';
sep.style.borderColor = 'transparent';
var item = document.createElement('div'), ts=function(){this.style.backgroundColor = '#d5e1ee';}, te=function(){this.style.backgroundColor = 'transparent';};
item.style.padding = '8px 10px 8px 48px';
item.style.minHeight = '20px';
item.style.background = '8px center no-repeat';
if (user.bdate) {
var bdate = contacts.appendChild(item.cloneNode(true)), ds = user.bdate.split('.');
bdate.innerHTML = ds[0] + ' ' + ['января','февраля','марта','апреля','мая','июня','июля','августа','сентября','октября','ноября','декабря'][ds[1]-1] + (ds[2] ? ' ' + ds[2] + ' года' : '');
bdate.style.backgroundImage = 'url("/img/contacts/birth.png")';
contacts.appendChild(sep.cloneNode());
}
if (user.city) {
var city = contacts.appendChild(item.cloneNode(true));
VK.api.getCityInfo(user.city, user.country, function(r){
city.innerHTML = r;
});
city.style.backgroundImage = 'url("/img/contacts/home.png")';
contacts.appendChild(sep.cloneNode());
}
if (user.mobile_phone) {
var mobile = contacts.appendChild(item.cloneNode(true));
mobile.innerHTML = user.mobile_phone;
mobile.style.backgroundImage = 'url("/img/contacts/mobile_phone.png")';
mobile.addEventListener('touchstart',ts);
mobile.addEventListener('touchend',te);
contacts.appendChild(sep.cloneNode());
}
if (user.home_phone) {
var home = contacts.appendChild(item.cloneNode(true));
home.innerHTML = user.home_phone;
home.style.backgroundImage = 'url("/img/contacts/home_phone.png")';
home.addEventListener('touchstart',ts);
home.addEventListener('touchend',te);
contacts.appendChild(sep.cloneNode());
}
if (user.skype) {
var skype = contacts.appendChild(item.cloneNode(true));
skype.innerHTML = user.skype;
skype.style.backgroundImage = 'url("/img/contacts/skype.png")';
skype.addEventListener('touchstart',ts);
skype.addEventListener('touchend',te);
contacts.appendChild(sep.cloneNode());
}
if (user.facebook) {
var facebook = contacts.appendChild(item.cloneNode(true));
facebook.innerHTML = user.facebook_name;
facebook.style.backgroundImage = 'url("/img/contacts/facebook.png")';
facebook.addEventListener('touchstart',ts);
facebook.addEventListener('touchend',te);
contacts.appendChild(sep.cloneNode());
}
if (user.twitter) {
var twitter = contacts.appendChild(item.cloneNode(true));
twitter.innerHTML = '@'+user.twitter;
twitter.style.backgroundImage = 'url("/img/contacts/twitter.png")';
twitter.addEventListener('touchstart',ts);
twitter.addEventListener('touchend',te);
contacts.appendChild(sep.cloneNode());
}
if (user.site) {
var site = contacts.appendChild(item.cloneNode(true));
site.innerHTML = user.site;
site.style.backgroundImage = 'url("/img/contacts/site.png")';
site.addEventListener('touchstart',ts);
site.addEventListener('touchend',te);
contacts.appendChild(sep.cloneNode());
}
var vk = contacts.appendChild(item.cloneNode(true));
vk.innerHTML = 'https://vk.com/'+user.screen_name;
vk.style.backgroundImage = 'url("/img/contacts/vk.png")';
vk.addEventListener('touchstart',ts);
vk.addEventListener('touchend',te);
for (var i in {
"uid": 1,
"first_name": 1,
"last_name": 1,
"nickname": 1,
"screen_name": 1,
"bdate": 1,
"city": 1,
"country": 1,
"photo_50": 1,
"online": 1,
"online_mobile": 1,
"mobile_phone": 1,
"home_phone": 1,
"skype": 1,
"facebook": 1,
"facebook_name": 1,
"twitter": 1,
"site": 1,
"status": 1,
"last_seen": 1,
}) delete(user[i]);
var dbg = block.appendChild(document.createElement('pre'));
dbg.style.overflow = 'hidden';
dbg.style.clear = 'both';
dbg.innerHTML = JSON.stringify(user,null,'\t');
};
return function(params){
var vk_params = {
"fields": "screen_name,nickname,sex,bdate,online,online_mobile,status,last_seen,"+
"fields": "screen_name,nickname,bdate,online,online_mobile,status,last_seen,"+
"city,country,photo_50,"+
"has_mobile,contacts,connections,site,"+
"contacts,connections,site,"+
"universities,schools,"+
"relation,relatives,counters,occupation,"+
"can_post,can_see_all_posts,can_see_audio,can_write_private_message,wall_comments,"+
......
......@@ -38,6 +38,16 @@ VK = {
};
xhr.send();
},
"getCityInfo": function(cid, coid, callback){
if (!VK.api.getCityInfo.cache) VK.api.getCityInfo.cache = [];
var cache = VK.api.getCityInfo.cache;
if (cache[coid+'_'+cid]) return callback(cache[coid+'_'+cid]);
VK.api.call('execute',{"code":
'var city=API.database.getCitiesById({city_ids:'+cid+'}),country=API.database.getCountriesById({country_ids:'+coid+'});return city[0].name+", "+country[0].name;'
},function(r){
callback(VK.api.getCityInfo.cache[coid+'_'+cid] = r.response);
});
},
"upload": function(dest, blob, callback, prog_callback){
var xhr = new XMLHttpRequest({mozAnon: true, mozSystem: true});
xhr.open('POST',dest,true);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment