From 49605c503558c21747df499efbf29ecaaa5b5d50 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 15 Sep 2011 22:23:01 +0200 Subject: [PATCH 1/5] Typo. --- 4chan_x.user.js | 2 +- script.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index f05d6c6f5..2b3c86f47 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1740,7 +1740,7 @@ html += "
"; } checked = conf['Auto Update'] ? 'checked' : ''; - html += "
"; + html += "
"; dialog = ui.dialog('updater', { bottom: '0', right: '0' diff --git a/script.coffee b/script.coffee index f671b62f2..34704926c 100644 --- a/script.coffee +++ b/script.coffee @@ -1387,7 +1387,7 @@ updater = checked = if conf['Auto Update'] then 'checked' else '' html += " -
+
" From 61167dc79265bcfe5d7625c850131c30d8826c9a Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Fri, 16 Sep 2011 18:29:46 +0200 Subject: [PATCH 2/5] Hide inlined quotes within the quote preview. --- 4chan_x.user.js | 2 +- changelog | 2 ++ script.coffee | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 84c7925d8..1938f3528 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -3215,7 +3215,7 @@ border: 1px solid;\ padding-bottom: 5px;\ }\ - #qp input {\ + #qp input, #qp .inline {\ display: none;\ }\ .qphl {\ diff --git a/changelog b/changelog index 8b80cbe0a..7613dffb6 100644 --- a/changelog +++ b/changelog @@ -1,4 +1,6 @@ master +- mayhem + do not display inlined quotes within the quote preview 2.19.3 - mayhem diff --git a/script.coffee b/script.coffee index a118719ae..96ce86b7c 100644 --- a/script.coffee +++ b/script.coffee @@ -2543,7 +2543,7 @@ Main = border: 1px solid; padding-bottom: 5px; } - #qp input { + #qp input, #qp .inline { display: none; } .qphl { From e9343bff56708bdf6e45b1bc4660a08a682a587c Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Fri, 16 Sep 2011 23:07:37 +0200 Subject: [PATCH 3/5] Fix cross quotes within cross quotes; We need to go deeper; God damn moot --- 4chan_x.user.js | 12 ++++++++---- changelog | 1 + script.coffee | 8 ++++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 1938f3528..5502d2572 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -652,7 +652,7 @@ } }, parse: function(req, pathname, thread, a) { - var body, br, link, next, quote, reply, table, tables, _i, _j, _k, _len, _len2, _len3, _ref, _ref2, _results; + var body, br, href, link, next, quote, reply, table, tables, _i, _j, _k, _len, _len2, _len3, _ref, _ref2, _results; if (req.status !== 200) { a.textContent = "" + req.status + " " + req.statusText; $.unbind(a, 'click', expandThread.cb.toggle); @@ -672,8 +672,10 @@ _ref2 = $$('a.quotelink', reply); for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) { quote = _ref2[_j]; - if (quote.getAttribute('href') === quote.hash) { + if ((href = quote.getAttribute('href')) === quote.hash) { quote.pathname = pathname; + } else if (href !== quote.href) { + quote.href = "res/" + href; } } link = $('a.quotejs', reply); @@ -2289,7 +2291,7 @@ return $.addClass(this, 'inlined'); }, parse: function(req, pathname, id, threadID, inline) { - var body, html, link, newInline, op, quote, reply, _i, _j, _len, _len2, _ref, _ref2; + var body, href, html, link, newInline, op, quote, reply, _i, _j, _len, _len2, _ref, _ref2; if (!inline.parentNode) { return; } @@ -2317,8 +2319,10 @@ _ref2 = $$('a.quotelink', newInline); for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) { quote = _ref2[_j]; - if (quote.getAttribute('href') === quote.hash) { + if ((href = quote.getAttribute('href')) === quote.hash) { quote.pathname = pathname; + } else if (!g.REPLY && href !== quote.href) { + quote.href = "res/" + href; } } link = $('a.quotejs', newInline); diff --git a/changelog b/changelog index 7613dffb6..dc615e9b2 100644 --- a/changelog +++ b/changelog @@ -1,6 +1,7 @@ master - mayhem do not display inlined quotes within the quote preview + fix cross threads quotes in expanded threads or inlined cross quotes 2.19.3 - mayhem diff --git a/script.coffee b/script.coffee index 96ce86b7c..afbc0161c 100644 --- a/script.coffee +++ b/script.coffee @@ -476,8 +476,10 @@ expandThread = for reply in $$ 'td[id]', body for quote in $$ 'a.quotelink', reply - if quote.getAttribute('href') is quote.hash + if (href = quote.getAttribute('href')) is quote.hash #add pathname to normal quotes quote.pathname = pathname + else if href isnt quote.href #fix x-thread links, not x-board ones + quote.href = "res/#{href}" link = $ 'a.quotejs', reply link.href = "res/#{thread.firstChild.id}##{reply.id}" link.nextSibling.href = "res/#{thread.firstChild.id}#q#{reply.id}" @@ -1786,8 +1788,10 @@ quoteInline = break newInline = quoteInline.table id, html for quote in $$ 'a.quotelink', newInline - if quote.getAttribute('href') is quote.hash + if (href = quote.getAttribute('href')) is quote.hash #add pathname to normal quotes quote.pathname = pathname + else if !g.REPLY and href isnt quote.href #fix x-thread links, not x-board ones + quote.href = "res/#{href}" link = $ 'a.quotejs', newInline link.href = "#{pathname}##{id}" link.nextSibling.href = "#{pathname}#q#{id}" From 716c34aa7c9b857b836c0d6fe295bb56ee2f6d34 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sat, 17 Sep 2011 22:17:05 +0200 Subject: [PATCH 4/5] Save ui position only once. I noticed that Chrome deletes empty localStorage keys when closing it. Dragging the QR to the bottom right would save empty top/right keys, resulting in its position reset when restarting the browser. --- 4chan_x.user.js | 29 +++++++++++++++-------------- script.coffee | 14 +++++++------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 5502d2572..366f09911 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -199,23 +199,25 @@ }; ui = { dialog: function(id, position, html) { - var el, left, top, _ref, _ref2; + var el, left, saved, top; el = d.createElement('div'); el.className = 'reply dialog'; el.innerHTML = html; el.id = id; - left = position.left, top = position.top; - left = (_ref = localStorage["" + NAMESPACE + id + "Left"]) != null ? _ref : left; - top = (_ref2 = localStorage["" + NAMESPACE + id + "Top"]) != null ? _ref2 : top; - if (left) { - el.style.left = left; + if (saved = localStorage["" + NAMESPACE + id + ".position"]) { + el.style.cssText = saved; } else { - el.style.right = 0; - } - if (top) { - el.style.top = top; - } else { - el.style.bottom = 0; + left = position.left, top = position.top; + if (left) { + el.style.left = left; + } else { + el.style.right = 0; + } + if (top) { + el.style.top = top; + } else { + el.style.bottom = 0; + } } el.querySelector('div.move').addEventListener('mousedown', ui.dragstart, false); return el; @@ -259,8 +261,7 @@ var el, id; el = ui.el; id = el.id; - localStorage["" + NAMESPACE + id + "Left"] = el.style.left; - localStorage["" + NAMESPACE + id + "Top"] = el.style.top; + localStorage["" + NAMESPACE + id + ".position"] = el.style.cssText; d.removeEventListener('mousemove', ui.drag, false); return d.removeEventListener('mouseup', ui.dragend, false); }, diff --git a/script.coffee b/script.coffee index afbc0161c..e0ce98f59 100644 --- a/script.coffee +++ b/script.coffee @@ -126,11 +126,12 @@ ui = el.className = 'reply dialog' el.innerHTML = html el.id = id - {left, top} = position - left = localStorage["#{NAMESPACE}#{id}Left"] ? left - top = localStorage["#{NAMESPACE}#{id}Top"] ? top - if left then el.style.left = left else el.style.right = 0 - if top then el.style.top = top else el.style.bottom = 0 + if saved = localStorage["#{NAMESPACE}#{id}.position"] + el.style.cssText = saved + else + {left, top} = position + if left then el.style.left = left else el.style.right = 0 + if top then el.style.top = top else el.style.bottom = 0 el.querySelector('div.move').addEventListener 'mousedown', ui.dragstart, false el dragstart: (e) -> @@ -170,8 +171,7 @@ ui = #a = (b = c.b, c).a; {el} = ui {id} = el - localStorage["#{NAMESPACE}#{id}Left"] = el.style.left - localStorage["#{NAMESPACE}#{id}Top"] = el.style.top + localStorage["#{NAMESPACE}#{id}.position"] = el.style.cssText d.removeEventListener 'mousemove', ui.drag, false d.removeEventListener 'mouseup', ui.dragend, false hover: (e) -> From afd9830168b6e2140b418230f13f268599d01b7d Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sat, 17 Sep 2011 22:31:19 +0200 Subject: [PATCH 5/5] Go deeper, shave lines. --- 4chan_x.user.js | 38 ++++++-------------------------------- script.coffee | 15 +++++---------- 2 files changed, 11 insertions(+), 42 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 366f09911..37c71aea1 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -199,26 +199,12 @@ }; ui = { dialog: function(id, position, html) { - var el, left, saved, top; + var el, saved; el = d.createElement('div'); el.className = 'reply dialog'; el.innerHTML = html; el.id = id; - if (saved = localStorage["" + NAMESPACE + id + ".position"]) { - el.style.cssText = saved; - } else { - left = position.left, top = position.top; - if (left) { - el.style.left = left; - } else { - el.style.right = 0; - } - if (top) { - el.style.top = top; - } else { - el.style.bottom = 0; - } - } + el.style.cssText = (saved = localStorage["" + NAMESPACE + id + ".position"]) ? saved : position; el.querySelector('div.move').addEventListener('mousedown', ui.dragstart, false); return el; }, @@ -1363,10 +1349,7 @@ THREAD_ID = g.THREAD_ID || $.x('ancestor::div[@class="thread"]/div', link).id; qr.challenge = $('#recaptcha_challenge_field').value; html = " X
Quick Reply
" + qr.spoiler + "
" + ($.get('captchas', []).length) + " captchas
"; - qr.el = ui.dialog('qr', { - top: '0px', - left: '0px' - }, html); + qr.el = ui.dialog('qr', 'top: 0; left: 0;', html); $.bind($('input[name=name]', qr.el), 'mousedown', function(e) { return e.stopPropagation(); }); @@ -1744,10 +1727,7 @@ } checked = conf['Auto Update'] ? 'checked' : ''; html += "
"; - dialog = ui.dialog('updater', { - bottom: '0', - right: '0' - }, html); + dialog = ui.dialog('updater', 'bottom: 0; right: 0;', html); updater.count = $('#count', dialog); updater.timer = $('#timer', dialog); updater.br = $('br[clear]'); @@ -1875,10 +1855,7 @@ init: function() { var favicon, html, input, inputs, _i, _len; html = '
Thread Watcher
'; - watcher.dialog = ui.dialog('watcher', { - top: '50px', - left: '0px' - }, html); + watcher.dialog = ui.dialog('watcher', 'top: 50px; left: 0px;', html); $.add(d.body, watcher.dialog); inputs = $$('.op input'); for (_i = 0, _len = inputs.length; _i < _len; _i++) { @@ -2474,10 +2451,7 @@ threadStats.posts = 1; threadStats.images = $('.op img[md5]') ? 1 : 0; html = "
" + threadStats.posts + " / " + threadStats.images + "
"; - dialog = ui.dialog('stats', { - bottom: '0px', - left: '0px' - }, html); + dialog = ui.dialog('stats', 'bottom: 0; left: 0;', html); dialog.className = 'dialog'; threadStats.postcountEl = $('#postcount', dialog); threadStats.imagecountEl = $('#imagecount', dialog); diff --git a/script.coffee b/script.coffee index e0ce98f59..1698fe712 100644 --- a/script.coffee +++ b/script.coffee @@ -126,12 +126,7 @@ ui = el.className = 'reply dialog' el.innerHTML = html el.id = id - if saved = localStorage["#{NAMESPACE}#{id}.position"] - el.style.cssText = saved - else - {left, top} = position - if left then el.style.left = left else el.style.right = 0 - if top then el.style.top = top else el.style.bottom = 0 + el.style.cssText = if saved = localStorage["#{NAMESPACE}#{id}.position"] then saved else position el.querySelector('div.move').addEventListener 'mousedown', ui.dragstart, false el dragstart: (e) -> @@ -1073,7 +1068,7 @@ qr = " - qr.el = ui.dialog 'qr', top: '0px', left: '0px', html + qr.el = ui.dialog 'qr', 'top: 0; left: 0;', html $.bind $('input[name=name]', qr.el), 'mousedown', (e) -> e.stopPropagation() $.bind $('input[name=upfile]', qr.el), 'change', qr.validateFileSize @@ -1393,7 +1388,7 @@ updater =
" - dialog = ui.dialog 'updater', bottom: '0', right: '0', html + dialog = ui.dialog 'updater', 'bottom: 0; right: 0;', html updater.count = $ '#count', dialog updater.timer = $ '#timer', dialog @@ -1501,7 +1496,7 @@ updater = watcher = init: -> html = '
Thread Watcher
' - watcher.dialog = ui.dialog 'watcher', top: '50px', left: '0px', html + watcher.dialog = ui.dialog 'watcher', 'top: 50px; left: 0px;', html $.add d.body, watcher.dialog #add watch buttons @@ -1885,7 +1880,7 @@ threadStats = threadStats.posts = 1 threadStats.images = if $ '.op img[md5]' then 1 else 0 html = "
#{threadStats.posts} / #{threadStats.images}
" - dialog = ui.dialog 'stats', bottom: '0px', left: '0px', html + dialog = ui.dialog 'stats', 'bottom: 0; left: 0;', html dialog.className = 'dialog' threadStats.postcountEl = $ '#postcount', dialog threadStats.imagecountEl = $ '#imagecount', dialog