summaryrefslogtreecommitdiff
path: root/js/inline.js
blob: 1130c68bff4d830a12c70abda820d715dc3c5576 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
;(function() {
  $('.body a').click(inline)

  $('head').append(
    '<style>' +
      '.inline {' +
      '  border: 1px dashed black;' +
      '  margin-left: 1em;' +
      '  padding: 1em;' +
      '}' +
    '</style>')
})()

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)
}