function showOnlineStatus(isOnline, msg) {
  const networkStatusOnline = document.getElementById('network-status-online');
  const networkStatusOffline = document.getElementById('network-status-offline');
  const networkStatusText = document.getElementById('network-status-text');
  
      if (isOnline) {
        networkStatusOffline.style.display = "none";
        networkStatusOnline.style.display = "inline-block";
        networkStatusOnline.innerText = msg;
        networkStatusText.innerHTML = "Try switching off your wifi or mobile internet to see a <span class='no-network'>no network connection</span> message.";
      } else {
        networkStatusOnline.style.display = "none";
        networkStatusOffline.style.display = "inline-block";
        networkStatusOffline.innerText = msg;
        networkStatusText.innerHTML = "Try switching on your wifi or mobile internet to see a <span class='available-network'>Back Online</span> message.";
      }
  
}
  


window.addEventListener('load', () => {
  if (navigator.onLine) {
    showOnlineStatus(true, "You're online! 😃");
  } else {
    showOnlineStatus(false, "You might be offline, please check your internet connection! ☹️");
  }
  
  window.addEventListener('online', () => {
    showOnlineStatus(true, "You are back online! 😎");
  });
  window.addEventListener('offline', () => {
    showOnlineStatus(false, "You might be offline, please check your internet connection! ☹️");
  });
});