Fix bug causing captcha to sometimes not work when replying from index.
This commit is contained in:
parent
14c4df1d9e
commit
a6f78ad1ec
@ -12,14 +12,21 @@ Captcha.t =
|
|||||||
moreNeeded: ->
|
moreNeeded: ->
|
||||||
return
|
return
|
||||||
|
|
||||||
|
getThread: ->
|
||||||
|
boardID = g.BOARD.ID
|
||||||
|
if QR.posts[0].thread is 'new'
|
||||||
|
threadID = '0'
|
||||||
|
else
|
||||||
|
threadID = '' + QR.posts[0].thread
|
||||||
|
{boardID, threadID}
|
||||||
|
|
||||||
setup: (focus) ->
|
setup: (focus) ->
|
||||||
return unless @isEnabled
|
return unless @isEnabled
|
||||||
|
|
||||||
if !@nodes.container
|
if !@nodes.container
|
||||||
@nodes.container = $.el 'div', className: 'captcha-container'
|
@nodes.container = $.el 'div', className: 'captcha-container'
|
||||||
$.prepend @nodes.root, @nodes.container
|
$.prepend @nodes.root, @nodes.container
|
||||||
boardID = g.BOARD.ID
|
Captcha.t.currentThread = Captcha.t.getThread()
|
||||||
threadID = '' + QR.posts[0].thread
|
|
||||||
$.global ->
|
$.global ->
|
||||||
el = document.querySelector '#qr .captcha-container'
|
el = document.querySelector '#qr .captcha-container'
|
||||||
window.TCaptcha.init el, @boardID, +@threadID
|
window.TCaptcha.init el, @boardID, +@threadID
|
||||||
@ -28,7 +35,7 @@ Captcha.t =
|
|||||||
type: 'warning',
|
type: 'warning',
|
||||||
content: '' + err
|
content: '' + err
|
||||||
}})
|
}})
|
||||||
, {boardID, threadID}
|
, Captcha.t.currentThread
|
||||||
|
|
||||||
if focus
|
if focus
|
||||||
$('#t-resp').focus()
|
$('#t-resp').focus()
|
||||||
@ -40,6 +47,13 @@ Captcha.t =
|
|||||||
$.rm @nodes.container
|
$.rm @nodes.container
|
||||||
delete @nodes.container
|
delete @nodes.container
|
||||||
|
|
||||||
|
updateThread: ->
|
||||||
|
{boardID, threadID} = Captcha.t.currentThread
|
||||||
|
newThread = Captcha.t.getThread()
|
||||||
|
unless newThread.boardID is boardID and newThread.threadID is threadID
|
||||||
|
Captcha.t.destroy()
|
||||||
|
Captcha.t.setup()
|
||||||
|
|
||||||
getOne: ->
|
getOne: ->
|
||||||
response = {}
|
response = {}
|
||||||
if @nodes.container
|
if @nodes.container
|
||||||
|
|||||||
@ -74,6 +74,7 @@ QR.post = class
|
|||||||
(QR.posts[index-1] or QR.posts[index+1]).select()
|
(QR.posts[index-1] or QR.posts[index+1]).select()
|
||||||
QR.posts.splice index, 1
|
QR.posts.splice index, 1
|
||||||
QR.status()
|
QR.status()
|
||||||
|
QR.captcha.updateThread?()
|
||||||
|
|
||||||
delete: ->
|
delete: ->
|
||||||
$.rm @nodes.el
|
$.rm @nodes.el
|
||||||
@ -129,6 +130,7 @@ QR.post = class
|
|||||||
when 'thread'
|
when 'thread'
|
||||||
(if @thread isnt 'new' then $.addClass else $.rmClass) QR.nodes.el, 'reply-to-thread'
|
(if @thread isnt 'new' then $.addClass else $.rmClass) QR.nodes.el, 'reply-to-thread'
|
||||||
QR.status()
|
QR.status()
|
||||||
|
QR.captcha.updateThread?()
|
||||||
when 'com'
|
when 'com'
|
||||||
@updateComment()
|
@updateComment()
|
||||||
when 'filename'
|
when 'filename'
|
||||||
@ -403,3 +405,4 @@ QR.post = class
|
|||||||
post = QR.posts.splice(oldIndex, 1)[0]
|
post = QR.posts.splice(oldIndex, 1)[0]
|
||||||
QR.posts.splice newIndex, 0, post
|
QR.posts.splice newIndex, 0, post
|
||||||
QR.status()
|
QR.status()
|
||||||
|
QR.captcha.updateThread?()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user