TeaWeb/web/app/UnloadHandler.ts

15 lines
503 B
TypeScript
Raw Normal View History

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