Lets not even bother linkifying a comment with no links.

Also switch out some loops.
This commit is contained in:
Zixaphir 2014-03-12 23:42:32 -07:00
parent 6bb31cc845
commit 61e1447a5f
5 changed files with 65 additions and 68 deletions

View File

@ -1,5 +1,5 @@
/*
* 4chan X - Version 1.4.1 - 2014-03-11
* 4chan X - Version 1.4.1 - 2014-03-12
*
* Licensed under the MIT license.
* https://github.com/Spittie/4chan-x/blob/master/LICENSE

View File

@ -24,7 +24,7 @@
// ==/UserScript==
/*
* 4chan X - Version 1.4.1 - 2014-03-11
* 4chan X - Version 1.4.1 - 2014-03-12
*
* Licensed under the MIT license.
* https://github.com/Spittie/4chan-x/blob/master/LICENSE
@ -3282,12 +3282,12 @@
});
},
buildThreads: function() {
var err, errors, i, posts, thread, threadData, threadRoot, threads, _i, _len, _ref;
var err, errors, i, liveThreadData, posts, thread, threadData, threadRoot, threads;
threads = [];
posts = [];
_ref = Index.liveThreadData;
for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
threadData = _ref[i];
i = 0;
liveThreadData = Index.liveThreadData;
while (threadData = liveThreadData[i]) {
threadRoot = Build.thread(g.BOARD, threadData);
if (thread = g.BOARD.threads[threadData.no]) {
thread.setPage(Math.floor(i / Index.threadsNumPerPage));
@ -3299,6 +3299,7 @@
thread = new Thread(threadData.no, g.BOARD);
threads.push(thread);
}
i++;
if (thread.ID in thread.posts) {
continue;
}
@ -3323,15 +3324,6 @@
Index.updateHideLabel();
return $.event('IndexRefresh');
},
buildHRs: function(threadRoots) {
var i, node, nodes;
nodes = [];
i = 0;
while (node = threadRoots[i++]) {
nodes.push(node, $.el('hr'));
}
return nodes;
},
buildReplies: function(threads) {
var data, err, errors, i, lastReplies, node, nodes, post, posts, thread, _i, _j, _len, _len1;
if (!Conf['Show Replies']) {
@ -3489,7 +3481,8 @@
}
},
buildIndex: function(infinite) {
var nodes, pageNum, thread, threads, threadsPerPage, _i, _j, _len, _len1, _ref;
var i, max, nodes, pageNum, sortedThreads, thread, threads, threadsPerPage;
sortedThreads = Index.sortedThreads;
switch (Conf['Index Mode']) {
case 'paged':
case 'infinite':
@ -3499,14 +3492,15 @@
return;
}
threadsPerPage = Index.getThreadsNumPerPage();
threads = Index.sortedThreads.slice(threadsPerPage * pageNum, threadsPerPage * (pageNum + 1));
nodes = [];
for (_i = 0, _len = threads.length; _i < _len; _i++) {
thread = threads[_i];
nodes.push(thread.OP.nodes.root.parentNode);
threads = [];
i = threadsPerPage * pageNum;
max = i + threadsPerPage;
while (i < max) {
threads.push(thread = sortedThreads[i++]);
nodes.push(thread.OP.nodes.root.parentNode, $.el('hr'));
}
Index.buildReplies(threads);
nodes = Index.buildHRs(nodes);
Index.buildPagelist();
Index.setPage();
break;
@ -3516,13 +3510,11 @@
break;
default:
nodes = [];
_ref = Index.sortedThreads;
for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
thread = _ref[_j];
nodes.push(thread.OP.nodes.root.parentNode);
i = 0;
while (thread = sortedThreads[i++]) {
nodes.push(thread.OP.nodes.root.parentNode, $.el('hr'));
}
Index.buildReplies(Index.sortedThreads);
nodes = Index.buildHRs(nodes);
Index.buildReplies(sortedThreads);
}
if (!infinite) {
$.rmAll(Index.root);
@ -8471,6 +8463,9 @@
}
return;
}
if (!Linkify.regString.test(this.info.comment)) {
return;
}
test = /[^\s'"]+/g;
space = /[\s'"]/;
snapshot = $.X('.//br|.//text()', this.nodes.comment);

View File

@ -1,6 +1,6 @@
// Generated by CoffeeScript
/*
* 4chan X - Version 1.4.1 - 2014-03-11
* 4chan X - Version 1.4.1 - 2014-03-12
*
* Licensed under the MIT license.
* https://github.com/Spittie/4chan-x/blob/master/LICENSE
@ -3341,12 +3341,12 @@
});
},
buildThreads: function() {
var err, errors, i, posts, thread, threadData, threadRoot, threads, _i, _len, _ref;
var err, errors, i, liveThreadData, posts, thread, threadData, threadRoot, threads;
threads = [];
posts = [];
_ref = Index.liveThreadData;
for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
threadData = _ref[i];
i = 0;
liveThreadData = Index.liveThreadData;
while (threadData = liveThreadData[i]) {
threadRoot = Build.thread(g.BOARD, threadData);
if (thread = g.BOARD.threads[threadData.no]) {
thread.setPage(Math.floor(i / Index.threadsNumPerPage));
@ -3358,6 +3358,7 @@
thread = new Thread(threadData.no, g.BOARD);
threads.push(thread);
}
i++;
if (thread.ID in thread.posts) {
continue;
}
@ -3382,15 +3383,6 @@
Index.updateHideLabel();
return $.event('IndexRefresh');
},
buildHRs: function(threadRoots) {
var i, node, nodes;
nodes = [];
i = 0;
while (node = threadRoots[i++]) {
nodes.push(node, $.el('hr'));
}
return nodes;
},
buildReplies: function(threads) {
var data, err, errors, i, lastReplies, node, nodes, post, posts, thread, _i, _j, _len, _len1;
if (!Conf['Show Replies']) {
@ -3548,7 +3540,8 @@
}
},
buildIndex: function(infinite) {
var nodes, pageNum, thread, threads, threadsPerPage, _i, _j, _len, _len1, _ref;
var i, max, nodes, pageNum, sortedThreads, thread, threads, threadsPerPage;
sortedThreads = Index.sortedThreads;
switch (Conf['Index Mode']) {
case 'paged':
case 'infinite':
@ -3558,14 +3551,15 @@
return;
}
threadsPerPage = Index.getThreadsNumPerPage();
threads = Index.sortedThreads.slice(threadsPerPage * pageNum, threadsPerPage * (pageNum + 1));
nodes = [];
for (_i = 0, _len = threads.length; _i < _len; _i++) {
thread = threads[_i];
nodes.push(thread.OP.nodes.root.parentNode);
threads = [];
i = threadsPerPage * pageNum;
max = i + threadsPerPage;
while (i < max) {
threads.push(thread = sortedThreads[i++]);
nodes.push(thread.OP.nodes.root.parentNode, $.el('hr'));
}
Index.buildReplies(threads);
nodes = Index.buildHRs(nodes);
Index.buildPagelist();
Index.setPage();
break;
@ -3575,13 +3569,11 @@
break;
default:
nodes = [];
_ref = Index.sortedThreads;
for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
thread = _ref[_j];
nodes.push(thread.OP.nodes.root.parentNode);
i = 0;
while (thread = sortedThreads[i++]) {
nodes.push(thread.OP.nodes.root.parentNode, $.el('hr'));
}
Index.buildReplies(Index.sortedThreads);
nodes = Index.buildHRs(nodes);
Index.buildReplies(sortedThreads);
}
if (!infinite) {
$.rmAll(Index.root);
@ -8486,6 +8478,9 @@
}
return;
}
if (!Linkify.regString.test(this.info.comment)) {
return;
}
test = /[^\s'"]+/g;
space = /[\s'"]/;
snapshot = $.X('.//br|.//text()', this.nodes.comment);

View File

@ -591,7 +591,9 @@ Index =
buildThreads: ->
threads = []
posts = []
for threadData, i in Index.liveThreadData
i = 0
{liveThreadData} = Index
while threadData = liveThreadData[i]
threadRoot = Build.thread g.BOARD, threadData
if thread = g.BOARD.threads[threadData.no]
thread.setPage i // Index.threadsNumPerPage
@ -602,6 +604,7 @@ Index =
else
thread = new Thread threadData.no, g.BOARD
threads.push thread
i++
continue if thread.ID of thread.posts
try
posts.push new Post $('.opContainer', threadRoot), thread, g.BOARD
@ -618,13 +621,6 @@ Index =
Index.updateHideLabel()
$.event 'IndexRefresh'
buildHRs: (threadRoots) ->
nodes = []
i = 0
while node = threadRoots[i++]
nodes.push node, $.el 'hr'
nodes
buildReplies: (threads) ->
return unless Conf['Show Replies']
posts = []
@ -728,6 +724,7 @@ Index =
return
buildIndex: (infinite) ->
{sortedThreads} = Index
switch Conf['Index Mode']
when 'paged', 'infinite'
pageNum = Index.getCurrentPage()
@ -736,21 +733,29 @@ Index =
Index.pageNav Index.getMaxPageNum()
return
threadsPerPage = Index.getThreadsNumPerPage()
threads = Index.sortedThreads[threadsPerPage * pageNum ... threadsPerPage * (pageNum + 1)]
nodes = []
nodes.push thread.OP.nodes.root.parentNode for thread in threads
nodes = []
threads = []
i = threadsPerPage * pageNum
max = i + threadsPerPage
while i < max
threads.push thread = sortedThreads[i++]
nodes.push thread.OP.nodes.root.parentNode, $.el 'hr'
Index.buildReplies threads
nodes = Index.buildHRs nodes
Index.buildPagelist()
Index.setPage()
when 'catalog'
nodes = Index.buildCatalogViews()
Index.sizeCatalogViews nodes
else
nodes = []
nodes.push thread.OP.nodes.root.parentNode for thread in Index.sortedThreads
Index.buildReplies Index.sortedThreads
nodes = Index.buildHRs nodes
i = 0
while thread = sortedThreads[i++]
nodes.push thread.OP.nodes.root.parentNode, $.el 'hr'
Index.buildReplies sortedThreads
$.rmAll Index.root unless infinite
$.add Index.root, nodes
$.event 'IndexBuild', nodes

View File

@ -23,6 +23,8 @@ Linkify =
return
return unless Linkify.regString.test @info.comment
test = /[^\s'"]+/g
space = /[\s'"]/