4chan-x/src/Quotelinks/QuoteOP.coffee
Zixaphir d15f8ee728 Merge branch 'v3' of git://github.com/MayhemYDG/4chan-x into v3
Conflicts:
	CHANGELOG.md
	Gruntfile.coffee
	LICENSE
	css/style.css
	html/Posting/QR.html
	img/changelog/3.2.0/0.png
	package.json
	src/General/Get.coffee
	src/General/Header.coffee
	src/General/Main.coffee
	src/General/Notice.coffee
	src/General/Notification.coffee
	src/General/Settings.coffee
	src/General/img/icon.gif
	src/General/lib/notification.class
	src/Monitoring/Favicon.coffee
	src/Posting/QuickReply.coffee
	src/Quotelinks/QuoteOP.coffee
2013-08-17 20:33:48 -07:00

37 lines
1.1 KiB
CoffeeScript
Executable File

QuoteOP =
init: ->
return if g.VIEW is 'catalog' or !Conf['Mark OP Quotes']
if Conf['Comment Expansion']
ExpandComment.callbacks.push @node
# \u00A0 is nbsp
@text = '\u00A0(OP)'
Post::callbacks.push
name: 'Mark OP Quotes'
cb: @node
node: ->
# Stop there if it's a clone of a post in the same thread.
return if @isClone and @thread is @context.thread
# Stop there if there's no quotes in that post.
return unless (quotes = @quotes).length
{quotelinks} = @nodes
# rm (OP) from cross-thread quotes.
if @isClone and quotes.contains @thread.fullID
i = 0
while quotelink = quotelinks[i++]
quotelink.textContent = quotelink.textContent.replace QuoteOP.text, ''
{fullID} = (if @isClone then @context else @).thread
# add (OP) to quotes quoting this context's OP.
return unless quotes.contains fullID
i = 0
while quotelink = quotelinks[i++]
{boardID, postID} = Get.postDataFromLink quotelink
if "#{boardID}.#{postID}" is fullID
$.add quotelink, $.tn QuoteOP.text
return