Spoilered images do not show the filename, use the .title of the fileinfo.
This commit is contained in:
parent
c7e5f3afab
commit
2fac05917d
@ -487,6 +487,15 @@
|
|||||||
$.add(d.head, script);
|
$.add(d.head, script);
|
||||||
return $.rm(script);
|
return $.rm(script);
|
||||||
},
|
},
|
||||||
|
shortenFilename: function(filename, isOP) {
|
||||||
|
var threshold;
|
||||||
|
threshold = isOP ? 40 : 30;
|
||||||
|
if (filename.replace(/\.\w+$/, '').length > threshold) {
|
||||||
|
return "" + filename.slice(0, threshold - 5) + "(...)" + (filename.match(/\.\w+$/));
|
||||||
|
} else {
|
||||||
|
return filename;
|
||||||
|
}
|
||||||
|
},
|
||||||
bytesToString: function(size) {
|
bytesToString: function(size) {
|
||||||
var unit;
|
var unit;
|
||||||
unit = 0;
|
unit = 0;
|
||||||
@ -3378,23 +3387,23 @@
|
|||||||
return Main.callbacks.push(this.node);
|
return Main.callbacks.push(this.node);
|
||||||
},
|
},
|
||||||
node: function(post) {
|
node: function(post) {
|
||||||
var alt, node, span;
|
var alt, filename, node, _ref;
|
||||||
if (post.isInlined && !post.isCrosspost || !post.fileInfo) {
|
if (post.isInlined && !post.isCrosspost || !post.fileInfo) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
node = post.fileInfo.firstElementChild;
|
node = post.fileInfo.firstElementChild;
|
||||||
alt = post.img.alt;
|
alt = post.img.alt;
|
||||||
span = $('span', node);
|
filename = ((_ref = $('span', node)) != null ? _ref.title : void 0) || node.title;
|
||||||
FileInfo.data = {
|
FileInfo.data = {
|
||||||
link: post.img.parentNode.href,
|
link: post.img.parentNode.href,
|
||||||
spoiler: /^Spoiler/.test(alt),
|
spoiler: /^Spoiler/.test(alt),
|
||||||
size: alt.match(/\d+\.?\d*/)[0],
|
size: alt.match(/\d+\.?\d*/)[0],
|
||||||
unit: alt.match(/\w+$/)[0],
|
unit: alt.match(/\w+$/)[0],
|
||||||
resolution: span.previousSibling.textContent.match(/\d+x\d+|PDF/)[0],
|
resolution: node.textContent.match(/\d+x\d+|PDF/)[0],
|
||||||
fullname: span.title,
|
fullname: filename,
|
||||||
shortname: span.textContent
|
shortname: $.shortenFilename(filename, post.isOP)
|
||||||
};
|
};
|
||||||
node.setAttribute('data-filename', span.title);
|
node.setAttribute('data-filename', filename);
|
||||||
return node.innerHTML = FileInfo.funk(FileInfo);
|
return node.innerHTML = FileInfo.funk(FileInfo);
|
||||||
},
|
},
|
||||||
setFormats: function() {
|
setFormats: function() {
|
||||||
@ -3537,7 +3546,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, name, nameBlock, pc, pi, piM, span, spoiler, subject, threadID, threshold, thumb_src, timestamp, trip, userID;
|
var bq, br, capcode, data, email, file, filename, filesize, isOP, name, nameBlock, pc, pi, piM, span, spoiler, subject, threadID, thumb_src, timestamp, trip, userID;
|
||||||
data = JSON.parse(req.response);
|
data = JSON.parse(req.response);
|
||||||
$.addClass(root, 'archivedPost');
|
$.addClass(root, 'archivedPost');
|
||||||
if (data.error) {
|
if (data.error) {
|
||||||
@ -3710,8 +3719,7 @@
|
|||||||
}));
|
}));
|
||||||
span = $('span[title]', file);
|
span = $('span[title]', file);
|
||||||
span.title = filename;
|
span.title = filename;
|
||||||
threshold = isOP ? 40 : 30;
|
span.textContent = $.shortenFilename(filename, isOP);
|
||||||
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',
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
master
|
master
|
||||||
|
-Mayhem
|
||||||
|
Fix support of change in 4chan's HTML about hidden filename in case of spoiler.
|
||||||
|
|
||||||
2.34.5
|
2.34.5
|
||||||
- Mayhem
|
- Mayhem
|
||||||
|
|||||||
@ -368,6 +368,15 @@ $.extend $,
|
|||||||
script = $.el 'script', textContent: code
|
script = $.el 'script', textContent: code
|
||||||
$.add d.head, script
|
$.add d.head, script
|
||||||
$.rm script
|
$.rm script
|
||||||
|
shortenFilename: (filename, isOP) ->
|
||||||
|
# FILENAME SHORTENING SCIENCE:
|
||||||
|
# OPs have a +10 characters threshold.
|
||||||
|
# The file extension is not taken into account.
|
||||||
|
threshold = if isOP then 40 else 30
|
||||||
|
if filename.replace(/\.\w+$/, '').length > threshold
|
||||||
|
"#{filename[...threshold - 5]}(...)#{filename.match(/\.\w+$/)}"
|
||||||
|
else
|
||||||
|
filename
|
||||||
bytesToString: (size) ->
|
bytesToString: (size) ->
|
||||||
unit = 0 # Bytes
|
unit = 0 # Bytes
|
||||||
while size >= 1024
|
while size >= 1024
|
||||||
@ -2675,17 +2684,17 @@ FileInfo =
|
|||||||
return if post.isInlined and not post.isCrosspost or not post.fileInfo
|
return if post.isInlined and not post.isCrosspost or not post.fileInfo
|
||||||
node = post.fileInfo.firstElementChild
|
node = post.fileInfo.firstElementChild
|
||||||
alt = post.img.alt
|
alt = post.img.alt
|
||||||
span = $ 'span', node
|
filename = $('span', node)?.title or node.title
|
||||||
FileInfo.data =
|
FileInfo.data =
|
||||||
link: post.img.parentNode.href
|
link: post.img.parentNode.href
|
||||||
spoiler: /^Spoiler/.test alt
|
spoiler: /^Spoiler/.test alt
|
||||||
size: alt.match(/\d+\.?\d*/)[0]
|
size: alt.match(/\d+\.?\d*/)[0]
|
||||||
unit: alt.match(/\w+$/)[0]
|
unit: alt.match(/\w+$/)[0]
|
||||||
resolution: span.previousSibling.textContent.match(/\d+x\d+|PDF/)[0]
|
resolution: node.textContent.match(/\d+x\d+|PDF/)[0]
|
||||||
fullname: span.title
|
fullname: filename
|
||||||
shortname: span.textContent
|
shortname: $.shortenFilename filename, post.isOP
|
||||||
# XXX GM/Scriptish
|
# XXX GM/Scriptish
|
||||||
node.setAttribute 'data-filename', span.title
|
node.setAttribute 'data-filename', filename
|
||||||
node.innerHTML = FileInfo.funk FileInfo
|
node.innerHTML = FileInfo.funk FileInfo
|
||||||
setFormats: ->
|
setFormats: ->
|
||||||
code = Conf['fileInfo'].replace /%([BKlLMnNprs])/g, (s, c) ->
|
code = Conf['fileInfo'].replace /%([BKlLMnNprs])/g, (s, c) ->
|
||||||
@ -2954,15 +2963,7 @@ 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
|
||||||
threshold = if isOP then 40 else 30
|
span.textContent = $.shortenFilename filename, isOP
|
||||||
span.textContent =
|
|
||||||
# FILENAME SHORTENING SCIENCE:
|
|
||||||
# OPs have a +10 characters threshold.
|
|
||||||
# The file extension is not taken into account.
|
|
||||||
if filename.replace(/\.\w+$/, '').length > threshold
|
|
||||||
"#{filename[...threshold - 5]}(...)#{filename.match(/\.\w+$/)}"
|
|
||||||
else
|
|
||||||
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 ''
|
||||||
$.add file, $.el 'a',
|
$.add file, $.el 'a',
|
||||||
className: if spoiler then 'fileThumb imgspoiler' else 'fileThumb'
|
className: if spoiler then 'fileThumb imgspoiler' else 'fileThumb'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user