Merge branch 'next'
This commit is contained in:
commit
9738a4f0d0
@ -95,7 +95,7 @@ Captcha.v1 =
|
||||
setup: (focus, force) ->
|
||||
return unless @isEnabled and (force or @needed())
|
||||
@create()
|
||||
@nodes.input.focus() if focus
|
||||
@nodes.input.focus() if focus and d.activeElement in [QR.nodes.status, d.body]
|
||||
|
||||
afterSetup: ->
|
||||
return unless challenge = $.id 'recaptcha_challenge_field_holder'
|
||||
@ -154,6 +154,7 @@ Captcha.v1 =
|
||||
challenge: @nodes.img.alt
|
||||
response: response
|
||||
timeout: @timeout
|
||||
@captchas.sort (a, b) -> a.timeout - b.timeout
|
||||
@count()
|
||||
@destroy()
|
||||
@setup false, true
|
||||
@ -196,6 +197,9 @@ Captcha.v1 =
|
||||
" (#{count} cached captchas)"
|
||||
@nodes.input.placeholder = placeholder
|
||||
@nodes.input.alt = count # For XTRM RICE.
|
||||
clearTimeout @timer
|
||||
if count
|
||||
@timer = setTimeout @clear.bind(@), @captchas[0].timeout - Date.now()
|
||||
|
||||
reload: (focus) ->
|
||||
# Recaptcha.should_focus = false: Hack to prevent the input from being focused
|
||||
|
||||
@ -42,7 +42,6 @@ Captcha.v2 =
|
||||
conn = new Connection window.parent, "#{location.protocol}//boards.4chan.org"
|
||||
conn.send {token}
|
||||
|
||||
shouldFocus: false
|
||||
timeouts: {}
|
||||
postsCount: 0
|
||||
|
||||
@ -74,17 +73,16 @@ Captcha.v2 =
|
||||
|
||||
setup: (focus, force) ->
|
||||
return unless @isEnabled and (@needed() or force)
|
||||
@shouldFocus = true if focus and not QR.inBubble()
|
||||
@nodes.counter.focus() if focus and d.activeElement in [QR.nodes.status, d.body]
|
||||
if @timeouts.destroy
|
||||
clearTimeout @timeouts.destroy
|
||||
delete @timeouts.destroy
|
||||
return @reload()
|
||||
|
||||
if @nodes.container
|
||||
if @shouldFocus and iframe = $ 'iframe', @nodes.container
|
||||
if d.activeElement is @nodes.counter and (iframe = $ 'iframe', @nodes.container)
|
||||
iframe.focus()
|
||||
QR.focus() # Event handler not fired in Firefox
|
||||
delete @shouldFocus
|
||||
return
|
||||
|
||||
@nodes.container = $.el 'div', className: 'captcha-container'
|
||||
@ -143,8 +141,7 @@ Captcha.v2 =
|
||||
if QR.nodes.el.getBoundingClientRect().bottom > doc.clientHeight
|
||||
QR.nodes.el.style.top = null
|
||||
QR.nodes.el.style.bottom = '0px'
|
||||
iframe.focus() if @shouldFocus
|
||||
@shouldFocus = false
|
||||
iframe.focus() if d.activeElement is @nodes.counter
|
||||
# XXX Stop Recaptcha from changing focus from iframe -> body -> iframe on submit.
|
||||
$.global ->
|
||||
f = document.querySelector('#qr iframe')
|
||||
@ -186,6 +183,7 @@ Captcha.v2 =
|
||||
@captchas.push
|
||||
response: token or $('textarea', @nodes.container).value
|
||||
timeout: Date.now() + @lifetime
|
||||
@captchas.sort (a, b) -> a.timeout - b.timeout
|
||||
$.set 'captchas', @captchas
|
||||
@count()
|
||||
|
||||
@ -193,7 +191,7 @@ Captcha.v2 =
|
||||
if @needed()
|
||||
if focus
|
||||
if QR.cooldown.auto or Conf['Post on Captcha Completion']
|
||||
@shouldFocus = true
|
||||
@nodes.counter.focus()
|
||||
else
|
||||
QR.nodes.status.focus()
|
||||
@reload()
|
||||
@ -216,7 +214,7 @@ Captcha.v2 =
|
||||
@captchas = @captchas[i..]
|
||||
@count()
|
||||
$.set 'captchas', @captchas
|
||||
@setup(d.activeElement is QR.nodes.status)
|
||||
@setup true
|
||||
|
||||
count: ->
|
||||
@nodes.counter.textContent = "Captchas: #{@captchas.length}"
|
||||
|
||||
@ -222,8 +222,6 @@ QR =
|
||||
else
|
||||
el = err
|
||||
el.removeAttribute 'style'
|
||||
if QR.captcha.isEnabled and /captcha|verification/i.test el.textContent
|
||||
QR.captcha.setup true
|
||||
notice = new Notice 'warning', el
|
||||
QR.notifications.push notice
|
||||
unless Header.areNotificationsEnabled
|
||||
@ -633,7 +631,9 @@ QR =
|
||||
|
||||
if QR.captcha.isEnabled and !err
|
||||
captcha = QR.captcha.getOne()
|
||||
err = 'No valid captcha.' unless captcha
|
||||
unless captcha
|
||||
err = 'No valid captcha.'
|
||||
QR.captcha.setup true
|
||||
|
||||
QR.cleanNotifications()
|
||||
if err
|
||||
@ -773,11 +773,11 @@ QR =
|
||||
QR.cooldown.addMute seconds
|
||||
else
|
||||
QR.cooldown.addDelay post, seconds
|
||||
QR.captcha.setup (d.activeElement is QR.nodes.status)
|
||||
else # stop auto-posting
|
||||
QR.cooldown.auto = false
|
||||
QR.status()
|
||||
QR.error err
|
||||
QR.captcha.setup true
|
||||
return
|
||||
|
||||
h1 = $ 'h1', resDoc
|
||||
@ -815,7 +815,7 @@ QR =
|
||||
QR.close()
|
||||
else
|
||||
post.rm()
|
||||
QR.captcha.setup(d.activeElement is QR.nodes.status)
|
||||
QR.captcha.setup true
|
||||
|
||||
QR.cooldown.add threadID, postID
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user