From b7ecec510415630f03f27a47d82ad6ef04dd70ba Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Fri, 7 Sep 2012 20:52:20 +0200 Subject: [PATCH] Fix filename title for spoiler images. Fix filenames in general. --- 4chan_x.user.js | 12 ++++++++++-- script.coffee | 17 +++++++++++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 89668854e..c257af51a 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -3715,7 +3715,7 @@ @license: https://github.com/4chan/4chan-JS/blob/master/LICENSE */ - var board, capcode, capcodeClass, capcodeStart, closed, comment, container, date, dateUTC, email, emailEnd, emailStart, ext, file, fileDims, fileHTML, fileInfo, fileSize, fileThumb, flag, flagCode, flagName, highlight, href, imgSrc, isClosed, isOP, isSticky, name, postID, quote, staticPath, sticky, subject, threadID, tripcode, uniqueID, userID, _i, _len, _ref; + var a, board, capcode, capcodeClass, capcodeStart, closed, comment, container, date, dateUTC, email, emailEnd, emailStart, ext, file, fileDims, fileHTML, fileInfo, fileSize, fileThumb, filename, flag, flagCode, flagName, highlight, href, imgSrc, isClosed, isOP, isSticky, name, postID, quote, shortFilename, staticPath, sticky, subject, threadID, tripcode, uniqueID, userID, _i, _len, _ref; postID = o.postID, threadID = o.threadID, board = o.board, name = o.name, capcode = o.capcode, tripcode = o.tripcode, uniqueID = o.uniqueID, email = o.email, subject = o.subject, flagCode = o.flagCode, flagName = o.flagName, date = o.date, dateUTC = o.dateUTC, isSticky = o.isSticky, isClosed = o.isClosed, comment = o.comment, file = o.file; isOP = postID === threadID; staticPath = '//static.4chan.org'; @@ -3800,8 +3800,16 @@ } } imgSrc = ("") + ("" + fileSize + ""); + a = $.el('a', { + innerHTML: file.name + }); + filename = a.textContent.replace(/%22/g, '"'); + a.textContent = Build.shortname(filename); + shortFilename = a.innerHTML; + a.textContent = filename; + filename = a.innerHTML; fileDims = ext === 'pdf' ? 'PDF' : "" + file.width + "x" + file.height; - fileInfo = ("File: " + file.timestamp + "") + ("-(" + fileSize + ", " + fileDims + (file.isSpoiler ? '' : ", " + (Build.shortFilename(file.name)) + "'")) + ")"; + fileInfo = ("File: " + file.timestamp + "") + ("-(" + fileSize + ", " + fileDims + (file.isSpoiler ? '' : ", " + filename + "'")) + ")"; fileHTML = "
" + fileInfo + "
" + imgSrc + "
"; } else { fileHTML = ''; diff --git a/script.coffee b/script.coffee index 1b4b2aecd..8f022a1dc 100644 --- a/script.coffee +++ b/script.coffee @@ -3039,13 +3039,26 @@ Build = imgSrc = "" + "#{fileSize}" + # Ha Ha filenames. + # html -> text, translate WebKit's %22s into "s + a = $.el 'a', innerHTML: file.name + filename = a.textContent.replace /%22/g, '"' + + # shorten filename, get html + a.textContent = Build.shortname filename + shortFilename = a.innerHTML + + # get html + a.textContent = filename + filename = a.innerHTML + fileDims = if ext is 'pdf' then 'PDF' else "#{file.width}x#{file.height}" - fileInfo = "File: #{file.timestamp}" + + fileInfo = "File: #{file.timestamp}" + "-(#{fileSize}, #{fileDims}#{ if file.isSpoiler '' else - ", #{Build.shortFilename file.name}'" + ", #{filename}'" }" + ")" fileHTML = "
#{fileInfo}
#{imgSrc}
"