Commit f625dfce authored by PhoeniX's avatar PhoeniX

Occupation/relatives show

parent 80af0383
......@@ -112,13 +112,13 @@ Blocks.page = (function(){
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('.');
var bdate = contacts.appendChild(item.cloneNode()), 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));
var city = contacts.appendChild(item.cloneNode());
VK.api.getCityInfo(user.city, user.country, function(r){
city.innerHTML = r;
});
......@@ -126,7 +126,7 @@ Blocks.page = (function(){
contacts.appendChild(sep.cloneNode());
}
if (user.mobile_phone) {
var mobile = contacts.appendChild(item.cloneNode(true));
var mobile = contacts.appendChild(item.cloneNode());
mobile.innerHTML = user.mobile_phone;
mobile.style.backgroundImage = 'url("/img/contacts/mobile_phone.png")';
mobile.addEventListener('touchstart',ts);
......@@ -134,7 +134,7 @@ Blocks.page = (function(){
contacts.appendChild(sep.cloneNode());
}
if (user.home_phone) {
var home = contacts.appendChild(item.cloneNode(true));
var home = contacts.appendChild(item.cloneNode());
home.innerHTML = user.home_phone;
home.style.backgroundImage = 'url("/img/contacts/home_phone.png")';
home.addEventListener('touchstart',ts);
......@@ -142,7 +142,7 @@ Blocks.page = (function(){
contacts.appendChild(sep.cloneNode());
}
if (user.skype) {
var skype = contacts.appendChild(item.cloneNode(true));
var skype = contacts.appendChild(item.cloneNode());
skype.innerHTML = user.skype;
skype.style.backgroundImage = 'url("/img/contacts/skype.png")';
skype.addEventListener('touchstart',ts);
......@@ -150,7 +150,7 @@ Blocks.page = (function(){
contacts.appendChild(sep.cloneNode());
}
if (user.facebook) {
var facebook = contacts.appendChild(item.cloneNode(true));
var facebook = contacts.appendChild(item.cloneNode());
facebook.innerHTML = user.facebook_name;
facebook.style.backgroundImage = 'url("/img/contacts/facebook.png")';
facebook.addEventListener('touchstart',ts);
......@@ -158,7 +158,7 @@ Blocks.page = (function(){
contacts.appendChild(sep.cloneNode());
}
if (user.twitter) {
var twitter = contacts.appendChild(item.cloneNode(true));
var twitter = contacts.appendChild(item.cloneNode());
twitter.innerHTML = '@'+user.twitter;
twitter.style.backgroundImage = 'url("/img/contacts/twitter.png")';
twitter.addEventListener('touchstart',ts);
......@@ -166,19 +166,82 @@ Blocks.page = (function(){
contacts.appendChild(sep.cloneNode());
}
if (user.site) {
var site = contacts.appendChild(item.cloneNode(true));
var site = contacts.appendChild(item.cloneNode());
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));
var vk = contacts.appendChild(item.cloneNode());
vk.innerHTML = 'https://vk.com/'+user.screen_name;
vk.style.backgroundImage = 'url("/img/contacts/vk.png")';
vk.addEventListener('touchstart',ts);
vk.addEventListener('touchend',te);
var links = fullinfo.appendChild(document.createElement('div')), ttitle = document.createElement('div'), timg = document.createElement('img'), ls;
links.style.margin = '10px 0';
links.style.borderTop = links.style.borderBottom = '1px solid #ccc';
links.style.backgroundColor = '#fff';
links.style.color = '#000';
item.style.padding = '0 26px 10px 5px';
item.style.minHeight = '50px';
item.style.background = 'url("img/subpage.png") -moz-calc(100%-16px) center no-repeat';
timg.style.width = timg.style.height = '50px';
timg.style.borderRadius = '4px';
timg.style.margin = '5px 5px 0 0';
timg.style.cssFloat = 'left';
ttitle.style.height = '10px';
ttitle.style.fontSize = '10px';
ttitle.style.margin = '4px 0';
ttitle.style.color = '#666';
sep.style.marginLeft = '60px';
if (user.occupation) {
var occupation = links.appendChild(item.cloneNode()), img = timg.cloneNode(), title = ttitle.cloneNode();
occupation.appendChild(img);
title.innerHTML =
user.occupation.type == 'work' ? 'Место работы' :
user.occupation.type == 'university' ? 'Место учёбы' :
user.occupation.type == 'school' ? 'Школа' : '';
occupation.appendChild(title);
occupation.appendChild(document.createTextNode(user.occupation.name));
(function(img){
VK.api.call('groups.getById',{gid:user.occupation.id},function(r){
img.src = r.response[0].photo;
});
})(img);
occupation.addEventListener('touchstart',ts);
occupation.addEventListener('touchend',te);
ls = links.appendChild(sep.cloneNode());
}
if (user.relatives) {
for (var i = 0; i < user.relatives.length; i++) {
var rel = user.relatives[i];
if (rel.uid < 0) continue;
var person = links.appendChild(item.cloneNode()), img = timg.cloneNode(), title = ttitle.cloneNode();
(function(rel,person,img,title){
person.appendChild(img);
person.appendChild(title);
VK.api.call('users.get',{uids:rel.uid,fields:"sex,photo_50"},function(r){
title.innerHTML =
rel.type == 'parent' ? ['Родитель','Мать','Отец'][r.response[0].sex] :
rel.type == 'sibling' ? ['Брат/сестра','Сестра','Брат'][r.response[0].sex] :
rel.type == 'child' ? ['Ребёнок','Дочь','Сын'][r.response[0].sex] :
rel.type == 'grandchild' ? ['Внук/внучка','Внучка','Внук'][r.response[0].sex] :
rel.type == 'grandparent' ? ['Дед/бабушка','Бабушка','Дед'][r.response[0].sex] : 'Родственник';
img.src = r.response[0].photo_50;
person.appendChild(document.createTextNode(r.response[0].first_name + ' ' + r.response[0].last_name));
});
person.addEventListener('touchstart',ts);
person.addEventListener('touchend',te);
})(rel,person,img,title);
ls = links.appendChild(sep.cloneNode());
}
}
if (ls) ls.remove();
if (links.childNodes.length == 0) links.remove();
for (var i in {
"uid": 1,
"first_name": 1,
......@@ -200,6 +263,8 @@ Blocks.page = (function(){
"site": 1,
"status": 1,
"last_seen": 1,
"occupation": 1,
"relatives": 1
}) delete(user[i]);
var dbg = block.appendChild(document.createElement('pre'));
......
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