More of a proof of concept than anything. May revert?
This commit is contained in:
parent
c32390c437
commit
6095a97921
@ -1523,19 +1523,40 @@
|
|||||||
this.length = 0;
|
this.length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
RandomAccessList.prototype.push = function(item) {
|
RandomAccessList.prototype.push = function(data) {
|
||||||
var ID, last;
|
var ID, item, last;
|
||||||
ID = item.ID;
|
ID = data.ID;
|
||||||
|
ID || (ID = data.id);
|
||||||
if (this[ID]) {
|
if (this[ID]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
last = this.last;
|
last = this.last;
|
||||||
|
this[ID] = item = {
|
||||||
|
prev: last,
|
||||||
|
next: null,
|
||||||
|
data: data,
|
||||||
|
ID: ID
|
||||||
|
};
|
||||||
item.prev = last;
|
item.prev = last;
|
||||||
this[ID] = item;
|
|
||||||
this.last = last ? last.next = item : this.first = item;
|
this.last = last ? last.next = item : this.first = item;
|
||||||
return this.length++;
|
return this.length++;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
RandomAccessList.prototype.before = function(root, item) {
|
||||||
|
var prev;
|
||||||
|
if (item.next === root) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.rmi(item);
|
||||||
|
prev = root.prev;
|
||||||
|
root.prev = item;
|
||||||
|
item.next = root;
|
||||||
|
item.prev = prev;
|
||||||
|
if (prev) {
|
||||||
|
return prev.next = item;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
RandomAccessList.prototype.after = function(root, item) {
|
RandomAccessList.prototype.after = function(root, item) {
|
||||||
var next;
|
var next;
|
||||||
if (item.prev === root) {
|
if (item.prev === root) {
|
||||||
@ -2360,7 +2381,7 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
scroll: $.debounce(100, function() {
|
scroll: $.debounce(100, function() {
|
||||||
var nodes, nodesPerPage, offset, pageNum;
|
var nodes, pageNum;
|
||||||
if (Index.req || Conf['Index Mode'] !== 'infinite' || (doc.scrollTop <= doc.scrollHeight - (300 + window.innerHeight)) || g.VIEW === 'thread') {
|
if (Index.req || Conf['Index Mode'] !== 'infinite' || (doc.scrollTop <= doc.scrollHeight - (300 + window.innerHeight)) || g.VIEW === 'thread') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2371,9 +2392,7 @@
|
|||||||
if (pageNum >= Index.pagesNum) {
|
if (pageNum >= Index.pagesNum) {
|
||||||
return Index.endNotice();
|
return Index.endNotice();
|
||||||
}
|
}
|
||||||
nodesPerPage = Index.threadsNumPerPage;
|
nodes = Index.buildSinglePage(pageNum);
|
||||||
offset = nodesPerPage * pageNum;
|
|
||||||
nodes = Index.sortedNodes.slice(offset, offset + nodesPerPage);
|
|
||||||
if (Conf['Show Replies']) {
|
if (Conf['Show Replies']) {
|
||||||
Index.buildReplies(nodes);
|
Index.buildReplies(nodes);
|
||||||
}
|
}
|
||||||
@ -2719,7 +2738,7 @@
|
|||||||
return Main.callbackNodes(Post, posts);
|
return Main.callbackNodes(Post, posts);
|
||||||
},
|
},
|
||||||
sort: function() {
|
sort: function() {
|
||||||
var cnd, fn, i, item, items, nodes, sortedThreadIDs, threadID, _i, _len;
|
var cnd, fn, i, item, items, node, nodes, sortedThreadIDs, threadID, _i, _j, _len, _len1;
|
||||||
sortedThreadIDs = {
|
sortedThreadIDs = {
|
||||||
lastreply: __slice.call(Index.liveThreadData).sort(function(a, b) {
|
lastreply: __slice.call(Index.liveThreadData).sort(function(a, b) {
|
||||||
if ('last_replies' in a) {
|
if ('last_replies' in a) {
|
||||||
@ -2747,14 +2766,18 @@
|
|||||||
return data.no;
|
return data.no;
|
||||||
})
|
})
|
||||||
}[Conf['Index Sort']];
|
}[Conf['Index Sort']];
|
||||||
Index.sortedNodes = [];
|
Index.sortedNodes = new RandomAccessList;
|
||||||
nodes = Index.nodes;
|
nodes = Index.nodes;
|
||||||
for (_i = 0, _len = sortedThreadIDs.length; _i < _len; _i++) {
|
for (_i = 0, _len = sortedThreadIDs.length; _i < _len; _i++) {
|
||||||
threadID = sortedThreadIDs[_i];
|
threadID = sortedThreadIDs[_i];
|
||||||
Index.sortedNodes.push(nodes[Index.liveThreadIDs.indexOf(threadID)]);
|
Index.sortedNodes.push(nodes[Index.liveThreadIDs.indexOf(threadID)]);
|
||||||
}
|
}
|
||||||
if (Index.isSearching && (nodes = Index.querySearch(Index.searchInput.value))) {
|
if (Index.isSearching && (nodes = Index.querySearch(Index.searchInput.value))) {
|
||||||
Index.sortedNodes = nodes;
|
Index.sortedNodes = new RandomAccessList;
|
||||||
|
for (_j = 0, _len1 = nodes.length; _j < _len1; _j++) {
|
||||||
|
node = nodes[_j];
|
||||||
|
Index.sortedNodes.push(node);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
items = [
|
items = [
|
||||||
{
|
{
|
||||||
@ -2783,25 +2806,36 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
sortOnTop: function(match) {
|
sortOnTop: function(match) {
|
||||||
var i, offset, threadRoot, _i, _len, _ref;
|
var j, offset, sortedNodes, target, threadRoot;
|
||||||
offset = 0;
|
offset = 0;
|
||||||
_ref = Index.sortedNodes;
|
sortedNodes = Index.sortedNodes;
|
||||||
for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
|
threadRoot = Index.sortedNodes.first;
|
||||||
threadRoot = _ref[i];
|
while (threadRoot) {
|
||||||
if (match(Get.threadFromRoot(threadRoot))) {
|
if (match(Get.threadFromRoot(threadRoot.data))) {
|
||||||
Index.sortedNodes.splice(offset++, 0, Index.sortedNodes.splice(i, 1)[0]);
|
target = Index.sortedNodes.first;
|
||||||
|
j = 0;
|
||||||
|
while (j++ < offset) {
|
||||||
|
target = target.next;
|
||||||
}
|
}
|
||||||
|
if (threadRoot !== target) {
|
||||||
|
offset++;
|
||||||
|
sortedNodes.before(target, threadRoot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
threadRoot = threadRoot.next;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
buildIndex: function() {
|
buildIndex: function() {
|
||||||
var nodes, nodesPerPage, offset, pageNum;
|
var nodes, target;
|
||||||
if (Conf['Index Mode'] !== 'all pages') {
|
if (Conf['Index Mode'] !== 'all pages') {
|
||||||
pageNum = Index.getCurrentPage();
|
nodes = Index.buildSinglePage(Index.getCurrentPage());
|
||||||
nodesPerPage = Index.threadsNumPerPage;
|
|
||||||
offset = nodesPerPage * pageNum;
|
|
||||||
nodes = Index.sortedNodes.slice(offset, offset + nodesPerPage);
|
|
||||||
} else {
|
} else {
|
||||||
nodes = Index.sortedNodes;
|
nodes = [];
|
||||||
|
target = Index.sortedNodes.first;
|
||||||
|
while (target) {
|
||||||
|
nodes.push(target.data);
|
||||||
|
target = target.next;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$.rmAll(Index.root);
|
$.rmAll(Index.root);
|
||||||
$.rmAll(Header.hover);
|
$.rmAll(Header.hover);
|
||||||
@ -2810,6 +2844,22 @@
|
|||||||
}
|
}
|
||||||
return Index.buildStructure(nodes);
|
return Index.buildStructure(nodes);
|
||||||
},
|
},
|
||||||
|
buildSinglePage: function(pageNum) {
|
||||||
|
var end, i, nodes, nodesPerPage, offset, target;
|
||||||
|
nodes = [];
|
||||||
|
nodesPerPage = Index.threadsNumPerPage;
|
||||||
|
offset = nodesPerPage * pageNum;
|
||||||
|
end = offset + nodesPerPage;
|
||||||
|
target = Index.sortedNodes.first;
|
||||||
|
i = 0;
|
||||||
|
while (i <= end) {
|
||||||
|
if (offset <= i++) {
|
||||||
|
nodes.push(target.data);
|
||||||
|
}
|
||||||
|
target = target.next;
|
||||||
|
}
|
||||||
|
return nodes;
|
||||||
|
},
|
||||||
buildStructure: function(nodes) {
|
buildStructure: function(nodes) {
|
||||||
var hr, i, node, result, _i, _len, _ref;
|
var hr, i, node, result, _i, _len, _ref;
|
||||||
result = $.frag();
|
result = $.frag();
|
||||||
@ -2866,16 +2916,17 @@
|
|||||||
return Index.search(keywords);
|
return Index.search(keywords);
|
||||||
},
|
},
|
||||||
search: function(keywords) {
|
search: function(keywords) {
|
||||||
var threadRoot, _i, _len, _ref, _results;
|
var data, found, target;
|
||||||
_ref = Index.sortedNodes;
|
found = [];
|
||||||
_results = [];
|
target = Index.sortedNodes.first;
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
while (target) {
|
||||||
threadRoot = _ref[_i];
|
data = target.data;
|
||||||
if (Index.searchMatch(Get.threadFromRoot(threadRoot), keywords)) {
|
if (Index.searchMatch(Get.threadFromRoot(data), keywords)) {
|
||||||
_results.push(threadRoot);
|
found.push(data);
|
||||||
}
|
}
|
||||||
|
target = target.next;
|
||||||
}
|
}
|
||||||
return _results;
|
return found;
|
||||||
},
|
},
|
||||||
searchMatch: function(thread, keywords) {
|
searchMatch: function(thread, keywords) {
|
||||||
var file, info, key, keyword, text, _i, _j, _len, _len1, _ref, _ref1;
|
var file, info, key, keyword, text, _i, _j, _len, _len1, _ref, _ref1;
|
||||||
@ -9904,10 +9955,10 @@
|
|||||||
if (!(post.prev || post.next)) {
|
if (!(post.prev || post.next)) {
|
||||||
Unread.posts.push(post);
|
Unread.posts.push(post);
|
||||||
}
|
}
|
||||||
Unread.addPostQuotingYou(post);
|
Unread.addPostQuotingYou(post.data);
|
||||||
}
|
}
|
||||||
if (Conf['Unread Line']) {
|
if (Conf['Unread Line']) {
|
||||||
Unread.setLine((_ref = Unread.posts.first, __indexOf.call(posts, _ref) >= 0));
|
Unread.setLine((_ref = Unread.posts.first.data, __indexOf.call(posts, _ref) >= 0));
|
||||||
}
|
}
|
||||||
Unread.read();
|
Unread.read();
|
||||||
return Unread.update();
|
return Unread.update();
|
||||||
@ -9989,13 +10040,13 @@
|
|||||||
height = doc.clientHeight;
|
height = doc.clientHeight;
|
||||||
posts = Unread.posts;
|
posts = Unread.posts;
|
||||||
while (post = posts.first) {
|
while (post = posts.first) {
|
||||||
if (!(Header.getBottomOf(post.nodes.root) > -1)) {
|
if (!(Header.getBottomOf(post.data.nodes.root) > -1)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ID = post.ID;
|
ID = post.ID;
|
||||||
posts.rm(ID);
|
posts.rm(ID);
|
||||||
if (Conf['Mark Quotes of You'] && post.info.yours) {
|
if (Conf['Mark Quotes of You'] && post.info.yours) {
|
||||||
QuoteYou.lastRead = post.nodes.root;
|
QuoteYou.lastRead = post.data.nodes.root;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!ID) {
|
if (!ID) {
|
||||||
|
|||||||
@ -1529,19 +1529,40 @@
|
|||||||
this.length = 0;
|
this.length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
RandomAccessList.prototype.push = function(item) {
|
RandomAccessList.prototype.push = function(data) {
|
||||||
var ID, last;
|
var ID, item, last;
|
||||||
ID = item.ID;
|
ID = data.ID;
|
||||||
|
ID || (ID = data.id);
|
||||||
if (this[ID]) {
|
if (this[ID]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
last = this.last;
|
last = this.last;
|
||||||
|
this[ID] = item = {
|
||||||
|
prev: last,
|
||||||
|
next: null,
|
||||||
|
data: data,
|
||||||
|
ID: ID
|
||||||
|
};
|
||||||
item.prev = last;
|
item.prev = last;
|
||||||
this[ID] = item;
|
|
||||||
this.last = last ? last.next = item : this.first = item;
|
this.last = last ? last.next = item : this.first = item;
|
||||||
return this.length++;
|
return this.length++;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
RandomAccessList.prototype.before = function(root, item) {
|
||||||
|
var prev;
|
||||||
|
if (item.next === root) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.rmi(item);
|
||||||
|
prev = root.prev;
|
||||||
|
root.prev = item;
|
||||||
|
item.next = root;
|
||||||
|
item.prev = prev;
|
||||||
|
if (prev) {
|
||||||
|
return prev.next = item;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
RandomAccessList.prototype.after = function(root, item) {
|
RandomAccessList.prototype.after = function(root, item) {
|
||||||
var next;
|
var next;
|
||||||
if (item.prev === root) {
|
if (item.prev === root) {
|
||||||
@ -2370,7 +2391,7 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
scroll: $.debounce(100, function() {
|
scroll: $.debounce(100, function() {
|
||||||
var nodes, nodesPerPage, offset, pageNum;
|
var nodes, pageNum;
|
||||||
if (Index.req || Conf['Index Mode'] !== 'infinite' || (doc.scrollTop <= doc.scrollHeight - (300 + window.innerHeight)) || g.VIEW === 'thread') {
|
if (Index.req || Conf['Index Mode'] !== 'infinite' || (doc.scrollTop <= doc.scrollHeight - (300 + window.innerHeight)) || g.VIEW === 'thread') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2381,9 +2402,7 @@
|
|||||||
if (pageNum >= Index.pagesNum) {
|
if (pageNum >= Index.pagesNum) {
|
||||||
return Index.endNotice();
|
return Index.endNotice();
|
||||||
}
|
}
|
||||||
nodesPerPage = Index.threadsNumPerPage;
|
nodes = Index.buildSinglePage(pageNum);
|
||||||
offset = nodesPerPage * pageNum;
|
|
||||||
nodes = Index.sortedNodes.slice(offset, offset + nodesPerPage);
|
|
||||||
if (Conf['Show Replies']) {
|
if (Conf['Show Replies']) {
|
||||||
Index.buildReplies(nodes);
|
Index.buildReplies(nodes);
|
||||||
}
|
}
|
||||||
@ -2729,7 +2748,7 @@
|
|||||||
return Main.callbackNodes(Post, posts);
|
return Main.callbackNodes(Post, posts);
|
||||||
},
|
},
|
||||||
sort: function() {
|
sort: function() {
|
||||||
var cnd, fn, i, item, items, nodes, sortedThreadIDs, threadID, _i, _len;
|
var cnd, fn, i, item, items, node, nodes, sortedThreadIDs, threadID, _i, _j, _len, _len1;
|
||||||
sortedThreadIDs = {
|
sortedThreadIDs = {
|
||||||
lastreply: __slice.call(Index.liveThreadData).sort(function(a, b) {
|
lastreply: __slice.call(Index.liveThreadData).sort(function(a, b) {
|
||||||
if ('last_replies' in a) {
|
if ('last_replies' in a) {
|
||||||
@ -2757,14 +2776,18 @@
|
|||||||
return data.no;
|
return data.no;
|
||||||
})
|
})
|
||||||
}[Conf['Index Sort']];
|
}[Conf['Index Sort']];
|
||||||
Index.sortedNodes = [];
|
Index.sortedNodes = new RandomAccessList;
|
||||||
nodes = Index.nodes;
|
nodes = Index.nodes;
|
||||||
for (_i = 0, _len = sortedThreadIDs.length; _i < _len; _i++) {
|
for (_i = 0, _len = sortedThreadIDs.length; _i < _len; _i++) {
|
||||||
threadID = sortedThreadIDs[_i];
|
threadID = sortedThreadIDs[_i];
|
||||||
Index.sortedNodes.push(nodes[Index.liveThreadIDs.indexOf(threadID)]);
|
Index.sortedNodes.push(nodes[Index.liveThreadIDs.indexOf(threadID)]);
|
||||||
}
|
}
|
||||||
if (Index.isSearching && (nodes = Index.querySearch(Index.searchInput.value))) {
|
if (Index.isSearching && (nodes = Index.querySearch(Index.searchInput.value))) {
|
||||||
Index.sortedNodes = nodes;
|
Index.sortedNodes = new RandomAccessList;
|
||||||
|
for (_j = 0, _len1 = nodes.length; _j < _len1; _j++) {
|
||||||
|
node = nodes[_j];
|
||||||
|
Index.sortedNodes.push(node);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
items = [
|
items = [
|
||||||
{
|
{
|
||||||
@ -2793,25 +2816,36 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
sortOnTop: function(match) {
|
sortOnTop: function(match) {
|
||||||
var i, offset, threadRoot, _i, _len, _ref;
|
var j, offset, sortedNodes, target, threadRoot;
|
||||||
offset = 0;
|
offset = 0;
|
||||||
_ref = Index.sortedNodes;
|
sortedNodes = Index.sortedNodes;
|
||||||
for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
|
threadRoot = Index.sortedNodes.first;
|
||||||
threadRoot = _ref[i];
|
while (threadRoot) {
|
||||||
if (match(Get.threadFromRoot(threadRoot))) {
|
if (match(Get.threadFromRoot(threadRoot.data))) {
|
||||||
Index.sortedNodes.splice(offset++, 0, Index.sortedNodes.splice(i, 1)[0]);
|
target = Index.sortedNodes.first;
|
||||||
|
j = 0;
|
||||||
|
while (j++ < offset) {
|
||||||
|
target = target.next;
|
||||||
}
|
}
|
||||||
|
if (threadRoot !== target) {
|
||||||
|
offset++;
|
||||||
|
sortedNodes.before(target, threadRoot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
threadRoot = threadRoot.next;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
buildIndex: function() {
|
buildIndex: function() {
|
||||||
var nodes, nodesPerPage, offset, pageNum;
|
var nodes, target;
|
||||||
if (Conf['Index Mode'] !== 'all pages') {
|
if (Conf['Index Mode'] !== 'all pages') {
|
||||||
pageNum = Index.getCurrentPage();
|
nodes = Index.buildSinglePage(Index.getCurrentPage());
|
||||||
nodesPerPage = Index.threadsNumPerPage;
|
|
||||||
offset = nodesPerPage * pageNum;
|
|
||||||
nodes = Index.sortedNodes.slice(offset, offset + nodesPerPage);
|
|
||||||
} else {
|
} else {
|
||||||
nodes = Index.sortedNodes;
|
nodes = [];
|
||||||
|
target = Index.sortedNodes.first;
|
||||||
|
while (target) {
|
||||||
|
nodes.push(target.data);
|
||||||
|
target = target.next;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$.rmAll(Index.root);
|
$.rmAll(Index.root);
|
||||||
$.rmAll(Header.hover);
|
$.rmAll(Header.hover);
|
||||||
@ -2820,6 +2854,22 @@
|
|||||||
}
|
}
|
||||||
return Index.buildStructure(nodes);
|
return Index.buildStructure(nodes);
|
||||||
},
|
},
|
||||||
|
buildSinglePage: function(pageNum) {
|
||||||
|
var end, i, nodes, nodesPerPage, offset, target;
|
||||||
|
nodes = [];
|
||||||
|
nodesPerPage = Index.threadsNumPerPage;
|
||||||
|
offset = nodesPerPage * pageNum;
|
||||||
|
end = offset + nodesPerPage;
|
||||||
|
target = Index.sortedNodes.first;
|
||||||
|
i = 0;
|
||||||
|
while (i <= end) {
|
||||||
|
if (offset <= i++) {
|
||||||
|
nodes.push(target.data);
|
||||||
|
}
|
||||||
|
target = target.next;
|
||||||
|
}
|
||||||
|
return nodes;
|
||||||
|
},
|
||||||
buildStructure: function(nodes) {
|
buildStructure: function(nodes) {
|
||||||
var hr, i, node, result, _i, _len, _ref;
|
var hr, i, node, result, _i, _len, _ref;
|
||||||
result = $.frag();
|
result = $.frag();
|
||||||
@ -2876,16 +2926,17 @@
|
|||||||
return Index.search(keywords);
|
return Index.search(keywords);
|
||||||
},
|
},
|
||||||
search: function(keywords) {
|
search: function(keywords) {
|
||||||
var threadRoot, _i, _len, _ref, _results;
|
var data, found, target;
|
||||||
_ref = Index.sortedNodes;
|
found = [];
|
||||||
_results = [];
|
target = Index.sortedNodes.first;
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
while (target) {
|
||||||
threadRoot = _ref[_i];
|
data = target.data;
|
||||||
if (Index.searchMatch(Get.threadFromRoot(threadRoot), keywords)) {
|
if (Index.searchMatch(Get.threadFromRoot(data), keywords)) {
|
||||||
_results.push(threadRoot);
|
found.push(data);
|
||||||
}
|
}
|
||||||
|
target = target.next;
|
||||||
}
|
}
|
||||||
return _results;
|
return found;
|
||||||
},
|
},
|
||||||
searchMatch: function(thread, keywords) {
|
searchMatch: function(thread, keywords) {
|
||||||
var file, info, key, keyword, text, _i, _j, _len, _len1, _ref, _ref1;
|
var file, info, key, keyword, text, _i, _j, _len, _len1, _ref, _ref1;
|
||||||
@ -9887,10 +9938,10 @@
|
|||||||
if (!(post.prev || post.next)) {
|
if (!(post.prev || post.next)) {
|
||||||
Unread.posts.push(post);
|
Unread.posts.push(post);
|
||||||
}
|
}
|
||||||
Unread.addPostQuotingYou(post);
|
Unread.addPostQuotingYou(post.data);
|
||||||
}
|
}
|
||||||
if (Conf['Unread Line']) {
|
if (Conf['Unread Line']) {
|
||||||
Unread.setLine((_ref = Unread.posts.first, __indexOf.call(posts, _ref) >= 0));
|
Unread.setLine((_ref = Unread.posts.first.data, __indexOf.call(posts, _ref) >= 0));
|
||||||
}
|
}
|
||||||
Unread.read();
|
Unread.read();
|
||||||
return Unread.update();
|
return Unread.update();
|
||||||
@ -9972,13 +10023,13 @@
|
|||||||
height = doc.clientHeight;
|
height = doc.clientHeight;
|
||||||
posts = Unread.posts;
|
posts = Unread.posts;
|
||||||
while (post = posts.first) {
|
while (post = posts.first) {
|
||||||
if (!(Header.getBottomOf(post.nodes.root) > -1)) {
|
if (!(Header.getBottomOf(post.data.nodes.root) > -1)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ID = post.ID;
|
ID = post.ID;
|
||||||
posts.rm(ID);
|
posts.rm(ID);
|
||||||
if (Conf['Mark Quotes of You'] && post.info.yours) {
|
if (Conf['Mark Quotes of You'] && post.info.yours) {
|
||||||
QuoteYou.lastRead = post.nodes.root;
|
QuoteYou.lastRead = post.data.nodes.root;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!ID) {
|
if (!ID) {
|
||||||
|
|||||||
@ -119,10 +119,7 @@ Index =
|
|||||||
pageNum = Index.pageNum++
|
pageNum = Index.pageNum++
|
||||||
return Index.endNotice() if pageNum >= Index.pagesNum
|
return Index.endNotice() if pageNum >= Index.pagesNum
|
||||||
|
|
||||||
nodesPerPage = Index.threadsNumPerPage
|
nodes = Index.buildSinglePage pageNum
|
||||||
offset = nodesPerPage * pageNum
|
|
||||||
nodes = Index.sortedNodes[offset ... offset + nodesPerPage]
|
|
||||||
|
|
||||||
Index.buildReplies nodes if Conf['Show Replies']
|
Index.buildReplies nodes if Conf['Show Replies']
|
||||||
Index.buildStructure nodes
|
Index.buildStructure nodes
|
||||||
Index.setPage pageNum
|
Index.setPage pageNum
|
||||||
@ -390,12 +387,13 @@ Index =
|
|||||||
replycount: [Index.liveThreadData...].sort((a, b) -> b.replies - a.replies).map (data) -> data.no
|
replycount: [Index.liveThreadData...].sort((a, b) -> b.replies - a.replies).map (data) -> data.no
|
||||||
filecount: [Index.liveThreadData...].sort((a, b) -> b.images - a.images ).map (data) -> data.no
|
filecount: [Index.liveThreadData...].sort((a, b) -> b.images - a.images ).map (data) -> data.no
|
||||||
}[Conf['Index Sort']]
|
}[Conf['Index Sort']]
|
||||||
Index.sortedNodes = []
|
Index.sortedNodes = new RandomAccessList
|
||||||
{nodes} = Index
|
{nodes} = Index
|
||||||
for threadID in sortedThreadIDs
|
for threadID in sortedThreadIDs
|
||||||
Index.sortedNodes.push nodes[Index.liveThreadIDs.indexOf(threadID)]
|
Index.sortedNodes.push nodes[Index.liveThreadIDs.indexOf(threadID)]
|
||||||
if Index.isSearching and nodes = Index.querySearch(Index.searchInput.value)
|
if Index.isSearching and nodes = Index.querySearch(Index.searchInput.value)
|
||||||
Index.sortedNodes = nodes
|
Index.sortedNodes = new RandomAccessList
|
||||||
|
Index.sortedNodes.push node for node in nodes
|
||||||
items = [
|
items = [
|
||||||
# Sticky threads
|
# Sticky threads
|
||||||
fn: (thread) -> thread.isSticky
|
fn: (thread) -> thread.isSticky
|
||||||
@ -415,23 +413,47 @@ Index =
|
|||||||
|
|
||||||
sortOnTop: (match) ->
|
sortOnTop: (match) ->
|
||||||
offset = 0
|
offset = 0
|
||||||
for threadRoot, i in Index.sortedNodes when match Get.threadFromRoot threadRoot
|
{sortedNodes} = Index
|
||||||
Index.sortedNodes.splice offset++, 0, Index.sortedNodes.splice(i, 1)[0]
|
threadRoot = Index.sortedNodes.first
|
||||||
|
while threadRoot
|
||||||
|
if match Get.threadFromRoot threadRoot.data
|
||||||
|
target = Index.sortedNodes.first
|
||||||
|
j = 0
|
||||||
|
while j++ < offset
|
||||||
|
target = target.next
|
||||||
|
unless threadRoot is target
|
||||||
|
offset++
|
||||||
|
sortedNodes.before target, threadRoot
|
||||||
|
threadRoot = threadRoot.next
|
||||||
return
|
return
|
||||||
|
|
||||||
buildIndex: ->
|
buildIndex: ->
|
||||||
if Conf['Index Mode'] isnt 'all pages'
|
if Conf['Index Mode'] isnt 'all pages'
|
||||||
pageNum = Index.getCurrentPage()
|
nodes = Index.buildSinglePage Index.getCurrentPage()
|
||||||
nodesPerPage = Index.threadsNumPerPage
|
|
||||||
offset = nodesPerPage * pageNum
|
|
||||||
nodes = Index.sortedNodes[offset ... offset + nodesPerPage]
|
|
||||||
else
|
else
|
||||||
nodes = Index.sortedNodes
|
nodes = []
|
||||||
|
target = Index.sortedNodes.first
|
||||||
|
while target
|
||||||
|
nodes.push target.data
|
||||||
|
target = target.next
|
||||||
$.rmAll Index.root
|
$.rmAll Index.root
|
||||||
$.rmAll Header.hover
|
$.rmAll Header.hover
|
||||||
Index.buildReplies nodes if Conf['Show Replies']
|
Index.buildReplies nodes if Conf['Show Replies']
|
||||||
Index.buildStructure nodes
|
Index.buildStructure nodes
|
||||||
|
|
||||||
|
buildSinglePage: (pageNum) ->
|
||||||
|
nodes = []
|
||||||
|
nodesPerPage = Index.threadsNumPerPage
|
||||||
|
offset = nodesPerPage * pageNum
|
||||||
|
end = offset + nodesPerPage
|
||||||
|
target = Index.sortedNodes.first
|
||||||
|
i = 0
|
||||||
|
while i <= end
|
||||||
|
if offset <= i++
|
||||||
|
nodes.push target.data
|
||||||
|
target = target.next
|
||||||
|
nodes
|
||||||
|
|
||||||
buildStructure: (nodes) ->
|
buildStructure: (nodes) ->
|
||||||
result = $.frag()
|
result = $.frag()
|
||||||
i = 0
|
i = 0
|
||||||
@ -478,7 +500,15 @@ Index =
|
|||||||
return unless keywords = query.toLowerCase().match /\S+/g
|
return unless keywords = query.toLowerCase().match /\S+/g
|
||||||
Index.search keywords
|
Index.search keywords
|
||||||
|
|
||||||
search: (keywords) -> threadRoot for threadRoot in Index.sortedNodes when Index.searchMatch Get.threadFromRoot(threadRoot), keywords
|
search: (keywords) ->
|
||||||
|
found = []
|
||||||
|
target = Index.sortedNodes.first
|
||||||
|
while target
|
||||||
|
{data} = target
|
||||||
|
if Index.searchMatch Get.threadFromRoot(data), keywords
|
||||||
|
found.push data
|
||||||
|
target = target.next
|
||||||
|
found
|
||||||
|
|
||||||
searchMatch: (thread, keywords) ->
|
searchMatch: (thread, keywords) ->
|
||||||
{info, file} = thread.OP
|
{info, file} = thread.OP
|
||||||
|
|||||||
@ -2,18 +2,34 @@ class RandomAccessList
|
|||||||
constructor: ->
|
constructor: ->
|
||||||
@length = 0
|
@length = 0
|
||||||
|
|
||||||
push: (item) ->
|
push: (data) ->
|
||||||
{ID} = item
|
{ID} = data
|
||||||
|
ID or= data.id
|
||||||
return if @[ID]
|
return if @[ID]
|
||||||
{last} = @
|
{last} = @
|
||||||
|
@[ID] = item =
|
||||||
|
prev: last
|
||||||
|
next: null
|
||||||
|
data: data
|
||||||
|
ID: ID
|
||||||
item.prev = last
|
item.prev = last
|
||||||
@[ID] = item
|
|
||||||
@last = if last
|
@last = if last
|
||||||
last.next = item
|
last.next = item
|
||||||
else
|
else
|
||||||
@first = item
|
@first = item
|
||||||
@length++
|
@length++
|
||||||
|
|
||||||
|
before: (root, item) ->
|
||||||
|
return if item.next is root
|
||||||
|
|
||||||
|
@rmi item
|
||||||
|
|
||||||
|
{prev} = root
|
||||||
|
root.prev = item
|
||||||
|
item.next = root
|
||||||
|
item.prev = prev
|
||||||
|
prev.next = item if prev
|
||||||
|
|
||||||
after: (root, item) ->
|
after: (root, item) ->
|
||||||
return if item.prev is root
|
return if item.prev is root
|
||||||
|
|
||||||
|
|||||||
@ -92,10 +92,10 @@ Unread =
|
|||||||
postID: ID
|
postID: ID
|
||||||
}
|
}
|
||||||
Unread.posts.push post unless post.prev or post.next
|
Unread.posts.push post unless post.prev or post.next
|
||||||
Unread.addPostQuotingYou post
|
Unread.addPostQuotingYou post.data
|
||||||
if Conf['Unread Line']
|
if Conf['Unread Line']
|
||||||
# Force line on visible threads if there were no unread posts previously.
|
# Force line on visible threads if there were no unread posts previously.
|
||||||
Unread.setLine Unread.posts.first in posts
|
Unread.setLine Unread.posts.first.data in posts
|
||||||
Unread.read()
|
Unread.read()
|
||||||
Unread.update()
|
Unread.update()
|
||||||
|
|
||||||
@ -151,12 +151,12 @@ Unread =
|
|||||||
|
|
||||||
{posts} = Unread
|
{posts} = Unread
|
||||||
while post = posts.first
|
while post = posts.first
|
||||||
break unless Header.getBottomOf(post.nodes.root) > -1 # post is not completely read
|
break unless Header.getBottomOf(post.data.nodes.root) > -1 # post is not completely read
|
||||||
{ID} = post
|
{ID} = post
|
||||||
posts.rm ID
|
posts.rm ID
|
||||||
|
|
||||||
if Conf['Mark Quotes of You'] and post.info.yours
|
if Conf['Mark Quotes of You'] and post.info.yours
|
||||||
QuoteYou.lastRead = post.nodes.root
|
QuoteYou.lastRead = post.data.nodes.root
|
||||||
|
|
||||||
return unless ID
|
return unless ID
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user