Fix preParsing of inserted posts.

Ha ha, back to Tera.
This commit is contained in:
Nicolas Stepien 2012-04-30 14:55:43 +02:00
parent b72083552c
commit 7b20be3a91
2 changed files with 19 additions and 17 deletions

View File

@ -4072,7 +4072,7 @@
} }
board = $('.board'); board = $('.board');
nodes = []; nodes = [];
_ref1 = $$('.post', board); _ref1 = $$('.postContainer', board);
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
node = _ref1[_j]; node = _ref1[_j];
nodes.push(Main.preParse(node)); nodes.push(Main.preParse(node));
@ -4117,21 +4117,22 @@
} }
}, },
preParse: function(node) { preParse: function(node) {
var fileInfo, img, klass, post; var el, fileInfo, img, klass, post;
klass = node.className; el = $('.post', node);
klass = el.className;
post = { post = {
root: node.parentNode, root: node,
el: node, el: el,
"class": klass, "class": klass,
id: node.id.slice(1), id: el.id.slice(1),
threadId: g.THREAD_ID || $.x('ancestor::div[@class="thread"]', node).id.slice(1), threadId: g.THREAD_ID || $.x('ancestor::div[@class="thread"]', node).id.slice(1),
isInlined: /\binline\b/.test(klass), isInlined: /\binline\b/.test(klass),
quotes: node.getElementsByClassName('quotelink'), quotes: el.getElementsByClassName('quotelink'),
backlinks: node.getElementsByClassName('backlink'), backlinks: el.getElementsByClassName('backlink'),
fileInfo: false, fileInfo: false,
img: false img: false
}; };
if (fileInfo = $('.fileInfo', node)) { if (fileInfo = $('.fileInfo', el)) {
img = fileInfo.nextElementSibling.firstElementChild; img = fileInfo.nextElementSibling.firstElementChild;
if (img.alt !== 'File deleted.') { if (img.alt !== 'File deleted.') {
post.fileInfo = fileInfo; post.fileInfo = fileInfo;

View File

@ -3137,7 +3137,7 @@ Main =
board = $ '.board' board = $ '.board'
nodes = [] nodes = []
for node in $$ '.post', board for node in $$ '.postContainer', board
nodes.push Main.preParse node nodes.push Main.preParse node
Main.node nodes, true Main.node nodes, true
@ -3172,19 +3172,20 @@ Main =
window.location = "https://raw.github.com/mayhemydg/4chan-x/#{version}/4chan_x.user.js" window.location = "https://raw.github.com/mayhemydg/4chan-x/#{version}/4chan_x.user.js"
preParse: (node) -> preParse: (node) ->
klass = node.className el = $ '.post', node
klass = el.className
post = post =
root: node.parentNode root: node
el: node el: el
class: klass class: klass
id: node.id[1..] id: el.id[1..]
threadId: g.THREAD_ID or $.x('ancestor::div[@class="thread"]', node).id[1..] threadId: g.THREAD_ID or $.x('ancestor::div[@class="thread"]', node).id[1..]
isInlined: /\binline\b/.test klass isInlined: /\binline\b/.test klass
quotes: node.getElementsByClassName 'quotelink' quotes: el.getElementsByClassName 'quotelink'
backlinks: node.getElementsByClassName 'backlink' backlinks: el.getElementsByClassName 'backlink'
fileInfo: false fileInfo: false
img: false img: false
if fileInfo = $ '.fileInfo', node if fileInfo = $ '.fileInfo', el
img = fileInfo.nextElementSibling.firstElementChild img = fileInfo.nextElementSibling.firstElementChild
if img.alt isnt 'File deleted.' if img.alt isnt 'File deleted.'
post.fileInfo = fileInfo post.fileInfo = fileInfo