From 9693ea5821499b38c1ff60ce08417dcfbcc3c2d5 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Fri, 23 Jan 2015 12:20:22 -0800 Subject: [PATCH] Make custom 'current' board links work on unlisted boards. --- src/General/Header.coffee | 64 ++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/src/General/Header.coffee b/src/General/Header.coffee index 9bb199bd4..5d3c83681 100755 --- a/src/General/Header.coffee +++ b/src/General/Header.coffee @@ -207,39 +207,47 @@ Header = g.BOARD.ID else t.match(/^[^-]+/)[0] - 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' - a.title - else if /-full/.test t - "/#{boardID}/ - #{a.title}" - else if text - text - else - a.textContent + for aOrig in as + if aOrig.textContent is boardID + a = aOrig.cloneNode true + if !a + if /^current/.test t + a = $.el 'a', + href: "/#{boardID}/" + textContent: boardID + else + return $.tn t - if m = t.match /-(index|catalog)/ - a.dataset.only = m[1] - a.href = CatalogLinks[m[1]] boardID - $.addClass a, 'catalog' if m[1] is 'catalog' + a.textContent = if /-title/.test(t) or /-replace/.test(t) and $.hasClass a, 'current' + a.title or a.textContent + else if /-full/.test t + "/#{boardID}/" + (if a.title then " - #{a.title}" else '') + else if text + text + else + a.textContent - if /-archive/.test t - if href = Redirect.to 'board', {boardID} - a.href = href - else - return $.tn a.textContent + if m = t.match /-(index|catalog)/ + a.dataset.only = m[1] + a.href = CatalogLinks[m[1]] boardID + $.addClass a, 'catalog' if m[1] is 'catalog' - if /-expired/.test t - if boardID not in ['b', 'f'] - a.href = "/#{boardID}/archive" - else - return $.tn a.textContent + if /-archive/.test t + if href = Redirect.to 'board', {boardID} + a.href = href + else + return $.tn a.textContent + + if /-expired/.test t + if boardID not in ['b', 'f'] + a.href = "/#{boardID}/archive" + else + return $.tn a.textContent + + $.addClass a, 'navSmall' if boardID is '@' + return a - $.addClass a, 'navSmall' if boardID is '@' - return a - $.tn t $.add list, nodes $.ready CatalogLinks.initBoardList