diff options
Diffstat (limited to 'static/js/autorefresh.js')
-rw-r--r-- | static/js/autorefresh.js | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/static/js/autorefresh.js b/static/js/autorefresh.js index 9aa6e0e..b09758c 100644 --- a/static/js/autorefresh.js +++ b/static/js/autorefresh.js @@ -35,10 +35,10 @@ function loadJSON() { } function updateThread(posts, total_replies, serverTime) { - thread_div = document.getElementsByClassName("thread")[0]; - - - for (var i = 0; i < posts.length; i++) { + var thread_div = document.getElementsByClassName("thread")[0]; + if (serviceType == 2) var last_elem = document.getElementById("size"); + else var last_elem = document.getElementsByClassName("cut")[0]; + for (var i=0; i<posts.length; i++) { post = posts[i]; var num = thread_length + i + 1; var div = document.createElement('div'); @@ -77,13 +77,9 @@ function updateThread(posts, total_replies, serverTime) { } } - if (serviceType == 2) thread_div.appendChild(div); - else thread_div.insertBefore(div, document.getElementsByClassName("cut")[0]); + thread_div.insertBefore(div, last_elem); thread_div.setAttribute("data-length",num); - if (serviceType == 2) { - var res=document.getElementsByTagName("h3")[0].getElementsByTagName("span")[0]; - res.innerText = res.innerText.replace(/[0-9]+/, num); - } + if (serviceType == 2) document.getElementsByTagName("h3")[0].getElementsByTagName("span")[0].innerText = "("+num+" respuestas)"; } if (posts.length > 0) { |