diff --git a/CHANGELOG.md b/CHANGELOG.md index 352ef32a5..c075422c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ 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 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. ### 3.11.5 - *2013-10-03* diff --git a/lib/$.coffee b/lib/$.coffee index 8b2202304..711159e6c 100644 --- a/lib/$.coffee +++ b/lib/$.coffee @@ -104,7 +104,7 @@ $.rm = do -> (el) -> el.parentNode?.removeChild el $.rmAll = (root) -> # jsperf.com/emptify-element - while node = root.firstChild + for node in [root.childNodes...] # HTMLSelectElement.remove !== Element.remove root.removeChild node return diff --git a/src/General/Config.coffee b/src/General/Config.coffee index dd3220383..95f1f2a48 100644 --- a/src/General/Config.coffee +++ b/src/General/Config.coffee @@ -139,8 +139,10 @@ Config = #//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/ """ - 'Index Mode': 'paged' 'Custom CSS': false + Index: + 'Index Mode': 'paged' + 'Index Sort': 'bump' Header: 'Header auto-hide': false 'Bottom header': false diff --git a/src/Miscellaneous/Index.coffee b/src/Miscellaneous/Index.coffee index 8de6fa1de..51aadffc3 100644 --- a/src/Miscellaneous/Index.coffee +++ b/src/Miscellaneous/Index.coffee @@ -9,34 +9,44 @@ Index = $.on button, 'click', Index.update Header.addShortcut button, 1 - subEntries = [] - - subEntry = - el: $.el 'span', textContent: 'Index Mode' + modeEntry = + el: $.el 'span', textContent: 'Index mode' subEntries: [ { el: $.el 'label', innerHTML: ' Paged' } { el: $.el 'label', innerHTML: ' All threads' } ] - for label in subEntry.subEntries + for label in modeEntry.subEntries input = label.el.firstChild input.checked = Conf['Index Mode'] is input.value $.on input, 'change', $.cb.value $.on input, 'change', @update - subEntries.push subEntry + + sortEntry = + el: $.el 'span', textContent: 'Sort by' + subEntries: [ + { el: $.el 'label', innerHTML: ' Bump order' } + { el: $.el 'label', innerHTML: ' 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', type: 'header' el: $.el 'span', textContent: 'Index Navigation' order: 90 - subEntries: subEntries + subEntries: [modeEntry, sortEntry] $.on d, '4chanXInitFinished', @initReady initReady: -> $.off d, '4chanXInitFinished', Index.initReady 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' Index.update() @@ -84,17 +94,17 @@ Index = for page in pages dataThr.push page.threads... - nodes = [] - threads = [] - liveThreads = [] - posts = [] + nodes = [] + threads = [] + posts = [] + Index.liveThreads = [] for data in dataThr threadRoot = Build.thread g.BOARD, data nodes.push threadRoot, $.el 'hr' unless thread = g.threads["#{g.BOARD}.#{data.no}"] thread = new Thread data.no, g.BOARD threads.push thread - liveThreads.push thread + Index.liveThreads.push thread for postRoot in $$ '.thread > .postContainer', threadRoot continue if thread.posts[postRoot.id.match /\d+/] try @@ -108,7 +118,7 @@ Index = error: err Main.handleErrors errors if errors - Index.collectDeadThreads liveThreads + Index.collectDeadThreads() # Add the threads and