function updateConnectivityStatus() {
  var notificationToShow = false;
  var notificationIcon = '';
  var notificationType = '';
  var notificationText = '';

  if (typeof navigator.onLine !== 'undefined') {
    if (!navigator.onLine) {
      notificationToShow = true;
      notificationIcon = 'offline';
      if ('serviceWorker' in navigator) {
        // If the browser supports Service Workers and the Cache API,
        // getting offline should be less stressful. Use a "warning"
        // message instead of an "error and provide a link to content
        // available in cache.

        // TODO: check if SW active and some content in cache
        notificationType = 'warning';
        notificationText =
          'It looks like <strong>the connection is lost</strong>. Continue reading this page, or look at <a href="/offline.html">other contents you can read while offline</a>.';
      } else {
        notificationType = 'error';
        notificationText =
          'It looks like <strong>the connection is lost</strong>. Continue reading this page, until the connection is back.';
      }
      isOffline = true;
    } else {
      if (isOffline) {
        isOffline = false;
        notificationIcon = 'online';
        notificationToShow = true;
        notificationType = 'success';
        notificationText =
          '<strong>You are back online!</strong> You can resume your navigation on the website.';
      }
    }

    if (notificationToShow) {
      Toast({
        text: notificationText,
        type: notificationType,
        icon: notificationIcon,
        duration: 7000,
      }).showToast();
    }
  }
}
// check if we're online, set a class on <body> if offline
check if we're online, set a class on  if offline
check if we ' re online set a class on if offline
function updateConnectivityStatus() {
  var notificationToShow = false;
  var notificationIcon = '';
  var notificationType = '';
  var notificationText = '';
  if (typeof navigator.onLine !== 'undefined') {
    if (!navigator.onLine) {
      notificationToShow = true;
      notificationIcon = 'offline';
      if ('serviceWorker' in navigator) {
        notificationType = 'warning';
        notificationText =
          'It looks like <strong>the connection is lost</strong>. Continue reading this page, or look at <a href="/offline.html">other contents you can read while offline</a>.';
      } else {
        notificationType = 'error';
        notificationText =
          'It looks like <strong>the connection is lost</strong>. Continue reading this page, until the connection is back.';
      }
      isOffline = true;
    } else {
      if (isOffline) {
        isOffline = false;
        notificationIcon = 'online';
        notificationToShow = true;
        notificationType = 'success';
        notificationText =
          '<strong>You are back online!</strong> You can resume your navigation on the website.';
      }
    }
    if (notificationToShow) {
      Toast({
        text: notificationText,
        type: notificationType,
        icon: notificationIcon,
        duration: 7000,
      }).showToast();
    }
  }
}
function updateConnectivityStatus ( ) { var notificationToShow = false ; var notificationIcon = '' ; var notificationType = '' ; var notificationText = '' ; if ( typeof navigator . onLine !== 'undefined' ) { if ( ! navigator . onLine ) { notificationToShow = true ; notificationIcon = 'offline' ; if ( 'serviceWorker' in navigator ) { notificationType = 'warning' ; notificationText = 'It looks like <strong>the connection is lost</strong>. Continue reading this page, or look at <a href="/offline.html">other contents you can read while offline</a>.' ; } else { notificationType = 'error' ; notificationText = 'It looks like <strong>the connection is lost</strong>. Continue reading this page, until the connection is back.' ; } isOffline = true ; } else { if ( isOffline ) { isOffline = false ; notificationIcon = 'online' ; notificationToShow = true ; notificationType = 'success' ; notificationText = '<strong>You are back online!</strong> You can resume your navigation on the website.' ; } } if ( notificationToShow ) { Toast ( { text : notificationText , type : notificationType , icon : notificationIcon , duration : 7000 , } ) . showToast ( ) ; } } }
check if we're online, set a class on <body> if offline
check if we ' re online set a class on <body > if offline
// If the browser supports Service Workers and the Cache API, // getting offline should be less stressful. Use a "warning" // message instead of an "error and provide a link to content // available in cache. // TODO: check if SW active and some content in cache