load check_online.php

Ligger pt i min fil: index.php
 avatar
Esbjerg82
javascript
a year ago
942 B
21
Indexable
Never
<script>
$(document).ready(function() {
  // Function to update online status of admins
  function updateOnlineStatus() {
    $.ajax({
      url: 'check_online.php',
      dataType: 'json',
      success: function(data) {
        // Loop through each admin and update their online status
        $.each(data, function(i, admin) {
          var $adminElement = $('#admin-' + admin.id);
          var isOnline = admin.online && (Date.now() - admin.lastseen) < 1000 * 60 * 10;

          if (admin.id === '1' && !isOnline) {
            $('#myModal').modal('show');
            $('#myModal').modal({backdrop: 'static', keyboard: false}, 'show');
          }

          if (isOnline) {
            $adminElement.removeClass('offline');
          } else {
            $adminElement.addClass('offline');
          }
        });
      }
    });
  }

  // Update online status every 30 seconds
  setInterval(updateOnlineStatus, 10000);
});

</script>