diff --git a/4chan_x.js b/4chan_x.js index 2ac46b0d0..01ac64089 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -1671,7 +1671,7 @@ g.callbacks.push(quotePreview.node); preview = $.el('div', { id: 'qp', - className: 'reply' + className: 'replyhl' }); $.hide(preview); return $.append(d.body, preview); @@ -1689,15 +1689,41 @@ return _results; }, mouseover: function(e) { - var el, id; + var el, id, qp; id = this.textContent.replace(">>", ''); - el = $('#qp'); - el.innerHTML = d.getElementById(id).innerHTML; - $.show(el); - return ui.el = el; + qp = $('#qp'); + if (el = d.getElementById(id)) { + qp.innerHTML = el.innerHTML; + } else { + qp.innerHTML = 'Loading...'; + quotePreview.get(this, id); + } + $.show(qp); + return ui.el = qp; }, mouseout: function(e) { return $.hide(ui.el); + }, + get: function(link, id) { + return $.get(link.href, (function() { + return quotePreview.get2(link, id, this); + })); + }, + get2: function(link, id, xhr) { + var body, reply, _i, _len, _ref, _results; + body = $.el('body', { + innerHTML: xhr.responseText + }); + _ref = $$('td.reply', body); + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + reply = _ref[_i]; + if (reply.id === id) { + ui.el.innerHTML = reply.innerHTML; + break; + } + } + return _results; } }; quickReport = { @@ -2390,6 +2416,13 @@ #watcher > div:last-child {\ padding-bottom: 5px;\ }\ +\ + #qp {\ + border: 1px solid;\ + }\ + #qp input {\ + display: none;\ + }\ ' }; main.init(); diff --git a/script.coffee b/script.coffee index 5d13e6b56..06fdb125e 100644 --- a/script.coffee +++ b/script.coffee @@ -1337,8 +1337,8 @@ quotePreview = init: -> g.callbacks.push quotePreview.node preview = $.el 'div', - id: 'qp', - className: 'reply' + id: 'qp' + className: 'replyhl' $.hide preview $.append d.body, preview node: (root) -> @@ -1348,12 +1348,26 @@ quotePreview = $.bind quote, 'mouseout', quotePreview.mouseout mouseover: (e) -> id = @textContent.replace ">>", '' - el = $ '#qp' - el.innerHTML = d.getElementById(id).innerHTML - $.show el - ui.el = el + qp = $ '#qp' + if el = d.getElementById id + qp.innerHTML = el.innerHTML + else + qp.innerHTML = 'Loading...' + quotePreview.get this, id + $.show qp + ui.el = qp mouseout: (e) -> $.hide ui.el + get: (link, id) -> + $.get link.href, (-> quotePreview.get2 link, id, this) + get2: (link, id, xhr) -> + body = $.el 'body', + innerHTML: xhr.responseText + + for reply in $$ 'td.reply', body + if reply.id == id + ui.el.innerHTML = reply.innerHTML + break quickReport = init: -> @@ -1906,6 +1920,13 @@ main = #watcher > div:last-child { padding-bottom: 5px; } + + #qp { + border: 1px solid; + } + #qp input { + display: none; + } ' main.init()