Не слишком силён в скриптах
Помогите исправить ошибку
Выкладываю часть скрипта. Лайки из соц.сети Мой мир не считается и не суммируется в общих данных.
Нужно поправить function getMailCount(url) и function mrc__shareInit( data )
function getMailCount(url) {
var checker = 'http://connect.mail.ru/share_count?func=mrc__shareInit&callback=1&url_list='+encodeURIComponent(escape(url));
var script = document.createElement("script");
script.type = "text/javascript";
document.body.appendChild(script);
script.src = checker;
}
function mrc__shareInit( data ) {
iteration++;
var is_voted = false;
for (var key in data) {
var json = data[key];
is_voted = true;
var on_sel = true;
if (typeof upd_vote !== 'undefined') {
for (var answ_id in upd_vote.url) {
if (upd_vote.url[answ_id] == key) {
addResult(answ_id, 'mail', json.shares*1);
on_sel = false;
}
}
}
if (on_sel) {
addLog('mail', json.shares*1);
}
}
if ( is_voted == false && (typeof upd_vote === 'undefined')) {
addLog('mail', 0);
}
}
function addResult(answ_id, service, count) {
if ( typeof load_cnt[answ_id] == 'undefined') {
load_cnt[answ_id] = new Object();
}
if (service == 'vk') {
load_cnt[answ_id].vk = new Array();
load_cnt[answ_id].vk = count;
} else if (service == 'mail') {
load_cnt[answ_id].mail = new Array();
load_cnt[answ_id].mail = count;
} else if (service == 'odno') {
load_cnt[answ_id].odno = new Array();
load_cnt[answ_id].odno = count;
} else if (service == 'twi') {
load_cnt[answ_id].twi = new Array();
load_cnt[answ_id].twi = count;
} else if (service == 'fb') {
load_cnt[answ_id].fb = new Array();
load_cnt[answ_id].fb = count;
}
if (iteration == (upd_vote.count * 5)) {
// передаем серверу
$.post(site_root + 'index.php', {
route: 'update_social',
data: load_cnt
}, function(data) {
//alert(data);
});
}
}
var log = [];
log['fb'] = 0;
log['vk'] = 0;
log['twi'] = 0;
log['odno'] = 0;
log['mail'] = 0;
var log_items = 0;
function addLog( service, data ) {
log[service] = data;
log_items++;
if (log_items == 5) {
var anws_id = data_parts[4];
$.post(site_root + "index.php", {
route:"update_social",
id:anws_id,
countTwi:log['twi'],
countVk:log['vk'],
countFb:log['fb'],
countOdno:log['odno'],
countMail:log['mail']
});
var new_all = (log['fb']*1) + (log['vk']*1) + (log['twi']*1) + (log['odno']*1) + (log['mail']*1);
$.modal.close();
$('#vore-r-' + anws_id).html(new_all);
log_items = 0;
log['fb'] = 0;
log['vk'] = 0;
log['twi'] = 0;
log['odno'] = 0;
log['mail'] = 0;
}
}