Better detection of when the captcha is open.

Old version didn't detect the noscript version that sometimes comes up.
This commit is contained in:
ccd0 2014-12-08 17:25:18 -08:00
parent cdc5925400
commit 7f32648ed0

View File

@ -30,15 +30,19 @@ QR.captcha =
shouldFocus: false shouldFocus: false
timeouts: {} timeouts: {}
occupied: ->
{container} = @nodes
(container.firstChild or container.dataset.widgetID) and !@timeouts.destroy
needed: -> needed: ->
captchaCount = @captchas.length captchaCount = @captchas.length
captchaCount++ if @nodes.container.dataset.widgetID and !@timeouts.destroy captchaCount++ if @occupied()
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
toggle: -> toggle: ->
if @nodes.container.dataset.widgetID and !@timeouts.destroy if @occupied()
@destroy() @destroy()
else else
@shouldFocus = true @shouldFocus = true
@ -51,7 +55,7 @@ QR.captcha =
clearTimeout @timeouts.destroy clearTimeout @timeouts.destroy
delete @timeouts.destroy delete @timeouts.destroy
return @reload() return @reload()
return if @nodes.container.dataset.widgetID return if @occupied()
$.globalEval ''' $.globalEval '''
(function() { (function() {
var container = document.querySelector("#qr .captcha-container"); var container = document.querySelector("#qr .captcha-container");