diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index f327a160d..0b74da538 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -3310,12 +3310,11 @@ return $.event('IndexRefresh'); }, buildHRs: function(threadRoots) { - var node, nodes, _i, _len; + var i, node, nodes; nodes = []; - for (_i = 0, _len = threadRoots.length; _i < _len; _i++) { - node = threadRoots[_i]; - nodes.push(node); - nodes.push($.el('hr')); + i = 0; + while (node = threadRoots[i++]) { + nodes.push(node, $.el('hr')); } return nodes; }, @@ -3360,7 +3359,7 @@ return Main.callbackNodes(Post, posts); }, buildCatalogViews: function() { - var catalogThreads, thread, _i, _len, _ref; + var catalogThreads, nodes, thread, _i, _j, _len, _len1, _ref, _ref1; catalogThreads = []; _ref = Index.sortedThreads; for (_i = 0, _len = _ref.length; _i < _len; _i++) { @@ -3370,9 +3369,13 @@ } } Main.callbackNodes(CatalogThread, catalogThreads); - return Index.sortedThreads.map(function(thread) { - return thread.catalogView.nodes.root; - }); + nodes = []; + _ref1 = Index.sortedThreads; + for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { + thread = _ref1[_j]; + nodes.push(thread.catalogView.nodes.root); + } + return nodes; }, sizeCatalogViews: function(nodes) { var height, node, ratio, size, thumb, width, _i, _len, _ref; @@ -3390,13 +3393,16 @@ } }, sort: function() { - var sortedThreadIDs; - switch (Conf['Index Sort']) { - case 'bump': - sortedThreadIDs = Index.liveThreadIDs; - break; - case 'lastreply': - sortedThreadIDs = __slice.call(Index.liveThreadData).sort(function(a, b) { + var sortedThreadIDs, sortedThreads, threadID, _i, _len; + sortedThreads = []; + sortedThreadIDs = []; + ({ + 'bump': function() { + return sortedThreadIDs = Index.liveThreadIDs; + }, + 'lastreply': function() { + var data, liveData, _i, _len; + liveData = __slice.call(Index.liveThreadData).sort(function(a, b) { var _ref, _ref1; if ('last_replies' in a) { _ref = a.last_replies, a = _ref[_ref.length - 1]; @@ -3405,32 +3411,43 @@ _ref1 = b.last_replies, b = _ref1[_ref1.length - 1]; } return b.no - a.no; - }).map(function(data) { - return data.no; }); - break; - case 'birth': - sortedThreadIDs = __slice.call(Index.liveThreadIDs).sort(function(a, b) { + for (_i = 0, _len = liveData.length; _i < _len; _i++) { + data = liveData[_i]; + sortedThreadIDs.push(data.no); + } + }, + 'birth': function() { + return sortedThreadIDs = __slice.call(Index.liveThreadIDs).sort(function(a, b) { return b - a; }); - break; - case 'replycount': - sortedThreadIDs = __slice.call(Index.liveThreadData).sort(function(a, b) { + }, + 'replycount': function() { + var data, liveData, _i, _len; + liveData = __slice.call(Index.liveThreadData).sort(function(a, b) { return b.replies - a.replies; - }).map(function(data) { - return data.no; }); - break; - case 'filecount': - sortedThreadIDs = __slice.call(Index.liveThreadData).sort(function(a, b) { + for (_i = 0, _len = liveData.length; _i < _len; _i++) { + data = liveData[_i]; + sortedThreadIDs.push(data.no); + } + }, + 'filecount': function() { + var data, liveData, _i, _len; + liveData = __slice.call(Index.liveThreadData).sort(function(a, b) { return b.images - a.images; - }).map(function(data) { - return data.no; }); + for (_i = 0, _len = liveData.length; _i < _len; _i++) { + data = liveData[_i]; + sortedThreadIDs.push(data.no); + } + } + })[Conf['Index Sort']](); + for (_i = 0, _len = sortedThreadIDs.length; _i < _len; _i++) { + threadID = sortedThreadIDs[_i]; + sortedThreads.push(g.BOARD.threads[threadID]); } - Index.sortedThreads = sortedThreadIDs.map(function(threadID) { - return g.BOARD.threads[threadID]; - }).filter(function(thread) { + Index.sortedThreads = sortedThreads.filter(function(thread) { return thread.isHidden === Index.showHiddenThreads; }); if (Index.isSearching) { @@ -3455,7 +3472,7 @@ } }, buildIndex: function(infinite) { - var nodes, pageNum, threads, threadsPerPage; + var nodes, pageNum, thread, threads, threadsPerPage, _i, _j, _len, _len1, _ref; switch (Conf['Index Mode']) { case 'paged': case 'infinite': @@ -3466,9 +3483,11 @@ } threadsPerPage = Index.getThreadsNumPerPage(); threads = Index.sortedThreads.slice(threadsPerPage * pageNum, threadsPerPage * (pageNum + 1)); - nodes = threads.map(function(thread) { - return thread.OP.nodes.root.parentNode; - }); + nodes = []; + for (_i = 0, _len = threads.length; _i < _len; _i++) { + thread = threads[_i]; + nodes.push(thread.OP.nodes.root.parentNode); + } Index.buildReplies(threads); nodes = Index.buildHRs(nodes); Index.buildPagelist(); @@ -3479,9 +3498,12 @@ Index.sizeCatalogViews(nodes); break; default: - nodes = Index.sortedThreads.map(function(thread) { - return thread.OP.nodes.root.parentNode; - }); + nodes = []; + _ref = Index.sortedThreads; + for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) { + thread = _ref[_j]; + nodes.push(thread.OP.nodes.root.parentNode); + } Index.buildReplies(Index.sortedThreads); nodes = Index.buildHRs(nodes); } diff --git a/builds/crx/script.js b/builds/crx/script.js index ddd862b08..9d7c2e7f0 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -3369,12 +3369,11 @@ return $.event('IndexRefresh'); }, buildHRs: function(threadRoots) { - var node, nodes, _i, _len; + var i, node, nodes; nodes = []; - for (_i = 0, _len = threadRoots.length; _i < _len; _i++) { - node = threadRoots[_i]; - nodes.push(node); - nodes.push($.el('hr')); + i = 0; + while (node = threadRoots[i++]) { + nodes.push(node, $.el('hr')); } return nodes; }, @@ -3419,7 +3418,7 @@ return Main.callbackNodes(Post, posts); }, buildCatalogViews: function() { - var catalogThreads, thread, _i, _len, _ref; + var catalogThreads, nodes, thread, _i, _j, _len, _len1, _ref, _ref1; catalogThreads = []; _ref = Index.sortedThreads; for (_i = 0, _len = _ref.length; _i < _len; _i++) { @@ -3429,9 +3428,13 @@ } } Main.callbackNodes(CatalogThread, catalogThreads); - return Index.sortedThreads.map(function(thread) { - return thread.catalogView.nodes.root; - }); + nodes = []; + _ref1 = Index.sortedThreads; + for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { + thread = _ref1[_j]; + nodes.push(thread.catalogView.nodes.root); + } + return nodes; }, sizeCatalogViews: function(nodes) { var height, node, ratio, size, thumb, width, _i, _len, _ref; @@ -3449,13 +3452,16 @@ } }, sort: function() { - var sortedThreadIDs; - switch (Conf['Index Sort']) { - case 'bump': - sortedThreadIDs = Index.liveThreadIDs; - break; - case 'lastreply': - sortedThreadIDs = __slice.call(Index.liveThreadData).sort(function(a, b) { + var sortedThreadIDs, sortedThreads, threadID, _i, _len; + sortedThreads = []; + sortedThreadIDs = []; + ({ + 'bump': function() { + return sortedThreadIDs = Index.liveThreadIDs; + }, + 'lastreply': function() { + var data, liveData, _i, _len; + liveData = __slice.call(Index.liveThreadData).sort(function(a, b) { var _ref, _ref1; if ('last_replies' in a) { _ref = a.last_replies, a = _ref[_ref.length - 1]; @@ -3464,32 +3470,43 @@ _ref1 = b.last_replies, b = _ref1[_ref1.length - 1]; } return b.no - a.no; - }).map(function(data) { - return data.no; }); - break; - case 'birth': - sortedThreadIDs = __slice.call(Index.liveThreadIDs).sort(function(a, b) { + for (_i = 0, _len = liveData.length; _i < _len; _i++) { + data = liveData[_i]; + sortedThreadIDs.push(data.no); + } + }, + 'birth': function() { + return sortedThreadIDs = __slice.call(Index.liveThreadIDs).sort(function(a, b) { return b - a; }); - break; - case 'replycount': - sortedThreadIDs = __slice.call(Index.liveThreadData).sort(function(a, b) { + }, + 'replycount': function() { + var data, liveData, _i, _len; + liveData = __slice.call(Index.liveThreadData).sort(function(a, b) { return b.replies - a.replies; - }).map(function(data) { - return data.no; }); - break; - case 'filecount': - sortedThreadIDs = __slice.call(Index.liveThreadData).sort(function(a, b) { + for (_i = 0, _len = liveData.length; _i < _len; _i++) { + data = liveData[_i]; + sortedThreadIDs.push(data.no); + } + }, + 'filecount': function() { + var data, liveData, _i, _len; + liveData = __slice.call(Index.liveThreadData).sort(function(a, b) { return b.images - a.images; - }).map(function(data) { - return data.no; }); + for (_i = 0, _len = liveData.length; _i < _len; _i++) { + data = liveData[_i]; + sortedThreadIDs.push(data.no); + } + } + })[Conf['Index Sort']](); + for (_i = 0, _len = sortedThreadIDs.length; _i < _len; _i++) { + threadID = sortedThreadIDs[_i]; + sortedThreads.push(g.BOARD.threads[threadID]); } - Index.sortedThreads = sortedThreadIDs.map(function(threadID) { - return g.BOARD.threads[threadID]; - }).filter(function(thread) { + Index.sortedThreads = sortedThreads.filter(function(thread) { return thread.isHidden === Index.showHiddenThreads; }); if (Index.isSearching) { @@ -3514,7 +3531,7 @@ } }, buildIndex: function(infinite) { - var nodes, pageNum, threads, threadsPerPage; + var nodes, pageNum, thread, threads, threadsPerPage, _i, _j, _len, _len1, _ref; switch (Conf['Index Mode']) { case 'paged': case 'infinite': @@ -3525,9 +3542,11 @@ } threadsPerPage = Index.getThreadsNumPerPage(); threads = Index.sortedThreads.slice(threadsPerPage * pageNum, threadsPerPage * (pageNum + 1)); - nodes = threads.map(function(thread) { - return thread.OP.nodes.root.parentNode; - }); + nodes = []; + for (_i = 0, _len = threads.length; _i < _len; _i++) { + thread = threads[_i]; + nodes.push(thread.OP.nodes.root.parentNode); + } Index.buildReplies(threads); nodes = Index.buildHRs(nodes); Index.buildPagelist(); @@ -3538,9 +3557,12 @@ Index.sizeCatalogViews(nodes); break; default: - nodes = Index.sortedThreads.map(function(thread) { - return thread.OP.nodes.root.parentNode; - }); + nodes = []; + _ref = Index.sortedThreads; + for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) { + thread = _ref[_j]; + nodes.push(thread.OP.nodes.root.parentNode); + } Index.buildReplies(Index.sortedThreads); nodes = Index.buildHRs(nodes); } diff --git a/src/General/Index.coffee b/src/General/Index.coffee index 657f08f03..6a4139e3a 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -616,9 +616,9 @@ Index = buildHRs: (threadRoots) -> nodes = [] - for node in threadRoots - nodes.push node - nodes.push $.el 'hr' + i = 0 + while node = threadRoots[i++] + nodes.push node, $.el 'hr' nodes buildReplies: (threads) -> @@ -651,7 +651,9 @@ Index = for thread in Index.sortedThreads when !thread.catalogView catalogThreads.push new CatalogThread Build.catalogThread(thread), thread Main.callbackNodes CatalogThread, catalogThreads - Index.sortedThreads.map (thread) -> thread.catalogView.nodes.root + nodes = [] + nodes.push thread.catalogView.nodes.root for thread in Index.sortedThreads + return nodes sizeCatalogViews: (nodes) -> # XXX When browsers support CSS3 attr(), use it instead. @@ -666,24 +668,32 @@ Index = return sort: -> - switch Conf['Index Sort'] - when 'bump' + sortedThreads = [] + sortedThreadIDs = [] + + { + 'bump': -> sortedThreadIDs = Index.liveThreadIDs - when 'lastreply' - sortedThreadIDs = [Index.liveThreadData...].sort (a, b) -> + 'lastreply': -> + liveData = [Index.liveThreadData...].sort (a, b) -> [..., a] = a.last_replies if 'last_replies' of a [..., b] = b.last_replies if 'last_replies' of b b.no - a.no - .map (data) -> data.no - when 'birth' + sortedThreadIDs.push data.no for data in liveData + return + 'birth': -> sortedThreadIDs = [Index.liveThreadIDs...].sort (a, b) -> b - a - when 'replycount' - sortedThreadIDs = [Index.liveThreadData...].sort((a, b) -> b.replies - a.replies).map (data) -> data.no - when 'filecount' - sortedThreadIDs = [Index.liveThreadData...].sort((a, b) -> b.images - a.images).map (data) -> data.no - Index.sortedThreads = sortedThreadIDs - .map (threadID) -> g.BOARD.threads[threadID] - .filter (thread) -> thread.isHidden is Index.showHiddenThreads + 'replycount': -> + liveData = [Index.liveThreadData...].sort((a, b) -> b.replies - a.replies) + sortedThreadIDs.push data.no for data in liveData + return + 'filecount': -> + liveData = [Index.liveThreadData...].sort((a, b) -> b.images - a.images) + sortedThreadIDs.push data.no for data in liveData + return + }[Conf['Index Sort']]() + sortedThreads.push g.BOARD.threads[threadID] for threadID in sortedThreadIDs + Index.sortedThreads = sortedThreads.filter (thread) -> thread.isHidden is Index.showHiddenThreads if Index.isSearching Index.sortedThreads = Index.querySearch(Index.searchInput.value) or Index.sortedThreads # Sticky threads @@ -707,7 +717,8 @@ Index = return threadsPerPage = Index.getThreadsNumPerPage() threads = Index.sortedThreads[threadsPerPage * pageNum ... threadsPerPage * (pageNum + 1)] - nodes = threads.map (thread) -> thread.OP.nodes.root.parentNode + nodes = [] + nodes.push thread.OP.nodes.root.parentNode for thread in threads Index.buildReplies threads nodes = Index.buildHRs nodes Index.buildPagelist() @@ -716,7 +727,8 @@ Index = nodes = Index.buildCatalogViews() Index.sizeCatalogViews nodes else - nodes = Index.sortedThreads.map (thread) -> thread.OP.nodes.root.parentNode + nodes = [] + nodes.push thread.OP.nodes.root.parentNode for thread in Index.sortedThreads Index.buildReplies Index.sortedThreads nodes = Index.buildHRs nodes $.rmAll Index.root unless infinite