diff options
author | Aurélien Bompard <aurelien@bompard.org> | 2013-05-17 18:52:37 +0200 |
---|---|---|
committer | Aurélien Bompard <aurelien@bompard.org> | 2013-05-17 18:52:37 +0200 |
commit | a6cc5ed7ac9e95a4e21c49f9159c66ff9a726600 (patch) | |
tree | 079a8bac20271a3c8f7cc852645f12f2317e11da /hyperkitty/static | |
parent | 3759498f4ecf5cae88eecf197b1f2cf075bc0565 (diff) | |
download | hyperkitty-a6cc5ed7ac9e95a4e21c49f9159c66ff9a726600.tar.gz hyperkitty-a6cc5ed7ac9e95a4e21c49f9159c66ff9a726600.tar.xz hyperkitty-a6cc5ed7ac9e95a4e21c49f9159c66ff9a726600.zip |
Load replies in chunks to avoid overloading the browser
Diffstat (limited to 'hyperkitty/static')
-rw-r--r-- | hyperkitty/static/js/hyperkitty.js | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/hyperkitty/static/js/hyperkitty.js b/hyperkitty/static/js/hyperkitty.js index 62bacf4..ee30c74 100644 --- a/hyperkitty/static/js/hyperkitty.js +++ b/hyperkitty/static/js/hyperkitty.js @@ -355,25 +355,33 @@ function activity_graph(elem_id, dates, counts, baseurl) { * Thread replies list */ function update_thread_replies(url) { - $.ajax({ - dataType: "json", - url: url, - success: function(data) { - // replies - var newcontent = $(data.replies_html); - $(".replies").html(newcontent); - // re-bind events - setup_emails_list(newcontent); - fold_quotes(newcontent); - setup_disabled_tooltips(newcontent); - setup_vote(newcontent); - // participants list - $("#participants").html(data.participants_html); - }, - error: function(jqXHR, textStatus, errorThrown) { - alert(jqXHR.responseText); - } - }); + function load_more(current_url) { + $.ajax({ + dataType: "json", + url: current_url, + success: function(data) { + // replies + var newcontent = $(data.replies_html); + $(".replies").append(newcontent) + .append($(".replies .ajaxloader")); + // re-bind events + setup_emails_list(newcontent); + fold_quotes(newcontent); + setup_disabled_tooltips(newcontent); + setup_vote(newcontent); + // load the rest if applicable + if (data.more_pending) { + load_more(url+"&offset="+data.next_offset); + } else { + $(".replies .ajaxloader").remove(); + } + }, + error: function(jqXHR, textStatus, errorThrown) { + alert(jqXHR.responseText); + } + }); + } + load_more(url); } |