confirmation dialog on proxy close (close #23)

This commit is contained in:
Serene Han 2016-03-02 05:45:27 -08:00
parent 8a8273e972
commit d2e61e315c
2 changed files with 21 additions and 0 deletions

View file

@ -44,6 +44,8 @@ MODE =
WEBRTC_CONNECTING: 1
WEBRTC_READY: 2
CONFIRMATION_MESSAGE = "You're currently serving a Tor user via Snowflake."
# Minimum viable snowflake for now - just 1 client.
class Snowflake
@ -200,4 +202,11 @@ init = ->
snowflake.setRelayAddr relayAddr
snowflake.beginWebRTC()
# Notification of closing tab with active proxy.
# TODO: Opt-in/out parameter or cookie
window.onbeforeunload = ->
if MODE.WEBRTC_READY == snowflake.state
return CONFIRMATION_MESSAGE
null
window.onload = init if window