(function($){ function prettyDate(time){ var date = new Date((time || "").replace(/-/g,"/").replace(/[TZ]/g," ")), diff = (((new Date()).getTime() - date.getTime()) / 1000), day_diff = Math.floor(diff / 86400); if ( isNaN(day_diff) || day_diff < 0 || day_diff >= 31 ) return; return day_diff == 0 && ( diff < 60 && "just now" || diff < 120 && "1 minute ago" || diff < 3600 && Math.floor( diff / 60 ) + " minutes ago" || diff < 7200 && "1 hour ago" || diff < 86400 && Math.floor( diff / 3600 ) + " hours ago") || day_diff == 1 && "Yesterday" || day_diff < 7 && day_diff + " days ago" || day_diff < 31 && Math.ceil( day_diff / 7 ) + " weeks ago"; } if ( typeof jQuery != "undefined" ) jQuery.fn.prettyDate = function(){ return this.each(function(){ var date = prettyDate(this.title); if ( date ) jQuery(this).text( date ); }); }; $.expr[':'].ext = function(obj){ var left = function(s,n) { return s.substring(0, n); } return obj.href != undefined && obj.href != "" && !obj.href.match(/^mailto\:/) && (obj.hostname != location.hostname) && (left(obj.href,10)!="javascript") && (left(obj.href,1)!="#"); }; $(function() { var _links = [], _parms = [],_click=null, dataCustom = []; $('.saq-time').each(function(){ $(this).html(prettyDate($(this).html())); }); _click = function(){ ; var _href= $.ajax({ type: 'POST', url: 'https://www.italianmotorcycleparts.it/wp-content/plugins/wp-click-info/wp-click-info.js.php?ver=1.26', data: { 'saqtrc': "1", 'target':dataCustom[$(this).attr('href')] }, error:function(d,a,f){ //alert('WP Click Info: Error while tracking URL.\n'+a+'\n'+d.responseText); console.log(d); }, dataType:'text' }); $(this).attr('href',$(this).data('href')); return true; } ; $('.row-web-link').each(function(i,n){ _links[$(this).attr('href')] = $(this); _parms.push($(this).attr('href')); $(this).data('href', $(this).attr('href')); dataCustom[$(this).attr('href')]="Sito Web "+$(this).attr('href'); }); //.click(_click) $('.row-email-link').each(function(i,n){ _links[$(this).attr('href')] = $(this); _parms.push($(this).attr('href')); $(this).data('href',$(this).attr('href')); dataCustom[$(this).attr('href')]="Email "+$(this).attr('href'); }); //.click(_click) $('.item-featured-link').each(function(i,n){ _links[$(this).attr('href')] = $(this); _parms.push($(this).attr('href')); $(this).data('href',$(this).attr('href')); dataCustom[$(this).attr('href')]=$(this).attr('href'); }); //.click(_click) $('.contact-owner-link').each(function(i,n){ _links[$(this).attr('href')] = $(this); _parms.push($(this).attr('href')); $(this).data('href',$(this).attr('href')); dataCustom[$(this).attr('href')]="ContactOwner "+$(this).attr('href'); }); //.click(_click) $('.contact-owner-popup-button').each(function(i,n){ _links[$(this).attr('href')] = $(this); _parms.push($(this).attr('href')); $(this).data('href',$(this).attr('href')); dataCustom[$(this).attr('href')]="ContactPopupOwner "+$(this).attr('href'); }); //.click(_click) if ($.fn.on) { $(document).on("click", ".row-web-link", _click); $(document).on("click", ".row-email-link", _click); $(document).on("click", ".item-featured-link", _click); $(document).on("click", ".contact-owner-link", _click); $(document).on("click", ".contact-owner-popup-button", _click); } else { if ($.fn.delegate) $(document).delegate(".row-web-link", "click", _click); // jQuery 1.4.3+ if ($.fn.delegate) $(document).delegate(".row-email-link", "click", _click); // jQuery 1.4.3+ if ($.fn.delegate) $(document).delegate(".item-featured-link", "click", _click); // jQuery 1.4.3+ if ($.fn.delegate) $(document).delegate(".contact-owner-link", "click", _click); // jQuery 1.4.3+ if ($.fn.delegate) $(document).delegate(".contact-owner-popup-button", "click", _click); // jQuery 1.4.3+ } $.ajax({ async:true, type: 'POST', url: 'https://www.italianmotorcycleparts.it/wp-content/plugins/wp-click-info/nfo.js.php?ver=1.26', data: { 'urls':_parms.join('^') }, success:function(d){ $(d).each(function(i,n){ var _item=$('a:ext[href="'+n.URL+'"]'),_title=_item.attr('title'); _title=(_title ? _title + ' - ' : ''); _item.attr('title', _title + ' ('+n.CLICKS+' clicks. Last was ' + prettyDate(n.DT) + ')'); }); } }); }); })(jQuery);