Files
6d486f49 09a8adfc4a Test
2026-08-14 17:19:24 -04:00

23 lines
809 B
JavaScript

window.networkStatus = {
dotNetHelper: null,
initialize: function (dotNetHelper) {
this.dotNetHelper = dotNetHelper;
window.addEventListener('online', this.handleStatusChange.bind(this));
window.addEventListener('offline', this.handleStatusChange.bind(this));
return navigator.onLine;
},
handleStatusChange: function () {
if (this.dotNetHelper) {
this.dotNetHelper.invokeMethodAsync('SetOnlineStatus', navigator.onLine);
}
},
isOnline: function () {
return navigator.onLine;
},
dispose: function () {
window.removeEventListener('online', this.handleStatusChange.bind(this));
window.removeEventListener('offline', this.handleStatusChange.bind(this));
this.dotNetHelper = null;
}
};