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: ->
|
||||
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) ->
|
||||
return unless @isEnabled
|
||||
|
||||
if !@nodes.container
|
||||
@nodes.container = $.el 'div', className: 'captcha-container'
|
||||
$.prepend @nodes.root, @nodes.container
|
||||
boardID = g.BOARD.ID
|
||||
threadID = '' + QR.posts[0].thread
|
||||
Captcha.t.currentThread = Captcha.t.getThread()
|
||||
$.global ->
|
||||
el = document.querySelector '#qr .captcha-container'
|
||||
window.TCaptcha.init el, @boardID, +@threadID
|
||||
@ -28,7 +35,7 @@ Captcha.t =
|
||||
type: 'warning',
|
||||
content: '' + err
|
||||
}})
|
||||
, {boardID, threadID}
|
||||
, Captcha.t.currentThread
|
||||
|
||||
if focus
|
||||
$('#t-resp').focus()
|
||||
@ -40,6 +47,13 @@ Captcha.t =
|
||||
$.rm @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: ->
|
||||
response = {}
|
||||
if @nodes.container
|
||||
|
||||
@ -74,6 +74,7 @@ QR.post = class
|
||||
(QR.posts[index-1] or QR.posts[index+1]).select()
|
||||
QR.posts.splice index, 1
|
||||
QR.status()
|
||||
QR.captcha.updateThread?()
|
||||
|
||||
delete: ->
|
||||
$.rm @nodes.el
|
||||
@ -129,6 +130,7 @@ QR.post = class
|
||||
when 'thread'
|
||||
(if @thread isnt 'new' then $.addClass else $.rmClass) QR.nodes.el, 'reply-to-thread'
|
||||
QR.status()
|
||||
QR.captcha.updateThread?()
|
||||
when 'com'
|
||||
@updateComment()
|
||||
when 'filename'
|
||||
@ -403,3 +405,4 @@ QR.post = class
|
||||
post = QR.posts.splice(oldIndex, 1)[0]
|
||||
QR.posts.splice newIndex, 0, post
|
||||
QR.status()
|
||||
QR.captcha.updateThread?()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user