jQuery(document).ready(function($){ var basic_network_list = "twitter,linkedin,facebook,pinterest,google,stumbleupon,vk,reddit,buffer,love,ok,mwp,xing,pocket,mail,print,comments,yummly"; var extended_network_list = "del,digg,weibo,flattr,tumblr,whatsapp,meneame,blogger,amazon,yahoomail,gmail,aol,newsvine,hackernews,evernote,myspace,mailru,viadeo,line,flipboard,sms,viber,telegram"; var plugin_url = essb_settings.essb3_plugin_url; var fb_value = essb_settings.essb3_facebook_total; var counter_admin = essb_settings.essb3_admin_ajax; var interal_counters_all = essb_settings.essb3_internal_counter; var button_counter_hidden = essb_settings.essb3_counter_button_min; var twitter_counter = typeof(essb_settings.twitter_counter) != "undefined" ? essb_settings.twitter_counter : ""; var google_counter = typeof(essb_settings.google_counter) != 'undefined' ? essb_settings.google_counter : ''; if (twitter_counter == "") { twitter_counter = "api"; } if (google_counter == '') google_counter = 'api'; var essb_shorten_number = function(n) { if ('number' !== typeof n) n = Number(n); var sgn = n < 0 ? '-' : '' , suffixes = ['k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'] , overflow = Math.pow(10, suffixes.length * 3 + 3) , suffix, digits; n = Math.abs(Math.round(n)); if (n < 1000) return sgn + n; if (n >= 1e100) return sgn + 'many'; if (n >= overflow) return (sgn + n).replace(/(\.\d*)?e\+?/i, 'e'); // 1e24 do { n = Math.floor(n); suffix = suffixes.shift(); digits = n % 1e6; n = n / 1000; if (n >= 1000) continue; // 1M onwards: get them in the next iteration if (n >= 10 && n < 1000 // 10k ... 999k || (n < 10 && (digits % 1000) < 100) // Xk (X000 ... X099) ) return sgn + Math.floor(n) + suffix; return (sgn + n).replace(/(\.\d).*/, '$1') + suffix; // #.#k } while (suffixes.length) return sgn + 'many'; } jQuery.fn.essb_total_counters = function(){ return this.each(function(){ // missing plugin settings - code cannot run from here if (typeof(essb_settings) == "undefined") { return; } var post_self_count_id = $(this).attr("data-post") || ""; var url = $(this).attr("data-url") || ""; var twitter_url = url; var instance_id = $(this).attr("data-essb-instance") || ""; var ajax_url = essb_settings.ajax_url; if (essb_settings.ajax_type == "light") { ajax_url = essb_settings.blog_url; } var $network_list = $(this).attr('data-network-list'); var $url = url; var $facebook_total = fb_value; var $post_id = post_self_count_id; //var $root = $(this).find('.essb-total-value'); var $value_element = $(this).find('.essb-total-value'); var $root = $(this); // definy the counter API var nonapi_counts_url = (counter_admin) ? ajax_url+"?action=essb_counts&nonce="+essb_settings.essb3_nonce+"&" : essb_settings.essb3_plugin_url+"/public/get-noapi-counts.php?"; var nonapi_internal_url = ajax_url+"?action=essb_counts&nonce="+essb_settings.essb3_nonce+"&"; //console.log(nonapi_internal_url); var basic_networks = basic_network_list.split(","); var extended_networks = extended_network_list.split(","); var direct_access_networks = []; var nonapi_count_networks = []; var nonapi_internal_count_networks = []; for (var i=0;i -1) { switch (basic_networks[i]) { //case "google": case "stumbleupon": case "vk": case "reddit": case "ok": case "mwp": case "xing": case "pocket": case "linkedin": if (counter_admin) { nonapi_internal_count_networks.push(basic_networks[i]); } else { nonapi_count_networks.push(basic_networks[i]); } break; case "mail": case "print": case "love": case "comments": nonapi_internal_count_networks.push(basic_networks[i]); break; case "twitter": if (twitter_counter == "api" || twitter_counter == "newsc") { direct_access_networks.push(basic_networks[i]); } else if (twitter_counter == "self") { nonapi_internal_count_networks.push(basic_networks[i]); } break; case "google": if (google_counter == 'self') nonapi_internal_count_networks.push(basic_networks[i]); else nonapi_count_networks.push(basic_networks[i]); break; default: direct_access_networks.push(basic_networks[i]); break; } } } if (interal_counters_all) { for (var i=0;i -1) { nonapi_internal_count_networks.push(extended_networks[i]); } } } // start populating counters - direct access API counters var operating_elements = {}; for (var i=0;i= 1e100) return sgn + 'many'; if (n >= overflow) return (sgn + n).replace(/(\.\d*)?e\+?/i, 'e'); // 1e24 do { n = Math.floor(n); suffix = suffixes.shift(); digits = n % 1e6; n = n / 1000; if (n >= 1000) continue; // 1M onwards: get them in the next iteration if (n >= 10 && n < 1000 // 10k ... 999k || (n < 10 && (digits % 1000) < 100) // Xk (X000 ... X099) ) return sgn + Math.floor(n) + suffix; return (sgn + n).replace(/(\.\d).*/, '$1') + suffix; // #.#k } while (suffixes.length) return sgn + 'many'; } setInterval(update_total, 1200); }); }; $('.essb-total').essb_total_counters(); $('.essb-total').essb_update_total_counters(); });