diff --git a/static/longpolling.js b/static/longpolling.js index 4e5f102f00..75c6faeaf3 100644 --- a/static/longpolling.js +++ b/static/longpolling.js @@ -13,29 +13,26 @@ connfailed= ' ' + '' ; -function longpoll(url, divid) { - (function( $ ) { - $.ajax({ - 'url': url, - 'dataType': 'html', - 'success': function(data, status, jqxhr) { - $('#' + divid).replaceWith(data); - connfails=0; - return 1; - }, - 'error': function(jqxhr, msg, e) { - connfails=connfails+1; - if (connfails > 3) { - // blocked by many browsers - window.close(); - $('#modal').replaceWith(connfailed); - $('#modal').modal('show'); - return 0; - } - else { - return 1; - } +function longpoll(url, divid, cont) { + $.ajax({ + 'url': url, + 'dataType': 'html', + 'success': function(data, status, jqxhr) { + $('#' + divid).replaceWith(data); + connfails=0; + cont(); + }, + 'error': function(jqxhr, msg, e) { + connfails=connfails+1; + if (connfails > 3) { + // blocked by many browsers + window.close(); + $('#modal').replaceWith(connfailed); + $('#modal').modal('show'); } - }); - })( jQuery ); + else { + cont(); + } + } + }); } diff --git a/templates/longpolling.julius b/templates/longpolling.julius index 29e533c418..d34d5b47d8 100644 --- a/templates/longpolling.julius +++ b/templates/longpolling.julius @@ -1,11 +1,9 @@ // longpolling for #{ident} function poller#{ident}() { - if (longpoll('@{gethtml}', '#{ident}')) { + longpoll('@{gethtml}', '#{ident}', function() { setTimeout(poller#{ident}, #{delay}); - } -} -(function( $ ) { - $(document).bind('ready.app', function() { - setTimeout(poller#{ident}, #{startdelay}); }); -})( jQuery ); +} +$(function() { + setTimeout(poller#{ident}, #{startdelay}); +});