From 855b7f0173f8aba4828730b65dfc95eb634de552 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Fri, 1 Nov 2013 04:52:21 +0100 Subject: [PATCH] Add 3 index sorting options: reply count, file count, last reply. --- CHANGELOG.md | 3 +++ src/Miscellaneous/Index.coffee | 13 +++++++++++++ src/Miscellaneous/Keybinds.coffee | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c075422c3..928d719eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ Index navigation improvements: - Threads in the index can now be sorted by: - bump order - creation date + - reply count + - file count + - last reply Added a keybind to open the catalog search field on index pages. diff --git a/src/Miscellaneous/Index.coffee b/src/Miscellaneous/Index.coffee index ed9a8cd56..75b8bbdd1 100644 --- a/src/Miscellaneous/Index.coffee +++ b/src/Miscellaneous/Index.coffee @@ -26,6 +26,9 @@ Index = subEntries: [ { el: $.el 'label', innerHTML: ' Bump order' } { el: $.el 'label', innerHTML: ' Creation date' } + { el: $.el 'label', innerHTML: ' Reply count' } + { el: $.el 'label', innerHTML: ' File count' } + { el: $.el 'label', innerHTML: ' Last reply' } ] for label in sortEntry.subEntries input = label.el.firstChild @@ -136,6 +139,16 @@ Index = sortedThreadIDs = Index.liveThreadIDs when '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 + when 'lastreply' + sortedThreadIDs = [Index.liveThreadData...].sort((a, b) -> + a = a.last_replies[a.last_replies.length - 1] if 'last_replies' of a + b = b.last_replies[b.last_replies.length - 1] if 'last_replies' of b + b.no - a.no + ).map (data) -> data.no Index.sortedNodes = [] for threadID in sortedThreadIDs i = Index.liveThreadIDs.indexOf(threadID) * 2 diff --git a/src/Miscellaneous/Keybinds.coffee b/src/Miscellaneous/Keybinds.coffee index 464bf76c2..c5fb5d59a 100644 --- a/src/Miscellaneous/Keybinds.coffee +++ b/src/Miscellaneous/Keybinds.coffee @@ -7,7 +7,7 @@ Keybinds = init = -> $.off d, '4chanXInitFinished', init - $.on d, 'keydown', Keybinds.keydown + $.on d, 'keydown', Keybinds.keydown for node in $$ '[accesskey]' node.removeAttribute 'accesskey' return