webseite-grav/plugins/admin/themes/grav/app/utils/offline.js

22 lines
469 B
JavaScript
Raw Permalink Normal View History

2021-04-30 11:23:26 +02:00
import $ from 'jquery';
import isOnline from '../utils/offline';
const offlineElement = $('#offline-status');
$(window).on('offline', () => {
offlineElement.slideDown();
});
$(window).on('online', () => {
offlineElement.slideUp();
});
$(document).ready(() => {
if (!isOnline) {
offlineElement.slideDown();
}
});
// assume online if can't check
export default typeof global.navigator.onLine !== 'undefined' ? global.navigator.onLine : true;