
fileupload.js
About this file
The JS file handles uploading files in chunks and checking status of the upload. In this file, file deletion is also handled.
Code Check Report
93:48 error Expected '!==' and instead saw '!=' eqeqeq 134:38 error A regular expression literal can be confused with '/=' no-div-regex 163:38 error Expected '!==' and instead saw '!=' eqeqeq ✖ 3 problems (3 errors, 0 warnings) 1 error and 0 warnings potentially fixable with the `--fix` option.
Documentation drawn from source code
function bindFileUpload(target,
/*
Binds jquery file upload to the element identified by 'target'
@param {string} target - jquery selector string (ex. "#fileupload")
@param {string} request_id - FOIL request id
@param {selector} duplicateFileModal - jQuery selector for duplicate file alert modal
@param {bool} for_update - editing a file?
@param {int} response_id - response id of file being replaced
@param {string} uploadTemplateId - jquery file upload uploadTemplateId
@param {string} downloadTemplateId - jquery file upload downloadTemplateId
@param {selector} nextButton - jquery selector for next button of file response workflow
*/
chunksend: function (e, data) {
chunkdone: function (e, data) {
chunkfail: function (e, data) {
}).bind("fileuploaddone", function (e, data) {
}).bind("fileuploadadd", function (e, data) {
$(this).fileupload("option").filesContainer.children().each(function () {
data.files = $.map(data.files, function (file, i) {
}).bind("fileuploadstarted", function (e, data) {
function encodeName(name) {
/*
Returns an encoded (base64 without padding) version of 'name' intended
for use as/in an html id attribute or for use in a url.
Padding is removed because '=' is an invalid character for an html id
and it is reserved character for urls.
*/
function pollUploadStatus(upload_filename, htmlId, request_id, for_update, nextButton) {
/*
Sends a request to the upload status endpoint
every 2 seconds until it receives a message indicating
the upload has completed or until it receives an error
message, then updates the download template.
*/
success: function(response) {
function deleteUpload(request_id,
/*
Send a DELETE request to the upload endpoint.
*/
function setRemoveBtn(request_id, button, sendDelete, for_update) {
/*
Reveal remove button and set its click event handler.
*/
button.click(function(e) {