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 threadDiv = document.getElementsByClassName("thread")[0]; if (serviceType == 2) { var repliesDiv = threadDiv.getElementsByClassName("replies")[0]; } for (var i = 0; i < posts.length; i++) { post = posts[i]; var num = thread_length + i + 1; var div = document.createElement("div"); div.id = 'p' + post.id; if (serviceType == 2) { div.dataset.n = num; div.className = "reply"; if (post.IS_DELETED > 0) { div.className += " deleted"; } } else { div.className = "replycont"; } var s_name = ''; if (post.email) s_name += '' + post.name + ''; if (post.tripcode) s_name += ' ' + post.tripcode; s_name += ''; if (post.email) s_name += ''; var s_img = ''; if (serviceType == 2) { if (post.file) { s_img = '' + ''; } if (post.IS_DELETED == 1) { div.innerHTML = '
' + post.message + ""; } else { 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 +
" |