Ignore:
Timestamp:
10/23/21 17:48:25 (3 years ago)
Author:
beratkjufliju <kufliju@…>
Branches:
develop, master
Children:
a8346eb
Parents:
4b7e2d3
Message:

minor bug fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • public/assets/js/app.js

    r4b7e2d3 rb39afb5  
    10151015    });
    10161016
    1017     function hasNew(response) {
    1018 
    1019         for(var i=0; i<response.length; i++) {
    1020             if(!response[i].isRead) {
    1021                 return true;
    1022             }
    1023         }
    1024 
    1025         return false;
    1026     }
    1027 
    1028     function notifications() {
    1029 
    1030         var url = "/dashboard/get-notifications";
    1031         var _token = $("meta[name='csrf-token']").attr("content");
    1032 
    1033         $.ajax({
    1034             url: url,
    1035             type: "post",
    1036             dataType: "json",
    1037             data: {
    1038                 _token : _token,
    1039             },
    1040             success: function(response) {
    1041 
    1042                 $(".dropdown-notifications a:not(:last)").remove();
    1043                 $(".dropdown-notifications-unread .nav-unread").hide();
    1044 
    1045                 var l = response.length;
    1046 
    1047                 if(hasNew(response)) {
    1048                     $(".dropdown-notifications .unreadNotificationsInfo").hide();
    1049                     $(".dropdown-notifications-unread .nav-unread").show();
    1050                 }
    1051 
    1052                 if(l == 0) {
    1053                     $(".dropdown-notifications .unreadNotificationsInfo").show();
    1054                 }
    1055 
    1056                 if(l > 0) {
    1057                     $(".dropdown-notifications .unreadNotificationsInfo").hide();
    1058                 }
    1059 
    1060                 for(var i=0; i<l; i++) {
    1061 
    1062                     var style = response[i].isRead ? "" : "background: #efefef; color: black;";
    1063 
    1064                     var notificationItem = `
    1065                                                 <a href="` + response[i].url + `" class="dropdown-item d-flex" style="` + style + `;">
    1066                                                         <div>
    1067                                                                 ` + response[i].message + `
    1068                                                                 <div class="small text-muted">` + response[i].ago + `</div>
    1069                                                         </div>
    1070                                                 </a>`;
    1071 
    1072                     $(".dropdown-notifications").prepend(notificationItem);
    1073                 }
    1074             },
    1075             error: function(response) {
    1076                 console.log(response);
    1077             }
    1078         });
    1079     }
    1080 
    1081     $(".dropdown-notifications-unread .nav-unread").hide();
    1082     notifications();
    1083     setInterval(function() { notifications(); }, 5000);
    1084 
    1085     $(".dropdown-notifications-wrapper").click(function() {
    1086         $(".dropdown-notifications-unread .nav-unread").hide();
    1087     });
    1088 
    10891017    $(document).on('click', '#btn-layout-builder', function () {
    10901018
Note: See TracChangeset for help on using the changeset viewer.