From 8d451280306c4f05ebb966399420ae4f08831965 Mon Sep 17 00:00:00 2001 From: ForklessAnon Date: Sat, 1 Nov 2014 04:29:21 -0500 Subject: [PATCH] Some code cleanup on thread stats. --- js/thread-stats.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/js/thread-stats.js b/js/thread-stats.js index e6fb1142..59fed912 100644 --- a/js/thread-stats.js +++ b/js/thread-stats.js @@ -7,10 +7,7 @@ * $config['additional_javascript'][] = 'js/jquery.min.js'; * $config['additional_javascript'][] = 'js/thread-stats.js'; */ -// THREAD STATS if (active_page == 'thread') { - - var thread_stats_timer = 30, thread_stats_timeout; //it has to be on a timer because there I haven't found a way to hook into when the actual page updates the thread... //check if page uses unique ID var IDsupport = ($('.poster_id').length > 0); var thread_id = (document.location.pathname + document.location.search).split('/'); @@ -27,7 +24,7 @@ if (active_page == 'thread') { el.prepend('0 images | '); el.prepend('0 replies | '); delete el; - function update_thread_stats(force){ + function update_thread_stats(){ var op = $('#thread_'+ thread_id +' > div.post.op:not(.post-hover):not(.inline)').first(); var replies = $('#thread_'+ thread_id +' > div.post.reply:not(.post-hover):not(.inline)'); // post count @@ -102,14 +99,11 @@ if (active_page == 'thread') { $('#thread_stats_page').text(page); if (!found) $('#thread_stats_page').css('color','red'); }); - },30000); $(document).ready(function(){ $('body').append(''); - update_thread_stats(true); + update_thread_stats(); $('#update_thread').click(update_thread_stats); - MutationObserver = window.MutationObserver || window.WebKitMutationObserver; - var observer = new MutationObserver(function(mutations, observer){update_thread_stats();}); - observer.observe($('#thread_' + thread_id)[0], {childList: true}); + $(document).on('new_post',update_thread_stats); }); } \ No newline at end of file