From 6015bfe4a7977b913d078926a2e6195abea38884 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Tue, 13 Jan 2015 17:24:58 -0700 Subject: [PATCH] Fix long-broken CatalogLinks header generation --- builds/appchan-x.user.js | 13 ++++++++----- builds/crx/script.js | 13 ++++++++----- src/Filtering/PostHiding.coffee | 2 ++ src/General/Header.coffee | 2 +- src/Miscellaneous/CatalogLinks.coffee | 5 +++-- 5 files changed, 22 insertions(+), 13 deletions(-) diff --git a/builds/appchan-x.user.js b/builds/appchan-x.user.js index 135ed790d..86dcec3de 100644 --- a/builds/appchan-x.user.js +++ b/builds/appchan-x.user.js @@ -4585,7 +4585,9 @@ return _results; })(); $.add(list, nodes); - return $.ready(CatalogLinks.initBoardList); + return $.ready(function() { + return CatalogLinks.set(Conf['Header catalog links']); + }); }, mapCustomNavigation: function(t, as) { var a, boardID, href, m, text, type, url, _i, _len; @@ -15650,19 +15652,20 @@ set: function(useCatalog) { var a, board, generateURL, path, _i, _len, _ref, _ref1; path = useCatalog ? 'catalog' : ''; - generateURL = useCatalog && Conf['External Catalog'] ? CatalogLinks.external : function(board) { - return a.href = "/" + board + "/" + path; - }; + generateURL = useCatalog && Conf['External Catalog'] ? CatalogLinks.external : CatalogLinks.internal; _ref = $$("#board-list a:not(.catalog), #boardNavDesktopFoot a"); for (_i = 0, _len = _ref.length; _i < _len; _i++) { a = _ref[_i]; if (((_ref1 = a.hostname) !== 'boards.4chan.org' && _ref1 !== 'catalog.neet.tv' && _ref1 !== '4index.gropes.us') || !(board = a.pathname.split('/')[1]) || (board === 'f' || board === 'status' || board === '4chan') || $.hasClass(a, 'external')) { continue; } - a.href = generateURL(board); + a.href = generateURL(board, path); } return CatalogLinks.el.title = "Turn catalog links " + (useCatalog ? 'off' : 'on') + "."; }, + internal: function(board, path) { + return "/" + board + "/" + path; + }, external: function(board) { if (board === 'a' || board === 'c' || board === 'g' || board === 'co' || board === 'k' || board === 'm' || board === 'o' || board === 'p' || board === 'v' || board === 'vg' || board === 'w' || board === 'cm' || board === '3' || board === 'adv' || board === 'an' || board === 'cgl' || board === 'ck' || board === 'diy' || board === 'fa' || board === 'fit' || board === 'int' || board === 'jp' || board === 'mlp' || board === 'lit' || board === 'mu' || board === 'n' || board === 'po' || board === 'sci' || board === 'toy' || board === 'trv' || board === 'tv' || board === 'vp' || board === 'x' || board === 'q') { return "http://catalog.neet.tv/" + board; diff --git a/builds/crx/script.js b/builds/crx/script.js index 8cf6e784f..40057c980 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -4603,7 +4603,9 @@ return _results; })(); $.add(list, nodes); - return $.ready(CatalogLinks.initBoardList); + return $.ready(function() { + return CatalogLinks.set(Conf['Header catalog links']); + }); }, mapCustomNavigation: function(t, as) { var a, boardID, href, m, text, type, url, _i, _len; @@ -15665,19 +15667,20 @@ set: function(useCatalog) { var a, board, generateURL, path, _i, _len, _ref, _ref1; path = useCatalog ? 'catalog' : ''; - generateURL = useCatalog && Conf['External Catalog'] ? CatalogLinks.external : function(board) { - return a.href = "/" + board + "/" + path; - }; + generateURL = useCatalog && Conf['External Catalog'] ? CatalogLinks.external : CatalogLinks.internal; _ref = $$("#board-list a:not(.catalog), #boardNavDesktopFoot a"); for (_i = 0, _len = _ref.length; _i < _len; _i++) { a = _ref[_i]; if (((_ref1 = a.hostname) !== 'boards.4chan.org' && _ref1 !== 'catalog.neet.tv' && _ref1 !== '4index.gropes.us') || !(board = a.pathname.split('/')[1]) || (board === 'f' || board === 'status' || board === '4chan') || $.hasClass(a, 'external')) { continue; } - a.href = generateURL(board); + a.href = generateURL(board, path); } return CatalogLinks.el.title = "Turn catalog links " + (useCatalog ? 'off' : 'on') + "."; }, + internal: function(board, path) { + return "/" + board + "/" + path; + }, external: function(board) { if (board === 'a' || board === 'c' || board === 'g' || board === 'co' || board === 'k' || board === 'm' || board === 'o' || board === 'p' || board === 'v' || board === 'vg' || board === 'w' || board === 'cm' || board === '3' || board === 'adv' || board === 'an' || board === 'cgl' || board === 'ck' || board === 'diy' || board === 'fa' || board === 'fit' || board === 'int' || board === 'jp' || board === 'mlp' || board === 'lit' || board === 'mu' || board === 'n' || board === 'po' || board === 'sci' || board === 'toy' || board === 'trv' || board === 'tv' || board === 'vp' || board === 'x' || board === 'q') { return "http://catalog.neet.tv/" + board; diff --git a/src/Filtering/PostHiding.coffee b/src/Filtering/PostHiding.coffee index 005a2addb..22e2c930a 100644 --- a/src/Filtering/PostHiding.coffee +++ b/src/Filtering/PostHiding.coffee @@ -1,6 +1,7 @@ PostHiding = init: -> @db = new DataBoard 'hiddenPosts' + @hideButton = $.el 'a', className: 'hide-post-button fa' href: 'javascript:;' @@ -162,6 +163,7 @@ PostHiding = return PostHiding.saveHiddenState post, {thisPost: false, hideRecursively: replies, makeStub} unless thisPost $.event 'CloseMenu' + show: (post) -> parent = @parentNode thisPost = $('input[name=thisPost]', parent).checked diff --git a/src/General/Header.coffee b/src/General/Header.coffee index 693d396cf..7d27875e6 100644 --- a/src/General/Header.coffee +++ b/src/General/Header.coffee @@ -163,7 +163,7 @@ Header = re = /[\w@]+(-(all|title|replace|full|index|catalog|archive|expired|(mode|sort|text|url):"[^"]+"(,"[^"]+")?))*|[^\w@]+/g nodes = (Header.mapCustomNavigation t, as for t in boardnav.match re) $.add list, nodes - $.ready CatalogLinks.initBoardList + $.ready -> CatalogLinks.set Conf['Header catalog links'] mapCustomNavigation: (t, as) -> if /^[^\w@]/.test t diff --git a/src/Miscellaneous/CatalogLinks.coffee b/src/Miscellaneous/CatalogLinks.coffee index a62a4ec6b..ae0eab89e 100755 --- a/src/Miscellaneous/CatalogLinks.coffee +++ b/src/Miscellaneous/CatalogLinks.coffee @@ -29,7 +29,7 @@ CatalogLinks = generateURL = if useCatalog and Conf['External Catalog'] CatalogLinks.external else - (board) -> a.href = "/#{board}/#{path}" + CatalogLinks.internal for a in $$ """#board-list a:not(.catalog), #boardNavDesktopFoot a""" continue if a.hostname not in ['boards.4chan.org', 'catalog.neet.tv', '4index.gropes.us'] or @@ -39,10 +39,11 @@ CatalogLinks = # Href is easier than pathname because then we don't have # conditions where External Catalog has been disabled between switches. - a.href = generateURL board + a.href = generateURL board, path CatalogLinks.el.title = "Turn catalog links #{if useCatalog then 'off' else 'on'}." + internal: (board, path) -> "/#{board}/#{path}" external: (board) -> if board in ['a', 'c', 'g', 'co', 'k', 'm', 'o', 'p', 'v', 'vg', 'w', 'cm', '3', 'adv', 'an', 'cgl', 'ck', 'diy', 'fa', 'fit', 'int', 'jp', 'mlp', 'lit', 'mu', 'n', 'po', 'sci', 'toy', 'trv', 'tv', 'vp', 'x', 'q'] "http://catalog.neet.tv/#{board}"