Unify onload and onerror paths in Quick Reply response.
This commit is contained in:
parent
5bd4a2859e
commit
7865b46c16
@ -707,18 +707,7 @@ QR =
|
|||||||
options =
|
options =
|
||||||
responseType: 'document'
|
responseType: 'document'
|
||||||
withCredentials: true
|
withCredentials: true
|
||||||
onload: QR.response
|
onloadend: QR.response
|
||||||
onerror: ->
|
|
||||||
# On connection error, the post most likely didn't go through.
|
|
||||||
# If the post did go through, it should be stopped by the duplicate reply cooldown.
|
|
||||||
delete QR.req
|
|
||||||
Captcha.cache.save QR.currentCaptcha if QR.currentCaptcha
|
|
||||||
delete QR.currentCaptcha
|
|
||||||
post.unlock()
|
|
||||||
QR.cooldown.auto = true
|
|
||||||
QR.cooldown.addDelay post, 2
|
|
||||||
QR.status()
|
|
||||||
QR.error QR.connectionError()
|
|
||||||
extra =
|
extra =
|
||||||
form: $.formData formData
|
form: $.formData formData
|
||||||
if Conf['Show Upload Progress']
|
if Conf['Show Upload Progress']
|
||||||
@ -764,20 +753,19 @@ QR =
|
|||||||
QR.status()
|
QR.status()
|
||||||
|
|
||||||
response: ->
|
response: ->
|
||||||
{req} = QR
|
return if @aborted
|
||||||
delete QR.req
|
delete QR.req
|
||||||
|
|
||||||
post = QR.posts[0]
|
post = QR.posts[0]
|
||||||
post.unlock()
|
post.unlock()
|
||||||
|
|
||||||
resDoc = req.response
|
if (err = @response?.getElementById 'errmsg') # error!
|
||||||
if (err = resDoc.getElementById 'errmsg') # error!
|
|
||||||
$('a', err)?.target = '_blank' # duplicate image link
|
$('a', err)?.target = '_blank' # duplicate image link
|
||||||
else if (connErr = resDoc.title isnt 'Post successful!')
|
else if (connErr = (!@response or @response.title isnt 'Post successful!'))
|
||||||
err = QR.connectionError()
|
err = QR.connectionError()
|
||||||
Captcha.cache.save QR.currentCaptcha if QR.currentCaptcha
|
Captcha.cache.save QR.currentCaptcha if QR.currentCaptcha
|
||||||
else if req.status isnt 200
|
else if @status isnt 200
|
||||||
err = "Error #{req.statusText} (#{req.status})"
|
err = "Error #{@statusText} (#{@status})"
|
||||||
|
|
||||||
delete QR.currentCaptcha
|
delete QR.currentCaptcha
|
||||||
|
|
||||||
@ -809,7 +797,7 @@ QR =
|
|||||||
QR.error err
|
QR.error err
|
||||||
return
|
return
|
||||||
|
|
||||||
h1 = $ 'h1', resDoc
|
h1 = $ 'h1', @response
|
||||||
|
|
||||||
[_, threadID, postID] = h1.nextSibling.textContent.match /thread:(\d+),no:(\d+)/
|
[_, threadID, postID] = h1.nextSibling.textContent.match /thread:(\d+),no:(\d+)/
|
||||||
postID = +postID
|
postID = +postID
|
||||||
@ -884,7 +872,8 @@ QR =
|
|||||||
check()
|
check()
|
||||||
|
|
||||||
abort: ->
|
abort: ->
|
||||||
if QR.req and !QR.req.isUploadFinished
|
if QR.req and !QR.req.isUploadFinished and QR.req.abort
|
||||||
|
QR.req.aborted = true
|
||||||
QR.req.abort()
|
QR.req.abort()
|
||||||
delete QR.req
|
delete QR.req
|
||||||
Captcha.cache.save QR.currentCaptcha if QR.currentCaptcha
|
Captcha.cache.save QR.currentCaptcha if QR.currentCaptcha
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user