fix typo in mason parameter name.
[sgn.git] / mason / breeders_toolbox / genotyping_trials / format / as_table.mas
blobdd1fe3f6cc85d5409fd22209361133369e06ac86
2 <%args>
3 $breeding_program_name
4 $breeding_program_id
5 $trial_name
6 $trial_id
7 </%args>
9 <& /util/import_javascript.mas, classes => [ 'jquery', 'jqueryui' ] &>
11 <h1>CASSAVABASE GENOTYPING TRIAL</h1>
12 <h1>Breeding program: <% $breeding_program_name %></h1>
13 <h2>Trial name: <a href='/breeders/trial/<% $trial_id %>'><% $trial_name %></a></h2>
14 <br/>
16 <div id="trial_plate_view_html">
17 <div class="well">
18 [LOADING...]
19 </div>
20 </div>
22 <script type="text/javascript">
24 jQuery(document).ready(function () {
26         jQuery.ajax ( {
27             url : '/ajax/breeders/trial/'+<% $trial_id %>+'/design',
28             beforeSend: function() {
29                 jQuery("#working_modal").modal("show");
30             },
31             success: function(response){
32                 console.log(response);
33                 jQuery("#working_modal").modal("hide");
34                 var trial_plate_view_html = "<table class='table table-hover table-condensed table-bordered' id='trial_plate_view_table'><thead><tr><th>&nbsp;</th>";
35                 for (col=1; col<13; col++) {
36                     var formatted_col = (col < 10 ? '0' : '') + col;
37                     trial_plate_view_html = trial_plate_view_html + "<th bgcolor='lightblue'>"+formatted_col+"<br/><br/></th>";
38                 }
40                 trial_plate_view_html = trial_plate_view_html + "</thead><tbody>";
42                 var rows = "ABCDEFGH".split("");
43                 jQuery.each(rows, function(row) {
44                     trial_plate_view_html = trial_plate_view_html + "<tr><td bgcolor = 'lightblue'><b>" + rows[row] + "</b></td>"
46                     for (col=1; col<13; col++) {
47                         var formatted_col = (col < 10 ? '0' : '') + col;
48                         var well = rows[row] + formatted_col;
50                         var cell = "&nbsp";
51                         var bgcolor = "lightgrey";
53                         if (response.design[well]) {
54                            if (response.design[well].accession_name) {
55                                if (response.design[well].accession_name == 'BLANK') {
56                                    bgcolor = "#FFCCBB";
57                                } else {
58                                    bgcolor="#FFFFFF";
59                                }
60                                //cell = "<br/>" + response.design[well].accession_name + "<br/><br/>";
61                                cell = "<br/><a href='/stock/" + response.design[well].accession_id +"/view'>" + response.design[well].accession_name + "</a>  <br/><br/>";
62                            }
63                         }
64                         trial_plate_view_html = trial_plate_view_html + "<td bgcolor=" + bgcolor + ">" + cell + "</td>";
65                       }
66                       trial_plate_view_html = trial_plate_view_html + "</tr>";
67                 });
69                 trial_plate_view_html = trial_plate_view_html + "</tbody></table>";
70                 jQuery('#trial_plate_view_html').empty();
71                 jQuery('#trial_plate_view_html').html(trial_plate_view_html);
72             },
73             error: function(response){
74                 jQuery("#working_modal").modal("hide");
75                 alert("Error retrieving plate layout.");
76             }
77         });
79 });
81 </script>