Fix shortened filename too short for OPs.

This commit is contained in:
Nicolas Stepien 2012-08-23 22:05:44 +02:00
parent 0248c180bd
commit 58f40bf917
2 changed files with 4 additions and 4 deletions

View File

@ -489,7 +489,7 @@
},
shortenFilename: function(filename, isOP) {
var threshold;
threshold = isOP ? 40 : 30;
threshold = 30 + 10 * isOP;
if (filename.replace(/\.\w+$/, '').length > threshold) {
return "" + filename.slice(0, threshold - 5) + "(...)" + (filename.match(/\.\w+$/));
} else {
@ -3401,7 +3401,7 @@
unit: alt.match(/\w+$/)[0],
resolution: node.textContent.match(/\d+x\d+|PDF/)[0],
fullname: filename,
shortname: $.shortenFilename(filename, post.isOP)
shortname: $.shortenFilename(filename, post.ID === post.threadID)
};
node.setAttribute('data-filename', filename);
return node.innerHTML = FileInfo.funk(FileInfo);

View File

@ -372,7 +372,7 @@ $.extend $,
# FILENAME SHORTENING SCIENCE:
# OPs have a +10 characters threshold.
# The file extension is not taken into account.
threshold = if isOP then 40 else 30
threshold = 30 + 10 * isOP
if filename.replace(/\.\w+$/, '').length > threshold
"#{filename[...threshold - 5]}(...)#{filename.match(/\.\w+$/)}"
else
@ -2692,7 +2692,7 @@ FileInfo =
unit: alt.match(/\w+$/)[0]
resolution: node.textContent.match(/\d+x\d+|PDF/)[0]
fullname: filename
shortname: $.shortenFilename filename, post.isOP
shortname: $.shortenFilename filename, post.ID is post.threadID
# XXX GM/Scriptish
node.setAttribute 'data-filename', filename
node.innerHTML = FileInfo.funk FileInfo