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(''); return text.join('');
}, },
filename: function(post) { filename: function(post) {
var file, fileinfo; var file, fileInfo;
fileinfo = post.fileinfo; fileInfo = post.fileInfo;
if (fileinfo && (file = $('span', fileinfo))) { if (fileInfo && (file = $('span', fileInfo))) {
return file.title; return file.title;
} }
return false; return false;
}, },
dimensions: function(post) { dimensions: function(post) {
var fileinfo, match; var fileInfo, match;
fileinfo = post.fileinfo; fileInfo = post.fileInfo;
if (fileinfo && (match = fileinfo.textContent.match(/\d+x\d+/))) { if (fileInfo && (match = fileInfo.textContent.match(/\d+x\d+/))) {
return match[0]; return match[0];
} }
return false; return false;
@ -2791,7 +2791,7 @@
link = _ref[_i]; link = _ref[_i];
nodes.push($.tn('\u00A0'), link(img)); nodes.push($.tn('\u00A0'), link(img));
} }
return $.add(post.fileinfo, nodes); return $.add(post.fileInfo, nodes);
} }
}; };
@ -4144,7 +4144,7 @@
} }
}, },
preParse: function(node) { preParse: function(node) {
var file, klass, post; var fileInfo, img, klass, post;
klass = node.className; klass = node.className;
post = { post = {
root: node.parentNode, root: node.parentNode,
@ -4154,14 +4154,16 @@
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: node.getElementsByClassName('quotelink'),
backlinks: node.getElementsByClassName('backlink') backlinks: node.getElementsByClassName('backlink'),
fileInfo: false,
img: false
}; };
if (file = $('.file', node)) { if (fileInfo = $('.fileInfo', node)) {
post.fileinfo = file.firstElementChild; img = fileInfo.nextElementSibling.firstElementChild;
post.img = file.lastElementChild.firstElementChild; if (img.alt !== 'File deleted.') {
} else { post.fileInfo = fileInfo;
post.fileinfo = false; post.img = img;
post.img = false; }
} }
return post; return post;
}, },

View File

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