Add {Post,Thread}::{hide,show}(). Merge reply hiding and thread hiding.
This commit is contained in:
parent
4860b59d1b
commit
61510ca272
@ -1,3 +1,7 @@
|
||||
- Post hiding rewrite:
|
||||
- `Thread Hiding` and `Reply Hiding` settings are merged into one: `Post Hiding`.
|
||||
- `Thread Hiding Link` and `Reply Hiding Link` settings are merged into one: `Post Hiding Link`.
|
||||
|
||||
### 3.18.1 - *2014-02-20*
|
||||
|
||||
- Fix the QR breaking after a change with 4chan.
|
||||
|
||||
@ -706,12 +706,12 @@ a.hide-announcement {
|
||||
border: 2px solid rgba(255, 0, 0, .5);
|
||||
}
|
||||
|
||||
/* Thread & Reply Hiding */
|
||||
.hide-thread-button,
|
||||
.hide-reply-button {
|
||||
/* Post Hiding */
|
||||
.hide-post-button {
|
||||
float: left;
|
||||
margin-right: 2px;
|
||||
margin-right: 3px;
|
||||
}
|
||||
.thread[hidden] + hr,
|
||||
.stub ~ * {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
@ -100,12 +100,8 @@ Filter =
|
||||
|
||||
# Hide
|
||||
if result.hide
|
||||
if @isReply
|
||||
PostHiding.hide @, result.stub
|
||||
else if g.VIEW is 'index'
|
||||
ThreadHiding.hide @thread, result.stub
|
||||
else
|
||||
continue
|
||||
continue unless @isReply or g.VIEW is 'index'
|
||||
@hide result.stub
|
||||
return
|
||||
|
||||
# Highlight
|
||||
|
||||
@ -1,186 +1,168 @@
|
||||
PostHiding =
|
||||
init: ->
|
||||
return if !Conf['Reply Hiding'] and !Conf['Reply Hiding Link']
|
||||
|
||||
@db = new DataBoard 'hiddenPosts'
|
||||
@hideButton = $.el 'a',
|
||||
className: 'hide-post-button'
|
||||
innerHTML: '<i class="fa fa-minus-square-o"></i>'
|
||||
href: 'javascript:;'
|
||||
@showButton = $.el 'a',
|
||||
className: 'show-post-button'
|
||||
innerHTML: '<i class="fa fa-plus-square-o"></i>'
|
||||
href: 'javascript:;'
|
||||
|
||||
Post.callbacks.push
|
||||
name: 'Reply Hiding'
|
||||
name: 'Post Hiding'
|
||||
cb: @node
|
||||
|
||||
# XXX tmp conversion
|
||||
$.get 'hiddenThreads', null, ({hiddenThreads}) ->
|
||||
return unless hiddenThreads
|
||||
for boardID, board of hiddenThreads.boards
|
||||
for threadID, val of board
|
||||
((PostHiding.db.data.boards[boardID] or= {})[threadID] or= {})[threadID] = val
|
||||
PostHiding.db.save()
|
||||
$.delete 'hiddenThreads'
|
||||
|
||||
node: ->
|
||||
return if !@isReply or @isClone
|
||||
return if !@isReply and g.VIEW isnt 'index' or @isClone
|
||||
|
||||
if data = PostHiding.db.get {boardID: @board.ID, threadID: @thread.ID, postID: @ID}
|
||||
if data.thisPost
|
||||
PostHiding.hide @, data.makeStub, data.hideRecursively
|
||||
if data.thisPost is false
|
||||
Recursive.apply 'hide', @, data.makeStub, true
|
||||
Recursive.add 'hide', @, data.makeStub, true
|
||||
else
|
||||
Recursive.apply PostHiding.hide, @, data.makeStub, true
|
||||
Recursive.add PostHiding.hide, @, data.makeStub, true
|
||||
return unless Conf['Reply Hiding']
|
||||
$.replace $('.sideArrows', @nodes.root), PostHiding.makeButton @, 'hide'
|
||||
@hide data.makeStub, data.hideRecursively
|
||||
|
||||
menu:
|
||||
init: ->
|
||||
return if !Conf['Menu'] or !Conf['Reply Hiding Link']
|
||||
return unless Conf['Post Hiding']
|
||||
a = PostHiding.makeButton true
|
||||
if @isReply
|
||||
$.replace $('.sideArrows', @nodes.root), a
|
||||
else
|
||||
$.prepend @nodes.root, a
|
||||
|
||||
# Hide
|
||||
div = $.el 'div',
|
||||
className: 'hide-reply-link'
|
||||
textContent: 'Hide reply'
|
||||
|
||||
apply = $.el 'a',
|
||||
textContent: 'Apply'
|
||||
href: 'javascript:;'
|
||||
$.on apply, 'click', PostHiding.menu.hide
|
||||
|
||||
thisPost = $.el 'label',
|
||||
innerHTML: '<input type=checkbox name=thisPost checked> This post'
|
||||
replies = $.el 'label',
|
||||
innerHTML: "<input type=checkbox name=replies checked=#{Conf['Recursive Hiding']}> Hide replies"
|
||||
makeStub = $.el 'label',
|
||||
innerHTML: "<input type=checkbox name=makeStub checked=#{Conf['Stubs']}> Make stub"
|
||||
|
||||
$.event 'AddMenuEntry',
|
||||
type: 'post'
|
||||
el: div
|
||||
order: 20
|
||||
open: (post) ->
|
||||
if !post.isReply or post.isClone or post.isHidden
|
||||
return false
|
||||
PostHiding.menu.post = post
|
||||
true
|
||||
subEntries: [{el: apply}, {el: thisPost}, {el: replies}, {el: makeStub}]
|
||||
|
||||
# Show
|
||||
div = $.el 'div',
|
||||
className: 'show-reply-link'
|
||||
textContent: 'Show reply'
|
||||
|
||||
apply = $.el 'a',
|
||||
textContent: 'Apply'
|
||||
href: 'javascript:;'
|
||||
$.on apply, 'click', PostHiding.menu.show
|
||||
|
||||
thisPost = $.el 'label',
|
||||
innerHTML: '<input type=checkbox name=thisPost> This post'
|
||||
replies = $.el 'label',
|
||||
innerHTML: "<input type=checkbox name=replies> Show replies"
|
||||
|
||||
$.event 'AddMenuEntry',
|
||||
type: 'post'
|
||||
el: div
|
||||
order: 20
|
||||
open: (post) ->
|
||||
if !post.isReply or post.isClone or !post.isHidden
|
||||
return false
|
||||
unless data = PostHiding.db.get {boardID: post.board.ID, threadID: post.thread.ID, postID: post.ID}
|
||||
return false
|
||||
PostHiding.menu.post = post
|
||||
thisPost.firstChild.checked = post.isHidden
|
||||
replies.firstChild.checked = if data?.hideRecursively? then data.hideRecursively else Conf['Recursive Hiding']
|
||||
true
|
||||
subEntries: [{el: apply}, {el: thisPost}, {el: replies}]
|
||||
hide: ->
|
||||
parent = @parentNode
|
||||
thisPost = $('input[name=thisPost]', parent).checked
|
||||
replies = $('input[name=replies]', parent).checked
|
||||
makeStub = $('input[name=makeStub]', parent).checked
|
||||
{post} = PostHiding.menu
|
||||
if thisPost
|
||||
PostHiding.hide post, makeStub, replies
|
||||
else if replies
|
||||
Recursive.apply PostHiding.hide, post, makeStub, true
|
||||
Recursive.add PostHiding.hide, post, makeStub, true
|
||||
else
|
||||
return
|
||||
PostHiding.saveHiddenState post, true, thisPost, makeStub, replies
|
||||
$.event 'CloseMenu'
|
||||
show: ->
|
||||
parent = @parentNode
|
||||
thisPost = $('input[name=thisPost]', parent).checked
|
||||
replies = $('input[name=replies]', parent).checked
|
||||
{post} = PostHiding.menu
|
||||
if thisPost
|
||||
PostHiding.show post, replies
|
||||
else if replies
|
||||
Recursive.apply PostHiding.show, post, true
|
||||
Recursive.rm PostHiding.hide, post, true
|
||||
else
|
||||
return
|
||||
if data = PostHiding.db.get {boardID: post.board.ID, threadID: post.thread.ID, postID: post.ID}
|
||||
PostHiding.saveHiddenState post, !(thisPost and replies), !thisPost, data.makeStub, !replies
|
||||
$.event 'CloseMenu'
|
||||
|
||||
makeButton: (post, type) ->
|
||||
span = $.el 'span',
|
||||
textContent: "[\u00A0#{if type is 'hide' then '-' else '+'}\u00A0]"
|
||||
a = $.el 'a',
|
||||
className: "#{type}-reply-button"
|
||||
href: 'javascript:;'
|
||||
$.add a, span
|
||||
$.on a, 'click', PostHiding.toggle
|
||||
makeButton: (hide) ->
|
||||
a = (if hide then PostHiding.hideButton else PostHiding.showButton).cloneNode true
|
||||
$.on a, 'click', PostHiding.onToggleClick
|
||||
a
|
||||
|
||||
saveHiddenState: (post, isHiding, thisPost, makeStub, hideRecursively) ->
|
||||
onToggleClick: ->
|
||||
PostHiding.toggle if $.x 'ancestor::div[contains(@class,"postContainer")][1]', @
|
||||
Get.postFromNode @
|
||||
else
|
||||
Get.threadFromNode(@).OP
|
||||
toggle: (post) ->
|
||||
if post.isHidden
|
||||
post.show()
|
||||
else
|
||||
post.hide()
|
||||
PostHiding.saveHiddenState post
|
||||
|
||||
saveHiddenState: (post, val) ->
|
||||
data =
|
||||
boardID: post.board.ID
|
||||
threadID: post.thread.ID
|
||||
postID: post.ID
|
||||
if isHiding
|
||||
data.val =
|
||||
thisPost: thisPost isnt false # undefined -> true
|
||||
makeStub: makeStub
|
||||
hideRecursively: hideRecursively
|
||||
if post.isHidden or val and !val.thisPost
|
||||
data.val = val or {}
|
||||
PostHiding.db.set data
|
||||
else
|
||||
PostHiding.db.delete data
|
||||
|
||||
toggle: ->
|
||||
post = Get.postFromNode @
|
||||
if post.isHidden
|
||||
PostHiding.show post
|
||||
else
|
||||
PostHiding.hide post
|
||||
PostHiding.saveHiddenState post, post.isHidden
|
||||
menu:
|
||||
init: ->
|
||||
return if !Conf['Menu'] or !Conf['Post Hiding Link']
|
||||
|
||||
hide: (post, makeStub=Conf['Stubs'], hideRecursively=Conf['Recursive Hiding']) ->
|
||||
return if post.isHidden
|
||||
post.isHidden = true
|
||||
# Hide
|
||||
apply =
|
||||
el: $.el 'a', textContent: 'Apply', href: 'javascript:;'
|
||||
open: (post) ->
|
||||
$.off @el, 'click', @cb if @cb
|
||||
@cb = -> PostHiding.menu.hide post
|
||||
$.on @el, 'click', @cb
|
||||
true
|
||||
thisPost =
|
||||
el: $.el 'label', innerHTML: '<input type=checkbox name=thisPost checked> This post'
|
||||
open: (post) -> post.isReply
|
||||
replies =
|
||||
el: $.el 'label', innerHTML: "<input type=checkbox name=replies checked=#{Conf['Recursive Hiding']}> Hide replies"
|
||||
open: (post) -> post.isReply
|
||||
makeStub =
|
||||
el: $.el 'label', innerHTML: "<input type=checkbox name=makeStub checked=#{Conf['Stubs']}> Make stub"
|
||||
|
||||
if hideRecursively
|
||||
Recursive.apply PostHiding.hide, post, makeStub, true
|
||||
Recursive.add PostHiding.hide, post, makeStub, true
|
||||
$.event 'AddMenuEntry',
|
||||
type: 'post'
|
||||
el: $.el 'div', className: 'hide-post-link'
|
||||
order: 20
|
||||
open: (post) ->
|
||||
if !post.isReply and g.VIEW isnt 'index' or Conf['Index Mode'] is 'catalog' and g.VIEW is 'index' or post.isClone or post.isHidden
|
||||
return false
|
||||
@el.textContent = if post.isReply then 'Hide reply' else 'Hide thread'
|
||||
true
|
||||
subEntries: [apply, thisPost, replies, makeStub]
|
||||
|
||||
for quotelink in Get.allQuotelinksLinkingTo post
|
||||
$.addClass quotelink, 'filtered'
|
||||
# Show
|
||||
apply =
|
||||
el: $.el 'a', textContent: 'Apply', href: 'javascript:;'
|
||||
open: (post) ->
|
||||
$.off @el, 'click', @cb if @cb
|
||||
@cb = -> PostHiding.menu.show post
|
||||
$.on @el, 'click', @cb
|
||||
true
|
||||
thisPost =
|
||||
el: $.el 'label', innerHTML: '<input type=checkbox name=thisPost> This post'
|
||||
open: (post) ->
|
||||
@el.firstChild.checked = post.isHidden
|
||||
true
|
||||
replies =
|
||||
el: $.el 'label', innerHTML: "<input type=checkbox name=replies> Unhide replies"
|
||||
open: (post) ->
|
||||
data = PostHiding.db.get {boardID: post.board.ID, threadID: post.thread.ID, postID: post.ID}
|
||||
@el.firstChild.checked = if 'hideRecursively' of data then data.hideRecursively else Conf['Recursive Hiding']
|
||||
true
|
||||
|
||||
unless makeStub
|
||||
post.nodes.root.hidden = true
|
||||
return
|
||||
|
||||
a = PostHiding.makeButton post, 'show'
|
||||
postInfo =
|
||||
if Conf['Anonymize']
|
||||
'Anonymous'
|
||||
$.event 'AddMenuEntry',
|
||||
type: 'post'
|
||||
el: $.el 'div', className: 'show-post-link'
|
||||
order: 20
|
||||
open: (post) ->
|
||||
if !post.isReply or post.isClone or !post.isHidden
|
||||
return false
|
||||
unless PostHiding.db.get {boardID: post.board.ID, threadID: post.thread.ID, postID: post.ID}
|
||||
return false
|
||||
@el.textContent = if post.isReply then 'Unhide reply' else 'Unhide thread'
|
||||
true
|
||||
subEntries: [apply, thisPost, replies]
|
||||
hide: (post) ->
|
||||
parent = @parentNode
|
||||
thisPost = $('input[name=thisPost]', parent).checked if post.isReply
|
||||
replies = $('input[name=replies]', parent).checked if post.isReply
|
||||
makeStub = $('input[name=makeStub]', parent).checked
|
||||
if !post.isReply
|
||||
post.hide makeStub
|
||||
else if thisPost
|
||||
post.hide makeStub, replies
|
||||
else if replies
|
||||
Recursive.apply 'hide', post, makeStub, true
|
||||
Recursive.add 'hide', post, makeStub, true
|
||||
else
|
||||
$('.nameBlock', post.nodes.info).textContent
|
||||
$.add a, $.tn " #{postInfo}"
|
||||
post.nodes.stub = $.el 'div',
|
||||
className: 'stub'
|
||||
$.add post.nodes.stub, a
|
||||
if Conf['Menu']
|
||||
$.add post.nodes.stub, Menu.makeButton()
|
||||
$.prepend post.nodes.root, post.nodes.stub
|
||||
|
||||
show: (post, showRecursively=Conf['Recursive Hiding']) ->
|
||||
if post.nodes.stub
|
||||
$.rm post.nodes.stub
|
||||
delete post.nodes.stub
|
||||
else
|
||||
post.nodes.root.hidden = false
|
||||
post.isHidden = false
|
||||
if showRecursively
|
||||
Recursive.apply PostHiding.show, post, true
|
||||
Recursive.rm PostHiding.hide, post
|
||||
for quotelink in Get.allQuotelinksLinkingTo post
|
||||
$.rmClass quotelink, 'filtered'
|
||||
return
|
||||
return
|
||||
val = if post.isReply
|
||||
{thisPost, hideRecursively: replies, makeStub}
|
||||
else
|
||||
{makeStub}
|
||||
PostHiding.saveHiddenState post, val
|
||||
$.event 'CloseMenu'
|
||||
show: (post) ->
|
||||
parent = @parentNode
|
||||
thisPost = $('input[name=thisPost]', parent).checked
|
||||
replies = $('input[name=replies]', parent).checked
|
||||
if thisPost
|
||||
post.show replies
|
||||
else if replies
|
||||
Recursive.apply 'show', post, true
|
||||
Recursive.rm 'hide', post, true
|
||||
else
|
||||
return
|
||||
val = {thisPost: !thisPost, hideRecursively: !replies, makeStub: !!post.nodes.stub}
|
||||
PostHiding.saveHiddenState post, val
|
||||
$.event 'CloseMenu'
|
||||
|
||||
@ -7,10 +7,9 @@ Recursive =
|
||||
|
||||
node: ->
|
||||
return if @isClone
|
||||
for quote in @quotes
|
||||
if obj = Recursive.recursives[quote]
|
||||
for recursive, i in obj.recursives
|
||||
recursive @, obj.args[i]...
|
||||
for quote in @quotes when obj = Recursive.recursives[quote]
|
||||
for recursive, i in obj.recursives
|
||||
@[recursive] obj.args[i]...
|
||||
return
|
||||
|
||||
add: (recursive, post, args...) ->
|
||||
@ -22,15 +21,13 @@ Recursive =
|
||||
|
||||
rm: (recursive, post) ->
|
||||
return unless obj = Recursive.recursives[post.fullID]
|
||||
for rec, i in obj.recursives
|
||||
if rec is recursive
|
||||
obj.recursives.splice i, 1
|
||||
obj.args.splice i, 1
|
||||
for rec, i in obj.recursives when rec is recursive
|
||||
obj.recursives.splice i, 1
|
||||
obj.args.splice i, 1
|
||||
return
|
||||
|
||||
apply: (recursive, post, args...) ->
|
||||
{fullID} = post
|
||||
for ID, post of g.posts
|
||||
if fullID in post.quotes
|
||||
recursive post, args...
|
||||
for ID, post of g.posts when fullID in post.quotes
|
||||
post[recursive] args...
|
||||
return
|
||||
|
||||
@ -1,126 +0,0 @@
|
||||
ThreadHiding =
|
||||
init: ->
|
||||
return if g.VIEW isnt 'index'
|
||||
|
||||
@db = new DataBoard 'hiddenThreads'
|
||||
$.on d, 'IndexRefresh', @onIndexRefresh
|
||||
Thread.callbacks.push
|
||||
name: 'Thread Hiding'
|
||||
cb: @node
|
||||
|
||||
node: ->
|
||||
if data = ThreadHiding.db.get {boardID: @board.ID, threadID: @ID}
|
||||
ThreadHiding.hide @, data.makeStub
|
||||
return unless Conf['Thread Hiding']
|
||||
$.prepend @OP.nodes.root, ThreadHiding.makeButton @, 'hide'
|
||||
|
||||
onIndexRefresh: ->
|
||||
for root, i in Index.nodes by 2
|
||||
thread = Get.threadFromRoot root
|
||||
continue unless thread.isHidden
|
||||
unless thread.stub
|
||||
Index.nodes[i + 1].hidden = true
|
||||
else unless root.contains thread.stub
|
||||
# When we come back to a page, the stub is already there.
|
||||
ThreadHiding.makeStub thread, root
|
||||
return
|
||||
|
||||
menu:
|
||||
init: ->
|
||||
return if g.VIEW isnt 'index' or !Conf['Menu'] or !Conf['Thread Hiding Link']
|
||||
|
||||
div = $.el 'div',
|
||||
className: 'hide-thread-link'
|
||||
textContent: 'Hide thread'
|
||||
|
||||
apply = $.el 'a',
|
||||
textContent: 'Apply'
|
||||
href: 'javascript:;'
|
||||
$.on apply, 'click', ThreadHiding.menu.hide
|
||||
|
||||
makeStub = $.el 'label',
|
||||
innerHTML: "<input type=checkbox checked=#{Conf['Stubs']}> Make stub"
|
||||
|
||||
$.event 'AddMenuEntry',
|
||||
type: 'post'
|
||||
el: div
|
||||
order: 20
|
||||
open: ({thread, isReply}) ->
|
||||
if isReply or thread.isHidden or Conf['Index Mode'] is 'catalog'
|
||||
return false
|
||||
ThreadHiding.menu.thread = thread
|
||||
true
|
||||
subEntries: [el: apply; el: makeStub]
|
||||
hide: ->
|
||||
makeStub = $('input', @parentNode).checked
|
||||
{thread} = ThreadHiding.menu
|
||||
ThreadHiding.hide thread, makeStub
|
||||
ThreadHiding.saveHiddenState thread, makeStub
|
||||
$.event 'CloseMenu'
|
||||
|
||||
makeButton: (thread, type) ->
|
||||
a = $.el 'a',
|
||||
className: "#{type}-thread-button"
|
||||
innerHTML: "<span>[ #{if type is 'hide' then '-' else '+'} ]</span>"
|
||||
href: 'javascript:;'
|
||||
a.dataset.fullID = thread.fullID
|
||||
$.on a, 'click', ThreadHiding.toggle
|
||||
a
|
||||
makeStub: (thread, root) ->
|
||||
numReplies = $$('.thread > .replyContainer', root).length
|
||||
numReplies += +summary.textContent.match /\d+/ if summary = $ '.summary', root
|
||||
opInfo = if Conf['Anonymize']
|
||||
'Anonymous'
|
||||
else
|
||||
$('.nameBlock', thread.OP.nodes.info).textContent
|
||||
|
||||
a = ThreadHiding.makeButton thread, 'show'
|
||||
$.add a, $.tn " #{opInfo} (#{if numReplies is 1 then '1 reply' else "#{numReplies} replies"})"
|
||||
thread.stub = $.el 'div',
|
||||
className: 'stub'
|
||||
if Conf['Menu']
|
||||
$.add thread.stub, [a, Menu.makeButton()]
|
||||
else
|
||||
$.add thread.stub, a
|
||||
$.prepend root, thread.stub
|
||||
|
||||
saveHiddenState: (thread, makeStub) ->
|
||||
if thread.isHidden
|
||||
ThreadHiding.db.set
|
||||
boardID: thread.board.ID
|
||||
threadID: thread.ID
|
||||
val: {makeStub}
|
||||
else
|
||||
ThreadHiding.db.delete
|
||||
boardID: thread.board.ID
|
||||
threadID: thread.ID
|
||||
|
||||
toggle: (thread) ->
|
||||
unless thread instanceof Thread
|
||||
thread = g.threads[@dataset.fullID]
|
||||
if thread.isHidden
|
||||
ThreadHiding.show thread
|
||||
else
|
||||
ThreadHiding.hide thread
|
||||
ThreadHiding.saveHiddenState thread
|
||||
|
||||
hide: (thread, makeStub=Conf['Stubs']) ->
|
||||
return if thread.isHidden
|
||||
threadRoot = thread.OP.nodes.root.parentNode
|
||||
thread.isHidden = true
|
||||
Index.updateHideLabel()
|
||||
|
||||
unless makeStub
|
||||
threadRoot.hidden = threadRoot.nextElementSibling.hidden = true # <hr>
|
||||
return
|
||||
|
||||
ThreadHiding.makeStub thread, threadRoot
|
||||
|
||||
show: (thread) ->
|
||||
if thread.stub
|
||||
$.rm thread.stub
|
||||
delete thread.stub
|
||||
threadRoot = thread.OP.nodes.root.parentNode
|
||||
threadRoot.nextElementSibling.hidden =
|
||||
threadRoot.hidden = thread.isHidden = false
|
||||
Index.updateHideLabel()
|
||||
@ -17,10 +17,9 @@ Config =
|
||||
'Filtering':
|
||||
'Anonymize': [false, 'Make everyone Anonymous.']
|
||||
'Filter': [true, 'Self-moderation placebo.']
|
||||
'Recursive Hiding': [true, 'Hide replies of hidden posts, recursively.']
|
||||
'Thread Hiding': [true, 'Add buttons to hide entire threads.']
|
||||
'Reply Hiding': [true, 'Add buttons to hide single replies.']
|
||||
'Post Hiding': [true, 'Add buttons to hide threads and replies.']
|
||||
'Stubs': [true, 'Show stubs of hidden threads / replies.']
|
||||
'Recursive Hiding': [true, 'Hide replies of hidden posts, recursively.']
|
||||
'Images':
|
||||
'Auto-GIF': [false, 'Animate GIF thumbnails (disabled on /gif/, /wsg/).']
|
||||
'Image Expansion': [true, 'Expand images inline.']
|
||||
@ -31,8 +30,7 @@ Config =
|
||||
'Menu':
|
||||
'Menu': [true, 'Add a drop-down menu to posts.']
|
||||
'Report Link': [true, 'Add a report link to the menu.']
|
||||
'Thread Hiding Link': [true, 'Add a link to hide entire threads.']
|
||||
'Reply Hiding Link': [true, 'Add a link to hide single replies.']
|
||||
'Post Hiding Link': [true, 'Add a link to hide threads and replies.']
|
||||
'Delete Link': [true, 'Add post and image deletion links to the menu.']
|
||||
<% if (type === 'crx') { %>
|
||||
'Download Link': [true, 'Add a download with original filename link to the menu.']
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
class DataBoard
|
||||
@keys = ['pinnedThreads', 'hiddenThreads', 'hiddenPosts', 'lastReadPosts', 'yourPosts', 'watchedThreads']
|
||||
@keys = ['pinnedThreads', 'hiddenPosts', 'lastReadPosts', 'yourPosts', 'watchedThreads']
|
||||
|
||||
constructor: (@key, sync, dontClean) ->
|
||||
@data = Conf[key]
|
||||
|
||||
@ -125,16 +125,16 @@ Index =
|
||||
type: 'post'
|
||||
el: $.el 'a', href: 'javascript:;'
|
||||
order: 5
|
||||
open: ({thread}) ->
|
||||
open: (post) ->
|
||||
return false if Conf['Index Mode'] isnt 'catalog'
|
||||
@el.textContent = if thread.isHidden
|
||||
@el.textContent = if post.isHidden
|
||||
'Unhide thread'
|
||||
else
|
||||
'Hide thread'
|
||||
$.off @el, 'click', @cb if @cb
|
||||
@cb = ->
|
||||
$.event 'CloseMenu'
|
||||
Index.toggleHide thread
|
||||
Index.toggleHide post
|
||||
$.on @el, 'click', @cb
|
||||
true
|
||||
|
||||
@ -166,7 +166,7 @@ Index =
|
||||
return if e.button isnt 0
|
||||
thread = g.threads[@parentNode.dataset.fullID]
|
||||
if e.shiftKey
|
||||
Index.toggleHide thread
|
||||
Index.toggleHide thread.OP
|
||||
else if e.altKey
|
||||
Index.togglePin thread
|
||||
else
|
||||
@ -194,15 +194,9 @@ Index =
|
||||
offsetX: 15
|
||||
offsetY: -20
|
||||
setTimeout (-> el.hidden = false if el.parentNode), .25 * $.SECOND
|
||||
toggleHide: (thread) ->
|
||||
$.rm thread.catalogView.nodes.root
|
||||
if Index.showHiddenThreads
|
||||
ThreadHiding.show thread
|
||||
return unless ThreadHiding.db.get {boardID: thread.board.ID, threadID: thread.ID}
|
||||
# Don't save when un-hiding filtered threads.
|
||||
else
|
||||
ThreadHiding.hide thread
|
||||
ThreadHiding.saveHiddenState thread
|
||||
toggleHide: (post) ->
|
||||
$.rm post.thread.catalogView.nodes.root
|
||||
PostHiding.toggle post
|
||||
togglePin: (thread) ->
|
||||
data =
|
||||
boardID: thread.board.ID
|
||||
@ -430,7 +424,7 @@ Index =
|
||||
Index.cb.toggleHiddenThreads() if Index.showHiddenThreads
|
||||
return
|
||||
Index.hideLabel.hidden = false
|
||||
$('#hidden-count', Index.navLinks).textContent = if hiddenCount is 1
|
||||
$('#hidden-count', Index.hideLabel).textContent = if hiddenCount is 1
|
||||
'1 hidden thread'
|
||||
else
|
||||
"#{hiddenCount} hidden threads"
|
||||
|
||||
@ -79,16 +79,14 @@ Main =
|
||||
initFeature 'Redirect', Redirect
|
||||
initFeature 'Resurrect Quotes', Quotify
|
||||
initFeature 'Filter', Filter
|
||||
initFeature 'Thread Hiding', ThreadHiding
|
||||
initFeature 'Reply Hiding', PostHiding
|
||||
initFeature 'Post Hiding', PostHiding
|
||||
initFeature 'Recursive', Recursive
|
||||
initFeature 'Strike-through Quotes', QuoteStrikeThrough
|
||||
initFeature 'Quick Reply', QR
|
||||
initFeature 'Menu', Menu
|
||||
initFeature 'Index Generator (Menu)', Index.menu
|
||||
initFeature 'Report Link', ReportLink
|
||||
initFeature 'Thread Hiding (Menu)', ThreadHiding.menu
|
||||
initFeature 'Reply Hiding (Menu)', PostHiding.menu
|
||||
initFeature 'Post Hiding (Menu)', PostHiding.menu
|
||||
initFeature 'Delete Link', DeleteLink
|
||||
initFeature 'Filter (Menu)', Filter.menu
|
||||
initFeature 'Download Link', DownloadLink
|
||||
|
||||
@ -151,6 +151,55 @@ class Post
|
||||
$.rmClass node, 'desktop'
|
||||
return
|
||||
|
||||
hide: (makeStub=Conf['Stubs'], hideRecursively=Conf['Recursive Hiding']) ->
|
||||
return if @isHidden
|
||||
@isHidden = true
|
||||
if !@isReply
|
||||
@thread.hide makeStub
|
||||
return
|
||||
|
||||
if hideRecursively
|
||||
Recursive.apply 'hide', @, makeStub, true
|
||||
Recursive.add 'hide', @, makeStub, true
|
||||
|
||||
for quotelink in Get.allQuotelinksLinkingTo @
|
||||
$.addClass quotelink, 'filtered'
|
||||
|
||||
unless makeStub
|
||||
@nodes.root.hidden = true
|
||||
return
|
||||
|
||||
a = PostHiding.makeButton false
|
||||
postInfo = if Conf['Anonymize']
|
||||
'Anonymous'
|
||||
else
|
||||
$('.nameBlock', @nodes.info).textContent
|
||||
$.add a, $.tn " #{postInfo}"
|
||||
@nodes.stub = $.el 'div',
|
||||
className: 'stub'
|
||||
$.add @nodes.stub, a
|
||||
$.add @nodes.stub, Menu.makeButton() if Conf['Menu']
|
||||
$.prepend @nodes.root, @nodes.stub
|
||||
show: (showRecursively=Conf['Recursive Hiding']) ->
|
||||
return if !@isHidden
|
||||
@isHidden = false
|
||||
if !@isReply
|
||||
@thread.show()
|
||||
return
|
||||
|
||||
if showRecursively
|
||||
Recursive.apply 'show', @, true
|
||||
Recursive.rm 'hide', @
|
||||
|
||||
for quotelink in Get.allQuotelinksLinkingTo @
|
||||
$.rmClass quotelink, 'filtered'
|
||||
|
||||
if @nodes.stub
|
||||
$.rm @nodes.stub
|
||||
delete @nodes.stub
|
||||
else
|
||||
@nodes.root.hidden = false
|
||||
|
||||
kill: (file) ->
|
||||
if file
|
||||
return if @file.isDead
|
||||
|
||||
@ -123,18 +123,16 @@ Settings =
|
||||
div = $.el 'div',
|
||||
innerHTML: "<button></button><span class=description>: Clear manually-hidden threads and posts on all boards. Reload the page to apply."
|
||||
button = $ 'button', div
|
||||
$.get {hiddenThreads: {}, hiddenPosts: {}}, ({hiddenThreads, hiddenPosts}) ->
|
||||
$.get 'hiddenPosts', {}, ({hiddenPosts}) ->
|
||||
hiddenNum = 0
|
||||
for ID, board of hiddenThreads.boards
|
||||
hiddenNum += Object.keys(board).length
|
||||
for ID, board of hiddenPosts.boards
|
||||
for ID, thread of board
|
||||
hiddenNum += Object.keys(thread).length
|
||||
button.textContent = "Hidden: #{hiddenNum}"
|
||||
$.on button, 'click', ->
|
||||
@textContent = 'Hidden: 0'
|
||||
$.delete ['hiddenThreads', 'hiddenPosts']
|
||||
$.after $('input[name="Stubs"]', section).parentNode.parentNode, div
|
||||
$.delete 'hiddenPosts'
|
||||
$.after $('input[name="Recursive Hiding"]', section).parentNode.parentNode, div
|
||||
export: ->
|
||||
# Make sure to export the most recent data.
|
||||
$.get Conf, (Conf) ->
|
||||
|
||||
@ -62,6 +62,39 @@ class Thread
|
||||
@isPinned = false
|
||||
$.rmClass @catalogView.nodes.root, 'pinned' if @catalogView
|
||||
|
||||
hide: (makeStub=Conf['Stubs']) ->
|
||||
return if @isHidden
|
||||
@isHidden = true
|
||||
root = @OP.nodes.root.parentNode
|
||||
Index.updateHideLabel()
|
||||
|
||||
unless makeStub
|
||||
root.hidden = true
|
||||
return
|
||||
|
||||
numReplies = $$('.thread > .replyContainer', root).length # Don't count clones.
|
||||
numReplies += +summary.textContent.match /\d+/ if summary = $ '.summary', root
|
||||
opInfo = if Conf['Anonymize']
|
||||
'Anonymous'
|
||||
else
|
||||
$('.nameBlock', @OP.nodes.info).textContent
|
||||
|
||||
a = PostHiding.makeButton false
|
||||
$.add a, $.tn " #{opInfo} (#{numReplies} repl#{if numReplies is 1 then 'y' else 'ies'})"
|
||||
@stub = $.el 'div',
|
||||
className: 'stub'
|
||||
$.add @stub, a
|
||||
$.add @stub, Menu.makeButton() if Conf['Menu']
|
||||
$.prepend root, @stub
|
||||
show: ->
|
||||
return if !@isHidden
|
||||
@isHidden = false
|
||||
if @stub
|
||||
$.rm @stub
|
||||
delete @stub
|
||||
@OP.nodes.root.parentNode.hidden = false
|
||||
Index.updateHideLabel()
|
||||
|
||||
kill: ->
|
||||
@isDead = true
|
||||
|
||||
|
||||
@ -120,7 +120,7 @@ Keybinds =
|
||||
when Conf['Deselect reply']
|
||||
Keybinds.hl 0, threadRoot
|
||||
when Conf['Hide']
|
||||
ThreadHiding.toggle thread if ThreadHiding.db
|
||||
PostHiding.toggle thread.OP
|
||||
else
|
||||
return
|
||||
e.preventDefault()
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
QuoteStrikeThrough =
|
||||
init: ->
|
||||
return if !Conf['Reply Hiding'] and !Conf['Reply Hiding Link'] and !Conf['Filter']
|
||||
return if !Conf['Post Hiding'] and !Conf['Post Hiding Link'] and !Conf['Filter']
|
||||
|
||||
Post.callbacks.push
|
||||
name: 'Strike-through Quotes'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user