Add option for quick filter MD5 button (%f) to File Info Formatting (Advanced settings tab). #377

This commit is contained in:
ccd0 2016-11-07 22:20:45 -08:00
parent 59cc8059f1
commit 76f8118872
3 changed files with 30 additions and 10 deletions

View File

@ -158,6 +158,29 @@ Filter =
filesize: (post) -> post.file?.size
MD5: (post) -> post.file?.MD5
addFilter: (type, re, cb) ->
$.get type, Conf[type], (item) ->
save = item[type]
# Add a new line before the regexp unless the text is empty.
save =
if save
"#{save}\n#{re}"
else
re
$.set type, save, cb
quickFilterMD5: ->
post = Get.postFromNode @
Filter.addFilter 'MD5', "/#{post.file.MD5}/"
origin = post.origin or post
if origin.isReply
PostHiding.hide origin
else if g.VIEW is 'index'
ThreadHiding.hide origin.thread
# If post is still visible, give an indication that the MD5 was filtered.
if post.nodes.post.getBoundingClientRect().height
new Notice 'info', 'MD5 filtered.', 2
menu:
init: ->
return unless g.VIEW in ['index', 'thread'] and Conf['Menu'] and Conf['Filter']
@ -240,16 +263,7 @@ Filter =
else
"/^#{re}$/"
# Add a new line before the regexp unless the text is empty.
$.get type, Conf[type], (item) ->
save = item[type]
save =
if save
"#{save}\n#{re}"
else
re
$.set type, save
Filter.addFilter type, re, ->
# Open the settings and display & focus the relevant filter textarea.
Settings.open 'Filter'
section = $ '.section-container'

View File

@ -77,6 +77,7 @@
<div>Link: <code>%l</code> (truncated), <code>%L</code> (untruncated), <code>%T</code> (4chan filename)</div>
<div>Filename: <code>%n</code> (truncated), <code>%N</code> (untruncated), <code>%t</code> (4chan filename)</div>
<div>Download button: <code>%d</code></div>
<div>Quick filter MD5: <code>%f</code></div>
<div>Spoiler indicator: <code>%p</code></div>
<div>Size: <code>%B</code> (Bytes), <code>%K</code> (KB), <code>%M</code> (MB), <code>%s</code> (4chan default)</div>
<div>Resolution: <code>%r</code> (Displays &#039;PDF&#039; for PDF files)</div>

View File

@ -11,6 +11,8 @@ FileInfo =
if @isClone
for a in $$ '.file-info .download-button', @file.text
$.on a, 'click', ImageCommon.download
for a in $$ '.file-info .quick-filter-md5', @file.text
$.on a, 'click', Filter.quickFilterMD5
return
oldInfo = $.el 'span', {className: 'fileText-original'}
@ -32,6 +34,8 @@ FileInfo =
$.extend outputNode, <%= html('@{output}') %>
for a in $$ '.download-button', outputNode
$.on a, 'click', ImageCommon.download
for a in $$ '.quick-filter-md5', outputNode
$.on a, 'click', Filter.quickFilterMD5
return
formatters:
@ -48,6 +52,7 @@ FileInfo =
<%= html('<span class="fnswitch"><span class="fntrunc">${shortname}</span><span class="fnfull">${fullname}</span></span>') %>
N: -> <%= html('${this.file.name}') %>
d: -> <%= html('<a href="${this.file.url}" download="${this.file.name}" class="fa fa-download download-button"></a>') %>
f: -> <%= html('<a href="javascript:;" class="fa fa-trash-o quick-filter-md5"></a>') %>
p: -> <%= html('?{this.file.isSpoiler}{Spoiler, }') %>
s: -> <%= html('${this.file.size}') %>
B: -> <%= html('${Math.round(this.file.sizeInBytes)} Bytes') %>