File manager - Edit - /home/autoph/public_html/data03252025consolidation/lms/resources/views/common/scripts/notification.js
Back
//START CONFIG FILE///////////////////////////////////////////////////////////////////////////////////////////////////// function init_notification_page() { init_header(); if (side_menu_loaded) { init_notification(); // console.log('asd') } else { $.when(init_side_content()).done(function(ajax1Results) { init_notification(); }); } } var init_notification = function() { return $.ajax({ url: "resources/views/notification.php", data: {}, type: "POST", beforeSend: function() {}, success: function(data) { document.title = 'Notifications'; $('#center_content').html(data); add_content_close_listener('center_content'); notification_display_limit = notification_display_limit_const; $.when(user_notification()).done(function(ajax2Results) { // console.log(ajax2Results['data']) //reset notification_display_limit notification_display_limit = notification_display_limit + notification_display_limit_const; //init objects $('#notification_list_div').html(''); $('#notification_view_more').on('click', function() { $.when(user_notification()).done(function(ajax1Results2) { var result_notification2 = ajax1Results2['data']; notification_display_limit = notification_display_limit + notification_display_limit_const; notification_display(result_notification2); }); }); //ajax when area var result_notification = ajax2Results['data']; notification_display(result_notification); mark_as_read_notification(); show_hide_preloader(false); }); show_hide_preloader(false); }, error: function() { toastr.remove(); toastr.error("Error has occurred. Try again.") } }); } function refresh_notification() { $.when(get_user_notification_info()).done(function(ajax2Results) { // console.log(); var notif_count = parseInt(ajax2Results.total); if(notif_count){ $('#notif_count_badge').text(notif_count); if(notif_count > 1){ $('#notif_count').text(notif_count+ ' Notifications'); }else{ $('#notif_count').text(notif_count+ ' Notification'); } $('#notif_div_container').html('') //display notification per category $.each(ajax2Results['data'], function(i, n) { // console.log(n['type']) $('#notif_div_container').append(` <a href="#" notification-header="`+n['id']+`" class="dropdown-item"> <i class="fas fa-bell mr-2"></i> `+n['count']+ ' ' +n['type']+` <span class="float-right text-muted text-sm">`+n['ago']+ `</span> </a> <div class="dropdown-divider"></div> `) }); }else{ $('#notif_count').text('0 Notification'); } $("[notification-header]").each(function() { $(this).off('click').on('click', function() { global_in_notif_section = true; selected_notification_category = $(this).attr('notification-header'); // console.log(selected_notification_category) init_notification_page(); }); }); }); } function mark_as_read_notification(){ return $.ajax({ url: "app/models/user.php", data: { model: 'mark_as_read_notification', type_id: selected_notification_category, }, type: "POST", dataType: 'json', beforeSend: function() {}, success: function(result) { // console.log(result) // setTimeout(function(){ refresh_notification(); global_in_notif_section = false; // }, 3000); }, error: function() { toastr.remove(); toastr.error( "Error has occurred. Try again." ) } }); } function user_notification() { return $.ajax({ url: "app/models/user.php", data: { model: 'user_notification', type_id: selected_notification_category, offset: notification_display_limit - notification_display_limit_const, limit: notification_display_limit_const }, type: "POST", dataType: 'json', beforeSend: function() {}, success: function(result) { // console.log(result) }, error: function() { toastr.remove(); toastr.error( "Error has occurred. Try again." ) } }); } function notification_display(ajaxResult) { $.each(ajaxResult, function(i, n) { var data = ajaxResult[i]; // console.log(data); var is_read = parseInt(data['is_read']) === 0? 'border-primary' : '' ; $('#notification_list_div').append(`<div class="card-header bg-white `+is_read+` cursor-pointer pl-2 pr-2 pt-2 pb-1 rounded-0 border mb-2"> <div class="col-12 col-sm-12 col-md-12 d-flex align-items-stretch flex-column"> <div class="card card-default shadow-none h-100 m-0 p-0"> <!-- /.card-header --> <div class="card-body p-0 bg-white mb-0"> <div class="row"> <div class="col-12"> <div class="p-1 bg-light col-12"><span class="">`+n['description']+` </span> </div> <span class="text-sm text-muted font-italic">`+n['date_added']+` </span> </div> </div> </div> </div> </div> </div> `); }); }
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings