(function () {
'use strict';
var headerElement = document.querySelector('header');
var metaTagTheme = document.querySelector('meta[name=theme-color]');
//After DOM Loaded
document.addEventListener('DOMContentLoaded', function(event) {
//On initial load to check connectivity
if (!navigator.onLine) {
updateNetworkStatus();
}
window.addEventListener('online', updateNetworkStatus, false);
window.addEventListener('offline', updateNetworkStatus, false);
});
//To update network status
function updateNetworkStatus() {
if (navigator.onLine) {
metaTagTheme.setAttribute('content', '#0288d1');
headerElement.classList.remove('app__offline');
}
else {
toast('App is offline');
metaTagTheme.setAttribute('content', '#6b6b6b');
headerElement.classList.add('app__offline');
}
}
})();
Created
November 3, 2019 17:28
-
-
Save adyontech/1fcb7e030fe024a05d143579c8e66ddd to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment