Added exit confirmation
This commit is contained in:
parent
dbeddccca6
commit
5799b0828f
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user