diff options
Diffstat (limited to 'uploader')
-rw-r--r-- | uploader/templates/phenotypes/add-phenotypes-raw-files.html | 78 |
1 files changed, 43 insertions, 35 deletions
diff --git a/uploader/templates/phenotypes/add-phenotypes-raw-files.html b/uploader/templates/phenotypes/add-phenotypes-raw-files.html index e283726..8d29823 100644 --- a/uploader/templates/phenotypes/add-phenotypes-raw-files.html +++ b/uploader/templates/phenotypes/add-phenotypes-raw-files.html @@ -548,42 +548,50 @@ }; - var r = errorHandler( - fileSuccessHandler( - uploadStartHandler( - filesAddedHandler( - markResumableDragAndDropElement( - makeResumableElement( - $("#frm-add-phenotypes").attr("data-resumable-target"), - $("#finput-phenotype-descriptions").parent(), - $("#resumable-phenotype-descriptions"), - $("#frm-add-phenotypes input[type=submit]"), - ["csv", "tsv"]), - $("#finput-phenotype-descriptions").parent(), - $("#resumable-phenotype-descriptions"), - $("#resumable-phenotype-descriptions-browse-button")), - (files) => { - // TODO: Also trigger preview! - resumableDisplayFiles( - $("#resumable-phenotype-descriptions-selected-files"), files); - files.forEach((file) => { - readFirstNLines( - file.file, - 10, - [makePreviewUpdater( - $("#tbl-preview-pheno-desc"))]) - }); - }), - startUpload($("#resumable-phenotype-descriptions-browse-button"), - $("#resumable-phenotype-descriptions-retry-button"), - $("#resumable-phenotype-descriptions-cancel-button"))), - uploadSuccess()), - uploadError()); - - progressHandler( - r, - indicateProgress(r, $("#resumable-phenotype-descriptions-progress-bar"))); + var makeResumableObject = (form_id, file_input_id, resumable_element_id, preview_table_id) => { + var the_form = $("#" + form_id); + var file_input = $("#" + file_input_id); + var submit_button = the_form.find("input[type=submit]"); + var r = errorHandler( + fileSuccessHandler( + uploadStartHandler( + filesAddedHandler( + markResumableDragAndDropElement( + makeResumableElement( + the_form.attr("data-resumable-target"), + file_input.parent(), + $("#" + resumable_element_id), + submit_button, + ["csv", "tsv"]), + file_input.parent(), + $("#" + resumable_element_id), + $("#" + resumable_element_id + "-browse-button")), + (files) => { + // TODO: Also trigger preview! + resumableDisplayFiles( + $("#" + resumable_element_id + "-selected-files"), files); + files.forEach((file) => { + readFirstNLines( + file.file, + 10, + [makePreviewUpdater( + $("#" + preview_table_id))]) + }); + }), + startUpload($("#" + resumable_element_id + "-browse-button"), + $("#" + resumable_element_id + "-retry-button"), + $("#" + resumable_element_id + "-cancel-button"))), + uploadSuccess()), + uploadError()); + + /** Setup progress indicator **/ + progressHandler( + r, + indicateProgress(r, $("#" + resumable_element_id + "-progress-bar"))); + + return r; + }; $("#frm-add-phenotypes input[type=submit]").on("click", (event) => { event.preventDefault(); |