function shariff_share_counts(){var d=document.getElementsByClassName("shariff");var a={};for(var i=0;d[i];i++){var e=d[i].dataset.url;var j=d[i].dataset.services;var h=d[i].dataset.timestamp;var g=d[i].dataset.backendurl;if(typeof g==="undefined"){g="/wp-json/shariff/v1/share_counts?"}var k=g+"url="+e+"&services="+j+"&timestamp="+h;if(typeof j!=="undefined"){if(a[e]){j=a[e][1]+"|"+j;var b=j.split("|");b=b.filter(function(l,m,c){return c.indexOf(l)===m});j=b.join("|");k=g+"url="+e+"&services="+j+"&timestamp="+h;a[e]=[e,j,h,k]}else{a[e]=[e,j,h,k]}}}for(var f in a){if(a.hasOwnProperty(f)){shariff_get_share_counts(a[f][0],a[f][3],d)}}}function shariff_get_share_counts(c,a,d){var b=new XMLHttpRequest();b.open("GET",a,true);b.onload=function(){if(b.status>=200&&b.status<400){shariff_add_share_counts(c,JSON.parse(b.responseText),d)}};b.send()}function shariff_add_share_counts(c,e,b){for(var g=0;b[g];g++){if(b[g].dataset.url===c){var j=b[g].getElementsByClassName("shariff-totalnumber");for(var a=0;j[a];a++){if(e!==null&&typeof e.total!=="undefined"){j[a].innerHTML=e.total}}var h=b[g].getElementsByClassName("shariff-total");for(var i=0;h[i];i++){if(e!==null&&typeof e.total!=="undefined"){h[i].innerHTML=e.total}}var f=b[g].getElementsByClassName("shariff-count");for(var k=0;f[k];k++){if(e!==null&&typeof e[f[k].dataset.service]!=="undefined"&&(typeof b[g].dataset.hidezero==="undefined"||(b[g].dataset.hidezero==="1"&&e[f[k].dataset.service]>0))){f[k].innerHTML=e[f[k].dataset.service];f[k].style.opacity=1}}}}}document.addEventListener("DOMContentLoaded",shariff_share_counts,false);