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