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;
|
connfails=0;
|
||||||
|
|
||||||
connfailed=
|
function longpoll(url, divid, cont, fail) {
|
||||||
'<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) {
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
'url': url,
|
'url': url,
|
||||||
'dataType': 'html',
|
'dataType': 'html',
|
||||||
|
@ -25,10 +15,7 @@ function longpoll(url, divid, cont) {
|
||||||
'error': function(jqxhr, msg, e) {
|
'error': function(jqxhr, msg, e) {
|
||||||
connfails=connfails+1;
|
connfails=connfails+1;
|
||||||
if (connfails > 3) {
|
if (connfails > 3) {
|
||||||
// blocked by many browsers
|
fail();
|
||||||
window.close();
|
|
||||||
$('#modal').replaceWith(connfailed);
|
|
||||||
$('#modal').modal('show');
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cont();
|
cont();
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
// longpolling for #{ident}
|
// longpolling for #{ident}
|
||||||
function poller#{ident}() {
|
function poller#{ident}() {
|
||||||
longpoll('@{gethtml}', '#{ident}', function() {
|
longpoll('@{gethtml}', '#{ident}'
|
||||||
setTimeout(poller#{ident}, #{delay});
|
, function() { setTimeout(poller#{ident}, #{delay}); }
|
||||||
});
|
, function() { webapp_disconnected(); }
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$(function() {
|
$(function() {
|
||||||
setTimeout(poller#{ident}, #{startdelay});
|
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