further refactoring my js
This commit is contained in:
parent
9648acc7a4
commit
d3413ee5a9
3 changed files with 23 additions and 18 deletions
|
@ -3,17 +3,7 @@
|
|||
|
||||
connfails=0;
|
||||
|
||||
connfailed=
|
||||
'<div id="modal" class="modal fade">' +
|
||||
' <div class="modal-header">' +
|
||||
' <h3>git-annex has shut down</h3>' +
|
||||
' </div>' +
|
||||
' <div class="modal-body">' +
|
||||
' You can now close this browser window.' +
|
||||
' </div>' +
|
||||
'</div>' ;
|
||||
|
||||
function longpoll(url, divid, cont) {
|
||||
function longpoll(url, divid, cont, fail) {
|
||||
$.ajax({
|
||||
'url': url,
|
||||
'dataType': 'html',
|
||||
|
@ -25,10 +15,7 @@ function longpoll(url, divid, cont) {
|
|||
'error': function(jqxhr, msg, e) {
|
||||
connfails=connfails+1;
|
||||
if (connfails > 3) {
|
||||
// blocked by many browsers
|
||||
window.close();
|
||||
$('#modal').replaceWith(connfailed);
|
||||
$('#modal').modal('show');
|
||||
fail();
|
||||
}
|
||||
else {
|
||||
cont();
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
// longpolling for #{ident}
|
||||
function poller#{ident}() {
|
||||
longpoll('@{gethtml}', '#{ident}', function() {
|
||||
setTimeout(poller#{ident}, #{delay});
|
||||
});
|
||||
longpoll('@{gethtml}', '#{ident}'
|
||||
, function() { setTimeout(poller#{ident}, #{delay}); }
|
||||
, function() { webapp_disconnected(); }
|
||||
);
|
||||
}
|
||||
$(function() {
|
||||
setTimeout(poller#{ident}, #{startdelay});
|
||||
|
|
17
templates/page.julius
Normal file
17
templates/page.julius
Normal file
|
@ -0,0 +1,17 @@
|
|||
connfailed =
|
||||
'<div id="modal" class="modal fade">' +
|
||||
' <div class="modal-header">' +
|
||||
' <h3>git-annex has shut down</h3>' +
|
||||
' </div>' +
|
||||
' <div class="modal-body">' +
|
||||
' You can now close this browser window.' +
|
||||
' </div>' +
|
||||
'</div>' ;
|
||||
|
||||
function webapp_disconnected () {
|
||||
$('#modal').replaceWith(connfailed);
|
||||
$('#modal').modal('show');
|
||||
|
||||
// ideal, but blocked by many browsers
|
||||
window.close();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue