Add sorting options by bump order and creation date.
This commit is contained in:
parent
0038f1f011
commit
092d9317e0
@ -1,6 +1,10 @@
|
|||||||
Index navigation improvements:
|
Index navigation improvements:
|
||||||
- You can now refresh the index page you are on with the icon in the header bar or the same keybind for refreshing threads.
|
- You can now refresh the index page you are on with the icon in the header bar or the same keybind for refreshing threads.
|
||||||
- You can now switch between single-page and all-pages navigation via the "Index Navigation" header sub-menu.
|
- You can now switch between single-page and all-pages navigation via the "Index Navigation" header sub-menu.
|
||||||
|
- Threads in the index can now be sorted by:
|
||||||
|
- bump order
|
||||||
|
- creation date
|
||||||
|
|
||||||
Added a keybind to open the catalog search field on index pages.
|
Added a keybind to open the catalog search field on index pages.
|
||||||
|
|
||||||
### 3.11.5 - *2013-10-03*
|
### 3.11.5 - *2013-10-03*
|
||||||
|
|||||||
@ -104,7 +104,7 @@ $.rm = do ->
|
|||||||
(el) -> el.parentNode?.removeChild el
|
(el) -> el.parentNode?.removeChild el
|
||||||
$.rmAll = (root) ->
|
$.rmAll = (root) ->
|
||||||
# jsperf.com/emptify-element
|
# jsperf.com/emptify-element
|
||||||
while node = root.firstChild
|
for node in [root.childNodes...]
|
||||||
# HTMLSelectElement.remove !== Element.remove
|
# HTMLSelectElement.remove !== Element.remove
|
||||||
root.removeChild node
|
root.removeChild node
|
||||||
return
|
return
|
||||||
|
|||||||
@ -139,8 +139,10 @@ Config =
|
|||||||
#//archive.foolz.us/%board/search/image/%MD5/;text:View same on foolz /%board/
|
#//archive.foolz.us/%board/search/image/%MD5/;text:View same on foolz /%board/
|
||||||
#//archive.installgentoo.net/%board/image/%MD5;text:View same on installgentoo /%board/
|
#//archive.installgentoo.net/%board/image/%MD5;text:View same on installgentoo /%board/
|
||||||
"""
|
"""
|
||||||
'Index Mode': 'paged'
|
|
||||||
'Custom CSS': false
|
'Custom CSS': false
|
||||||
|
Index:
|
||||||
|
'Index Mode': 'paged'
|
||||||
|
'Index Sort': 'bump'
|
||||||
Header:
|
Header:
|
||||||
'Header auto-hide': false
|
'Header auto-hide': false
|
||||||
'Bottom header': false
|
'Bottom header': false
|
||||||
|
|||||||
@ -9,34 +9,44 @@ Index =
|
|||||||
$.on button, 'click', Index.update
|
$.on button, 'click', Index.update
|
||||||
Header.addShortcut button, 1
|
Header.addShortcut button, 1
|
||||||
|
|
||||||
subEntries = []
|
modeEntry =
|
||||||
|
el: $.el 'span', textContent: 'Index mode'
|
||||||
subEntry =
|
|
||||||
el: $.el 'span', textContent: 'Index Mode'
|
|
||||||
subEntries: [
|
subEntries: [
|
||||||
{ el: $.el 'label', innerHTML: '<input type=radio name="Index Mode" value="paged"> Paged' }
|
{ el: $.el 'label', innerHTML: '<input type=radio name="Index Mode" value="paged"> Paged' }
|
||||||
{ el: $.el 'label', innerHTML: '<input type=radio name="Index Mode" value="all pages"> All threads' }
|
{ el: $.el 'label', innerHTML: '<input type=radio name="Index Mode" value="all pages"> All threads' }
|
||||||
]
|
]
|
||||||
for label in subEntry.subEntries
|
for label in modeEntry.subEntries
|
||||||
input = label.el.firstChild
|
input = label.el.firstChild
|
||||||
input.checked = Conf['Index Mode'] is input.value
|
input.checked = Conf['Index Mode'] is input.value
|
||||||
$.on input, 'change', $.cb.value
|
$.on input, 'change', $.cb.value
|
||||||
$.on input, 'change', @update
|
$.on input, 'change', @update
|
||||||
subEntries.push subEntry
|
|
||||||
|
sortEntry =
|
||||||
|
el: $.el 'span', textContent: 'Sort by'
|
||||||
|
subEntries: [
|
||||||
|
{ el: $.el 'label', innerHTML: '<input type=radio name="Index Sort" value="bump"> Bump order' }
|
||||||
|
{ el: $.el 'label', innerHTML: '<input type=radio name="Index Sort" value="birth"> Creation date' }
|
||||||
|
]
|
||||||
|
for label in sortEntry.subEntries
|
||||||
|
input = label.el.firstChild
|
||||||
|
input.checked = Conf['Index Sort'] is input.value
|
||||||
|
$.on input, 'change', $.cb.value
|
||||||
|
$.on input, 'change', @resort
|
||||||
|
|
||||||
$.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: subEntries
|
subEntries: [modeEntry, sortEntry]
|
||||||
|
|
||||||
$.on d, '4chanXInitFinished', @initReady
|
$.on d, '4chanXInitFinished', @initReady
|
||||||
|
|
||||||
initReady: ->
|
initReady: ->
|
||||||
$.off d, '4chanXInitFinished', Index.initReady
|
$.off d, '4chanXInitFinished', Index.initReady
|
||||||
Index.root = $ '.board'
|
Index.root = $ '.board'
|
||||||
Index.setIndex $$ '.board > .thread, .board > hr', Index.root
|
Index.liveThreads = $$('.board > .thread', Index.root).map Get.threadFromRoot
|
||||||
|
Index.resort()
|
||||||
return if Conf['Index Mode'] is 'paged'
|
return if Conf['Index Mode'] is 'paged'
|
||||||
Index.update()
|
Index.update()
|
||||||
|
|
||||||
@ -84,17 +94,17 @@ Index =
|
|||||||
for page in pages
|
for page in pages
|
||||||
dataThr.push page.threads...
|
dataThr.push page.threads...
|
||||||
|
|
||||||
nodes = []
|
nodes = []
|
||||||
threads = []
|
threads = []
|
||||||
liveThreads = []
|
posts = []
|
||||||
posts = []
|
Index.liveThreads = []
|
||||||
for data in dataThr
|
for data in dataThr
|
||||||
threadRoot = Build.thread g.BOARD, data
|
threadRoot = Build.thread g.BOARD, data
|
||||||
nodes.push threadRoot, $.el 'hr'
|
nodes.push threadRoot, $.el 'hr'
|
||||||
unless thread = g.threads["#{g.BOARD}.#{data.no}"]
|
unless thread = g.threads["#{g.BOARD}.#{data.no}"]
|
||||||
thread = new Thread data.no, g.BOARD
|
thread = new Thread data.no, g.BOARD
|
||||||
threads.push thread
|
threads.push thread
|
||||||
liveThreads.push thread
|
Index.liveThreads.push thread
|
||||||
for postRoot in $$ '.thread > .postContainer', threadRoot
|
for postRoot in $$ '.thread > .postContainer', threadRoot
|
||||||
continue if thread.posts[postRoot.id.match /\d+/]
|
continue if thread.posts[postRoot.id.match /\d+/]
|
||||||
try
|
try
|
||||||
@ -108,7 +118,7 @@ Index =
|
|||||||
error: err
|
error: err
|
||||||
Main.handleErrors errors if errors
|
Main.handleErrors errors if errors
|
||||||
|
|
||||||
Index.collectDeadThreads liveThreads
|
Index.collectDeadThreads()
|
||||||
# Add the threads and <hr>s in a container to make sure all features work.
|
# Add the threads and <hr>s in a container to make sure all features work.
|
||||||
$.nodes nodes
|
$.nodes nodes
|
||||||
Main.callbackNodes Thread, threads
|
Main.callbackNodes Thread, threads
|
||||||
@ -120,19 +130,32 @@ Index =
|
|||||||
$.rmAll Index.root
|
$.rmAll Index.root
|
||||||
$.add Index.root, Index.sort nodes
|
$.add Index.root, Index.sort nodes
|
||||||
$('.pagelist').hidden = Conf['Index Mode'] isnt 'paged'
|
$('.pagelist').hidden = Conf['Index Mode'] isnt 'paged'
|
||||||
sort: (nodes) ->
|
sort: (unsortedNodes) ->
|
||||||
|
nodes = []
|
||||||
|
switch Conf['Index Sort']
|
||||||
|
when 'bump'
|
||||||
|
for thread in Index.liveThreads
|
||||||
|
i = unsortedNodes.indexOf thread.OP.nodes.root.parentNode
|
||||||
|
nodes.push unsortedNodes[i], unsortedNodes[i + 1]
|
||||||
|
when 'birth'
|
||||||
|
dates = []
|
||||||
|
for threadRoot, i in unsortedNodes by 2
|
||||||
|
dates.push Get.threadFromRoot(threadRoot).OP.info.date
|
||||||
|
unsortedDates = [dates...]
|
||||||
|
for date in dates.sort((a, b) -> b - a)
|
||||||
|
i = unsortedDates.indexOf(date) * 2
|
||||||
|
nodes.push unsortedNodes[i], unsortedNodes[i + 1]
|
||||||
return nodes unless Conf['Filter']
|
return nodes unless Conf['Filter']
|
||||||
# Put the highlighted thread & <hr> on top of the index
|
# Put the highlighted thread & <hr> on top of the index
|
||||||
# while keeping the original order they appear in.
|
# while keeping the original order they appear in.
|
||||||
i = offset = 0
|
offset = 0
|
||||||
while threadRoot = nodes[i]
|
for threadRoot, i in nodes by 2 when Get.threadFromRoot(threadRoot).isOnTop
|
||||||
if Get.threadFromRoot(threadRoot).isOnTop
|
nodes.splice offset++ * 2, 0, nodes.splice(i, 2)...
|
||||||
nodes.splice offset, 0, nodes.splice(i, 2)...
|
|
||||||
offset += 2
|
|
||||||
i += 2
|
|
||||||
nodes
|
nodes
|
||||||
|
resort: ->
|
||||||
|
Index.setIndex $$ '.board > .thread, .board > hr', Index.root
|
||||||
|
|
||||||
collectDeadThreads: (liveThreads) ->
|
collectDeadThreads: (liveThreads) ->
|
||||||
for threadID, thread of g.threads when thread not in liveThreads
|
for threadID, thread of g.threads when thread not in Index.liveThreads
|
||||||
thread.collect()
|
thread.collect()
|
||||||
return
|
return
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user