2014-09-23 22:52:06 -04:00
|
|
|
;(function() {
|
2014-09-24 15:49:18 -04:00
|
|
|
var cache = {}
|
|
|
|
|
2014-09-24 00:25:34 -04:00
|
|
|
var inline = function(e) {
|
|
|
|
e.preventDefault()
|
|
|
|
|
2014-09-25 13:11:33 -04:00
|
|
|
var $root = $(this).closest('.post')
|
2014-09-24 00:25:34 -04:00
|
|
|
var postNum = this.textContent.slice(2)
|
|
|
|
|
2014-09-25 13:11:33 -04:00
|
|
|
var $clone = $root.find('#inline_' + postNum)
|
2014-09-24 00:25:34 -04:00
|
|
|
if ($clone.length)
|
|
|
|
return $clone.remove()
|
|
|
|
|
2014-09-24 15:17:30 -04:00
|
|
|
var postOP = this.pathname.match(/(\d+).html/)[1]
|
|
|
|
var selector = postNum === postOP
|
2014-09-24 00:25:34 -04:00
|
|
|
? '.op .body'
|
2014-10-03 12:53:11 -04:00
|
|
|
: '#reply_' + postNum
|
2014-09-24 00:25:34 -04:00
|
|
|
|
2014-09-25 13:11:33 -04:00
|
|
|
var node = this.className
|
2014-10-03 12:17:19 -04:00
|
|
|
// XXX post hover element is added to the quoting post
|
2014-10-03 13:00:44 -04:00
|
|
|
? $root.find('> .files, > .inline').first()
|
2014-09-25 13:11:33 -04:00
|
|
|
: this.nextSibling
|
|
|
|
|
2014-09-24 00:25:34 -04:00
|
|
|
var link = {
|
2014-09-25 13:11:33 -04:00
|
|
|
node: node,
|
|
|
|
postNum: postNum
|
2014-09-24 00:25:34 -04:00
|
|
|
}
|
2014-09-24 15:17:30 -04:00
|
|
|
|
|
|
|
var OP = $('input[name="thread"]').val()
|
|
|
|
if (OP === postOP) {
|
2014-10-03 12:17:19 -04:00
|
|
|
// XXX post hover adds fetched threads to the DOM
|
2014-09-24 15:37:25 -04:00
|
|
|
selector = '#thread_' + OP + ' ' + selector
|
2014-09-24 15:17:30 -04:00
|
|
|
var $target = $(selector)
|
2014-09-24 15:49:18 -04: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 15:17:30 -04:00
|
|
|
}
|
2014-09-24 15:49:18 -04:00
|
|
|
|
|
|
|
$.get(url, function(data) {
|
|
|
|
cache[url] = data
|
|
|
|
var $target = $(data).find(selector)
|
|
|
|
add(link, $target)
|
|
|
|
})
|
2014-09-24 00:25:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
var add = function(link, $target) {
|
|
|
|
var $clone = $target.clone(true)
|
|
|
|
$clone.attr({
|
2014-10-03 12:53:11 -04:00
|
|
|
"class": 'inline post',
|
2014-09-24 00:25:34 -04:00
|
|
|
id: 'inline_' + link.postNum
|
|
|
|
})
|
2014-09-25 13:11:33 -04:00
|
|
|
$clone.insertBefore(link.node)
|
2014-09-24 00:25:34 -04:00
|
|
|
}
|
2014-09-23 22:52:06 -04:00
|
|
|
|
|
|
|
$('head').append(
|
|
|
|
'<style>' +
|
2014-10-03 12:53:11 -04:00
|
|
|
'.inline { border: 1px dashed black; }' +
|
|
|
|
'div.post div.body { white-space: normal; }' +
|
2014-09-23 22:52:06 -04:00
|
|
|
'</style>')
|
|
|
|
|
2014-09-25 13:11:33 -04:00
|
|
|
$('.body a, .mentioned a')
|
2014-10-03 12:17:19 -04:00
|
|
|
.attr('onclick', null)// XXX disable highlightReply
|
2014-09-25 12:58:44 -04:00
|
|
|
.click(inline)
|
2014-09-24 00:25:34 -04:00
|
|
|
})()
|