Added exit confirmation

This commit is contained in:
Mattias Erming 2014-09-15 11:32:25 -07:00
parent dbeddccca6
commit 5799b0828f
1 changed files with 15 additions and 2 deletions

View File

@ -62,14 +62,14 @@ $(function() {
});
socket.on("connect_error", function(e) {
location.reload();
refresh();
});
socket.on("auth", function(data) {
var body = $("body");
var login = $("#sign-in");
if (!login.length) {
location.reload();
refresh();
return;
}
if (body.hasClass("signed-out")) {
@ -110,6 +110,7 @@ $(function() {
channels: channels
})
);
confirmExit();
}
$("body").removeClass("signed-out");
@ -198,6 +199,7 @@ $(function() {
.find(".btn")
.prop("disabled", false)
.end();
confirmExit();
});
socket.on("nick", function(data) {
@ -558,6 +560,17 @@ $(function() {
);
}
function confirmExit() {
window.onbeforeunload = function() {
return "Are you sure you want to navigate away from this page?";
};
}
function refresh() {
window.onbeforeunload = null;
location.reload();
}
document.addEventListener(
"visibilitychange",
function() {