From 89d5abd69656510a0955e7e971ad1b6f7a60fca7 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Wed, 1 Jun 2011 21:13:04 +0200 Subject: [PATCH 1/2] Fix quote inlining in some cases. --- 4chan_x.user.js | 7 ++++--- script.coffee | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 7917a4566..4dda8be61 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1783,10 +1783,11 @@ return _results; }, toggle: function(e) { - var el, id, inline, pathname, root, table, threadID; + var el, id, inline, link, pathname, root, table, threadID; e.preventDefault(); id = this.hash.slice(1); root = $.x('ancestor::td[1]', this); + link = this.parentNode.nodeName === 'FONT' ? this.parentNode : this.nextSibling; if (table = $("#i" + id, root)) { $.rm(table); $.removeClass(this, 'inlined'); @@ -1801,7 +1802,7 @@ $.after(this.parentNode, inline); $.hide($.x('ancestor::table[1]', el)); } else { - $.after(this.parentNode, inline); + $.after(link, inline); } } else { inline = $.el('td', { @@ -1809,7 +1810,7 @@ id: "i" + id, innerHTML: "Loading " + id + "..." }); - $.after(this.parentNode, inline); + $.after(link, inline); pathname = this.pathname; threadID = pathname.split('/').pop(); $.cache(pathname, (function() { diff --git a/script.coffee b/script.coffee index 22e2acc63..e82ce452a 100644 --- a/script.coffee +++ b/script.coffee @@ -1419,6 +1419,7 @@ quoteInline = e.preventDefault() id = @hash[1..] root = $.x 'ancestor::td[1]', @ + link = if @parentNode.nodeName is 'FONT' then @parentNode else @nextSibling if table = $ "#i#{id}", root $.rm table $.removeClass @, 'inlined' @@ -1431,13 +1432,13 @@ quoteInline = $.after @parentNode, inline $.hide $.x 'ancestor::table[1]', el else - $.after @parentNode, inline + $.after link, inline else inline = $.el 'td', className: 'reply inline' id: "i#{id}" innerHTML: "Loading #{id}..." - $.after @parentNode, inline + $.after link, inline {pathname} = @ threadID = pathname.split('/').pop() $.cache pathname, (-> quoteInline.parse @, pathname, id, threadID, inline) From 70296d1f857a9b75aa4119bcd7711affef8e1c5d Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Wed, 1 Jun 2011 22:07:24 +0200 Subject: [PATCH 2/2] Picky. --- 4chan_x.user.js | 11 +++++------ script.coffee | 9 ++++----- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 4dda8be61..8ccc92849 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1783,12 +1783,10 @@ return _results; }, toggle: function(e) { - var el, id, inline, link, pathname, root, table, threadID; + var el, id, inline, pathname, root, table, threadID; e.preventDefault(); id = this.hash.slice(1); - root = $.x('ancestor::td[1]', this); - link = this.parentNode.nodeName === 'FONT' ? this.parentNode : this.nextSibling; - if (table = $("#i" + id, root)) { + if (table = $("#i" + id, $.x('ancestor::td[1]', this))) { $.rm(table); $.removeClass(this, 'inlined'); if (this.className === 'backlink') { @@ -1796,13 +1794,14 @@ } return; } + root = this.parentNode.nodeName === 'FONT' ? this.parentNode : this.nextSibling; if (el = d.getElementById(id)) { inline = quoteInline.table(id, el.innerHTML); if (this.className === 'backlink') { $.after(this.parentNode, inline); $.hide($.x('ancestor::table[1]', el)); } else { - $.after(link, inline); + $.after(root, inline); } } else { inline = $.el('td', { @@ -1810,7 +1809,7 @@ id: "i" + id, innerHTML: "Loading " + id + "..." }); - $.after(link, inline); + $.after(root, inline); pathname = this.pathname; threadID = pathname.split('/').pop(); $.cache(pathname, (function() { diff --git a/script.coffee b/script.coffee index e82ce452a..df86712a6 100644 --- a/script.coffee +++ b/script.coffee @@ -1418,27 +1418,26 @@ quoteInline = toggle: (e) -> e.preventDefault() id = @hash[1..] - root = $.x 'ancestor::td[1]', @ - link = if @parentNode.nodeName is 'FONT' then @parentNode else @nextSibling - if table = $ "#i#{id}", root + if table = $ "#i#{id}", $.x 'ancestor::td[1]', @ $.rm table $.removeClass @, 'inlined' if @className is 'backlink' $.show $.x 'ancestor::table[1]', d.getElementById id return + root = if @parentNode.nodeName is 'FONT' then @parentNode else @nextSibling if el = d.getElementById id inline = quoteInline.table id, el.innerHTML if @className is 'backlink' $.after @parentNode, inline $.hide $.x 'ancestor::table[1]', el else - $.after link, inline + $.after root, inline else inline = $.el 'td', className: 'reply inline' id: "i#{id}" innerHTML: "Loading #{id}..." - $.after link, inline + $.after root, inline {pathname} = @ threadID = pathname.split('/').pop() $.cache pathname, (-> quoteInline.parse @, pathname, id, threadID, inline)