Add the Show replies index setting.

This commit is contained in:
Mayhem 2013-11-16 00:09:08 +01:00
parent 07bca42d63
commit 8afcac8d6f
5 changed files with 44 additions and 20 deletions

View File

@ -1,11 +1,15 @@
- Searching in the index is now possible and will show matched OPs by: - More index navigation improvements:
- comment - Searching in the index is now possible and will show matched OPs by:
- subject <ul>
- filename <li> comment
- name <li> subject
- tripcode <li> filename
- e-mail <li> name
- The elapsed time since the last index refresh is now indicated at the top of the index. <li> tripcode
<li> e-mail
</ul>
- The elapsed time since the last index refresh is now indicated at the top of the index.
- New setting: `Show replies`, enabled by default. Disable it to only show OPs in the index.
### 3.12.1 - *2013-11-04* ### 3.12.1 - *2013-11-04*

View File

@ -279,8 +279,13 @@ Build =
id: "t#{data.no}" id: "t#{data.no}"
nodes = [if OP then OP.nodes.root else Build.postFromObject data, board.ID] nodes = [if OP then OP.nodes.root else Build.postFromObject data, board.ID]
if data.omitted_posts if data.omitted_posts or !Conf['Show Replies'] and data.replies
nodes.push Build.summary board.ID, data.no, data.omitted_posts, data.omitted_images [posts, files] = if Conf['Show Replies']
[data.omitted_posts, data.omitted_images]
else
# XXX data.images is not accurate.
[data.replies, data.omitted_images + data.last_replies.filter((data) -> !!data.ext).length]
nodes.push Build.summary board.ID, data.no, posts, files
$.add root, nodes $.add root, nodes
root root

View File

@ -142,6 +142,7 @@ Config =
Index: Index:
'Index Mode': 'paged' 'Index Mode': 'paged'
'Index Sort': 'bump' 'Index Sort': 'bump'
'Show Replies': true
Header: Header:
'Header auto-hide': false 'Header auto-hide': false
'Bottom header': false 'Bottom header': false

View File

@ -36,12 +36,19 @@ Index =
$.on input, 'change', $.cb.value $.on input, 'change', $.cb.value
$.on input, 'change', @cb.sort $.on input, 'change', @cb.sort
repliesEntry =
el: $.el 'label', innerHTML: '<input type=checkbox name="Show Replies"> Show replies'
input = repliesEntry.el.firstChild
input.checked = Conf['Show Replies']
$.on input, 'change', $.cb.checked
$.on input, 'change', @cb.replies
$.event 'AddMenuEntry', $.event 'AddMenuEntry',
type: 'header' type: 'header'
el: $.el 'span', el: $.el 'span',
textContent: 'Index Navigation' textContent: 'Index Navigation'
order: 90 order: 90
subEntries: [modeEntry, sortEntry] subEntries: [modeEntry, sortEntry, repliesEntry]
$.addClass doc, 'index-loading' $.addClass doc, 'index-loading'
@update() @update()
@ -85,6 +92,10 @@ Index =
sort: -> sort: ->
Index.sort() Index.sort()
Index.buildIndex() Index.buildIndex()
replies: ->
Index.buildThreads()
Index.sort()
Index.buildIndex()
popstate: (e) -> popstate: (e) ->
pageNum = Index.getCurrentPage() pageNum = Index.getCurrentPage()
Index.pageLoad pageNum if Index.currentPage isnt pageNum Index.pageLoad pageNum if Index.currentPage isnt pageNum
@ -328,7 +339,7 @@ Index =
else else
nodes = Index.sortedNodes nodes = Index.sortedNodes
$.rmAll Index.root $.rmAll Index.root
Index.buildReplies nodes Index.buildReplies nodes if Conf['Show Replies']
$.event 'IndexBuild', nodes $.event 'IndexBuild', nodes
$.add Index.root, nodes $.add Index.root, nodes

View File

@ -50,16 +50,19 @@ ExpandThread =
a.textContent = ExpandThread.text '+', a.textContent.match(/\d+/g)... if a a.textContent = ExpandThread.text '+', a.textContent.match(/\d+/g)... if a
return return
num = if thread.isSticky replies = $$ '.thread > .replyContainer', threadRoot
1 if Conf['Show Replies']
else switch g.BOARD.ID num = if thread.isSticky
# XXX boards config 1
when 'b', 'vg' then 3 else switch g.BOARD.ID
when 't' then 1 # XXX boards config
else 5 when 'b', 'vg' then 3
when 't' then 1
else 5
replies = replies[...-num]
postsCount = 0 postsCount = 0
filesCount = 0 filesCount = 0
for reply in $$('.thread > .replyContainer', threadRoot)[...-num] for reply in replies
# rm clones # rm clones
inlined.click() while inlined = $ '.inlined', reply if Conf['Quote Inlining'] inlined.click() while inlined = $ '.inlined', reply if Conf['Quote Inlining']
postsCount++ postsCount++