diff options
author | 2012-07-30 14:50:32 -0400 | |
---|---|---|
committer | 2012-07-30 14:50:32 -0400 | |
commit | 78b3dada5b056320922cb9f453343ae4d95b0407 (patch) | |
tree | 216aaba0b7218ab80866c15f9e8b3fc023724bbf /templates | |
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')
-rw-r--r-- | templates/longpolling.julius | 13 | ||||
-rw-r--r-- | templates/page.hamlet | 7 |
2 files changed, 13 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'); } }, }); diff --git a/templates/page.hamlet b/templates/page.hamlet index 500424125..919724f87 100644 --- a/templates/page.hamlet +++ b/templates/page.hamlet @@ -21,3 +21,10 @@ <div .container-fluid> <div .row-fluid> ^{content} +<div #lostconnection .modal .fade> + <div .modal-header> + <h3> + git-annex has shut down + <div .modal-body> + <p> + You can now close this browser window. |