2012-07-26 21:03:46 -04:00
|
|
|
|
2012-07-28 23:55:41 -04:00
|
|
|
// Uses long-polling to update a div with id=#{ident}
|
2012-07-26 21:03:46 -04:00
|
|
|
// The gethtml route should return a new div, with the same id.
|
|
|
|
//
|
|
|
|
// Maximum update frequency is controlled by #{startdelay}
|
|
|
|
// and #{delay}, both in milliseconds.
|
2012-07-26 17:56:24 -04:00
|
|
|
|
|
|
|
(function( $ ) {
|
|
|
|
|
2012-07-27 00:17:04 -04:00
|
|
|
numerrs=0;
|
|
|
|
|
2012-07-29 03:23:17 -04:00
|
|
|
$.LongPoll#{ident} = (function() {
|
2012-07-26 17:56:24 -04:00
|
|
|
return {
|
|
|
|
send : function() {
|
|
|
|
$.ajax({
|
2012-07-26 21:03:46 -04:00
|
|
|
'url': '@{gethtml}',
|
2012-07-26 17:56:24 -04:00
|
|
|
'dataType': 'html',
|
|
|
|
'success': function(data, status, jqxhr) {
|
2012-07-28 23:55:41 -04:00
|
|
|
$('##{ident}').replaceWith(data);
|
2012-07-29 03:23:17 -04:00
|
|
|
setTimeout($.LongPoll#{ident}.send, #{show delay});
|
2012-07-27 00:17:04 -04:00
|
|
|
numerrs=0;
|
|
|
|
},
|
|
|
|
'error': function(jqxhr, msg, e) {
|
|
|
|
numerrs=numerrs+1;
|
|
|
|
if (numerrs > 3) {
|
|
|
|
window.close();
|
|
|
|
}
|
|
|
|
else {
|
2012-07-29 03:23:17 -04:00
|
|
|
setTimeout($.LongPoll#{ident}.send, #{show delay});
|
2012-07-27 00:17:04 -04:00
|
|
|
}
|
2012-07-26 17:56:24 -04:00
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}());
|
|
|
|
|
|
|
|
$(document).bind('ready.app', function() {
|
2012-07-29 03:23:17 -04:00
|
|
|
setTimeout($.LongPoll#{ident}.send, #{show startdelay});
|
2012-07-26 17:56:24 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
})( jQuery );
|