Make header and board list work on Tinyboard.

This commit is contained in:
name 2017-12-11 16:01:54 -08:00
parent 86e4e06299
commit 5a177796a8
3 changed files with 18 additions and 13 deletions

View File

@ -84,15 +84,15 @@ Header =
$.on window, 'load popstate', Header.hashScroll $.on window, 'load popstate', Header.hashScroll
$.on d, 'CreateNotification', @createNotification $.on d, 'CreateNotification', @createNotification
@setBoardList()
$.onExists doc, 'body', => $.onExists doc, 'body', =>
return unless Main.isThisPageLegit() return unless Main.isThisPageLegit()
$.prepend d.body, @bar $.prepend d.body, @bar
$.add d.body, Header.hover $.add d.body, Header.hover
@setBarPosition Conf['Bottom Header'] @setBarPosition Conf['Bottom Header']
# Wait for #boardNavMobile instead of #boardNavDesktop, $.onExists doc, "#{Site.selectors.boardList} + *", Header.generateFullBoardList
# it might be incomplete otherwise.
$.onExists doc, '#boardNavMobile', Header.setBoardList
Main.ready -> Main.ready ->
if not (footer = $.id 'boardNavDesktopFoot') if not (footer = $.id 'boardNavDesktopFoot')
@ -154,9 +154,20 @@ Header =
btn = $('.hide-board-list-button', boardList) btn = $('.hide-board-list-button', boardList)
$.on btn, 'click', Header.toggleBoardList $.on btn, 'click', Header.toggleBoardList
$.add Header.bar, [Header.boardList, Header.shortcuts, Header.noticesRoot, Header.toggle]
Header.setCustomNav Conf['Custom Board Navigation']
Header.generateBoardList Conf['boardnav']
$.sync 'Custom Board Navigation', Header.setCustomNav
$.sync 'boardnav', Header.generateBoardList
generateFullBoardList: ->
nodes = [] nodes = []
spacer = -> $.el 'span', className: 'spacer' spacer = -> $.el 'span', className: 'spacer'
for node in $('#boardNavDesktop > .boardList').childNodes items = $.X './/a|.//text()[not(ancestor::a)]', $(Site.selectors.boardList)
i = 0
while node = items.snapshotItem i++
switch node.nodeName switch node.nodeName
when '#text' when '#text'
for chr in node.nodeValue for chr in node.nodeValue
@ -169,18 +180,10 @@ Header =
a = node.cloneNode true a = node.cloneNode true
a.className = 'current' if a.pathname.split('/')[1] is g.BOARD.ID a.className = 'current' if a.pathname.split('/')[1] is g.BOARD.ID
nodes.push a nodes.push a
fullBoardList = $ '.boardList', boardList fullBoardList = $ '.boardList', Header.boardList
$.add fullBoardList, nodes $.add fullBoardList, nodes
CatalogLinks.setLinks fullBoardList CatalogLinks.setLinks fullBoardList
$.add Header.bar, [Header.boardList, Header.shortcuts, Header.noticesRoot, Header.toggle]
Header.setCustomNav Conf['Custom Board Navigation']
Header.generateBoardList Conf['boardnav']
$.sync 'Custom Board Navigation', Header.setCustomNav
$.sync 'boardnav', Header.generateBoardList
generateBoardList: (boardnav) -> generateBoardList: (boardnav) ->
list = $ '#custom-board-list', Header.boardList list = $ '#custom-board-list', Header.boardList
$.rmAll list $.rmAll list

View File

@ -67,6 +67,7 @@ SW.tinyboard =
comment: '.body' comment: '.body'
spoiler: '.spoiler' spoiler: '.spoiler'
quotelink: 'a[onclick^="highlightReply("]' quotelink: 'a[onclick^="highlightReply("]'
boardList: '.boardlist'
xpath: xpath:
thread: 'div[starts-with(@id,"thread_")]' thread: 'div[starts-with(@id,"thread_")]'

View File

@ -33,6 +33,7 @@ SW.yotsuba =
comment: '.postMessage' comment: '.postMessage'
spoiler: 's' spoiler: 's'
quotelink: ':not(pre) > .quotelink' # XXX https://github.com/4chan/4chan-JS/issues/77: 4chan currently creates quote links inside [code] tags; ignore them quotelink: ':not(pre) > .quotelink' # XXX https://github.com/4chan/4chan-JS/issues/77: 4chan currently creates quote links inside [code] tags; ignore them
boardList: '#boardNavDesktop > .boardList'
xpath: xpath:
thread: 'div[contains(concat(" ",@class," ")," thread ")]' thread: 'div[contains(concat(" ",@class," ")," thread ")]'