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
|
|
|
|
2021-01-10 16:36:57 +00:00
|
|
|
const active_connections = server_connections.getAllConnectionHandlers().filter(e => e.connected);
|
2020-08-22 15:50:38 +00:00
|
|
|
if(active_connections.length == 0) return;
|
|
|
|
|
|
|
|
event.returnValue = "Are you really sure?<br>You're still connected!";
|
|
|
|
});
|