Skip to content

Commit

Permalink
Add dialogs for offline events
Browse files Browse the repository at this point in the history
  • Loading branch information
SamyPesse committed Apr 23, 2015
1 parent d33619b commit 9e66887
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion editor/core/application.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
var _ = require("hr.utils");
var $ = require("jquery");
var Q = require("q");

var logger = require("hr.logger")("app");
var Application = require("hr.app");
var GridView = require("hr.gridview");

var dialogs = require("../utils/dialogs");
var workspace = require("./workspace");

// Define base application
Expand All @@ -23,6 +24,18 @@ var CodeboxApplication = Application.extend({
}, this);
this.grid.$el.addClass("main-grid");
this.grid.appendTo(this);

// Signal offline
function updateOnlineStatus(event) {
logger.log("connection changed", navigator.onLine);
if (!navigator.onLine) {
dialogs.alert("It looks like you lost your internet connection. The IDE requires an internet connection.");
} else {
dialogs.alert("Your internet connection is up again. Restart your navigator tab to ensure that codebox works perfectly.");
}
}
window.addEventListener('online', updateOnlineStatus);
window.addEventListener('offline', updateOnlineStatus);
},

render: function() {
Expand Down

0 comments on commit 9e66887

Please sign in to comment.