TeaWeb/web/app/UnloadHandler.ts

15 lines
503 B
TypeScript
Raw Permalink Normal View History

2020-08-22 15:50:38 +00:00
import {Settings, settings} from "tc-shared/settings";
2020-09-24 09:24:31 +00:00
import {server_connections} from "tc-shared/ConnectionManager";
2020-08-22 15:50:38 +00:00
window.addEventListener("beforeunload", event => {
2021-01-10 15:13:15 +00:00
if(settings.getValue(Settings.KEY_DISABLE_UNLOAD_DIALOG)) {
2020-08-22 15:50:38 +00:00
return;
2021-01-10 15:13:15 +00:00
}
2020-08-22 15:50:38 +00:00
const active_connections = server_connections.getAllConnectionHandlers().filter(e => e.connected);
if(active_connections.length == 0) {
return;
}
2020-08-22 15:50:38 +00:00
event.returnValue = "Are you really sure?<br>You're still connected!";
});