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