1jQuery(document).ready(function() { 2 // Load notification count when the page loads 3 wppm_loadNotifications(); 4 // Refresh every 30 seconds 5 setInterval(function () { 6 if (!document.hidden) { 7 wppm_loadNotifications(); 8 } 9 }, 60000); 10}); 11 12jQuery(document).on('click', function (e) { 13 if ( 14 !jQuery(e.target).closest('#wppm_notification_bell').length && 15 !jQuery(e.target).closest('#wppm-notification-container').length 16 ) { 17 jQuery('#wppm-notification-container').hide(); 18 } 19}); 20 21function wppm_loadNotifications() { 22 jQuery.ajax({ 23 url: wppm_notification.ajax_url, 24 type: "POST", 25 data: { 26 action: "wppm_get_notifications" 27 }, 28 dataType: "json", 29 success: function(response) { 30 if(response.length > 0){ 31 jQuery("#wppm_notification_bell").addClass("wppm-has-notification"); 32 jQuery(".wppm-badge").text(response.length).show(); 33 }else{ 34 jQuery("#wppm_notification_bell").removeClass("wppm-has-notification"); 35 jQuery(".wppm-badge").text("0").show(); 36 } 37 var html = ""; 38 if(response.length > 0){ 39 jQuery.each(response, function(i, notification){ 40 html += '<div class="wppm-notification-item" data-id="' + notification.id + '" data-link="' + notification.link + '">'; 41 html += '<div class="wppm-notification-message">'+notification.message+'</div>'; 42 html += '<small>'+notification.created_at+'</small>'; 43 html += '</div>'; 44 }); 45 }else{ 46 html = '<div class="wppm-no-notification">No new notifications</div>'; 47 } 48 jQuery("#wppm-notification-container").html(html); 49 } 50 }); 51} 52 53jQuery(document).on("click", ".wppm-notification-item", function () { 54 var id = jQuery(this).data("id"); 55 jQuery.ajax({ 56 url: wppm_notification.ajax_url, 57 type: "POST", 58 data: { 59 action: "wppm_mark_notification_read", 60 id: id 61 } 62 }); 63 // Then open the task 64}); 65jQuery(document).on('click', '#wppm_notification_bell', function () { 66 wppm_loadNotifications(); 67 jQuery('#wppm-notification-container').toggle(); 68});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.