diff options
author | Joey Hess <joey@kitenet.net> | 2012-07-30 14:50:32 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-07-30 14:50:32 -0400 |
commit | 78b3dada5b056320922cb9f453343ae4d95b0407 (patch) | |
tree | 216aaba0b7218ab80866c15f9e8b3fc023724bbf /templates/longpolling.julius | |
parent | a9941308434354046fa51d3327c5e05ff080a247 (diff) |
better connection close handling
Depending on how the webapp was started up and whether the user clicked on
any links in it, window.close() may be disallowed by browser security
policy. Also if that fails, display a modal dialog that nicely blackens out
the webapp.
TODO: avoid Escape closing it. Bootstrap's docs are unclear about how to do
that.
Diffstat (limited to 'templates/longpolling.julius')
-rw-r--r-- | templates/longpolling.julius | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/templates/longpolling.julius b/templates/longpolling.julius index 95425d615..a4077c3d5 100644 --- a/templates/longpolling.julius +++ b/templates/longpolling.julius @@ -5,9 +5,9 @@ // Maximum update frequency is controlled by #{startdelay} // and #{delay}, both in milliseconds. -(function( $ ) { +$dead=0; -numerrs=0; +(function( $ ) { $.LongPoll#{ident} = (function() { return { @@ -21,12 +21,11 @@ $.LongPoll#{ident} = (function() { numerrs=0; }, 'error': function(jqxhr, msg, e) { - numerrs=numerrs+1; - if (numerrs > 3) { + if (! $dead) { + $dead=1; + // blocked by many browsers window.close(); - } - else { - setTimeout($.LongPoll#{ident}.send, #{show delay}); + $('#lostconnection').modal('show'); } }, }); |