More compatible File Info Formatting.

This commit is contained in:
Nicolas Stepien 2012-03-19 23:34:15 +01:00
parent 4ea4dc863b
commit 8712d29e46
2 changed files with 21 additions and 22 deletions

View File

@ -2945,21 +2945,23 @@
return g.callbacks.push(this.node); return g.callbacks.push(this.node);
}, },
node: function(post) { node: function(post) {
var fullname, link, node, regexp, resolution, shortname, size, type, unit, _, _ref; var data, link, node, regexp, resolution, size, span, unit, _, _ref;
if (post["class"] === 'inline' || !(node = post.filesize)) return; if (post["class"] === 'inline' || !(node = post.filesize)) return;
type = node.childElementCount === 2 ? 0 : 1; regexp = /^File: (<.+>)-\((?:Spoiler Image, )?([\d\.]+) (\w+), (\d+x\d+|PDF)/;
regexp = type ? /^File: (<.+>)-\((?:Spoiler Image, )?([\d\.]+) (\w+), (\d+x\d+|PDF)/ : /^File: (<.+>)-\((?:Spoiler Image, )?([\d\.]+) (\w+), (\d+x\d+|PDF), <span title="(.+)">([^<]+)/; _ref = node.innerHTML.match(regexp), _ = _ref[0], link = _ref[1], size = _ref[2], unit = _ref[3], resolution = _ref[4];
_ref = node.innerHTML.match(regexp), _ = _ref[0], link = _ref[1], size = _ref[2], unit = _ref[3], resolution = _ref[4], fullname = _ref[5], shortname = _ref[6]; data = {
FileInfo.data = {
link: link, link: link,
size: size, size: size,
unit: unit, unit: unit,
resolution: resolution, resolution: resolution
fullname: fullname,
shortname: shortname,
type: type
}; };
return node.innerHTML = FileInfo.funks[type](FileInfo); if (span = $('span', node)) {
data.fullname = span.title;
data.shortname = span.textContent;
}
data.type = +(!span);
FileInfo.data = data;
return node.innerHTML = FileInfo.funks[data.type](FileInfo);
}, },
setFormats: function() { setFormats: function() {
var code, format, funks, i, param; var code, format, funks, i, param;

View File

@ -2476,23 +2476,20 @@ FileInfo =
g.callbacks.push @node g.callbacks.push @node
node: (post) -> node: (post) ->
return if post.class is 'inline' or not node = post.filesize return if post.class is 'inline' or not node = post.filesize
type = if node.childElementCount is 2 then 0 else 1 regexp = /^File: (<.+>)-\((?:Spoiler Image, )?([\d\.]+) (\w+), (\d+x\d+|PDF)/
regexp = [_, link, size, unit, resolution] =
if type
/^File: (<.+>)-\((?:Spoiler Image, )?([\d\.]+) (\w+), (\d+x\d+|PDF)/
else
/^File: (<.+>)-\((?:Spoiler Image, )?([\d\.]+) (\w+), (\d+x\d+|PDF), <span title="(.+)">([^<]+)/
[_, link, size, unit, resolution, fullname, shortname] =
node.innerHTML.match regexp node.innerHTML.match regexp
FileInfo.data = data =
link: link link: link
size: size size: size
unit: unit unit: unit
resolution: resolution resolution: resolution
fullname: fullname if span = $ 'span', node
shortname: shortname data.fullname = span.title
type: type data.shortname = span.textContent
node.innerHTML = FileInfo.funks[type] FileInfo data.type = +!span
FileInfo.data = data
node.innerHTML = FileInfo.funks[data.type] FileInfo
setFormats: -> setFormats: ->
funks = [] funks = []
for i in [0..1] for i in [0..1]