Improve conditions for loading v2 captcha when more captchas are needed.
This commit is contained in:
parent
136b7d5666
commit
af7b158846
@ -101,9 +101,7 @@ Captcha.v1 =
|
|||||||
postsCount = 0 if postsCount is 1 and !Conf['Auto-load captcha'] and !QR.posts[0].com and !QR.posts[0].file
|
postsCount = 0 if postsCount is 1 and !Conf['Auto-load captcha'] and !QR.posts[0].com and !QR.posts[0].file
|
||||||
captchaCount < postsCount
|
captchaCount < postsCount
|
||||||
|
|
||||||
onNewPost: ->
|
moreNeeded: ->
|
||||||
|
|
||||||
onPostChange: ->
|
|
||||||
|
|
||||||
setup: (focus, force) ->
|
setup: (focus, force) ->
|
||||||
return unless @isEnabled and (force or @needed())
|
return unless @isEnabled and (force or @needed())
|
||||||
|
|||||||
@ -34,7 +34,7 @@ Captcha.v2 =
|
|||||||
$.queueTask => @save false
|
$.queueTask => @save false
|
||||||
|
|
||||||
timeouts: {}
|
timeouts: {}
|
||||||
postsCount: 0
|
prevNeeded: 0
|
||||||
|
|
||||||
noscriptURL: ->
|
noscriptURL: ->
|
||||||
url = 'https://www.google.com/recaptcha/api/fallback?k=<%= meta.recaptchaKey %>'
|
url = 'https://www.google.com/recaptcha/api/fallback?k=<%= meta.recaptchaKey %>'
|
||||||
@ -45,16 +45,17 @@ Captcha.v2 =
|
|||||||
needed: ->
|
needed: ->
|
||||||
captchaCount = @captchas.length
|
captchaCount = @captchas.length
|
||||||
captchaCount++ if QR.req
|
captchaCount++ if QR.req
|
||||||
@postsCount = QR.posts.length
|
postsCount = QR.posts.length
|
||||||
@postsCount = 0 if @postsCount is 1 and !Conf['Auto-load captcha'] and !QR.posts[0].com and !QR.posts[0].file
|
postsCount = 0 if postsCount is 1 and !Conf['Auto-load captcha'] and !QR.posts[0].com and !QR.posts[0].file
|
||||||
captchaCount < @postsCount
|
captchaCount < postsCount
|
||||||
|
|
||||||
onNewPost: ->
|
moreNeeded: ->
|
||||||
@setup()
|
# Post count temporarily off by 1 when called from QR.post.rm, QR.close, or QR.submit
|
||||||
|
$.queueTask =>
|
||||||
onPostChange: ->
|
needed = @needed()
|
||||||
@setup() if @postsCount is 0
|
if needed and not @prevNeeded
|
||||||
@postsCount = 0 if QR.posts.length is 1 and !Conf['Auto-load captcha'] and !QR.posts[0].com and !QR.posts[0].file
|
@setup(QR.cooldown.auto and d.activeElement is QR.nodes.status)
|
||||||
|
@prevNeeded = needed
|
||||||
|
|
||||||
toggle: ->
|
toggle: ->
|
||||||
if @nodes.container and !@timeouts.destroy
|
if @nodes.container and !@timeouts.destroy
|
||||||
@ -215,10 +216,10 @@ Captcha.v2 =
|
|||||||
@captchas = @captchas[i..]
|
@captchas = @captchas[i..]
|
||||||
@count()
|
@count()
|
||||||
$.set 'captchas', @captchas
|
$.set 'captchas', @captchas
|
||||||
@setup(d.activeElement is QR.nodes.status)
|
|
||||||
|
|
||||||
count: ->
|
count: ->
|
||||||
@nodes.counter.textContent = "Captchas: #{@captchas.length}"
|
@nodes.counter.textContent = "Captchas: #{@captchas.length}"
|
||||||
|
@moreNeeded()
|
||||||
clearTimeout @timeouts.clear
|
clearTimeout @timeouts.clear
|
||||||
if @captchas.length
|
if @captchas.length
|
||||||
@timeouts.clear = setTimeout @clear.bind(@), @captchas[0].timeout - Date.now()
|
@timeouts.clear = setTimeout @clear.bind(@), @captchas[0].timeout - Date.now()
|
||||||
|
|||||||
@ -57,8 +57,7 @@ QR.post = class
|
|||||||
(@load() if QR.selected is @) # load persona
|
(@load() if QR.selected is @) # load persona
|
||||||
@select() if select
|
@select() if select
|
||||||
@unlock()
|
@unlock()
|
||||||
# Post count temporarily off by 1 when called from QR.post.rm or QR.close
|
QR.captcha.moreNeeded()
|
||||||
$.queueTask -> QR.captcha.onNewPost()
|
|
||||||
|
|
||||||
rm: ->
|
rm: ->
|
||||||
@delete()
|
@delete()
|
||||||
@ -161,8 +160,7 @@ QR.post = class
|
|||||||
if @ is QR.selected
|
if @ is QR.selected
|
||||||
QR.characterCount()
|
QR.characterCount()
|
||||||
@nodes.span.textContent = @com
|
@nodes.span.textContent = @com
|
||||||
# Post count temporarily off by 1 when called from QR.post.rm or QR.close
|
QR.captcha.moreNeeded()
|
||||||
$.queueTask -> QR.captcha.onPostChange()
|
|
||||||
|
|
||||||
@rmErrored: (e) ->
|
@rmErrored: (e) ->
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
@ -203,7 +201,7 @@ QR.post = class
|
|||||||
@filesize = $.bytesToString @file.size
|
@filesize = $.bytesToString @file.size
|
||||||
@checkSize()
|
@checkSize()
|
||||||
$.addClass @nodes.el, 'has-file'
|
$.addClass @nodes.el, 'has-file'
|
||||||
$.queueTask -> QR.captcha.onPostChange()
|
QR.captcha.moreNeeded()
|
||||||
URL.revokeObjectURL @URL
|
URL.revokeObjectURL @URL
|
||||||
@saveFilename()
|
@saveFilename()
|
||||||
if @ is QR.selected
|
if @ is QR.selected
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user