// Generated by CoffeeScript 1.8.0 var add_trait_data, assemble_into_json, back_to_collections, collection_click, collection_list, color_by_trait, create_trait_data_csv, get_this_trait_vals, get_trait_data, process_traits, selected_traits, submit_click, this_trait_data, trait_click, __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; this_trait_data = null; selected_traits = {}; $('#collections_list').attr("style", "width: 100%;"); $('#trait_table').dataTable( { "drawCallback": function( settings ) { $('#trait_table tr').click(function(event) { if (event.target.type !== 'checkbox') { $(':checkbox', this).trigger('click'); } }); }, "columns": [ { "type": "natural", "width": "3%" }, { "type": "natural", "width": "8%" }, { "type": "natural", "width": "20%" }, { "type": "natural", "width": "25%" }, { "type": "natural", "width": "25%" }, { "type": "natural", "width": "15%" } ], "columnDefs": [ { "targets": 0, "orderable": false } ], "order": [[1, "asc" ]], "sDom": "RZtr", "iDisplayLength": -1, "autoWidth": true, "bDeferRender": true, "bSortClasses": false, "paging": false, "orderClasses": true } ); if ( ! $.fn.DataTable.isDataTable( '#collection_table' ) ) { $('#collection_table').dataTable( { "createdRow": function ( row, data, index ) { if ($('td', row).eq(2).text().length > 40) { $('td', row).eq(2).text($('td', row).eq(2).text().substring(0, 40)); $('td', row).eq(2).text($('td', row).eq(2).text() + '...') } if ($('td', row).eq(4).text().length > 50) { $('td', row).eq(4).text($('td', row).eq(4).text().substring(0, 50)); $('td', row).eq(4).text($('td', row).eq(4).text() + '...') } }, "columnDefs": [ { "targets": 0, "orderable": false } ], "order": [[1, "asc" ]], "sDom": "ZRtr", "iDisplayLength": -1, "autoWidth": true, "bSortClasses": false, "paging": false, "orderClasses": true } ); } collection_click = function() { var this_collection_url; this_collection_url = $(this).find('.collection_name').prop("href"); this_collection_url += "&json"; collection_list = $("#collections_holder").html(); return $.ajax({ dataType: "json", url: this_collection_url, success: process_traits }); }; submit_click = function() { var covariates_string = ""; var covariates_as_set = new Set(); $(".selected-covariates:first option").each(function() { if ($(this).val() != ""){ covariates_as_set.add($(this).val() + "," + $(this).text()); } }); $('#collections_holder').find('input[type=checkbox]:checked').each(function() { var this_dataset, this_trait; this_trait = $(this).parents('tr').find('.trait').text(); this_trait_display = $(this).parents('tr').find('.trait').data("display_name"); this_description = $(this).parents('tr').find('.description').text(); this_dataset = $(this).parents('tr').find('.dataset').data("dataset"); this_covariate_display_string = this_trait_display if (this_covariate_display_string.length > 50) { this_covariate_display_string = this_covariate_display_string.substring(0, 45) + "..." } covariates_as_set.add(this_trait + ":" + this_dataset + "," + this_covariate_display_string) }); covariates_as_list = Array.from(covariates_as_set) // Removed the starting "No covariates selected" option before adding options for each covariate if (covariates_as_list.length > 0){ $(".selected-covariates option[value='']").each(function() { $(this).remove(); }); } $(".selected-covariates option").each(function() { $(this).remove(); }); covariate_list_for_form = [] $.each(covariates_as_list, function (index, value) { option_value = value.split(",")[0] option_text = value.split(",")[1] $(".selected-covariates").append($("