Only need progress event for upload monitoring.

This commit is contained in:
ccd0 2019-03-23 21:59:30 -07:00
parent 4af0e0b962
commit 5bd4a2859e
2 changed files with 8 additions and 9 deletions

View File

@ -722,16 +722,15 @@ QR =
extra =
form: $.formData formData
if Conf['Show Upload Progress']
extra.upCallbacks =
onload: ->
extra.onprogress = (e) ->
if e.loaded < e.total
# Uploading...
QR.req.progress = "#{Math.round e.loaded / e.total * 100}%"
else
# Upload done, waiting for server response.
QR.req.isUploadFinished = true
QR.req.progress = '...'
QR.status()
onprogress: (e) ->
# Uploading...
QR.req.progress = "#{Math.round e.loaded / e.total * 100}%"
QR.status()
QR.status()
cb = (response) ->
if response?

View File

@ -47,7 +47,7 @@ $.ajax = do ->
pageXHR = XMLHttpRequest
(url, options={}, extra={}) ->
{type, upCallbacks, form, headers} = extra
{type, onprogress, form, headers} = extra
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/'
@ -58,7 +58,7 @@ $.ajax = do ->
for key, value of (headers or {})
r.setRequestHeader key, value
$.extend r, options
$.extend r.upload, upCallbacks
$.extend r.upload, {onprogress}
# connection error or content blocker
$.on r, 'error', -> (c.warn "4chan X failed to load: #{url}" unless r.status)
<% if (type === 'crx') { %>