Added internet connection check

This commit is contained in:
sairaj mote 2023-08-16 14:31:28 +05:30
parent 27d7ad2132
commit 0e41a80aa4

View File

@ -151,6 +151,19 @@
<!-- <script src="scripts/main.js"></script> -->
<script>
const { html, render: renderElem } = uhtml;
//Checks for internet connection status
uiGlobals.connectionErrorNotification = []
if (!navigator.onLine)
uiGlobals.connectionErrorNotification.push(notify('There seems to be a problem connecting to the internet, Please check you internet connection.', 'error'))
window.addEventListener('offline', () => {
uiGlobals.connectionErrorNotification.push(notify('There seems to be a problem connecting to the internet, Please check you internet connection.', 'error'))
})
window.addEventListener('online', () => {
uiGlobals.connectionErrorNotification.forEach(notification => notification.remove())
notify('We are back online.', 'success')
location.reload()
uiGlobals.connectionErrorNotification = []
})
// Use instead of document.getElementById
function getRef(elementId) {
return document.getElementById(elementId)