0) {
for (index = 0; index < VKWidgetsLike.length; ++index) {
VK.Widgets.Like(VKWidgetsLike[index].element_id, VKWidgetsLike[index].options);
}
}
if (typeof VKWidgetsGroup !== 'undefined' && VKWidgetsGroup.length > 0) {
for (index = 0; index < VKWidgetsGroup.length; ++index) {
//console.log(VKWidgetsGroup);
VK.Widgets.Group(VKWidgetsGroup[index].element_id, VKWidgetsGroup[index].options, VKWidgetsGroup[index].group_id);
}
VK.Observer.subscribe('widgets.groups.joined', function (n) {
console.log(VKWidgetsGroup[n - 1].group_id);
var data = {
action: 'evc_add_vk_widget_stats',
gid: VKWidgetsGroup[n - 1].group_id,
widget: 'group',
waction: 'joined'
};
jQuery.ajax({
url: ajaxurl,
data: data,
type: "POST",
dataType: 'json'
});
});
VK.Observer.subscribe('widgets.groups.leaved', function (n) {
//console.log(VKWidgetsGroup[n - 1].group_id);
var data = {
action: 'evc_add_vk_widget_stats',
gid: VKWidgetsGroup[n - 1].group_id,
widget: 'group',
waction: 'leaved'
};
jQuery.ajax({
url: ajaxurl,
data: data,
type: "POST",
dataType: 'json'
});
});
}
// console.log(VKWidgetsContactUs);
// Contact Us
if (typeof VKWidgetsContactUs !== 'undefined' ) {
console.log(VKWidgetsContactUs);
for (index = 0; index < VKWidgetsContactUs.length; ++index) {
VK.Widgets.ContactUs(
VKWidgetsContactUs[index].element_id,
VKWidgetsContactUs[index].options,
VKWidgetsContactUs[index].owner_id
);
}
}
//console.log(VKWidgetsComments);
// COMMENTS
if (typeof VKWidgetsComments !== 'undefined' ) {
//console.log(VKWidgetsComments);
for (index = 0; index < VKWidgetsComments.length; ++index) {
VK.Widgets.Comments(
VKWidgetsComments[index].element_id,
VKWidgetsComments[index].options,
VKWidgetsComments[index].page_id
);
}
evcCommentsRefresh = false;
var new_data = {
post_id: evc_post_id,
url: document.URL,
widget_api_id: jQuery('meta[property="vk:app_id"]').attr('content'),
action: 'evc_comments_refresh'
};
VK.Observer.subscribe('widgets.comments.new_comment', function(num, last_comment, date, sign, wID, n) {
if ( typeof VKWidgetsComments[n - 1] !== 'undefined' && typeof VKWidgetsComments[n - 1].page_id !== 'undefined' )
new_data.page_id = VKWidgetsComments[n - 1].page_id;
else
new_data.page_id = VKWidgetsComments[0].page_id;
//console.log(new_data); //
if (!evcCommentsRefresh) {
evcCommentsRefresh = true;
jQuery.ajax({
url: ajaxurl,
data: new_data,
type:"POST",
dataType: 'json',
success: function(data) {
//console.log(data); //
evcCommentsRefresh = false;
}
});
}
});
VK.Observer.subscribe('widgets.comments.delete_comment', function(num, last_comment, date, sign) {
//console.log(date);
});
}
//console.log(VKWidgetsPolls);
// Polls
if (typeof VKWidgetsPolls !== 'undefined' ) {
//console.log(VKWidgetsPolls);
for (index = 0; index < VKWidgetsPolls.length; ++index) {
VK.Widgets.Poll(
VKWidgetsPolls[index].element_id,
VKWidgetsPolls[index].options,
VKWidgetsPolls[index].poll_id
);
}
evcCommentsRefresh = false;
var new_data = {
post_id: evc_post_id,
url: document.URL,
widget_api_id: jQuery('meta[property="vk:app_id"]').attr('content'),
action: 'evc_comments_refresh'
};
VK.Observer.subscribe('widgets.comments.new_comment', function(num, last_comment, date, sign, wID, n) {
if ( typeof VKWidgetsComments[n - 1] !== 'undefined' && typeof VKWidgetsComments[n - 1].page_id !== 'undefined' )
new_data.page_id = VKWidgetsComments[n - 1].page_id;
else
new_data.page_id = VKWidgetsComments[0].page_id;
//console.log(new_data); //
if (!evcCommentsRefresh) {
evcCommentsRefresh = true;
jQuery.ajax({
url: ajaxurl,
data: new_data,
type:"POST",
dataType: 'json',
success: function(data) {
//console.log(data); //
evcCommentsRefresh = false;
}
});
}
});
VK.Observer.subscribe('widgets.comments.delete_comment', function(num, last_comment, date, sign) {
//console.log(date);
});
}
//console.log(VKWidgetsSubscribe);
// Widget Subscribe
if (typeof VKWidgetsSubscribe !== 'undefined' ) {
var subscribeCookieExpires = 1; // !!!
for (index = 0; index < VKWidgetsSubscribe.length; ++index) {
VK.Widgets.Subscribe(
VKWidgetsSubscribe[index].element_id,
VKWidgetsSubscribe[index].options,
VKWidgetsSubscribe[index].owner_id
);
}
VK.Observer.subscribe('widgets.subscribed', function(n) {
vkwidget = jQuery("#vkwidget" + n).parent();
vkwidgetID = jQuery(vkwidget).attr('id');
if (jQuery(vkwidget).hasClass('evc-vk-lock')) {
console.log('Fire');
//vkwidgetID = jQuery("#vkwidget" + n).parent().attr('id');
subscribeObj = jQuery.grep(VKWidgetsSubscribe, function(e){ return e.element_id == vkwidgetID; });
if (subscribeObj.length != 0) {
o = subscribeObj[0].owner_id;
if (jQuery.cookie('vkUnLock' + o) == 'undefined' || !jQuery.cookie('vkUnLock' + o) || jQuery.cookie('vkUnLock' + o) != subscribeObj[0].owner_id ) {
jQuery.cookie('vkUnLock' + o, subscribeObj[0].owner_id, { expires: subscribeCookieExpires, path: '/' });
}
location.reload();
}
}
});
VK.Observer.subscribe('widgets.unsubscribed', function(n) {
vkwidget = jQuery("#vkwidget" + n).parent();
vkwidgetID = jQuery(vkwidget).attr('id');
if (jQuery(vkwidget).hasClass('evc-vk-lock')) {
console.log('Fire');
subscribeObj = jQuery.grep(VKWidgetsSubscribe, function(e){ return e.element_id == vkwidgetID;});
if (subscribeObj.length != 0) {
o = subscribeObj[0].owner_id;
if (jQuery.cookie('vkUnLock' + o) != 'undefined') {
jQuery.removeCookie('vkUnLock' + o);
}
}
}
});
}
// console.log(VKWidgetsContactUs);
// Contact Us
if (typeof VKWidgetsCommunityMessages !== 'undefined') {
console.log(VKWidgetsCommunityMessages);
for (index = 0; index < VKWidgetsCommunityMessages.length; ++index) {
VK.Widgets.CommunityMessages(
VKWidgetsCommunityMessages[index].element_id,
VKWidgetsCommunityMessages[index].group_id,
VKWidgetsCommunityMessages[index].options
);
}
}
};
/* ]]> */