HEX
Server: nginx/1.24.0
System: Linux DGT-WORDPRESS-VM-SERVER 6.14.0-1014-azure #14~24.04.1-Ubuntu SMP Fri Oct 3 20:52:11 UTC 2025 x86_64
User: ubuntu (1000)
PHP: 8.4.12
Disabled: NONE
Upload Files
File: /mnt/data/ifa-wp/wp-content/themes/dreamsrent/assets/js/notification.js
 

jQuery(document).ready(function ($) {
    // Load notifications when the bell icon is clicked
    $('#notification-bell').on('click', function () {
        $.ajax({
            url: notificationData.ajax_url,
            type: 'POST',
            data: {
                action: 'fetch_notifications'
            },
            success: function (response) {
                if (response.success) {
                    $('#notification-dropdown').html(response.data.html);
                    $('#notification-count').text(response.data.unread_count > 0 ? response.data.unread_count : '');
                }
            }
        });
    });

    // Clear all notifications when 'Clear All' is clicked
    $(document).on('click', '.clear-noti', function () {
        $.ajax({
            url: notificationData.ajax_url,
            type: 'POST',
            data: {
                action: 'clear_notifications',
                user_id: notificationData.user_id // Ensure this is passed if needed
            },
            success: function (response) {
                if (response.success) {
                    $('#notification-dropdown .noti-content .notification-list').html('<li class="notification-message"><p>No new notifications.</p></li>');
                    $('#notification-count').text(''); // Clear the notification count
                }
            }
        });
    });
});