Rewrite catalog links. #239

This commit is contained in:
ccd0 2015-01-01 23:18:44 -08:00
parent f0e2bce4ef
commit 2f8a509c71

View File

@ -12,18 +12,30 @@ CatalogLinks =
when "/#{g.BOARD}/catalog" then link.href = CatalogLinks.catalog() when "/#{g.BOARD}/catalog" then link.href = CatalogLinks.catalog()
return return
return unless Conf['Catalog Links'] if Conf['JSON Navigation'] and Conf['Use 4chan X Catalog']
Post.callbacks.push
name: 'Catalog Link Rewrite'
cb: @node
CatalogThread.callbacks.push
name: 'Catalog Link Rewrite'
cb: @node
if Conf['Catalog Links']
CatalogLinks.el = el = UI.checkbox 'Header catalog links', ' Catalog Links' CatalogLinks.el = el = UI.checkbox 'Header catalog links', ' Catalog Links'
el.id = 'toggleCatalog' el.id = 'toggleCatalog'
input = $ 'input', el input = $ 'input', el
$.on input, 'change', @toggle $.on input, 'change', @toggle
$.sync 'Header catalog links', CatalogLinks.set $.sync 'Header catalog links', CatalogLinks.set
Header.menu.addEntry Header.menu.addEntry
el: el el: el
order: 95 order: 95
node: ->
for a in $$ 'a', @nodes.comment
if m = a.href.match /^https?:\/\/boards\.4chan\.org\/([^\/]+)\/catalog(#s=.*)?/
a.href = "//boards.4chan.org/#{m[1]}/#{m[2] or '#catalog'}"
return
# Set links on load or custom board list change. # Set links on load or custom board list change.
# Called by Header when both board lists (header and footer) are ready. # Called by Header when both board lists (header and footer) are ready.
initBoardList: -> initBoardList: ->