From 95dfe14528663923ca2a88ec928f1d8d9df2402b Mon Sep 17 00:00:00 2001
From: bai
Date: Fri, 29 Mar 2019 02:14:43 +0000
Subject: Init
---
static/js/autorefresh.js | 275 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 275 insertions(+)
create mode 100644 static/js/autorefresh.js
(limited to 'static/js/autorefresh.js')
diff --git a/static/js/autorefresh.js b/static/js/autorefresh.js
new file mode 100644
index 0000000..0ed3e06
--- /dev/null
+++ b/static/js/autorefresh.js
@@ -0,0 +1,275 @@
+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) {
+ 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 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 + ' |