Add option for quick filter MD5 button (%f) to File Info Formatting (Advanced settings tab). #377
This commit is contained in:
parent
59cc8059f1
commit
76f8118872
@ -158,6 +158,29 @@ Filter =
|
|||||||
filesize: (post) -> post.file?.size
|
filesize: (post) -> post.file?.size
|
||||||
MD5: (post) -> post.file?.MD5
|
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:
|
menu:
|
||||||
init: ->
|
init: ->
|
||||||
return unless g.VIEW in ['index', 'thread'] and Conf['Menu'] and Conf['Filter']
|
return unless g.VIEW in ['index', 'thread'] and Conf['Menu'] and Conf['Filter']
|
||||||
@ -240,16 +263,7 @@ Filter =
|
|||||||
else
|
else
|
||||||
"/^#{re}$/"
|
"/^#{re}$/"
|
||||||
|
|
||||||
# Add a new line before the regexp unless the text is empty.
|
Filter.addFilter type, re, ->
|
||||||
$.get type, Conf[type], (item) ->
|
|
||||||
save = item[type]
|
|
||||||
save =
|
|
||||||
if save
|
|
||||||
"#{save}\n#{re}"
|
|
||||||
else
|
|
||||||
re
|
|
||||||
$.set type, save
|
|
||||||
|
|
||||||
# Open the settings and display & focus the relevant filter textarea.
|
# Open the settings and display & focus the relevant filter textarea.
|
||||||
Settings.open 'Filter'
|
Settings.open 'Filter'
|
||||||
section = $ '.section-container'
|
section = $ '.section-container'
|
||||||
|
|||||||
@ -77,6 +77,7 @@
|
|||||||
<div>Link: <code>%l</code> (truncated), <code>%L</code> (untruncated), <code>%T</code> (4chan filename)</div>
|
<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>Filename: <code>%n</code> (truncated), <code>%N</code> (untruncated), <code>%t</code> (4chan filename)</div>
|
||||||
<div>Download button: <code>%d</code></div>
|
<div>Download button: <code>%d</code></div>
|
||||||
|
<div>Quick filter MD5: <code>%f</code></div>
|
||||||
<div>Spoiler indicator: <code>%p</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>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 'PDF' for PDF files)</div>
|
<div>Resolution: <code>%r</code> (Displays 'PDF' for PDF files)</div>
|
||||||
|
|||||||
@ -11,6 +11,8 @@ FileInfo =
|
|||||||
if @isClone
|
if @isClone
|
||||||
for a in $$ '.file-info .download-button', @file.text
|
for a in $$ '.file-info .download-button', @file.text
|
||||||
$.on a, 'click', ImageCommon.download
|
$.on a, 'click', ImageCommon.download
|
||||||
|
for a in $$ '.file-info .quick-filter-md5', @file.text
|
||||||
|
$.on a, 'click', Filter.quickFilterMD5
|
||||||
return
|
return
|
||||||
|
|
||||||
oldInfo = $.el 'span', {className: 'fileText-original'}
|
oldInfo = $.el 'span', {className: 'fileText-original'}
|
||||||
@ -32,6 +34,8 @@ FileInfo =
|
|||||||
$.extend outputNode, <%= html('@{output}') %>
|
$.extend outputNode, <%= html('@{output}') %>
|
||||||
for a in $$ '.download-button', outputNode
|
for a in $$ '.download-button', outputNode
|
||||||
$.on a, 'click', ImageCommon.download
|
$.on a, 'click', ImageCommon.download
|
||||||
|
for a in $$ '.quick-filter-md5', outputNode
|
||||||
|
$.on a, 'click', Filter.quickFilterMD5
|
||||||
return
|
return
|
||||||
|
|
||||||
formatters:
|
formatters:
|
||||||
@ -48,6 +52,7 @@ FileInfo =
|
|||||||
<%= html('<span class="fnswitch"><span class="fntrunc">${shortname}</span><span class="fnfull">${fullname}</span></span>') %>
|
<%= html('<span class="fnswitch"><span class="fntrunc">${shortname}</span><span class="fnfull">${fullname}</span></span>') %>
|
||||||
N: -> <%= html('${this.file.name}') %>
|
N: -> <%= html('${this.file.name}') %>
|
||||||
d: -> <%= html('<a href="${this.file.url}" download="${this.file.name}" class="fa fa-download download-button"></a>') %>
|
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, }') %>
|
p: -> <%= html('?{this.file.isSpoiler}{Spoiler, }') %>
|
||||||
s: -> <%= html('${this.file.size}') %>
|
s: -> <%= html('${this.file.size}') %>
|
||||||
B: -> <%= html('${Math.round(this.file.sizeInBytes)} Bytes') %>
|
B: -> <%= html('${Math.round(this.file.sizeInBytes)} Bytes') %>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user