From 58f40bf9173a9d5dcb44eb84d4b8aa6c8136860f Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 23 Aug 2012 22:05:44 +0200 Subject: [PATCH] Fix shortened filename too short for OPs. --- 4chan_x.user.js | 4 ++-- script.coffee | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 504ed3233..3b9f3295e 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -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); diff --git a/script.coffee b/script.coffee index 82436346f..32d38b95f 100644 --- a/script.coffee +++ b/script.coffee @@ -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