function seeNotification(elem){ var node=$(elem).parent().find('.notification-hidden'); var notif_id=node.attr("notifId") var text=node.html(); var notifLink=node.attr("notifLink"); var linkText=""; if(notifLink!=undefined && notifLink!=null && notifLink!="null") linkText="
"+notifLink+""; if(!$(elem).parent().hasClass("seen")){ $.ajax({ url: remoteAPIurl+'/api/v1/notification/'+notif_id+'?api_token='+token, crossDomain: true, type: "put", dataType: 'json', success: function(result, statusText, resObject){ $('[notifId="'+notif_id+'"]').parent().addClass("seen"); }, error: function() { console.log('error'); } }); } alert(text+linkText); } function getNotifications(category, offset){ var create_deferred = $.Deferred(); if(!offset) offset=0; var limit=25; $.ajax({ url: remoteAPIurl+'/api/v1/user/notifications?api_token='+token+"&limit="+limit+"&offset="+offset+"&category="+category, crossDomain: true, type: "get", dataType: 'json', success: function(result, statusText, resObject){ var counter=0; $('.notifications .tab-pane').html(''); var tot_unpaging_record=result.tot_unpaging_record; number_of_pages=Math.ceil(tot_unpaging_record/limit); //$('.notifications .list-group li:not(:first-of-type)').remove(); //console.log(result.data); $.each(result.data,function(id,elem){ counter++; if(counter==1) var more_class="no-top-border"; else var more_class=""; notification_date=formatDate(elem.created_at); var seen=""; if(elem.status==1) seen="seen"; $('.notifications .tab-'+category).append( '
  • '+ ''+elem.description+''+ '
    '+elem.id+') '+notification_date+'
    '+ '
    '+elem.name+'
    Vedi
    '+ '
  • ' ); }); if($('.expand-list').length==0){ $('.expand-list').click(function(){ //console.log("expand"); $('.notifications .list-group').addClass('max-height-auto'); $('.expand-list').remove(); }); } if($('.notifications .tab-'+category+' ul.pagination').length==0){ $('.notifications .tab-'+category).append(''); } if($('.notifications .tab-'+category+' ul.pagination li').length==0){ //non ci sono pagine di paginazione, allora le creo for(i=1;i<=number_of_pages;i++){ $('.tab-'+category).find('.pagination').append("
  • "+i+"
  • "); } } create_deferred.resolve(); }, error: function() { console.log('error'); } }); return create_deferred; } $(function(){ getNotifications("user",0); });