diff options
author | zsloan | 2023-03-16 19:59:14 +0000 |
---|---|---|
committer | zsloan | 2023-03-16 19:59:22 +0000 |
commit | 4aa3ff24d6b5ccbda621c2ef25c688886433ab50 (patch) | |
tree | e533b9fb3ee1537f59b6e47f8d5e1a1dd2a43c76 | |
parent | 82dc61ba1c6d9e96c3b7a06627cd29d92285fadf (diff) | |
download | genenetwork2-4aa3ff24d6b5ccbda621c2ef25c688886433ab50.tar.gz |
Edit dataset dropdown JS to handle Species sub-categories
-rw-r--r-- | wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js b/wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js index de6ebf5b..62e78bf3 100644 --- a/wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js +++ b/wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js @@ -96,7 +96,44 @@ redo_dropdown = function(dropdown, items) { dropdown.empty(); _results = []; - if (dropdown.attr('id') == "group"){ + if (dropdown.attr('id') == "species"){ + species_family_list = []; + for (_i = 0, _len = items.length; _i < _len; _i++) { + item = items[_i]; + species_family = item[2].toString() + species_family_list.push([item[0], item[1], species_family]) + } + + current_family = "" + this_opt_group = null + for (_i = 0, _len = species_family_list.length; _i < _len; _i++) { + item = species_family_list[_i]; + if (item[2] != "None" && current_family == ""){ + current_family = item[2] + this_opt_group = $("<optgroup label=\"" + item[2] + "\">") + this_opt_group.append($("<option />").val(item[0]).text(item[1])); + } else if (current_family != "" && item[2] == current_family){ + this_opt_group.append($("<option />").val(item[0]).text(item[1])); + if (_i == species_family_list.length - 1){ + _results.push(dropdown.append(this_opt_group)) + } + } else if (current_family != "" && item[2] != current_family && item[2] != "None"){ + current_family = item[2] + _results.push(dropdown.append(this_opt_group)) + this_opt_group = $("<optgroup label=\"" + current_family + "\">") + this_opt_group.append($("<option />").val(item[0]).text(item[1])); + if (_i == species_family_list.length - 1){ + _results.push(dropdown.append(this_opt_group)) + } + } else if (current_family != "" && this_opt_group != null && item[2] == "None"){ + _results.push(dropdown.append(this_opt_group)) + current_family = "" + _results.push(dropdown.append($("<option />").val(item[0]).text(item[1]))); + } else { + _results.push(dropdown.append($("<option />").val(item[0]).text(item[1]))); + } + } + } else if (dropdown.attr('id') == "group"){ group_family_list = []; for (_i = 0, _len = items.length; _i < _len; _i++) { item = items[_i]; |