diff --git a/src/General/Index.coffee b/src/General/Index.coffee index 6eeda43a3..9beefd233 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -95,17 +95,20 @@ Index = @hideLabel = $ '#hidden-label', @navLinks $.on $('#hidden-toggle a', @navLinks), 'click', @cb.toggleHiddenThreads - # Drop-down menus + # Drop-down menus and reverse sort toggle + @selectRev = $ '#index-rev', @navLinks @selectMode = $ '#index-mode', @navLinks @selectSort = $ '#index-sort', @navLinks @selectSize = $ '#index-size', @navLinks + $.on @selectRev, 'change', @cb.sort $.on @selectMode, 'change', @cb.mode $.on @selectSort, 'change', @cb.sort $.on @selectSize, 'change', $.cb.value $.on @selectSize, 'change', @cb.size for select in [@selectMode, @selectSize] select.value = Conf[select.name] - @selectSort.value = Index.currentSort + @selectRev.checked = /-rev$/.test Index.currentSort + @selectSort.value = Index.currentSort.replace /-rev$/, '' # Thread container @root = $.el 'div', className: 'board json-index' @@ -252,7 +255,8 @@ Index = Index.pageLoad false sort: -> - Index.pushState {sort: @value} + value = if Index.selectRev.checked then Index.selectSort.value + "-rev" else Index.selectSort.value + Index.pushState {sort: value} Index.pageLoad false resort: (e) -> @@ -342,12 +346,12 @@ Index = 'all-pages': 'all pages' 'catalog': 'catalog' sort: - 'bump-order': 'bump' - 'last-reply': 'lastreply' - 'last-long-reply': 'lastlong' - 'creation-date': 'birth' - 'reply-count': 'replycount' - 'file-count': 'filecount' + 'bump-order': 'bump' + 'last-reply': 'lastreply' + 'last-long-reply': 'lastlong' + 'creation-date': 'birth' + 'reply-count': 'replycount' + 'file-count': 'filecount' processHash: -> # XXX https://bugzilla.mozilla.org/show_bug.cgi?id=483304 @@ -362,8 +366,9 @@ Index = else if command is 'index' state.mode = Conf['Previous Index Mode'] state.page = 1 - else if (sort = Index.hashCommands.sort[command]) + else if (sort = Index.hashCommands.sort[command.replace(/-rev$/, '')]) state.sort = sort + state.sort += '-rev' if /-rev$/.test(command) else if /^s=/.test command state.search = decodeURIComponent(command[2..]).replace(/\+/g, ' ').trim() else @@ -446,7 +451,8 @@ Index = $('#hidden-toggle a', Index.navLinks).textContent = 'Show' setupSort: -> - Index.selectSort.value = Index.currentSort + Index.selectRev.checked = /-rev$/.test Index.currentSort + Index.selectSort.value = Index.currentSort.replace /-rev$/, '' getPagesNum: -> if Index.search @@ -744,7 +750,7 @@ Index = sort: -> {liveThreadIDs, liveThreadData} = Index return unless liveThreadData - Index.sortedThreadIDs = switch Index.currentSort + Index.sortedThreadIDs = switch Index.currentSort.replace(/-rev$/, '') when 'lastreply' [liveThreadData...].sort((a, b) -> a = num[num.length - 1] if (num = a.last_replies) @@ -764,6 +770,8 @@ Index = when 'replycount' then [liveThreadData...].sort((a, b) -> b.replies - a.replies).map (post) -> post.no when 'filecount' then [liveThreadData...].sort((a, b) -> b.images - a.images ).map (post) -> post.no else liveThreadIDs + if /-rev$/.test(Index.currentSort) + Index.sortedThreadIDs = [Index.sortedThreadIDs...].reverse() if Index.search and (threadIDs = Index.querySearch Index.search) Index.sortedThreadIDs = threadIDs # Sticky threads diff --git a/src/General/Index/NavLinks.html b/src/General/Index/NavLinks.html index 90d1794fc..e69e93af2 100644 --- a/src/General/Index/NavLinks.html +++ b/src/General/Index/NavLinks.html @@ -6,6 +6,7 @@ × — [Show] + Index Mode Paged diff --git a/src/General/Settings/Advanced.html b/src/General/Settings/Advanced.html index cb09ffc15..324e5e55c 100644 --- a/src/General/Settings/Advanced.html +++ b/src/General/Settings/Advanced.html @@ -40,7 +40,7 @@ Index-only link: g-index Catalog-only link: g-catalog Index mode: g-mode:"infinite scrolling" - Index sort: g-sort:"creation date" + Index sort: g-sort:"creation date rev" External link: external-text:"Google","http://www.google.com" Combinations are possible: g-index-text:"Technology Index" Full board list toggle: toggle-all diff --git a/src/css/style.css b/src/css/style.css index ae039dd1a..fed72a975 100644 --- a/src/css/style.css +++ b/src/css/style.css @@ -706,7 +706,7 @@ div[data-checked="false"] > .suboption-list { #index-search:not([data-searching]) + #index-search-clear { display: none; } -#index-mode, #index-sort, #index-size { +#index-rev, #index-mode, #index-sort, #index-size { float: right; } .summary {
g-index
g-catalog
g-mode:"infinite scrolling"
g-sort:"creation date"
g-sort:"creation date rev"
external-text:"Google","http://www.google.com"
g-index-text:"Technology Index"
toggle-all