TeaWeb/web/app/UnloadHandler.ts

12 lines
480 B
TypeScript
Raw Normal View History

2020-08-22 17:50:38 +02:00
import {Settings, settings} from "tc-shared/settings";
import {server_connections} from "tc-shared/ui/frames/connection_handlers";
window.addEventListener("beforeunload", event => {
if(settings.static(Settings.KEY_DISABLE_UNLOAD_DIALOG))
return;
const active_connections = server_connections.all_connections().filter(e => e.connected);
if(active_connections.length == 0) return;
event.returnValue = "Are you really sure?<br>You're still connected!";
});