From cb92ee048303a6d9065c2e7b9dd4f9532152db34 Mon Sep 17 00:00:00 2001 From: James Campos Date: Tue, 23 Sep 2014 19:52:06 -0700 Subject: [PATCH] inline --- js/inline.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 js/inline.js diff --git a/js/inline.js b/js/inline.js new file mode 100644 index 00000000..1130c68b --- /dev/null +++ b/js/inline.js @@ -0,0 +1,34 @@ +;(function() { + $('.body a').click(inline) + + $('head').append( + '') +})() + +function inline(e) { + e.preventDefault() + var postNum = parseInt(this.textContent.slice(2)) + + var cloneID = 'inline_' + postNum + var $clone = $('#' + cloneID) + if ($clone.length) + return $clone.remove() + + var OP = location.pathname.match(/(\d+).html/)[1] + var selector = postNum === OP + ? '.op .body' + : '#reply_' + postNum + ' .body' + + $clone = $(selector).clone(true) + $clone.attr({ + className: 'inline', + id: cloneID + }) + $clone.insertAfter(this) +}