git-annex/templates/longpolling.julius
Joey Hess 7e3c1e008d webapp now uses twitter bootstrap
mocked up the main screen, and am actually pretty happy with it!
2012-07-27 04:48:50 -04:00

41 lines
856 B
Text

// Uses long-polling to update a div with id=#{updating}
// The gethtml route should return a new div, with the same id.
//
// Maximum update frequency is controlled by #{startdelay}
// and #{delay}, both in milliseconds.
(function( $ ) {
numerrs=0;
$.LongPoll = (function() {
return {
send : function() {
$.ajax({
'url': '@{gethtml}',
'dataType': 'html',
'success': function(data, status, jqxhr) {
$('##{updating}').replaceWith(data);
setTimeout($.LongPoll.send, #{delay});
numerrs=0;
},
'error': function(jqxhr, msg, e) {
numerrs=numerrs+1;
if (numerrs > 3) {
window.close();
}
else {
setTimeout($.LongPoll.send, #{delay});
}
},
});
}
}
}());
$(document).bind('ready.app', function() {
setTimeout($.LongPoll.send, #{startdelay});
});
})( jQuery );