From b93047fdf48d31c879fa39102cae61dc14b5845b Mon Sep 17 00:00:00 2001
From: Terry
Date: Fri, 29 Mar 2019 02:23:17 -0300
Subject: Fix + Test + nofollow
---
static/js/autorefresh.js | 29 ++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)
(limited to 'static/js')
diff --git a/static/js/autorefresh.js b/static/js/autorefresh.js
index 0ed3e06..aa04bf1 100644
--- a/static/js/autorefresh.js
+++ b/static/js/autorefresh.js
@@ -36,13 +36,11 @@ function loadJSON() {
function updateThread(posts, total_replies, serverTime) {
thread_div = document.getElementsByClassName("thread")[0];
- if (serviceType == 2)
- last_elem = document.getElementsByClassName("size")[0];
- else
- 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');
if (serviceType == 2) div.className = "reply";
else div.className = "replycont";
@@ -57,10 +55,10 @@ function updateThread(posts, total_replies, serverTime) {
if (post.file) {
s_img = '
' + Math.round(post.file_size/1024) + 'KB ' + post.file.substring(post.file.lastIndexOf(".")+1, post.file.length).toUpperCase() + '';
} else s_img = '';
- if (post.IS_DELETED == 1) div.innerHTML = '
' + (thread_length + i + 1) + ' : Mensaje eliminado por el usuario.
';
- else if (post.IS_DELETED == 2) div.innerHTML = '' + (thread_length + i + 1) + ' : Mensaje eliminado por miembro del staff.
';
+ if (post.IS_DELETED == 1) div.innerHTML = '' + num + ' : Mensaje eliminado por el usuario.
';
+ else if (post.IS_DELETED == 2) div.innerHTML = '' + num + ' : Mensaje eliminado por miembro del staff.
';
else
- div.innerHTML = '' + (thread_length + i + 1) + ' : ' + s_name + ' : ' + post.timestamp_formatted + ' rep del
' + s_img + '' + post.message + '
';
+ div.innerHTML = '' + num + ' : ' + s_name + ' : ' + post.timestamp_formatted + ' rep del
' + s_img + '' + post.message + '
';
} else {
if (post.file) {
if (post.image_width != 0) {
@@ -79,20 +77,21 @@ function updateThread(posts, total_replies, serverTime) {
}
}
- thread_div.insertBefore(div, last_elem);
- thread_div.setAttribute("data-length",(thread_length + i + 1));
- if (serviceType == 2)
- document.getElementsByTagName("h3")[0].getElementsByTagName("span")[0].innerText = "(" + (thread_length + i + 1) + " respuestas)";
+ if (serviceType == 2) thread_div.appendChild(div);
+ else thread_div.insertBefore(div, document.getElementsByClassName("cut")[0]);
+ 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 (posts.length > 0) {
if (!manual)
refreshMaxTime = 10;
if (!document.hasFocus())
- if (posts.length > 1)
- notif(thread_title, posts.length + ' nuevos mensajes');
- else
- notif(thread_title, 'Un nuevo mensaje');
+ if (posts.length > 1) notif(thread_title, posts.length + ' nuevos mensajes');
+ else notif(thread_title, 'Un nuevo mensaje');
} else {
if (refreshMaxTime <= 60)
refreshMaxTime += 5;
--
cgit v1.2.1-18-gbd029