Upvotes.
This commit is contained in:
parent
8850ac9df6
commit
a596691f77
@ -576,6 +576,10 @@ Config =
|
||||
false
|
||||
'Thread conversations'
|
||||
]
|
||||
'Upvotes': [
|
||||
true
|
||||
'Upvote posts.'
|
||||
]
|
||||
|
||||
imageExpansion:
|
||||
'Fit width': [
|
||||
|
||||
@ -410,6 +410,7 @@ Main =
|
||||
['Edit Link', QR.oekaki.menu]
|
||||
['Download Link', DownloadLink]
|
||||
['Archive Link', ArchiveLink]
|
||||
['Upvotes', Upvotes]
|
||||
['Quote Inlining', QuoteInline]
|
||||
['Quote Previewing', QuotePreview]
|
||||
['Quote Backlinks', QuoteBacklink]
|
||||
|
||||
49
src/Quotelinks/Upvotes.coffee
Normal file
49
src/Quotelinks/Upvotes.coffee
Normal file
@ -0,0 +1,49 @@
|
||||
Upvotes =
|
||||
text: '\u305D\u3046\u3060\u306D'
|
||||
count: {}
|
||||
|
||||
init: ->
|
||||
return unless g.VIEW is 'thread' and Conf['Upvotes']
|
||||
Post.callbacks.push
|
||||
name: 'Upvotes'
|
||||
cb: @node
|
||||
|
||||
node: ->
|
||||
return if @isFetchedQuote or @origin?.isFetchedQuote
|
||||
|
||||
if @isClone
|
||||
@nodes.vote = $ '.upvote', @nodes.info
|
||||
$.on @nodes.vote, 'click', Upvotes.vote
|
||||
return
|
||||
|
||||
a = $.el 'a',
|
||||
className: 'upvote'
|
||||
href: 'javascript:;'
|
||||
textContent: '+'
|
||||
$.add @nodes.info, a
|
||||
@nodes.vote = a
|
||||
$.on a, 'click', Upvotes.vote
|
||||
|
||||
Upvotes.count[@fullID] = 0
|
||||
|
||||
if @quotes.length is 1 and @info.comment.indexOf(Upvotes.text) >= 0
|
||||
Upvotes.increment @quotes[0]
|
||||
|
||||
increment: (fullID) ->
|
||||
return unless fullID of Upvotes.count
|
||||
count = ++Upvotes.count[fullID]
|
||||
post = g.posts[fullID]
|
||||
for post in [post, post.clones...]
|
||||
post.nodes.vote.textContent = "#{Upvotes.text}x#{count}"
|
||||
return
|
||||
|
||||
vote: ->
|
||||
return unless QR.postingIsEnabled
|
||||
QR.quote.call @
|
||||
{com} = QR.nodes
|
||||
text = "#{Upvotes.text}\n"
|
||||
pos = com.selectionStart
|
||||
com.value = com.value[..pos] + text + com.value[pos...]
|
||||
pos += text.length
|
||||
com.setSelectionRange pos, pos
|
||||
$.event 'input', null, com
|
||||
@ -2084,3 +2084,8 @@ grunt.file.expand('src/Linkification/icons/*.png').map(function(file) {
|
||||
:root.gallery-open.fixed #header-bar:not(.autohide) #shortcuts .fa::before {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
/* Upvotes */
|
||||
.upvote {
|
||||
margin: 0 4px;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user