Add Threads per Page setting.
This commit is contained in:
parent
079e852277
commit
cc4121070a
@ -1,3 +1,5 @@
|
|||||||
|
- Added a setting to configure the number of threads per page for the paged mode of the index.
|
||||||
|
|
||||||
### 3.16.4 - *2014-02-04*
|
### 3.16.4 - *2014-02-04*
|
||||||
|
|
||||||
- Firefox release only: fix catalog layout alignment.
|
- Firefox release only: fix catalog layout alignment.
|
||||||
|
|||||||
@ -271,7 +271,7 @@ Build =
|
|||||||
"<div class='subject'>#{thread.OP.info.subject}</div>"
|
"<div class='subject'>#{thread.OP.info.subject}</div>"
|
||||||
else
|
else
|
||||||
''
|
''
|
||||||
comment = thread.OP.nodes.comment.innerHTML.replace /(<br>){2,}/g, '<br>'
|
comment = thread.OP.nodes.comment.innerHTML.replace /(<br>\s*){2,}/g, '<br>'
|
||||||
|
|
||||||
root = $.el 'div',
|
root = $.el 'div',
|
||||||
className: 'catalog-thread'
|
className: 'catalog-thread'
|
||||||
|
|||||||
@ -141,6 +141,7 @@ Config =
|
|||||||
Index:
|
Index:
|
||||||
'Index Mode': 'paged'
|
'Index Mode': 'paged'
|
||||||
'Index Sort': 'bump'
|
'Index Sort': 'bump'
|
||||||
|
'Threads per Page': 0
|
||||||
'Show Replies': true
|
'Show Replies': true
|
||||||
'Anchor Hidden Threads': true
|
'Anchor Hidden Threads': true
|
||||||
'Refreshed Navigation': false
|
'Refreshed Navigation': false
|
||||||
|
|||||||
@ -56,6 +56,16 @@ Index =
|
|||||||
$.on input, 'change', $.cb.value
|
$.on input, 'change', $.cb.value
|
||||||
$.on input, 'change', @cb.sort
|
$.on input, 'change', @cb.sort
|
||||||
|
|
||||||
|
threadNumEntry =
|
||||||
|
el: $.el 'span', textContent: 'Threads per page'
|
||||||
|
subEntries: [
|
||||||
|
{ el: $.el 'label', innerHTML: '<input type=number name="Threads per Page">', title: 'Use 0 for default value' }
|
||||||
|
]
|
||||||
|
threadsNumInput = threadNumEntry.subEntries[0].el.firstChild
|
||||||
|
threadsNumInput.value = Conf['Threads per Page']
|
||||||
|
$.on threadsNumInput, 'change', $.cb.value
|
||||||
|
$.on threadsNumInput, 'change', @cb.threadsNum
|
||||||
|
|
||||||
repliesEntry =
|
repliesEntry =
|
||||||
el: $.el 'label',
|
el: $.el 'label',
|
||||||
innerHTML: '<input type=checkbox name="Show Replies"> Show replies'
|
innerHTML: '<input type=checkbox name="Show Replies"> Show replies'
|
||||||
@ -83,7 +93,7 @@ Index =
|
|||||||
el: $.el 'span',
|
el: $.el 'span',
|
||||||
textContent: 'Index Navigation'
|
textContent: 'Index Navigation'
|
||||||
order: 90
|
order: 90
|
||||||
subEntries: [modeEntry, sortEntry, repliesEntry, anchorEntry, refNavEntry]
|
subEntries: [modeEntry, sortEntry, threadNumEntry, repliesEntry, anchorEntry, refNavEntry]
|
||||||
|
|
||||||
$.addClass doc, 'index-loading'
|
$.addClass doc, 'index-loading'
|
||||||
@update()
|
@update()
|
||||||
@ -222,6 +232,10 @@ Index =
|
|||||||
sort: ->
|
sort: ->
|
||||||
Index.sort()
|
Index.sort()
|
||||||
Index.buildIndex()
|
Index.buildIndex()
|
||||||
|
threadsNum: ->
|
||||||
|
return unless Conf['Index Mode'] is 'paged'
|
||||||
|
Index.buildPagelist()
|
||||||
|
Index.buildIndex()
|
||||||
replies: ->
|
replies: ->
|
||||||
Index.buildThreads()
|
Index.buildThreads()
|
||||||
Index.sort()
|
Index.sort()
|
||||||
@ -263,11 +277,17 @@ Index =
|
|||||||
Index.setPage()
|
Index.setPage()
|
||||||
Index.scrollToIndex()
|
Index.scrollToIndex()
|
||||||
|
|
||||||
getPagesNum: ->
|
getThreadsNumPerPage: ->
|
||||||
if Index.isSearching
|
if Conf['Threads per Page'] > 0
|
||||||
Math.ceil (Index.sortedNodes.length / 2) / Index.threadsNumPerPage
|
+Conf['Threads per Page']
|
||||||
else
|
else
|
||||||
Index.pagesNum
|
Index.threadsNumPerPage
|
||||||
|
getPagesNum: ->
|
||||||
|
numThreads = if Index.isSearching
|
||||||
|
Index.sortedNodes.length / 2
|
||||||
|
else
|
||||||
|
Index.liveThreadIDs.length
|
||||||
|
Math.ceil numThreads / Index.getThreadsNumPerPage()
|
||||||
getMaxPageNum: ->
|
getMaxPageNum: ->
|
||||||
Math.max 0, Index.getPagesNum() - 1
|
Math.max 0, Index.getPagesNum() - 1
|
||||||
togglePagelist: ->
|
togglePagelist: ->
|
||||||
@ -402,7 +422,6 @@ Index =
|
|||||||
Index.buildIndex()
|
Index.buildIndex()
|
||||||
Index.setPage()
|
Index.setPage()
|
||||||
parseThreadList: (pages) ->
|
parseThreadList: (pages) ->
|
||||||
Index.pagesNum = pages.length
|
|
||||||
Index.threadsNumPerPage = pages[0].threads.length
|
Index.threadsNumPerPage = pages[0].threads.length
|
||||||
Index.liveThreadData = pages.reduce ((arr, next) -> arr.concat next.threads), []
|
Index.liveThreadData = pages.reduce ((arr, next) -> arr.concat next.threads), []
|
||||||
Index.liveThreadIDs = Index.liveThreadData.map (data) -> data.no
|
Index.liveThreadIDs = Index.liveThreadData.map (data) -> data.no
|
||||||
@ -513,7 +532,7 @@ Index =
|
|||||||
switch Conf['Index Mode']
|
switch Conf['Index Mode']
|
||||||
when 'paged'
|
when 'paged'
|
||||||
pageNum = Index.getCurrentPage()
|
pageNum = Index.getCurrentPage()
|
||||||
nodesPerPage = Index.threadsNumPerPage * 2
|
nodesPerPage = Index.getThreadsNumPerPage() * 2
|
||||||
nodes = Index.sortedNodes[nodesPerPage * pageNum ... nodesPerPage * (pageNum + 1)]
|
nodes = Index.sortedNodes[nodesPerPage * pageNum ... nodesPerPage * (pageNum + 1)]
|
||||||
when 'catalog'
|
when 'catalog'
|
||||||
nodes = Index.buildCatalogViews()
|
nodes = Index.buildCatalogViews()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user