From 3e71a2eec8507f900e51dd3962d76aa4ba272fbb Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 6 Jan 2025 11:26:06 -0600 Subject: Make the preview updater more generic Build the preview-updater in a function call to ease maintenance. --- .../phenotypes/add-phenotypes-raw-files.html | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'uploader/templates') diff --git a/uploader/templates/phenotypes/add-phenotypes-raw-files.html b/uploader/templates/phenotypes/add-phenotypes-raw-files.html index 3eb042e..8a7463a 100644 --- a/uploader/templates/phenotypes/add-phenotypes-raw-files.html +++ b/uploader/templates/phenotypes/add-phenotypes-raw-files.html @@ -400,6 +400,16 @@ } }; + var makePreviewUpdater = (preview_table) => { + return (data) => { + update_preview( + preview_table, + data, + filesMetadata(), + PREVIEW_ROWS); + }; + }; + var preview_tables_to_elements_map = { "#tbl-preview-pheno-desc": "#finput-phenotype-descriptions", "#tbl-preview-pheno-data": "#finput-phenotype-data", @@ -426,12 +436,7 @@ readFirstNLines( file_input[0].files[0], 10, - [(data) => { - update_preview( - $(mapentry[0]), - data, - files_metadata(), - PREVIEW_ROWS);}]); + [makePreviewUpdater(preview_table)]); } }); }; @@ -454,13 +459,8 @@ readFirstNLines( event.target.files[0], 10, - [(data) => { - update_preview( - $("#" + event.target.getAttribute("data-preview-table")), - data, - files_metadata(), - PREVIEW_ROWS); - }]); + [makePreviewUpdater( + $("#" + event.target.getAttribute("data-preview-table")))]); }); }); -- cgit v1.2.3