From 456c9af18d00d566e7b36bb462c9941cef349d35 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Tue, 7 Jan 2014 11:52:07 -0700 Subject: [PATCH 1/3] Bind an index refresh to the current board's link I mean, this makes sense, right? --- builds/4chan-X.user.js | 9 +++++++++ builds/crx/script.js | 9 +++++++++ src/General/Header.coffee | 2 ++ src/General/Index.coffee | 4 ++++ 4 files changed, 24 insertions(+) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index a95e209b2..8c39f1eef 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -1711,6 +1711,7 @@ _this.footer = $.id('boardNavDesktopFoot'); if (a = $("a[href*='/" + g.BOARD + "/']", $.id('boardNavDesktopFoot'))) { a.className = 'current'; + $.on(a, 'click', Index.cb.link); } cs = $.el('a', { id: 'settingsWindowLink', @@ -1745,6 +1746,7 @@ fourchannav = $.id('boardNavDesktop'); if (a = $("a[href*='/" + g.BOARD + "/']", fourchannav)) { a.className = 'current'; + $.on(a, 'click', Index.cb.link); } boardList = $.el('span', { id: 'board-list', @@ -2259,6 +2261,13 @@ } e.preventDefault(); return Index.userPageNav(+a.pathname.split('/')[2]); + }, + link: function(e) { + if (g.VIEW !== 'index' || /catalog/.test(this.href)) { + return; + } + e.preventDefault(); + return Index.update(); } }, scrollToIndex: function() { diff --git a/builds/crx/script.js b/builds/crx/script.js index e2cf6275a..5efcefa95 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -1721,6 +1721,7 @@ _this.footer = $.id('boardNavDesktopFoot'); if (a = $("a[href*='/" + g.BOARD + "/']", $.id('boardNavDesktopFoot'))) { a.className = 'current'; + $.on(a, 'click', Index.cb.link); } cs = $.el('a', { id: 'settingsWindowLink', @@ -1755,6 +1756,7 @@ fourchannav = $.id('boardNavDesktop'); if (a = $("a[href*='/" + g.BOARD + "/']", fourchannav)) { a.className = 'current'; + $.on(a, 'click', Index.cb.link); } boardList = $.el('span', { id: 'board-list', @@ -2269,6 +2271,13 @@ } e.preventDefault(); return Index.userPageNav(+a.pathname.split('/')[2]); + }, + link: function(e) { + if (g.VIEW !== 'index' || /catalog/.test(this.href)) { + return; + } + e.preventDefault(); + return Index.update(); } }, scrollToIndex: function() { diff --git a/src/General/Header.coffee b/src/General/Header.coffee index 18c3eb810..60355b4e4 100755 --- a/src/General/Header.coffee +++ b/src/General/Header.coffee @@ -104,6 +104,7 @@ Header = @footer = $.id 'boardNavDesktopFoot' if a = $ "a[href*='/#{g.BOARD}/']", $.id 'boardNavDesktopFoot' a.className = 'current' + $.on a, 'click', Index.cb.link cs = $.el 'a', id: 'settingsWindowLink' @@ -136,6 +137,7 @@ Header = fourchannav = $.id 'boardNavDesktop' if a = $ "a[href*='/#{g.BOARD}/']", fourchannav a.className = 'current' + $.on a, 'click', Index.cb.link boardList = $.el 'span', id: 'board-list' innerHTML: "" diff --git a/src/General/Index.coffee b/src/General/Index.coffee index e67f91569..a3f54c8e5 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -127,6 +127,10 @@ Index = return if a.textContent is 'Catalog' e.preventDefault() Index.userPageNav +a.pathname.split('/')[2] + link: (e) -> + return if g.VIEW isnt 'index' or /catalog/.test @href + e.preventDefault() + Index.update() scrollToIndex: -> Header.scrollToIfNeeded Index.root From 767b89a82ceeb0f7237f416eb3958914b8d94a94 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Tue, 7 Jan 2014 11:56:54 -0700 Subject: [PATCH 2/3] da fuq? --- builds/4chan-X.user.js | 6 +++--- builds/crx/script.js | 6 +++--- src/General/Header.coffee | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 8c39f1eef..c6784a65f 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -1707,9 +1707,9 @@ return _this; }); $.ready(function() { - var a, cs; - _this.footer = $.id('boardNavDesktopFoot'); - if (a = $("a[href*='/" + g.BOARD + "/']", $.id('boardNavDesktopFoot'))) { + var a, cs, footer; + _this.footer = footer = $.id('boardNavDesktopFoot'); + if (a = $("a[href*='/" + g.BOARD + "/']", footer)) { a.className = 'current'; $.on(a, 'click', Index.cb.link); } diff --git a/builds/crx/script.js b/builds/crx/script.js index 5efcefa95..f8330b898 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -1717,9 +1717,9 @@ return _this; }); $.ready(function() { - var a, cs; - _this.footer = $.id('boardNavDesktopFoot'); - if (a = $("a[href*='/" + g.BOARD + "/']", $.id('boardNavDesktopFoot'))) { + var a, cs, footer; + _this.footer = footer = $.id('boardNavDesktopFoot'); + if (a = $("a[href*='/" + g.BOARD + "/']", footer)) { a.className = 'current'; $.on(a, 'click', Index.cb.link); } diff --git a/src/General/Header.coffee b/src/General/Header.coffee index 60355b4e4..4e42cce8c 100755 --- a/src/General/Header.coffee +++ b/src/General/Header.coffee @@ -101,8 +101,8 @@ Header = @ $.ready => - @footer = $.id 'boardNavDesktopFoot' - if a = $ "a[href*='/#{g.BOARD}/']", $.id 'boardNavDesktopFoot' + @footer = footer = $.id 'boardNavDesktopFoot' + if a = $ "a[href*='/#{g.BOARD}/']", footer a.className = 'current' $.on a, 'click', Index.cb.link From 4ce942c540845fb4936ab6d8d8432f88ddf7f99a Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Tue, 7 Jan 2014 12:10:08 -0700 Subject: [PATCH 3/3] Looks like I failed to understand exactly what was happening here --- builds/4chan-X.user.js | 16 ++++++++++------ builds/crx/script.js | 16 ++++++++++------ src/General/Header.coffee | 12 ++++++++---- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index c6784a65f..748348b7d 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -1744,14 +1744,14 @@ setBoardList: function() { var a, boardList, btn, fourchannav, fullBoardList; fourchannav = $.id('boardNavDesktop'); - if (a = $("a[href*='/" + g.BOARD + "/']", fourchannav)) { - a.className = 'current'; - $.on(a, 'click', Index.cb.link); - } boardList = $.el('span', { id: 'board-list', innerHTML: "" }); + if (a = $("a[href*='/" + g.BOARD + "/']", boardList)) { + a.className = 'current'; + $.on(a, 'click', Index.cb.link); + } fullBoardList = $('#full-board-list', boardList); btn = $('.hide-board-list-button', fullBoardList); $.on(btn, 'click', Header.toggleBoardList); @@ -1772,7 +1772,7 @@ } as = $$('#full-board-list a[title]', Header.bar); nodes = text.match(/[\w@]+((-(all|title|replace|full|index|catalog|url:"[^"]+[^"]"|text:"[^"]+")|\,"[^"]+[^"]"))*|[^\w@]+/g).map(function(t) { - var a, board, m, _i, _len; + var a, board, current, m, _i, _len; if (/^[^\w@]/.test(t)) { return $.tn(t); } @@ -1798,7 +1798,11 @@ a = as[_i]; if (a.textContent === board) { a = a.cloneNode(true); - a.textContent = /-title/.test(t) || /-replace/.test(t) && $.hasClass(a, 'current') ? a.title : /-full/.test(t) ? "/" + board + "/ - " + a.title : (m = t.match(/-text:"(.+)"/)) ? m[1] : a.textContent; + current = $.hasClass(a, 'current'); + if (current) { + $.on(a, 'click', Index.cb.link); + } + a.textContent = /-title/.test(t) || /-replace/.test(t) && current ? a.title : /-full/.test(t) ? "/" + board + "/ - " + a.title : (m = t.match(/-text:"(.+)"/)) ? m[1] : a.textContent; if (m = t.match(/-(index|catalog)/)) { a.dataset.only = m[1]; a.href = "//boards.4chan.org/" + board + "/"; diff --git a/builds/crx/script.js b/builds/crx/script.js index f8330b898..4f5048c1f 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -1754,14 +1754,14 @@ setBoardList: function() { var a, boardList, btn, fourchannav, fullBoardList; fourchannav = $.id('boardNavDesktop'); - if (a = $("a[href*='/" + g.BOARD + "/']", fourchannav)) { - a.className = 'current'; - $.on(a, 'click', Index.cb.link); - } boardList = $.el('span', { id: 'board-list', innerHTML: "" }); + if (a = $("a[href*='/" + g.BOARD + "/']", boardList)) { + a.className = 'current'; + $.on(a, 'click', Index.cb.link); + } fullBoardList = $('#full-board-list', boardList); btn = $('.hide-board-list-button', fullBoardList); $.on(btn, 'click', Header.toggleBoardList); @@ -1782,7 +1782,7 @@ } as = $$('#full-board-list a[title]', Header.bar); nodes = text.match(/[\w@]+((-(all|title|replace|full|index|catalog|url:"[^"]+[^"]"|text:"[^"]+")|\,"[^"]+[^"]"))*|[^\w@]+/g).map(function(t) { - var a, board, m, _i, _len; + var a, board, current, m, _i, _len; if (/^[^\w@]/.test(t)) { return $.tn(t); } @@ -1808,7 +1808,11 @@ a = as[_i]; if (a.textContent === board) { a = a.cloneNode(true); - a.textContent = /-title/.test(t) || /-replace/.test(t) && $.hasClass(a, 'current') ? a.title : /-full/.test(t) ? "/" + board + "/ - " + a.title : (m = t.match(/-text:"(.+)"/)) ? m[1] : a.textContent; + current = $.hasClass(a, 'current'); + if (current) { + $.on(a, 'click', Index.cb.link); + } + a.textContent = /-title/.test(t) || /-replace/.test(t) && current ? a.title : /-full/.test(t) ? "/" + board + "/ - " + a.title : (m = t.match(/-text:"(.+)"/)) ? m[1] : a.textContent; if (m = t.match(/-(index|catalog)/)) { a.dataset.only = m[1]; a.href = "//boards.4chan.org/" + board + "/"; diff --git a/src/General/Header.coffee b/src/General/Header.coffee index 4e42cce8c..a6eec0c65 100755 --- a/src/General/Header.coffee +++ b/src/General/Header.coffee @@ -135,12 +135,12 @@ Header = setBoardList: -> fourchannav = $.id 'boardNavDesktop' - if a = $ "a[href*='/#{g.BOARD}/']", fourchannav - a.className = 'current' - $.on a, 'click', Index.cb.link boardList = $.el 'span', id: 'board-list' innerHTML: "" + if a = $ "a[href*='/#{g.BOARD}/']", boardList + a.className = 'current' + $.on a, 'click', Index.cb.link fullBoardList = $ '#full-board-list', boardList btn = $ '.hide-board-list-button', fullBoardList $.on btn, 'click', Header.toggleBoardList @@ -184,7 +184,11 @@ Header = if a.textContent is board a = a.cloneNode true - a.textContent = if /-title/.test(t) or /-replace/.test(t) and $.hasClass a, 'current' + current = $.hasClass a, 'current' + if current + $.on a, 'click', Index.cb.link + + a.textContent = if /-title/.test(t) or /-replace/.test(t) and current a.title else if /-full/.test t "/#{board}/ - #{a.title}"