Fix file deleted preParsing.

This commit is contained in:
Nicolas Stepien 2012-04-29 14:52:43 +02:00
parent f1a7942d56
commit def88abec6
2 changed files with 29 additions and 26 deletions

View File

@ -704,17 +704,17 @@
return text.join('');
},
filename: function(post) {
var file, fileinfo;
fileinfo = post.fileinfo;
if (fileinfo && (file = $('span', fileinfo))) {
var file, fileInfo;
fileInfo = post.fileInfo;
if (fileInfo && (file = $('span', fileInfo))) {
return file.title;
}
return false;
},
dimensions: function(post) {
var fileinfo, match;
fileinfo = post.fileinfo;
if (fileinfo && (match = fileinfo.textContent.match(/\d+x\d+/))) {
var fileInfo, match;
fileInfo = post.fileInfo;
if (fileInfo && (match = fileInfo.textContent.match(/\d+x\d+/))) {
return match[0];
}
return false;
@ -2791,7 +2791,7 @@
link = _ref[_i];
nodes.push($.tn('\u00A0'), link(img));
}
return $.add(post.fileinfo, nodes);
return $.add(post.fileInfo, nodes);
}
};
@ -4144,7 +4144,7 @@
}
},
preParse: function(node) {
var file, klass, post;
var fileInfo, img, klass, post;
klass = node.className;
post = {
root: node.parentNode,
@ -4154,14 +4154,16 @@
threadId: g.THREAD_ID || $.x('ancestor::div[@class="thread"]', node).id.slice(1),
isInlined: /\binline\b/.test(klass),
quotes: node.getElementsByClassName('quotelink'),
backlinks: node.getElementsByClassName('backlink')
backlinks: node.getElementsByClassName('backlink'),
fileInfo: false,
img: false
};
if (file = $('.file', node)) {
post.fileinfo = file.firstElementChild;
post.img = file.lastElementChild.firstElementChild;
} else {
post.fileinfo = false;
post.img = false;
if (fileInfo = $('.fileInfo', node)) {
img = fileInfo.nextElementSibling.firstElementChild;
if (img.alt !== 'File deleted.') {
post.fileInfo = fileInfo;
post.img = img;
}
}
return post;
},

View File

@ -576,13 +576,13 @@ Filter =
text.push if data = nodes.snapshotItem(i).data then data else '\n'
text.join ''
filename: (post) ->
{fileinfo} = post
if fileinfo and file = $ 'span', fileinfo
{fileInfo} = post
if fileInfo and file = $ 'span', fileInfo
return file.title
false
dimensions: (post) ->
{fileinfo} = post
if fileinfo and match = fileinfo.textContent.match /\d+x\d+/
{fileInfo} = post
if fileInfo and match = fileInfo.textContent.match /\d+x\d+/
return match[0]
false
filesize: (post) ->
@ -2211,7 +2211,7 @@ Sauce =
for link in Sauce.links
# \u00A0 is nbsp
nodes.push $.tn('\u00A0'), link img
$.add post.fileinfo, nodes
$.add post.fileInfo, nodes
RevealSpoilers =
init: ->
@ -3200,12 +3200,13 @@ Main =
isInlined: /\binline\b/.test klass
quotes: node.getElementsByClassName 'quotelink'
backlinks: node.getElementsByClassName 'backlink'
if file = $ '.file', node
post.fileinfo = file.firstElementChild
post.img = file.lastElementChild.firstElementChild
else
post.fileinfo = false
post.img = false
fileInfo: false
img: false
if fileInfo = $ '.fileInfo', node
img = fileInfo.nextElementSibling.firstElementChild
if img.alt isnt 'File deleted.'
post.fileInfo = fileInfo
post.img = img
post
node: (nodes, notify) ->
for callback in Main.callbacks