about summary refs log tree commit diff
path: root/wqflask/wqflask/templates/gsearch_pheno.html
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask/wqflask/templates/gsearch_pheno.html')
-rw-r--r--wqflask/wqflask/templates/gsearch_pheno.html76
1 files changed, 68 insertions, 8 deletions
diff --git a/wqflask/wqflask/templates/gsearch_pheno.html b/wqflask/wqflask/templates/gsearch_pheno.html
index 42bf1b64..f6ffff47 100644
--- a/wqflask/wqflask/templates/gsearch_pheno.html
+++ b/wqflask/wqflask/templates/gsearch_pheno.html
@@ -9,8 +9,10 @@
 
     <div class="container">
 
-        <h3>GN searched 51 datasets and 13763 traits across 10 species, and found {{ trait_count }} results that match your query.
-        You can filter these results by adding key words in the fields below and you can also sort results on most columns.</h3>
+        <h3>GN searched for the term(s) <b>"{{ terms }}"</b> in 51 datasets and 13763 traits across 10 species<br/>
+            and found <b>{{ trait_count }}</b> results that match your query.<br/>
+            You can filter these results by adding key words in the fields below<br/>
+            and you can also sort results on most columns.</h3>
         <p>To study a record, click on its ID below.<br />Check records below and click Add button to add to selection.</p>
 
         <div>
@@ -21,14 +23,14 @@
             <button class="btn btn-default" id="add" disabled ><span class="glyphicon glyphicon-plus-sign"></span> Add</button>
             <input type="text" id="searchbox" class="form-control" style="width: 200px; display: inline;" placeholder="Search This Table For ...">
             <input type="text" id="select_top" class="form-control" style="width: 200px; display: inline;" placeholder="Select Top ...">
-            <br />
-            <br />
-            <form id="export_form" method="POST" action="/export_traits_csv">
+            <form id="export_form" method="POST" action="/export_traits_csv" style="display: inline;">
+              <input type="hidden" name="headers" id="headers" value="{% for field in header_fields %}{{ field }},{% endfor %}">
               <input type="hidden" name="database_name" id="database_name" value="None">
               <input type="hidden" name="export_data" id="export_data" value="">
               <button class="btn btn-default" id="export_traits">Download CSV</button>
             </form>
             <br />
+            <br />
             <div style="width: 100%;">
               <table id="trait_table" class="table-hover table-striped cell-border" style="float: left;">
                 <tbody>
@@ -79,8 +81,43 @@
                 }
             });
 
+            function change_buttons() {
+                buttons = ["#add", "#remove"];
+                num_checked = $('.trait_checkbox:checked').length;
+                if (num_checked === 0) {
+                    for (_i = 0, _len = buttons.length; _i < _len; _i++) {
+                        button = buttons[_i];
+                        $(button).prop("disabled", true);
+                    }
+                } else {
+                    for (_j = 0, _len2 = buttons.length; _j < _len2; _j++) {
+                        button = buttons[_j];
+                        $(button).prop("disabled", false);
+                    }
+                }
+                         //});
+                if ($(this).is(":checked")) {
+                    if (!$(this).closest('tr').hasClass('selected')) {
+                        $(this).closest('tr').addClass('selected')
+                    }
+                }
+                else {
+                    if ($(this).closest('tr').hasClass('selected')) {
+                        $(this).closest('tr').removeClass('selected')
+                    }
+                }
+            }
+
             console.time("Creating table");
             $('#trait_table').DataTable( {
+                'drawCallback': function( settings ) {
+                     $('#trait_table tr').click(function(event) {
+                         if (event.target.type !== 'checkbox' && event.target.tagName.toLowerCase() !== 'a') {
+                             $(':checkbox', this).trigger('click');
+                         }
+                     });
+                     $('.trait_checkbox:checkbox').on("change", change_buttons);
+                },
                 "createdRow": function ( row, data, index ) {
                     $('td', row).eq(0).attr("style", "text-align: center; padding: 4px 10px 2px 10px;");
                     $('td', row).eq(1).attr("align", "right");
@@ -95,6 +132,16 @@
                         $('td', row).eq(6).text($('td', row).eq(6).text() + '...')
                     }
                     $('td', row).slice(8,11).attr("align", "right");
+                    $('td', row).eq(1).attr('data-export', $('td', row).eq(1).text());
+                    $('td', row).eq(2).attr('data-export', $('td', row).eq(2).text());
+                    $('td', row).eq(3).attr('data-export', $('td', row).eq(3).text());
+                    $('td', row).eq(4).attr('data-export', $('td', row).eq(4).text());
+                    $('td', row).eq(5).attr('data-export', $('td', row).eq(5).text());
+                    $('td', row).eq(6).attr('data-export', $('td', row).eq(6).text());
+                    $('td', row).eq(7).attr('data-export', $('td', row).eq(7).text());
+                    $('td', row).eq(8).attr('data-export', $('td', row).eq(8).text());
+                    $('td', row).eq(9).attr('data-export', $('td', row).eq(9).text());
+                    $('td', row).eq(10).attr('data-export', $('td', row).eq(10).text());
                 },
                 'data': the_rows,
                 'columns': [
@@ -126,7 +173,7 @@
                       'type': "natural",
                       'data': null,
                       'render': function(data, type, row, meta) {
-                        return '<a href="/show_trait?trait_id=' + data.name + '&dataset=' + data.dataset + '">' + data.name + '</a>'
+                        return '<a target="_blank" href="/show_trait?trait_id=' + data.name + '&dataset=' + data.dataset + '">' + data.display_name + '</a>'
                       }
                     },
                     {
@@ -143,6 +190,12 @@
                       }
                     },
                     {
+                      'title': "Mean",
+                      'type': "natural",
+                      'width': "10%",
+                      'data': "mean"
+                    },
+                    {
                       'title': "Authors",
                       'type': "natural",
                       'width': "25%",
@@ -150,10 +203,17 @@
                       'render': function(data, type, row, meta) {
                         author_list = data.authors.split(",")
                         if (author_list.length >= 6) {
-                          return author_list.slice(0, 6).join(",") + ", et al."
+                          author_string = author_list.slice(0, 6).join(",") + ", et al."
                         } else{
-                          return data.authors
+                          author_string = data.authors
                         }
+
+			                  try {
+                            return decodeURIComponent(escape(author_string))
+			                  } catch(err) {
+			                      return author_string
+                        }
+
                       }
                     },
                     {