diff --git a/4chan_x.js b/4chan_x.js
index 4dc9677be..2673f5e5a 100644
--- a/4chan_x.js
+++ b/4chan_x.js
@@ -58,7 +58,7 @@
*/
(function() {
- var $, $$, Favicon, NAMESPACE, Recaptcha, anonymize, config, d, expandComment, expandThread, g, imageHover, imgExpand, imgGif, imgPreloading, keybinds, localize, log, main, nav, nodeInserted, options, qr, quoteBacklink, quotePreview, redirect, replyHiding, reportButton, sauce, threadHiding, threading, titlePost, ui, unread, updater, watcher, _config, _ref;
+ var $, $$, Favicon, NAMESPACE, Recaptcha, anonymize, config, d, expandComment, expandThread, g, imageHover, imgExpand, imgGif, imgPreloading, keybinds, localize, log, main, nav, nodeInserted, options, qr, quoteBacklink, quoteInline, quotePreview, redirect, replyHiding, reportButton, sauce, threadHiding, threading, titlePost, ui, unread, updater, watcher, _config, _ref;
var __slice = Array.prototype.slice;
if (typeof console !== "undefined" && console !== null) {
log = function(arg) {
@@ -84,6 +84,7 @@
'Post in Title': [true, 'Show the op\'s post in the tab title'],
'Quick Reply': [true, 'Reply without leaving the page'],
'Quote Backlinks': [false, 'Add quote backlinks'],
+ 'Quote Inline': [false, 'Show quoted post inline on quote click'],
'Quote Preview': [false, 'Show quote content on hover'],
'Reply Hiding': [true, 'Hide single replies'],
'Report Button': [true, 'Add report buttons'],
@@ -1715,6 +1716,85 @@
return _results;
}
};
+ quoteInline = {
+ init: function() {
+ return g.callbacks.push(quoteInline.node);
+ },
+ node: function(root) {
+ var quote, _i, _len, _ref, _results;
+ _ref = $$('a.quotelink', root);
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ quote = _ref[_i];
+ quote.removeAttribute('onclick');
+ _results.push($.bind(quote, 'click', quoteInline.toggle));
+ }
+ return _results;
+ },
+ toggle: function(e) {
+ var el, id, inline, next, req, td, threadID;
+ e.preventDefault();
+ if (!(id = this.hash.slice(1))) {
+ return;
+ }
+ if ((next = this.parentNode.nextSibling) && (next.nodeName === 'TABLE')) {
+ $.rm(next);
+ return;
+ }
+ inline = $.el('table', {
+ className: 'inline',
+ innerHTML: '
|
'
+ });
+ td = $('td', inline);
+ if (el = d.getElementById(id)) {
+ td.innerHTML = el.innerHTML;
+ } else {
+ td.innerHTML = "Loading " + id + "...";
+ threadID = this.pathname.split('/').pop() || $.x('ancestor::div[@class="thread"]/div', this).id;
+ if (req = g.requests[threadID]) {
+ if (req.readyState === 4) {
+ quoteInline.parse(req, id, threadID, inline);
+ }
+ } else {
+ g.requests[threadID] = $.get(this.href, (function() {
+ return quoteInline.parse(this, id, threadID, inline);
+ }));
+ }
+ }
+ return $.after(this.parentNode, inline);
+ },
+ parse: function(req, id, threadID, oldInline) {
+ var body, html, inline, op, reply, td, _i, _len, _ref;
+ inline = $.el('table', {
+ className: 'inline',
+ innerHTML: ' |
'
+ });
+ td = $('td', inline);
+ if (req.status !== 200) {
+ td.innerHTML = "" + req.status + " " + req.statusText;
+ $.replace(oldInline, inline);
+ return;
+ }
+ body = $.el('body', {
+ innerHTML: req.responseText
+ });
+ if (id === threadID) {
+ op = threading.op($('form[name=delform] > *', body));
+ html = op.innerHTML;
+ } else {
+ _ref = $$('td.reply', body);
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ reply = _ref[_i];
+ if (reply.id === id) {
+ html = reply.innerHTML;
+ break;
+ }
+ }
+ }
+ td.innerHTML = html;
+ return $.replace(oldInline, inline);
+ }
+ };
quotePreview = {
init: function() {
var preview;
@@ -2267,6 +2347,9 @@
if ($.config('Quote Backlinks')) {
quoteBacklink.init();
}
+ if ($.config('Quote Inline')) {
+ quoteInline.init();
+ }
if ($.config('Quote Preview')) {
quotePreview.init();
}
diff --git a/script.coffee b/script.coffee
index 9f091374d..18cc4fcef 100644
--- a/script.coffee
+++ b/script.coffee
@@ -28,6 +28,7 @@ config =
'Post in Title': [true, 'Show the op\'s post in the tab title']
'Quick Reply': [true, 'Reply without leaving the page']
'Quote Backlinks': [false, 'Add quote backlinks']
+ 'Quote Inline': [false, 'Show quoted post inline on quote click']
'Quote Preview': [false, 'Show quote content on hover']
'Reply Hiding': [true, 'Hide single replies']
'Report Button': [true, 'Add report buttons']
@@ -1372,6 +1373,62 @@ quoteBacklink =
$.bind link, 'mouseout', ui.hoverend
$.before $('td > br, blockquote', el), link
+quoteInline =
+ init: ->
+ g.callbacks.push quoteInline.node
+ node: (root) ->
+ for quote in $$ 'a.quotelink', root
+ quote.removeAttribute 'onclick'
+ $.bind quote, 'click', quoteInline.toggle
+ toggle: (e) ->
+ e.preventDefault()
+ return unless id = @hash[1..]
+ if (next = @parentNode.nextSibling) and (next.nodeName is 'TABLE')
+ $.rm next
+ return
+ inline = $.el 'table',
+ className: 'inline'
+ innerHTML: ' |
'
+ td = $ 'td', inline
+ if el = d.getElementById id
+ td.innerHTML = el.innerHTML
+ else
+ td.innerHTML = "Loading #{id}..."
+ # or ... is for index page new posts.
+ # FIXME x-thread quotes
+ threadID = @pathname.split('/').pop() or $.x('ancestor::div[@class="thread"]/div', this).id
+ if req = g.requests[threadID]
+ if req.readyState is 4
+ quoteInline.parse req, id, threadID, inline
+ else
+ #FIXME need an array of callbacks
+ g.requests[threadID] = $.get @href, (-> quoteInline.parse this, id, threadID, inline)
+ $.after @parentNode, inline
+ parse: (req, id, threadID, oldInline) ->
+ #this is fucking stupid
+ inline = $.el 'table',
+ className: 'inline'
+ innerHTML: ' |
'
+ td = $ 'td', inline
+
+ if req.status isnt 200
+ td.innerHTML = "#{req.status} #{req.statusText}"
+ $.replace oldInline, inline
+ return
+
+ body = $.el 'body',
+ innerHTML: req.responseText
+ if id == threadID #OP
+ op = threading.op $ 'form[name=delform] > *', body
+ html = op.innerHTML
+ else
+ for reply in $$ 'td.reply', body
+ if reply.id == id
+ html = reply.innerHTML
+ break
+ td.innerHTML = html
+ $.replace oldInline, inline
+
quotePreview =
init: ->
g.callbacks.push quotePreview.node
@@ -1770,6 +1827,9 @@ main =
if $.config 'Quote Backlinks'
quoteBacklink.init()
+ if $.config 'Quote Inline'
+ quoteInline.init()
+
if $.config 'Quote Preview'
quotePreview.init()