var lastTime = 0;
var refreshInterval;
var refreshMaxTime = 30;
var refreshTime;
var manual = 0;
var serviceType = 0; // 2 = BBS, 3 = IB
var thread_length = 0;
var thread_lastreply = 0;
var thread_title = "";
var thread_first_length = 0;
var http_request = new XMLHttpRequest();
function checkNew(e) {
e.preventDefault();
manual = 1;
loadJSON();
if (chk.checked) refreshMaxTime = 25;
}
function loadJSON() {
if (chk.checked) stopCounter("...");
if (manual) document.getElementById("counter").innerText = "...";
var data_file;
if (serviceType == 2 || serviceType == 3) {
board = document.getElementsByName("board")[0].value;
parent = document.getElementsByName("parent")[0].value;
data_file =
"/cgi/api/thread?dir=" +
board +
"&id=" +
parent +
"&offset=" +
thread_length +
"&time=" +
lastTime;
} else {
return false;
}
http_request.open("GET", data_file, true);
http_request.send();
}
function updateThread(posts, total_replies, serverTime) {
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");
if (serviceType == 2) div.className = "reply";
else div.className = "replycont";
if (post.email) {
if (post.tripcode)
s_name =
'' +
post.name +
" " +
post.tripcode +
"";
else
s_name =
'' +
post.name +
"";
} else {
if (post.tripcode)
s_name =
'' +
post.name +
" " +
post.tripcode +
"";
else s_name = '' + post.name + "";
}
if (serviceType == 2) {
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 =
'
' + post.message + ""; } else { s_img = ""; s_msg = "
" + post.message + ""; } if (post.IS_DELETED == 0) { div.innerHTML = '
… | ' +
(post.subject
? ' ' + post.subject + ""
: "") +
" " +
s_name +
" " +
'' +
post.timestamp_formatted +
' No.' +
post.id +
' rep ' +
s_img +
s_msg +
" |