Update filename threshold in parseArchivedPost.

This commit is contained in:
Nicolas Stepien 2012-07-10 15:56:04 +02:00
parent 6956b4a4e1
commit bfbfcf1de9
2 changed files with 7 additions and 9 deletions

View File

@ -3497,7 +3497,7 @@
} }
}, },
parseArchivedPost: function(req, board, postID, root, cb) { parseArchivedPost: function(req, board, postID, root, cb) {
var bq, br, capcode, data, email, file, filename, filesize, isOP, max, name, nameBlock, pc, pi, piM, span, spoiler, subject, threadID, thumb_src, timestamp, trip; var bq, br, capcode, data, email, file, filename, filesize, isOP, name, nameBlock, pc, pi, piM, span, spoiler, subject, threadID, threshold, thumb_src, timestamp, trip;
data = JSON.parse(req.response); data = JSON.parse(req.response);
$.addClass(root, 'archivedPost'); $.addClass(root, 'archivedPost');
if (data.error) { if (data.error) {
@ -3635,8 +3635,8 @@
})); }));
span = $('span[title]', file); span = $('span[title]', file);
span.title = filename; span.title = filename;
max = isOP ? 40 : 30; threshold = isOP ? 40 : 30;
span.textContent = filename.replace(/\.\w+$/, '').length > max ? "" + filename.slice(0, max) + "(...)" + (filename.match(/\.\w+$/)) : filename; span.textContent = filename.replace(/\.\w+$/, '').length > threshold ? "" + filename.slice(0, threshold - 5) + "(...)" + (filename.match(/\.\w+$/)) : filename;
thumb_src = data.media_status === 'available' ? "src=" + data.thumb_link : ''; thumb_src = data.media_status === 'available' ? "src=" + data.thumb_link : '';
$.add(file, $.el('a', { $.add(file, $.el('a', {
className: spoiler ? 'fileThumb imgspoiler' : 'fileThumb', className: spoiler ? 'fileThumb imgspoiler' : 'fileThumb',

View File

@ -2892,15 +2892,13 @@ Get =
innerHTML: "<span id=fT#{postID} class=fileText>File: <a href='#{data.media_link or data.remote_media_link}' target=_blank>#{data.media_orig}</a>-(#{if spoiler then 'Spoiler Image, ' else ''}#{filesize}, #{data.media_w}x#{data.media_h}, <span title></span>)</span>" innerHTML: "<span id=fT#{postID} class=fileText>File: <a href='#{data.media_link or data.remote_media_link}' target=_blank>#{data.media_orig}</a>-(#{if spoiler then 'Spoiler Image, ' else ''}#{filesize}, #{data.media_w}x#{data.media_h}, <span title></span>)</span>"
span = $ 'span[title]', file span = $ 'span[title]', file
span.title = filename span.title = filename
max = if isOP then 40 else 30 threshold = if isOP then 40 else 30
span.textContent = span.textContent =
# FILENAME SHORTENING SCIENCE: # FILENAME SHORTENING SCIENCE:
# OPs have +10 characters max. # OPs have a +10 characters threshold.
# The file extension is not taken into account. # The file extension is not taken into account.
# abcdefghijklmnopqrstuvwxyz_1234.jpg is shortened. if filename.replace(/\.\w+$/, '').length > threshold
# abcdefghijklmnopqrstuvwxyz_123.jpg is not shortened. "#{filename[...threshold - 5]}(...)#{filename.match(/\.\w+$/)}"
if filename.replace(/\.\w+$/, '').length > max
"#{filename[...max]}(...)#{filename.match(/\.\w+$/)}"
else else
filename filename
thumb_src = if data.media_status is 'available' then "src=#{data.thumb_link}" else '' thumb_src = if data.media_status is 'available' then "src=#{data.thumb_link}" else ''