2014-09-24 04:52:06 +02:00
|
|
|
;(function() {
|
2014-09-24 21:49:18 +02:00
|
|
|
var cache = {}
|
|
|
|
|
2014-09-24 06:25:34 +02:00
|
|
|
var inline = function(e) {
|
|
|
|
e.preventDefault()
|
|
|
|
|
|
|
|
var postNum = this.textContent.slice(2)
|
|
|
|
|
|
|
|
var $clone = $('#inline_' + postNum)
|
|
|
|
if ($clone.length)
|
|
|
|
return $clone.remove()
|
|
|
|
|
2014-09-24 21:17:30 +02:00
|
|
|
var postOP = this.pathname.match(/(\d+).html/)[1]
|
|
|
|
var selector = postNum === postOP
|
2014-09-24 06:25:34 +02:00
|
|
|
? '.op .body'
|
|
|
|
: '#reply_' + postNum + ' .body'
|
|
|
|
|
|
|
|
var link = {
|
|
|
|
postNum: postNum,
|
|
|
|
node: this
|
|
|
|
}
|
2014-09-24 21:17:30 +02:00
|
|
|
|
|
|
|
var OP = $('input[name="thread"]').val()
|
|
|
|
if (OP === postOP) {
|
2014-09-24 21:37:25 +02:00
|
|
|
// XXX WTF the post hover script adds fetched threads to the DOM
|
|
|
|
selector = '#thread_' + OP + ' ' + selector
|
2014-09-24 21:17:30 +02:00
|
|
|
var $target = $(selector)
|
2014-09-24 21:49:18 +02:00
|
|
|
return add(link, $target)
|
|
|
|
}
|
|
|
|
|
|
|
|
var url = this.pathname
|
|
|
|
var data = cache[url]
|
|
|
|
if (data) {
|
|
|
|
var $target = $(data).find(selector)
|
|
|
|
return add(link, $target)
|
2014-09-24 21:17:30 +02:00
|
|
|
}
|
2014-09-24 21:49:18 +02:00
|
|
|
|
|
|
|
$.get(url, function(data) {
|
|
|
|
cache[url] = data
|
|
|
|
var $target = $(data).find(selector)
|
|
|
|
add(link, $target)
|
|
|
|
})
|
2014-09-24 06:25:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var add = function(link, $target) {
|
|
|
|
var $clone = $target.clone(true)
|
|
|
|
$clone.attr({
|
|
|
|
"class": 'inline',
|
|
|
|
id: 'inline_' + link.postNum
|
|
|
|
})
|
|
|
|
$clone.insertAfter(link.node)
|
|
|
|
}
|
2014-09-24 04:52:06 +02:00
|
|
|
|
|
|
|
$('head').append(
|
|
|
|
'<style>' +
|
|
|
|
'.inline {' +
|
|
|
|
' border: 1px dashed black;' +
|
|
|
|
' margin-left: 1em;' +
|
|
|
|
' padding: 1em;' +
|
|
|
|
'}' +
|
|
|
|
'</style>')
|
|
|
|
|
2014-09-25 18:58:44 +02:00
|
|
|
$('.body a')
|
|
|
|
.attr('onclick', null)// disable highlightReply. so hacky
|
|
|
|
.click(inline)
|
2014-09-24 06:25:34 +02:00
|
|
|
|
|
|
|
})()
|