# HG changeset patch # User neko259 # Date 2013-11-20 11:39:23 # Node ID 0a2454a1ead6dd45269be0598468a7eab6c23596 # Parent 501a128f520aa1cdfdef08fc0b57fbdd5ed6d411 Update reply and image count after thread update diff --git a/boards/static/js/thread_update.js b/boards/static/js/thread_update.js --- a/boards/static/js/thread_update.js +++ b/boards/static/js/thread_update.js @@ -92,6 +92,9 @@ function updateThread() { var $target = $('html,body'); $target.animate({scrollTop: $target.height()}, 1000); } + + $('#reply-count').text(getReplyCount()); + $('#image-count').text(getImageCount()); }) .error(function(data) { // TODO Show error message that server is unavailable? @@ -114,3 +117,11 @@ function initAutoupdate() { setInterval(updateThread, THREAD_UPDATE_DELAY); } + +function getReplyCount() { + return $('.thread').children('.post').length - 1 +} + +function getImageCount() { + return $('.thread').find('img').length +} diff --git a/boards/templates/boards/thread.html b/boards/templates/boards/thread.html --- a/boards/templates/boards/thread.html +++ b/boards/templates/boards/thread.html @@ -154,8 +154,8 @@ {% cache 600 thread_meta posts.0.last_edit_time moderator LANGUAGE_CODE %} - {{ posts.0.get_reply_count }} {% trans 'replies' %}, - {{ posts.0.get_images_count }} {% trans 'images' %}. + {{ posts.0.get_reply_count }} {% trans 'replies' %}, + {{ posts.0.get_images_count }} {% trans 'images' %}. {% trans 'Last update: ' %}{{ posts.0.last_edit_time }} [RSS] {% endcache %} diff --git a/todo.txt b/todo.txt --- a/todo.txt +++ b/todo.txt @@ -39,7 +39,7 @@ post or its part (delimited by N charact [DONE] Fix bug with creating threads from tag view [DONE] Quote characters within quote causes quote parsing to fail -[NOT STARTED] Replies, images, last update time in bottom panel doesn't change when +[IN PROGRESS] Replies, images, last update time in bottom panel doesn't change when thread updates = Testing =