Fix file preParsing for /f/. Close #445

This commit is contained in:
Nicolas Stepien 2012-06-14 22:04:35 +02:00
parent 7f1c8fbb4b
commit 07ada39342
2 changed files with 10 additions and 14 deletions

View File

@ -4302,7 +4302,7 @@
} }
}, },
preParse: function(node) { preParse: function(node) {
var el, fileInfo, img, post, rootClass; var el, img, post, rootClass;
rootClass = node.className; rootClass = node.className;
el = $('.post', node); el = $('.post', node);
post = { post = {
@ -4319,12 +4319,9 @@
fileInfo: false, fileInfo: false,
img: false img: false
}; };
if (fileInfo = $('.fileInfo', el)) { if (img = $('img[data-md5]', el)) {
img = fileInfo.nextElementSibling.firstElementChild; post.fileInfo = img.parentNode.previousElementSibling;
if (img.alt !== 'File deleted.') { post.img = img;
post.fileInfo = fileInfo;
post.img = img;
}
} }
Main.prettify(post.blockquote); Main.prettify(post.blockquote);
return post; return post;

View File

@ -1487,7 +1487,6 @@ QR =
# save selected reply's data # save selected reply's data
for name in ['name', 'email', 'sub', 'com'] for name in ['name', 'email', 'sub', 'com']
# The input event replaces keyup, change and paste events. # The input event replaces keyup, change and paste events.
# XXX Does Opera support the `input` event?
$.on $("[name=#{name}]", QR.el), 'input', -> $.on $("[name=#{name}]", QR.el), 'input', ->
QR.selected[@name] = @value QR.selected[@name] = @value
# Disable auto-posting if you're typing in the first reply # Disable auto-posting if you're typing in the first reply
@ -2148,7 +2147,7 @@ Sauce =
@links = [] @links = []
for link in Conf['sauces'].split '\n' for link in Conf['sauces'].split '\n'
continue if link[0] is '#' continue if link[0] is '#'
# .trim() is there to fix Opera reading two different line breaks. # XXX .trim() is there to fix Opera reading two different line breaks.
@links.push @createSauceLink link.trim() @links.push @createSauceLink link.trim()
return unless @links.length return unless @links.length
Main.callbacks.push @node Main.callbacks.push @node
@ -3292,11 +3291,11 @@ Main =
backlinks: el.getElementsByClassName 'backlink' backlinks: el.getElementsByClassName 'backlink'
fileInfo: false fileInfo: false
img: false img: false
if fileInfo = $ '.fileInfo', el if img = $ 'img[data-md5]', el
img = fileInfo.nextElementSibling.firstElementChild # Make sure to not add deleted images,
if img.alt isnt 'File deleted.' # those do not have a data-md5 attribute.
post.fileInfo = fileInfo post.fileInfo = img.parentNode.previousElementSibling
post.img = img post.img = img
Main.prettify post.blockquote Main.prettify post.blockquote
post post
node: (nodes, notify) -> node: (nodes, notify) ->