Skip to content

Commit 9e66887

Browse files
committed
Add dialogs for offline events
1 parent d33619b commit 9e66887

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

editor/core/application.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
var _ = require("hr.utils");
22
var $ = require("jquery");
33
var Q = require("q");
4-
4+
var logger = require("hr.logger")("app");
55
var Application = require("hr.app");
66
var GridView = require("hr.gridview");
77

8+
var dialogs = require("../utils/dialogs");
89
var workspace = require("./workspace");
910

1011
// Define base application
@@ -23,6 +24,18 @@ var CodeboxApplication = Application.extend({
2324
}, this);
2425
this.grid.$el.addClass("main-grid");
2526
this.grid.appendTo(this);
27+
28+
// Signal offline
29+
function updateOnlineStatus(event) {
30+
logger.log("connection changed", navigator.onLine);
31+
if (!navigator.onLine) {
32+
dialogs.alert("It looks like you lost your internet connection. The IDE requires an internet connection.");
33+
} else {
34+
dialogs.alert("Your internet connection is up again. Restart your navigator tab to ensure that codebox works perfectly.");
35+
}
36+
}
37+
window.addEventListener('online', updateOnlineStatus);
38+
window.addEventListener('offline', updateOnlineStatus);
2639
},
2740

2841
render: function() {

0 commit comments

Comments
 (0)