Eliminate Index.liveThreadIDs
This commit is contained in:
parent
60b3d447c5
commit
f81c03f5a2
@ -3145,7 +3145,7 @@
|
|||||||
for (threadID in _ref) {
|
for (threadID in _ref) {
|
||||||
thread = _ref[threadID];
|
thread = _ref[threadID];
|
||||||
if (thread.isHidden) {
|
if (thread.isHidden) {
|
||||||
if (_ref1 = thread.ID, __indexOf.call(Index.liveThreadIDs, _ref1) >= 0) {
|
if (_ref1 = thread.ID, __indexOf.call(Index.liveThreadData.keys, _ref1) >= 0) {
|
||||||
hiddenCount++;
|
hiddenCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3265,34 +3265,32 @@
|
|||||||
return Index.buildIndex();
|
return Index.buildIndex();
|
||||||
},
|
},
|
||||||
parseThreadList: function(pages) {
|
parseThreadList: function(pages) {
|
||||||
var data, i, live, page, thread;
|
var i, j, live, page, thread, threads;
|
||||||
Index.threadsNumPerPage = pages[0].threads.length;
|
Index.threadsNumPerPage = pages[0].threads.length;
|
||||||
live = [];
|
live = new SimpleDict();
|
||||||
i = 0;
|
i = 0;
|
||||||
while (page = pages[i++]) {
|
while (page = pages[i++]) {
|
||||||
live = live.concat(page.threads);
|
j = 0;
|
||||||
|
threads = page.threads;
|
||||||
|
while (thread = threads[j++]) {
|
||||||
|
live.push(thread.no, thread);
|
||||||
}
|
}
|
||||||
data = [];
|
|
||||||
i = 0;
|
|
||||||
while (thread = live[i++]) {
|
|
||||||
data.push(thread.no);
|
|
||||||
}
|
}
|
||||||
Index.liveThreadData = live;
|
Index.liveThreadData = live;
|
||||||
Index.liveThreadIDs = data;
|
|
||||||
return g.BOARD.threads.forEach(function(thread) {
|
return g.BOARD.threads.forEach(function(thread) {
|
||||||
var _ref;
|
var _ref;
|
||||||
if (_ref = thread.ID, __indexOf.call(Index.liveThreadIDs, _ref) < 0) {
|
if (_ref = thread.ID, __indexOf.call(Index.liveThreadData.keys, _ref) < 0) {
|
||||||
return thread.collect();
|
return thread.collect();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
buildThreads: function() {
|
buildThreads: function() {
|
||||||
var err, errors, i, liveThreadData, posts, thread, threadData, threadRoot, threads;
|
var errors, posts, threads;
|
||||||
threads = [];
|
threads = [];
|
||||||
posts = [];
|
posts = [];
|
||||||
i = 0;
|
errors = null;
|
||||||
liveThreadData = Index.liveThreadData;
|
Index.liveThreadData.forEach(function(threadData) {
|
||||||
while (threadData = liveThreadData[i]) {
|
var err, thread, threadRoot;
|
||||||
threadRoot = Build.thread(g.BOARD, threadData);
|
threadRoot = Build.thread(g.BOARD, threadData);
|
||||||
if (thread = g.BOARD.threads[threadData.no]) {
|
if (thread = g.BOARD.threads[threadData.no]) {
|
||||||
thread.setPage(Math.floor(i / Index.threadsNumPerPage));
|
thread.setPage(Math.floor(i / Index.threadsNumPerPage));
|
||||||
@ -3304,23 +3302,22 @@
|
|||||||
thread = new Thread(threadData.no, g.BOARD);
|
thread = new Thread(threadData.no, g.BOARD);
|
||||||
threads.push(thread);
|
threads.push(thread);
|
||||||
}
|
}
|
||||||
i++;
|
|
||||||
if (thread.ID in thread.posts) {
|
if (thread.ID in thread.posts) {
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
posts.push(new Post($('.opContainer', threadRoot), thread, g.BOARD));
|
return posts.push(new Post($('.opContainer', threadRoot), thread, g.BOARD));
|
||||||
} catch (_error) {
|
} catch (_error) {
|
||||||
err = _error;
|
err = _error;
|
||||||
if (!errors) {
|
if (!errors) {
|
||||||
errors = [];
|
errors = [];
|
||||||
}
|
}
|
||||||
errors.push({
|
return errors.push({
|
||||||
message: "Parsing of Thread No." + thread + " failed. Thread will be skipped.",
|
message: "Parsing of Thread No." + thread + " failed. Thread will be skipped.",
|
||||||
error: err
|
error: err
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
if (errors) {
|
if (errors) {
|
||||||
Main.handleErrors(errors);
|
Main.handleErrors(errors);
|
||||||
}
|
}
|
||||||
@ -3330,13 +3327,12 @@
|
|||||||
return $.event('IndexRefresh');
|
return $.event('IndexRefresh');
|
||||||
},
|
},
|
||||||
buildReplies: function(thread) {
|
buildReplies: function(thread) {
|
||||||
var data, err, errors, i, lastReplies, node, nodes, post, posts, _i, _len;
|
var data, err, errors, lastReplies, node, nodes, post, posts, _i, _len;
|
||||||
if (!Conf['Show Replies']) {
|
if (!Conf['Show Replies']) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
posts = [];
|
posts = [];
|
||||||
i = Index.liveThreadIDs.indexOf(thread.ID);
|
if (!(lastReplies = Index.liveThreadData[thread.ID].last_replies)) {
|
||||||
if (!(lastReplies = Index.liveThreadData[i].last_replies)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
nodes = [];
|
nodes = [];
|
||||||
@ -3400,16 +3396,20 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
sort: function() {
|
sort: function() {
|
||||||
var i, sortedThreadIDs, sortedThreads, thread, threadID;
|
var i, liveData, sortedThreadIDs, sortedThreads, thread, threadID;
|
||||||
sortedThreads = [];
|
sortedThreads = [];
|
||||||
sortedThreadIDs = [];
|
sortedThreadIDs = [];
|
||||||
|
liveData = [];
|
||||||
|
Index.liveThreadData.forEach(function(data) {
|
||||||
|
return liveData.push(data);
|
||||||
|
});
|
||||||
({
|
({
|
||||||
'bump': function() {
|
'bump': function() {
|
||||||
return sortedThreadIDs = Index.liveThreadIDs;
|
return sortedThreadIDs = Index.liveThreadData.keys;
|
||||||
},
|
},
|
||||||
'lastreply': function() {
|
'lastreply': function() {
|
||||||
var data, i, liveData;
|
var data, i;
|
||||||
liveData = __slice.call(Index.liveThreadData).sort(function(a, b) {
|
liveData.sort(function(a, b) {
|
||||||
var _ref, _ref1;
|
var _ref, _ref1;
|
||||||
if ('last_replies' in a) {
|
if ('last_replies' in a) {
|
||||||
_ref = a.last_replies, a = _ref[_ref.length - 1];
|
_ref = a.last_replies, a = _ref[_ref.length - 1];
|
||||||
@ -3425,13 +3425,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
'birth': function() {
|
'birth': function() {
|
||||||
return sortedThreadIDs = __slice.call(Index.liveThreadIDs).sort(function(a, b) {
|
return sortedThreadIDs = __slice.call(Index.liveThreadData.keys).sort(function(a, b) {
|
||||||
return b - a;
|
return b - a;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
'replycount': function() {
|
'replycount': function() {
|
||||||
var data, i, liveData;
|
var data, i;
|
||||||
liveData = __slice.call(Index.liveThreadData).sort(function(a, b) {
|
liveData.sort(function(a, b) {
|
||||||
return b.replies - a.replies;
|
return b.replies - a.replies;
|
||||||
});
|
});
|
||||||
i = 0;
|
i = 0;
|
||||||
@ -3440,8 +3440,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
'filecount': function() {
|
'filecount': function() {
|
||||||
var data, i, liveData;
|
var data, i;
|
||||||
liveData = __slice.call(Index.liveThreadData).sort(function(a, b) {
|
liveData = [];
|
||||||
|
Index.liveThreadData.forEach(function(data) {
|
||||||
|
return liveData.push(data);
|
||||||
|
});
|
||||||
|
liveData.sort(function(a, b) {
|
||||||
return b.images - a.images;
|
return b.images - a.images;
|
||||||
});
|
});
|
||||||
i = 0;
|
i = 0;
|
||||||
@ -3734,7 +3738,7 @@
|
|||||||
sticky = isSticky ? " <img src=" + staticPath + "sticky" + gifIcon + " title=Sticky class=stickyIcon>" : '';
|
sticky = isSticky ? " <img src=" + staticPath + "sticky" + gifIcon + " title=Sticky class=stickyIcon>" : '';
|
||||||
closed = isClosed ? " <img src=" + staticPath + "closed" + gifIcon + " title=Closed class=closedIcon>" : '';
|
closed = isClosed ? " <img src=" + staticPath + "closed" + gifIcon + " title=Closed class=closedIcon>" : '';
|
||||||
if (isOP && g.VIEW === 'index') {
|
if (isOP && g.VIEW === 'index') {
|
||||||
pageNum = Math.floor(Index.liveThreadIDs.indexOf(postID) / Index.threadsNumPerPage);
|
pageNum = Math.floor(Index.liveThreadData.keys.indexOf(postID) / Index.threadsNumPerPage);
|
||||||
pageIcon = " <span class=page-num title='This thread is on page " + pageNum + " in the original index.'>Page " + pageNum + "</span>";
|
pageIcon = " <span class=page-num title='This thread is on page " + pageNum + " in the original index.'>Page " + pageNum + "</span>";
|
||||||
replyLink = " <span>[<a href='/" + boardID + "/res/" + threadID + "' class=replylink>Reply</a>]</span>";
|
replyLink = " <span>[<a href='/" + boardID + "/res/" + threadID + "' class=replylink>Reply</a>]</span>";
|
||||||
} else {
|
} else {
|
||||||
@ -3800,10 +3804,10 @@
|
|||||||
catalogThread: function(thread) {
|
catalogThread: function(thread) {
|
||||||
var comment, data, fileCount, gifIcon, pageCount, postCount, pp, quotelink, root, spoilerRange, src, staticPath, subject, thumb, _i, _j, _len, _len1, _ref, _ref1;
|
var comment, data, fileCount, gifIcon, pageCount, postCount, pp, quotelink, root, spoilerRange, src, staticPath, subject, thumb, _i, _j, _len, _len1, _ref, _ref1;
|
||||||
staticPath = Build.staticPath, gifIcon = Build.gifIcon;
|
staticPath = Build.staticPath, gifIcon = Build.gifIcon;
|
||||||
data = Index.liveThreadData[Index.liveThreadIDs.indexOf(thread.ID)];
|
data = Index.liveThreadData[thread.ID];
|
||||||
postCount = data.replies + 1;
|
postCount = data.replies + 1;
|
||||||
fileCount = data.images + !!data.ext;
|
fileCount = data.images + !!data.ext;
|
||||||
pageCount = Math.floor(Index.liveThreadIDs.indexOf(thread.ID) / Index.threadsNumPerPage);
|
pageCount = Math.floor(Index.liveThreadData.keys.indexOf(thread.ID) / Index.threadsNumPerPage);
|
||||||
subject = thread.OP.info.subject ? "<div class='subject'>" + thread.OP.info.subject + "</div>" : '';
|
subject = thread.OP.info.subject ? "<div class='subject'>" + thread.OP.info.subject + "</div>" : '';
|
||||||
comment = thread.OP.nodes.comment.innerHTML.replace(/(<br>\s*){2,}/g, '<br>');
|
comment = thread.OP.nodes.comment.innerHTML.replace(/(<br>\s*){2,}/g, '<br>');
|
||||||
root = $.el('div', {
|
root = $.el('div', {
|
||||||
|
|||||||
@ -3204,7 +3204,7 @@
|
|||||||
for (threadID in _ref) {
|
for (threadID in _ref) {
|
||||||
thread = _ref[threadID];
|
thread = _ref[threadID];
|
||||||
if (thread.isHidden) {
|
if (thread.isHidden) {
|
||||||
if (_ref1 = thread.ID, __indexOf.call(Index.liveThreadIDs, _ref1) >= 0) {
|
if (_ref1 = thread.ID, __indexOf.call(Index.liveThreadData.keys, _ref1) >= 0) {
|
||||||
hiddenCount++;
|
hiddenCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3324,34 +3324,32 @@
|
|||||||
return Index.buildIndex();
|
return Index.buildIndex();
|
||||||
},
|
},
|
||||||
parseThreadList: function(pages) {
|
parseThreadList: function(pages) {
|
||||||
var data, i, live, page, thread;
|
var i, j, live, page, thread, threads;
|
||||||
Index.threadsNumPerPage = pages[0].threads.length;
|
Index.threadsNumPerPage = pages[0].threads.length;
|
||||||
live = [];
|
live = new SimpleDict();
|
||||||
i = 0;
|
i = 0;
|
||||||
while (page = pages[i++]) {
|
while (page = pages[i++]) {
|
||||||
live = live.concat(page.threads);
|
j = 0;
|
||||||
|
threads = page.threads;
|
||||||
|
while (thread = threads[j++]) {
|
||||||
|
live.push(thread.no, thread);
|
||||||
}
|
}
|
||||||
data = [];
|
|
||||||
i = 0;
|
|
||||||
while (thread = live[i++]) {
|
|
||||||
data.push(thread.no);
|
|
||||||
}
|
}
|
||||||
Index.liveThreadData = live;
|
Index.liveThreadData = live;
|
||||||
Index.liveThreadIDs = data;
|
|
||||||
return g.BOARD.threads.forEach(function(thread) {
|
return g.BOARD.threads.forEach(function(thread) {
|
||||||
var _ref;
|
var _ref;
|
||||||
if (_ref = thread.ID, __indexOf.call(Index.liveThreadIDs, _ref) < 0) {
|
if (_ref = thread.ID, __indexOf.call(Index.liveThreadData.keys, _ref) < 0) {
|
||||||
return thread.collect();
|
return thread.collect();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
buildThreads: function() {
|
buildThreads: function() {
|
||||||
var err, errors, i, liveThreadData, posts, thread, threadData, threadRoot, threads;
|
var errors, posts, threads;
|
||||||
threads = [];
|
threads = [];
|
||||||
posts = [];
|
posts = [];
|
||||||
i = 0;
|
errors = null;
|
||||||
liveThreadData = Index.liveThreadData;
|
Index.liveThreadData.forEach(function(threadData) {
|
||||||
while (threadData = liveThreadData[i]) {
|
var err, thread, threadRoot;
|
||||||
threadRoot = Build.thread(g.BOARD, threadData);
|
threadRoot = Build.thread(g.BOARD, threadData);
|
||||||
if (thread = g.BOARD.threads[threadData.no]) {
|
if (thread = g.BOARD.threads[threadData.no]) {
|
||||||
thread.setPage(Math.floor(i / Index.threadsNumPerPage));
|
thread.setPage(Math.floor(i / Index.threadsNumPerPage));
|
||||||
@ -3363,23 +3361,22 @@
|
|||||||
thread = new Thread(threadData.no, g.BOARD);
|
thread = new Thread(threadData.no, g.BOARD);
|
||||||
threads.push(thread);
|
threads.push(thread);
|
||||||
}
|
}
|
||||||
i++;
|
|
||||||
if (thread.ID in thread.posts) {
|
if (thread.ID in thread.posts) {
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
posts.push(new Post($('.opContainer', threadRoot), thread, g.BOARD));
|
return posts.push(new Post($('.opContainer', threadRoot), thread, g.BOARD));
|
||||||
} catch (_error) {
|
} catch (_error) {
|
||||||
err = _error;
|
err = _error;
|
||||||
if (!errors) {
|
if (!errors) {
|
||||||
errors = [];
|
errors = [];
|
||||||
}
|
}
|
||||||
errors.push({
|
return errors.push({
|
||||||
message: "Parsing of Thread No." + thread + " failed. Thread will be skipped.",
|
message: "Parsing of Thread No." + thread + " failed. Thread will be skipped.",
|
||||||
error: err
|
error: err
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
if (errors) {
|
if (errors) {
|
||||||
Main.handleErrors(errors);
|
Main.handleErrors(errors);
|
||||||
}
|
}
|
||||||
@ -3389,13 +3386,12 @@
|
|||||||
return $.event('IndexRefresh');
|
return $.event('IndexRefresh');
|
||||||
},
|
},
|
||||||
buildReplies: function(thread) {
|
buildReplies: function(thread) {
|
||||||
var data, err, errors, i, lastReplies, node, nodes, post, posts, _i, _len;
|
var data, err, errors, lastReplies, node, nodes, post, posts, _i, _len;
|
||||||
if (!Conf['Show Replies']) {
|
if (!Conf['Show Replies']) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
posts = [];
|
posts = [];
|
||||||
i = Index.liveThreadIDs.indexOf(thread.ID);
|
if (!(lastReplies = Index.liveThreadData[thread.ID].last_replies)) {
|
||||||
if (!(lastReplies = Index.liveThreadData[i].last_replies)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
nodes = [];
|
nodes = [];
|
||||||
@ -3459,16 +3455,20 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
sort: function() {
|
sort: function() {
|
||||||
var i, sortedThreadIDs, sortedThreads, thread, threadID;
|
var i, liveData, sortedThreadIDs, sortedThreads, thread, threadID;
|
||||||
sortedThreads = [];
|
sortedThreads = [];
|
||||||
sortedThreadIDs = [];
|
sortedThreadIDs = [];
|
||||||
|
liveData = [];
|
||||||
|
Index.liveThreadData.forEach(function(data) {
|
||||||
|
return liveData.push(data);
|
||||||
|
});
|
||||||
({
|
({
|
||||||
'bump': function() {
|
'bump': function() {
|
||||||
return sortedThreadIDs = Index.liveThreadIDs;
|
return sortedThreadIDs = Index.liveThreadData.keys;
|
||||||
},
|
},
|
||||||
'lastreply': function() {
|
'lastreply': function() {
|
||||||
var data, i, liveData;
|
var data, i;
|
||||||
liveData = __slice.call(Index.liveThreadData).sort(function(a, b) {
|
liveData.sort(function(a, b) {
|
||||||
var _ref, _ref1;
|
var _ref, _ref1;
|
||||||
if ('last_replies' in a) {
|
if ('last_replies' in a) {
|
||||||
_ref = a.last_replies, a = _ref[_ref.length - 1];
|
_ref = a.last_replies, a = _ref[_ref.length - 1];
|
||||||
@ -3484,13 +3484,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
'birth': function() {
|
'birth': function() {
|
||||||
return sortedThreadIDs = __slice.call(Index.liveThreadIDs).sort(function(a, b) {
|
return sortedThreadIDs = __slice.call(Index.liveThreadData.keys).sort(function(a, b) {
|
||||||
return b - a;
|
return b - a;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
'replycount': function() {
|
'replycount': function() {
|
||||||
var data, i, liveData;
|
var data, i;
|
||||||
liveData = __slice.call(Index.liveThreadData).sort(function(a, b) {
|
liveData.sort(function(a, b) {
|
||||||
return b.replies - a.replies;
|
return b.replies - a.replies;
|
||||||
});
|
});
|
||||||
i = 0;
|
i = 0;
|
||||||
@ -3499,8 +3499,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
'filecount': function() {
|
'filecount': function() {
|
||||||
var data, i, liveData;
|
var data, i;
|
||||||
liveData = __slice.call(Index.liveThreadData).sort(function(a, b) {
|
liveData = [];
|
||||||
|
Index.liveThreadData.forEach(function(data) {
|
||||||
|
return liveData.push(data);
|
||||||
|
});
|
||||||
|
liveData.sort(function(a, b) {
|
||||||
return b.images - a.images;
|
return b.images - a.images;
|
||||||
});
|
});
|
||||||
i = 0;
|
i = 0;
|
||||||
@ -3793,7 +3797,7 @@
|
|||||||
sticky = isSticky ? " <img src=" + staticPath + "sticky" + gifIcon + " title=Sticky class=stickyIcon>" : '';
|
sticky = isSticky ? " <img src=" + staticPath + "sticky" + gifIcon + " title=Sticky class=stickyIcon>" : '';
|
||||||
closed = isClosed ? " <img src=" + staticPath + "closed" + gifIcon + " title=Closed class=closedIcon>" : '';
|
closed = isClosed ? " <img src=" + staticPath + "closed" + gifIcon + " title=Closed class=closedIcon>" : '';
|
||||||
if (isOP && g.VIEW === 'index') {
|
if (isOP && g.VIEW === 'index') {
|
||||||
pageNum = Math.floor(Index.liveThreadIDs.indexOf(postID) / Index.threadsNumPerPage);
|
pageNum = Math.floor(Index.liveThreadData.keys.indexOf(postID) / Index.threadsNumPerPage);
|
||||||
pageIcon = " <span class=page-num title='This thread is on page " + pageNum + " in the original index.'>Page " + pageNum + "</span>";
|
pageIcon = " <span class=page-num title='This thread is on page " + pageNum + " in the original index.'>Page " + pageNum + "</span>";
|
||||||
replyLink = " <span>[<a href='/" + boardID + "/res/" + threadID + "' class=replylink>Reply</a>]</span>";
|
replyLink = " <span>[<a href='/" + boardID + "/res/" + threadID + "' class=replylink>Reply</a>]</span>";
|
||||||
} else {
|
} else {
|
||||||
@ -3859,10 +3863,10 @@
|
|||||||
catalogThread: function(thread) {
|
catalogThread: function(thread) {
|
||||||
var comment, data, fileCount, gifIcon, pageCount, postCount, pp, quotelink, root, spoilerRange, src, staticPath, subject, thumb, _i, _j, _len, _len1, _ref, _ref1;
|
var comment, data, fileCount, gifIcon, pageCount, postCount, pp, quotelink, root, spoilerRange, src, staticPath, subject, thumb, _i, _j, _len, _len1, _ref, _ref1;
|
||||||
staticPath = Build.staticPath, gifIcon = Build.gifIcon;
|
staticPath = Build.staticPath, gifIcon = Build.gifIcon;
|
||||||
data = Index.liveThreadData[Index.liveThreadIDs.indexOf(thread.ID)];
|
data = Index.liveThreadData[thread.ID];
|
||||||
postCount = data.replies + 1;
|
postCount = data.replies + 1;
|
||||||
fileCount = data.images + !!data.ext;
|
fileCount = data.images + !!data.ext;
|
||||||
pageCount = Math.floor(Index.liveThreadIDs.indexOf(thread.ID) / Index.threadsNumPerPage);
|
pageCount = Math.floor(Index.liveThreadData.keys.indexOf(thread.ID) / Index.threadsNumPerPage);
|
||||||
subject = thread.OP.info.subject ? "<div class='subject'>" + thread.OP.info.subject + "</div>" : '';
|
subject = thread.OP.info.subject ? "<div class='subject'>" + thread.OP.info.subject + "</div>" : '';
|
||||||
comment = thread.OP.nodes.comment.innerHTML.replace(/(<br>\s*){2,}/g, '<br>');
|
comment = thread.OP.nodes.comment.innerHTML.replace(/(<br>\s*){2,}/g, '<br>');
|
||||||
root = $.el('div', {
|
root = $.el('div', {
|
||||||
|
|||||||
@ -181,7 +181,7 @@ Build =
|
|||||||
''
|
''
|
||||||
|
|
||||||
if isOP and g.VIEW is 'index'
|
if isOP and g.VIEW is 'index'
|
||||||
pageNum = Index.liveThreadIDs.indexOf(postID) // Index.threadsNumPerPage
|
pageNum = Index.liveThreadData.keys.indexOf(postID) // Index.threadsNumPerPage
|
||||||
pageIcon = " <span class=page-num title='This thread is on page #{pageNum} in the original index.'>Page #{pageNum}</span>"
|
pageIcon = " <span class=page-num title='This thread is on page #{pageNum} in the original index.'>Page #{pageNum}</span>"
|
||||||
replyLink = " <span>[<a href='/#{boardID}/res/#{threadID}' class=replylink>Reply</a>]</span>"
|
replyLink = " <span>[<a href='/#{boardID}/res/#{threadID}' class=replylink>Reply</a>]</span>"
|
||||||
else
|
else
|
||||||
@ -237,11 +237,11 @@ Build =
|
|||||||
|
|
||||||
catalogThread: (thread) ->
|
catalogThread: (thread) ->
|
||||||
{staticPath, gifIcon} = Build
|
{staticPath, gifIcon} = Build
|
||||||
data = Index.liveThreadData[Index.liveThreadIDs.indexOf thread.ID]
|
data = Index.liveThreadData[thread.ID]
|
||||||
|
|
||||||
postCount = data.replies + 1
|
postCount = data.replies + 1
|
||||||
fileCount = data.images + !!data.ext
|
fileCount = data.images + !!data.ext
|
||||||
pageCount = Index.liveThreadIDs.indexOf(thread.ID) // Index.threadsNumPerPage
|
pageCount = Index.liveThreadData.keys.indexOf(thread.ID) // Index.threadsNumPerPage
|
||||||
|
|
||||||
subject = if thread.OP.info.subject
|
subject = if thread.OP.info.subject
|
||||||
"<div class='subject'>#{thread.OP.info.subject}</div>"
|
"<div class='subject'>#{thread.OP.info.subject}</div>"
|
||||||
|
|||||||
@ -477,7 +477,7 @@ Index =
|
|||||||
updateHideLabel: ->
|
updateHideLabel: ->
|
||||||
hiddenCount = 0
|
hiddenCount = 0
|
||||||
for threadID, thread of g.BOARD.threads when thread.isHidden
|
for threadID, thread of g.BOARD.threads when thread.isHidden
|
||||||
hiddenCount++ if thread.ID in Index.liveThreadIDs
|
hiddenCount++ if thread.ID in Index.liveThreadData.keys
|
||||||
unless hiddenCount
|
unless hiddenCount
|
||||||
Index.hideLabel.hidden = true
|
Index.hideLabel.hidden = true
|
||||||
Index.cb.toggleHiddenThreads() if Index.showHiddenThreads
|
Index.cb.toggleHiddenThreads() if Index.showHiddenThreads
|
||||||
@ -576,28 +576,25 @@ Index =
|
|||||||
parseThreadList: (pages) ->
|
parseThreadList: (pages) ->
|
||||||
Index.threadsNumPerPage = pages[0].threads.length
|
Index.threadsNumPerPage = pages[0].threads.length
|
||||||
|
|
||||||
live = []
|
live = new SimpleDict()
|
||||||
i = 0
|
i = 0
|
||||||
while page = pages[i++]
|
while page = pages[i++]
|
||||||
live = live.concat page.threads
|
j = 0
|
||||||
|
{threads} = page
|
||||||
data = []
|
while thread = threads[j++]
|
||||||
i = 0
|
live.push thread.no, thread
|
||||||
while thread = live[i++]
|
|
||||||
data.push thread.no
|
|
||||||
|
|
||||||
Index.liveThreadData = live
|
Index.liveThreadData = live
|
||||||
Index.liveThreadIDs = data
|
|
||||||
|
|
||||||
g.BOARD.threads.forEach (thread) ->
|
g.BOARD.threads.forEach (thread) ->
|
||||||
thread.collect() unless thread.ID in Index.liveThreadIDs
|
thread.collect() unless thread.ID in Index.liveThreadData.keys
|
||||||
|
|
||||||
buildThreads: ->
|
buildThreads: ->
|
||||||
threads = []
|
threads = []
|
||||||
posts = []
|
posts = []
|
||||||
i = 0
|
errors = null
|
||||||
{liveThreadData} = Index
|
|
||||||
while threadData = liveThreadData[i]
|
Index.liveThreadData.forEach (threadData) ->
|
||||||
threadRoot = Build.thread g.BOARD, threadData
|
threadRoot = Build.thread g.BOARD, threadData
|
||||||
if thread = g.BOARD.threads[threadData.no]
|
if thread = g.BOARD.threads[threadData.no]
|
||||||
thread.setPage i // Index.threadsNumPerPage
|
thread.setPage i // Index.threadsNumPerPage
|
||||||
@ -605,31 +602,34 @@ Index =
|
|||||||
thread.setCount 'file', threadData.images + !!threadData.ext, threadData.imagelimit
|
thread.setCount 'file', threadData.images + !!threadData.ext, threadData.imagelimit
|
||||||
thread.setStatus 'Sticky', !!threadData.sticky
|
thread.setStatus 'Sticky', !!threadData.sticky
|
||||||
thread.setStatus 'Closed', !!threadData.closed
|
thread.setStatus 'Closed', !!threadData.closed
|
||||||
|
|
||||||
else
|
else
|
||||||
thread = new Thread threadData.no, g.BOARD
|
thread = new Thread threadData.no, g.BOARD
|
||||||
threads.push thread
|
threads.push thread
|
||||||
i++
|
|
||||||
continue if thread.ID of thread.posts
|
return if thread.ID of thread.posts
|
||||||
|
|
||||||
try
|
try
|
||||||
posts.push new Post $('.opContainer', threadRoot), thread, g.BOARD
|
posts.push new Post $('.opContainer', threadRoot), thread, g.BOARD
|
||||||
|
|
||||||
catch err
|
catch err
|
||||||
# Skip posts that we failed to parse.
|
# Skip posts that we failed to parse.
|
||||||
errors = [] unless errors
|
errors = [] unless errors
|
||||||
errors.push
|
errors.push
|
||||||
message: "Parsing of Thread No.#{thread} failed. Thread will be skipped."
|
message: "Parsing of Thread No.#{thread} failed. Thread will be skipped."
|
||||||
error: err
|
error: err
|
||||||
Main.handleErrors errors if errors
|
|
||||||
|
|
||||||
|
Main.handleErrors errors if errors
|
||||||
Main.callbackNodes Thread, threads
|
Main.callbackNodes Thread, threads
|
||||||
Main.callbackNodes Post, posts
|
Main.callbackNodes Post, posts
|
||||||
Index.updateHideLabel()
|
Index.updateHideLabel()
|
||||||
|
|
||||||
$.event 'IndexRefresh'
|
$.event 'IndexRefresh'
|
||||||
|
|
||||||
buildReplies: (thread) ->
|
buildReplies: (thread) ->
|
||||||
return unless Conf['Show Replies']
|
return unless Conf['Show Replies']
|
||||||
posts = []
|
posts = []
|
||||||
i = Index.liveThreadIDs.indexOf thread.ID
|
return unless lastReplies = Index.liveThreadData[thread.ID].last_replies
|
||||||
return unless lastReplies = Index.liveThreadData[i].last_replies
|
|
||||||
nodes = []
|
nodes = []
|
||||||
for data in lastReplies
|
for data in lastReplies
|
||||||
if post = thread.posts[data.no]
|
if post = thread.posts[data.no]
|
||||||
@ -676,11 +676,14 @@ Index =
|
|||||||
sortedThreads = []
|
sortedThreads = []
|
||||||
sortedThreadIDs = []
|
sortedThreadIDs = []
|
||||||
|
|
||||||
|
liveData = []
|
||||||
|
Index.liveThreadData.forEach (data) -> liveData.push data
|
||||||
|
|
||||||
{
|
{
|
||||||
'bump': ->
|
'bump': ->
|
||||||
sortedThreadIDs = Index.liveThreadIDs
|
sortedThreadIDs = Index.liveThreadData.keys
|
||||||
'lastreply': ->
|
'lastreply': ->
|
||||||
liveData = [Index.liveThreadData...].sort (a, b) ->
|
liveData.sort (a, b) ->
|
||||||
[..., a] = a.last_replies if 'last_replies' of a
|
[..., a] = a.last_replies if 'last_replies' of a
|
||||||
[..., b] = b.last_replies if 'last_replies' of b
|
[..., b] = b.last_replies if 'last_replies' of b
|
||||||
b.no - a.no
|
b.no - a.no
|
||||||
@ -689,15 +692,17 @@ Index =
|
|||||||
sortedThreadIDs.push data.no
|
sortedThreadIDs.push data.no
|
||||||
return
|
return
|
||||||
'birth': ->
|
'birth': ->
|
||||||
sortedThreadIDs = [Index.liveThreadIDs...].sort (a, b) -> b - a
|
sortedThreadIDs = [Index.liveThreadData.keys...].sort (a, b) -> b - a
|
||||||
'replycount': ->
|
'replycount': ->
|
||||||
liveData = [Index.liveThreadData...].sort((a, b) -> b.replies - a.replies)
|
liveData.sort (a, b) -> b.replies - a.replies
|
||||||
i = 0
|
i = 0
|
||||||
while data = liveData[i++]
|
while data = liveData[i++]
|
||||||
sortedThreadIDs.push data.no
|
sortedThreadIDs.push data.no
|
||||||
return
|
return
|
||||||
'filecount': ->
|
'filecount': ->
|
||||||
liveData = [Index.liveThreadData...].sort((a, b) -> b.images - a.images)
|
liveData = []
|
||||||
|
Index.liveThreadData.forEach (data) -> liveData.push data
|
||||||
|
liveData.sort (a, b) -> b.images - a.images
|
||||||
i = 0
|
i = 0
|
||||||
while data = liveData[i++]
|
while data = liveData[i++]
|
||||||
sortedThreadIDs.push data.no
|
sortedThreadIDs.push data.no
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user