aboutsummaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-07-30 18:01:41 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-07-30 18:01:41 -0400
commit502bc5d5f84a26bfd2ca700d8f90d78a81c7b1ac (patch)
tree113863fb55a035b57ef912f01ad974b01a829423 /templates
parentd1358cc96f2e719a90e2192a24e61c57ce9ed50c (diff)
rewrote longpolling, trying to avoid duplication
does not work though. stupid JS
Diffstat (limited to 'templates')
-rw-r--r--templates/longpolling.julius61
1 files changed, 9 insertions, 52 deletions
diff --git a/templates/longpolling.julius b/templates/longpolling.julius
index 35205bd04..29e533c41 100644
--- a/templates/longpolling.julius
+++ b/templates/longpolling.julius
@@ -1,54 +1,11 @@
-
-// Uses long-polling to update a div with id=#{ident}
-// The gethtml route should return a new div, with the same id.
-//
-// Maximum update frequency is controlled by #{startdelay}
-// and #{delay}, both in milliseconds.
-
-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#{ident} = (function() {
- return {
- send : function() {
- $.ajax({
- 'url': '@{gethtml}',
- 'dataType': 'html',
- 'success': function(data, status, jqxhr) {
- $('##{ident}').replaceWith(data);
- setTimeout($.LongPoll#{ident}.send, #{show delay});
- numerrs=0;
- },
- 'error': function(jqxhr, msg, e) {
- connfails=connfails+1;
- if (connfails > 3) {
- // blocked by many browsers
- window.close();
- $('#modal').replaceWith(connfailed);
- $('#modal').modal('show');
- }
- else {
- setTimeout($.LongPoll#{ident}.send, #{show delay});
- }
- },
- });
- }
+// longpolling for #{ident}
+function poller#{ident}() {
+ if (longpoll('@{gethtml}', '#{ident}')) {
+ setTimeout(poller#{ident}, #{delay});
}
-}());
-
-$(document).bind('ready.app', function() {
- setTimeout($.LongPoll#{ident}.send, #{show startdelay});
-});
-
+}
+(function( $ ) {
+ $(document).bind('ready.app', function() {
+ setTimeout(poller#{ident}, #{startdelay});
+ });
})( jQuery );