diff --git a/CHANGELOG.md b/CHANGELOG.md index f9917766e..a24c8778e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ - Added `Image Size` setting for the catalog. - Added `Open threads in a new tab` setting for the catalog. +- Added `board-mode:"type"` and `board-sort:"type"` parameters to custom board navigation. +- Added OP name/date tooltip in the catalog. - Added a keybind to cycle through index sort types, `Ctrl+x` by default. - Added keybindings for index modes, `Ctrl+{1,2,3}` by default. diff --git a/css/style.css b/css/style.css index 83e1e8d08..472dafcea 100644 --- a/css/style.css +++ b/css/style.css @@ -497,7 +497,7 @@ a[href="javascript:;"] { } .thread-info { position: fixed; - background: inherit; + background-color: inherit; padding: 2px; border-radius: 2px; box-shadow: 0 0 5px rgba(0, 0, 0, .25); diff --git a/html/General/Index-pagelist.html b/html/General/Index-pagelist.html index 803cdca54..a025c7caf 100644 --- a/html/General/Index-pagelist.html +++ b/html/General/Index-pagelist.html @@ -10,5 +10,5 @@ diff --git a/html/General/Settings-section-Rice.html b/html/General/Settings-section-Rice.html index fe89c50ef..b0a092bef 100644 --- a/html/General/Settings-section-Rice.html +++ b/html/General/Settings-section-Rice.html @@ -8,6 +8,9 @@
Board link (Replace with title when on that board): board-replace
Full text link: board-full
Custom text link: board-text:"VIP Board"
+
Index mode: board-mode:"type" where type is paged, all threads or catalog
+
Index sort: board-sort:"type" where type is bump order, last reply, creation date, reply count or file count
+
Combinations are possible: board-text:"VIP Catalog"-mode:"catalog"-sort:"creation date"
Full board list toggle: toggle-all
diff --git a/src/General/Header.coffee b/src/General/Header.coffee index 164054adf..5260bb77c 100644 --- a/src/General/Header.coffee +++ b/src/General/Header.coffee @@ -112,10 +112,12 @@ Header = list = $ '#custom-board-list', Header.bar $.rmAll list return unless text - as = $$ '#full-board-list a[title]', Header.bar - nodes = text.match(/[\w@]+(-(all|title|replace|full|archive|text:"[^"]+"))*|[^\w@]+/g).map (t) -> + as = $$ '.boardList a[title]', Header.bar + re = /[\w@]+(-(all|title|replace|full|archive|(mode|sort|text):"[^"]+"))*|[^\w@]+/g + nodes = text.match(re).map (t) -> if /^[^\w@]/.test t return $.tn t + if /^toggle-all/.test t a = $.el 'a', className: 'show-board-list-button' @@ -123,32 +125,47 @@ Header = href: 'javascript:;' $.on a, 'click', Header.toggleBoardList return a - boardID = if /^current/.test t - g.BOARD.ID + + boardID = t.split('-')[0] + boardID = g.BOARD.ID if boardID is 'current' + for a in as when a.textContent is boardID + a = a.cloneNode() + break + return $.tn boardID if a.parentNode # Not a clone. + + if /-archive/.test t + if href = Redirect.to 'board', {boardID} + a.href = href + else + return a.firstChild # Its text node. + + a.textContent = if /-title/.test(t) or /-replace/.test(t) and boardID is g.BOARD.ID + a.title + else if /-full/.test t + "/#{boardID}/ - #{a.title}" + else if m = t.match /-text:"([^"]+)"/ + m[1] else - t.match(/^[^-]+/)[0] - for a in as - if a.textContent is boardID - a = a.cloneNode true + boardID - a.textContent = if /-title/.test(t) or /-replace/.test(t) and $.hasClass a, 'current' - a.title - else if /-full/.test t - "/#{boardID}/ - #{a.title}" - else if m = t.match /-text:"(.+)"/ - m[1] - else - a.textContent + if m = t.match /-mode:"([^"]+)"/ + type = m[1].toLowerCase() + a.dataset.indexMode = switch type + when 'all threads' then 'all pages' + when 'paged', 'catalog' then type + else 'paged' + if m = t.match /-sort:"([^"]+)"/ + type = m[1].toLowerCase() + a.dataset.indexSort = switch type + when 'bump order' then 'bump' + when 'last reply' then 'lastreply' + when 'creation date' then 'birth' + when 'reply count' then 'replycount' + when 'file count' then 'filecount' + else 'bump' - if /-archive/.test t - if href = Redirect.to 'board', {boardID} - a.href = href - else - return $.tn a.textContent - - $.addClass a, 'navSmall' if boardID is '@' - return a - $.tn t + $.addClass a, 'navSmall' if boardID is '@' + a $.add list, nodes toggleBoardList: -> diff --git a/src/General/Index.coffee b/src/General/Index.coffee index 837c360ea..bc484e48e 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -95,6 +95,7 @@ Index = @currentPage = @getCurrentPage() $.on window, 'popstate', @cb.popstate $.on @pagelist, 'click', @cb.pageNav + $.on $('#custom-board-list', Header.bar), 'click', @cb.headerNav @cb.toggleCatalogMode() @@ -260,10 +261,10 @@ Index = 'Show' Index.sort() Index.buildIndex() - mode: -> + mode: (e) -> Index.cb.toggleCatalogMode() Index.togglePagelist() - Index.buildIndex() + Index.buildIndex() if e mode = Conf['Index Mode'] if mode not in ['catalog', Conf['Previous Index Mode']] Conf['Previous Index Mode'] = mode @@ -273,9 +274,9 @@ Index = QR.hide() else QR.unhide() - sort: -> + sort: (e) -> Index.sort() - Index.buildIndex() + Index.buildIndex() if e size: (e) -> if Conf['Index Mode'] isnt 'catalog' $.rmClass Index.root, 'catalog-small' @@ -316,13 +317,36 @@ Index = else return e.preventDefault() - if a.textContent is 'Catalog' - $.set 'Index Mode', 'catalog' - Conf['Index Mode'] = 'catalog' - Index.selectMode.value = 'catalog' - Index.cb.mode() - Index.scrollToIndex() + return if Index.cb.indexNav a, true Index.userPageNav +a.pathname.split('/')[2] + headerNav: (e) -> + a = e.target + return if e.button isnt 0 or a.nodeName isnt 'A' or a.hostname isnt 'boards.4chan.org' + # Save settings + onSameBoard = a.pathname.split('/')[1] is g.BOARD.ID + Index.cb.indexNav a, onSameBoard + # Do nav if this isn't a simple click, or different board. + return if e.shiftKey or e.altKey or e.ctrlKey or e.metaKey or !onSameBoard + e.preventDefault() + indexNav: (a, onSameBoard) -> + {indexMode, indexSort} = a.dataset + if indexMode + $.set 'Index Mode', indexMode + Conf['Index Mode'] = indexMode + if g.VIEW is 'index' and onSameBoard + Index.selectMode.value = indexMode + Index.cb.mode() + if indexSort + $.set 'Index Sort', indexSort + Conf['Index Sort'] = indexSort + if g.VIEW is 'index' and onSameBoard + Index.selectSort.value = indexSort + Index.cb.sort() + if g.VIEW is 'index' and onSameBoard and (indexMode or indexSort) + Index.buildIndex() + Index.scrollToIndex() + return true + false scrollToIndex: -> Header.scrollToIfNeeded Index.navLinks