Provide a visual indication that the captcha is loading.
This commit is contained in:
parent
6a3f0f44bb
commit
c85aebbceb
@ -37,6 +37,7 @@ Captcha.cache =
|
||||
if !$.event('RequestCaptcha', {isReply})
|
||||
@prerequested = true
|
||||
@submitCB = @save.bind(@)
|
||||
@updateCount()
|
||||
|
||||
haveCookie: ->
|
||||
/\b_ct=/.test(d.cookie) and QR.posts[0].thread isnt 'new'
|
||||
@ -53,17 +54,21 @@ Captcha.cache =
|
||||
request: (isReply) ->
|
||||
if !@submitCB
|
||||
return if $.event('RequestCaptcha', {isReply})
|
||||
(cb) => @submitCB = cb
|
||||
(cb) =>
|
||||
@submitCB = cb
|
||||
@updateCount()
|
||||
|
||||
abort: ->
|
||||
if @submitCB
|
||||
delete @submitCB
|
||||
$.event 'AbortCaptcha'
|
||||
@updateCount()
|
||||
|
||||
saveAPI: (captcha) ->
|
||||
if (cb = @submitCB)
|
||||
delete @submitCB
|
||||
cb captcha
|
||||
@updateCount()
|
||||
else
|
||||
@save captcha
|
||||
|
||||
@ -74,6 +79,7 @@ Captcha.cache =
|
||||
QR.captcha.setup(d.activeElement is QR.nodes.status)
|
||||
delete @submitCB
|
||||
cb()
|
||||
@updateCount()
|
||||
|
||||
save: (captcha) ->
|
||||
if (cb = @submitCB)
|
||||
@ -97,4 +103,7 @@ Captcha.cache =
|
||||
clearTimeout @timer
|
||||
if @captchas.length
|
||||
@timer = setTimeout @clear.bind(@), @captchas[0].timeout - Date.now()
|
||||
@updateCount()
|
||||
|
||||
updateCount: ->
|
||||
$.event 'CaptchaCount', @captchas.length
|
||||
|
||||
@ -181,7 +181,8 @@ Captcha.v2 =
|
||||
|
||||
count: ->
|
||||
count = Captcha.cache.getCount()
|
||||
@nodes.counter.textContent = "Captchas: #{count}"
|
||||
loading = if Captcha.cache.submitCB then '...' else ''
|
||||
@nodes.counter.textContent = "Captchas: #{count}#{loading}"
|
||||
@moreNeeded()
|
||||
|
||||
reload: ->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user