No longer accept arbitrary properties in $.ajax; make it clear what we support.
This commit is contained in:
parent
7db3041504
commit
71896af275
@ -83,7 +83,6 @@ DeleteLink =
|
||||
responseType: 'document'
|
||||
withCredentials: true
|
||||
onloadend: -> DeleteLink.load link, post, fileOnly, @response
|
||||
,
|
||||
form: $.formData form
|
||||
|
||||
load: (link, post, fileOnly, resDoc) ->
|
||||
|
||||
@ -76,13 +76,13 @@ Report =
|
||||
results = []
|
||||
for [name, url] in urls
|
||||
do (name, url) ->
|
||||
$.ajax url,
|
||||
$.ajax url, {
|
||||
onloadend: ->
|
||||
results.push [name, @response or {error: ''}]
|
||||
if results.length is urls.length
|
||||
cb results
|
||||
,
|
||||
{form}
|
||||
form
|
||||
}
|
||||
return
|
||||
|
||||
archiveResults: (results) ->
|
||||
|
||||
@ -708,10 +708,9 @@ QR =
|
||||
responseType: 'document'
|
||||
withCredentials: true
|
||||
onloadend: QR.response
|
||||
extra =
|
||||
form: $.formData formData
|
||||
if Conf['Show Upload Progress']
|
||||
extra.onprogress = (e) ->
|
||||
options.onprogress = (e) ->
|
||||
if e.loaded < e.total
|
||||
# Uploading...
|
||||
QR.req.progress = "#{Math.round e.loaded / e.total * 100}%"
|
||||
@ -725,11 +724,11 @@ QR =
|
||||
if response?
|
||||
QR.currentCaptcha = response
|
||||
if response.challenge?
|
||||
extra.form.append 'recaptcha_challenge_field', response.challenge
|
||||
extra.form.append 'recaptcha_response_field', response.response
|
||||
options.form.append 'recaptcha_challenge_field', response.challenge
|
||||
options.form.append 'recaptcha_response_field', response.response
|
||||
else
|
||||
extra.form.append 'g-recaptcha-response', response.response
|
||||
QR.req = $.ajax "https://sys.#{location.hostname.split('.')[1]}.org/#{g.BOARD}/post", options, extra
|
||||
options.form.append 'g-recaptcha-response', response.response
|
||||
QR.req = $.ajax "https://sys.#{location.hostname.split('.')[1]}.org/#{g.BOARD}/post", options
|
||||
QR.req.progress = '...'
|
||||
|
||||
if typeof captcha is 'function'
|
||||
@ -867,7 +866,6 @@ QR =
|
||||
cb()
|
||||
else
|
||||
setTimeout check, attempts * $.SECOND
|
||||
,
|
||||
type: 'HEAD'
|
||||
check()
|
||||
|
||||
|
||||
@ -46,9 +46,9 @@ $.ajax = do ->
|
||||
else
|
||||
pageXHR = XMLHttpRequest
|
||||
|
||||
(url, options={}, extra={}) ->
|
||||
{type, onprogress, form, headers} = extra
|
||||
options.responseType ?= 'json'
|
||||
(url, options={}) ->
|
||||
{onloadend, timeout, responseType, withCredentials, type, onprogress, form, headers} = options
|
||||
responseType ?= 'json'
|
||||
# XXX https://forums.lanik.us/viewtopic.php?f=64&t=24173&p=78310
|
||||
url = url.replace /^((?:https?:)?\/\/(?:\w+\.)?4c(?:ha|d)n\.org)\/adv\//, '$1//adv/'
|
||||
r = new pageXHR()
|
||||
@ -57,7 +57,7 @@ $.ajax = do ->
|
||||
r.open type, url, true
|
||||
for key, value of (headers or {})
|
||||
r.setRequestHeader key, value
|
||||
$.extend r, options
|
||||
$.extend r, {onloadend, timeout, responseType, withCredentials}
|
||||
$.extend r.upload, {onprogress}
|
||||
# connection error or content blocker
|
||||
$.on r, 'error', -> (c.warn "4chan X failed to load: #{url}" unless r.status)
|
||||
@ -72,9 +72,9 @@ $.ajax = do ->
|
||||
catch err
|
||||
# XXX Some content blockers in Firefox (e.g. Adblock Plus and NoScript) throw an exception instead of simulating a connection error.
|
||||
throw err unless err.result is 0x805e0006
|
||||
for event in ['error', 'loadend']
|
||||
r["on#{event}"] = options["on#{event}"]
|
||||
$.queueTask $.event, event, null, r
|
||||
r.onloadend = onloadend
|
||||
$.queueTask $.event, 'error', null, r
|
||||
$.queueTask $.event, 'loadend', null, r
|
||||
r
|
||||
|
||||
# Status Code 304: Not modified
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user