Add board-mode and board-sort to custom board navigation.
This commit is contained in:
parent
9eda01601c
commit
fe5f19d705
@ -1,5 +1,7 @@
|
|||||||
- Added `Image Size` setting for the catalog.
|
- Added `Image Size` setting for the catalog.
|
||||||
- Added `Open threads in a new tab` 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 a keybind to cycle through index sort types, `Ctrl+x` by default.
|
||||||
- Added keybindings for index modes, `Ctrl+{1,2,3}` by default.
|
- Added keybindings for index modes, `Ctrl+{1,2,3}` by default.
|
||||||
|
|
||||||
|
|||||||
@ -497,7 +497,7 @@ a[href="javascript:;"] {
|
|||||||
}
|
}
|
||||||
.thread-info {
|
.thread-info {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
background: inherit;
|
background-color: inherit;
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
box-shadow: 0 0 5px rgba(0, 0, 0, .25);
|
box-shadow: 0 0 5px rgba(0, 0, 0, .25);
|
||||||
|
|||||||
@ -10,5 +10,5 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="pages cataloglink">
|
<div class="pages cataloglink">
|
||||||
<a href="./">Catalog</a>
|
<a href="./" data-index-mode="catalog">Catalog</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -8,6 +8,9 @@
|
|||||||
<div>Board link (Replace with title when on that board): <code>board-replace</code></div>
|
<div>Board link (Replace with title when on that board): <code>board-replace</code></div>
|
||||||
<div>Full text link: <code>board-full</code></div>
|
<div>Full text link: <code>board-full</code></div>
|
||||||
<div>Custom text link: <code>board-text:"VIP Board"</code></div>
|
<div>Custom text link: <code>board-text:"VIP Board"</code></div>
|
||||||
|
<div>Index mode: <code>board-mode:"type"</code> where type is <code>paged</code>, <code>all threads</code> or <code>catalog</code></div>
|
||||||
|
<div>Index sort: <code>board-sort:"type"</code> where type is <code>bump order</code>, <code>last reply</code>, <code>creation date</code>, <code>reply count</code> or <code>file count</code></div>
|
||||||
|
<div>Combinations are possible: <code>board-text:"VIP Catalog"-mode:"catalog"-sort:"creation date"</code></div>
|
||||||
<div>Full board list toggle: <code>toggle-all</code></div>
|
<div>Full board list toggle: <code>toggle-all</code></div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
|||||||
@ -112,10 +112,12 @@ Header =
|
|||||||
list = $ '#custom-board-list', Header.bar
|
list = $ '#custom-board-list', Header.bar
|
||||||
$.rmAll list
|
$.rmAll list
|
||||||
return unless text
|
return unless text
|
||||||
as = $$ '#full-board-list a[title]', Header.bar
|
as = $$ '.boardList a[title]', Header.bar
|
||||||
nodes = text.match(/[\w@]+(-(all|title|replace|full|archive|text:"[^"]+"))*|[^\w@]+/g).map (t) ->
|
re = /[\w@]+(-(all|title|replace|full|archive|(mode|sort|text):"[^"]+"))*|[^\w@]+/g
|
||||||
|
nodes = text.match(re).map (t) ->
|
||||||
if /^[^\w@]/.test t
|
if /^[^\w@]/.test t
|
||||||
return $.tn t
|
return $.tn t
|
||||||
|
|
||||||
if /^toggle-all/.test t
|
if /^toggle-all/.test t
|
||||||
a = $.el 'a',
|
a = $.el 'a',
|
||||||
className: 'show-board-list-button'
|
className: 'show-board-list-button'
|
||||||
@ -123,32 +125,47 @@ Header =
|
|||||||
href: 'javascript:;'
|
href: 'javascript:;'
|
||||||
$.on a, 'click', Header.toggleBoardList
|
$.on a, 'click', Header.toggleBoardList
|
||||||
return a
|
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
|
else
|
||||||
t.match(/^[^-]+/)[0]
|
boardID
|
||||||
for a in as
|
|
||||||
if a.textContent is boardID
|
|
||||||
a = a.cloneNode true
|
|
||||||
|
|
||||||
a.textContent = if /-title/.test(t) or /-replace/.test(t) and $.hasClass a, 'current'
|
if m = t.match /-mode:"([^"]+)"/
|
||||||
a.title
|
type = m[1].toLowerCase()
|
||||||
else if /-full/.test t
|
a.dataset.indexMode = switch type
|
||||||
"/#{boardID}/ - #{a.title}"
|
when 'all threads' then 'all pages'
|
||||||
else if m = t.match /-text:"(.+)"/
|
when 'paged', 'catalog' then type
|
||||||
m[1]
|
else 'paged'
|
||||||
else
|
if m = t.match /-sort:"([^"]+)"/
|
||||||
a.textContent
|
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
|
$.addClass a, 'navSmall' if boardID is '@'
|
||||||
if href = Redirect.to 'board', {boardID}
|
a
|
||||||
a.href = href
|
|
||||||
else
|
|
||||||
return $.tn a.textContent
|
|
||||||
|
|
||||||
$.addClass a, 'navSmall' if boardID is '@'
|
|
||||||
return a
|
|
||||||
$.tn t
|
|
||||||
$.add list, nodes
|
$.add list, nodes
|
||||||
|
|
||||||
toggleBoardList: ->
|
toggleBoardList: ->
|
||||||
|
|||||||
@ -95,6 +95,7 @@ Index =
|
|||||||
@currentPage = @getCurrentPage()
|
@currentPage = @getCurrentPage()
|
||||||
$.on window, 'popstate', @cb.popstate
|
$.on window, 'popstate', @cb.popstate
|
||||||
$.on @pagelist, 'click', @cb.pageNav
|
$.on @pagelist, 'click', @cb.pageNav
|
||||||
|
$.on $('#custom-board-list', Header.bar), 'click', @cb.headerNav
|
||||||
|
|
||||||
@cb.toggleCatalogMode()
|
@cb.toggleCatalogMode()
|
||||||
|
|
||||||
@ -260,10 +261,10 @@ Index =
|
|||||||
'Show'
|
'Show'
|
||||||
Index.sort()
|
Index.sort()
|
||||||
Index.buildIndex()
|
Index.buildIndex()
|
||||||
mode: ->
|
mode: (e) ->
|
||||||
Index.cb.toggleCatalogMode()
|
Index.cb.toggleCatalogMode()
|
||||||
Index.togglePagelist()
|
Index.togglePagelist()
|
||||||
Index.buildIndex()
|
Index.buildIndex() if e
|
||||||
mode = Conf['Index Mode']
|
mode = Conf['Index Mode']
|
||||||
if mode not in ['catalog', Conf['Previous Index Mode']]
|
if mode not in ['catalog', Conf['Previous Index Mode']]
|
||||||
Conf['Previous Index Mode'] = mode
|
Conf['Previous Index Mode'] = mode
|
||||||
@ -273,9 +274,9 @@ Index =
|
|||||||
QR.hide()
|
QR.hide()
|
||||||
else
|
else
|
||||||
QR.unhide()
|
QR.unhide()
|
||||||
sort: ->
|
sort: (e) ->
|
||||||
Index.sort()
|
Index.sort()
|
||||||
Index.buildIndex()
|
Index.buildIndex() if e
|
||||||
size: (e) ->
|
size: (e) ->
|
||||||
if Conf['Index Mode'] isnt 'catalog'
|
if Conf['Index Mode'] isnt 'catalog'
|
||||||
$.rmClass Index.root, 'catalog-small'
|
$.rmClass Index.root, 'catalog-small'
|
||||||
@ -316,13 +317,36 @@ Index =
|
|||||||
else
|
else
|
||||||
return
|
return
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
if a.textContent is 'Catalog'
|
return if Index.cb.indexNav a, true
|
||||||
$.set 'Index Mode', 'catalog'
|
|
||||||
Conf['Index Mode'] = 'catalog'
|
|
||||||
Index.selectMode.value = 'catalog'
|
|
||||||
Index.cb.mode()
|
|
||||||
Index.scrollToIndex()
|
|
||||||
Index.userPageNav +a.pathname.split('/')[2]
|
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: ->
|
scrollToIndex: ->
|
||||||
Header.scrollToIfNeeded Index.navLinks
|
Header.scrollToIfNeeded Index.navLinks
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user