app/views/match/_match_results.html.erb
<table class="table">
<% @spectra.each do |spectrum| %>
<tr id="spectrum_<%= spectrum.id %>">
<td width="240px;"><a href="<%= spectrum_path(spectrum.id) %>" ><b><%= spectrum.title %></b></a><% if @spectrum.id == spectrum.id %> <br />(You searched for this)<% end %><br /> by <a href="<%= user_path(spectrum.author) %>"><%= spectrum.author %></a> <%= time_ago_in_words(spectrum.created_at) %> ago</td>
<!--<a class="" id="spectrum_btn_<%= spectrum.id %>" href="javascript:void(0);">Add +</a> <span id="scaledFlag_<%= spectrum.id %>"></span>-->
<td><a data-dismiss="modal" class="btn btn-primary" id="spectrum_btn_<%= spectrum.id %>" href="javascript:void(0)">Compare</a></td>
<script>
spectrum_<%= spectrum.id %> = <%= raw spectrum.data || "{lines:[]}" %>
spectrum_<%= spectrum.id %>_data = []
scaled = true
$.each(spectrum_<%= spectrum.id %>.lines,function(index,line) {
if (line.wavelength == null) {
line.wavelength = index
scaled = false
}
spectrum_<%= spectrum.id %>_data.push([line.wavelength,line.average/2.55])
})
if (!scaled) {
$('#scaledFlag_<%= spectrum.id %>').html('(<a href="http://publiclaboratory.org/wiki/spectral-workbench-calibration">Uncalibrated</a>)')
}
$("#spectrum_btn_<%= spectrum.id %>").click(function() {
spectra.push(<%= spectrum.id %>)
$("#createSet").show()
$W.data.push({id: <%= spectrum.id %>, label:"<%= spectrum.title.gsub('"',"'") %> = 0% (<a href='javascript:void(0);' onClick='remove_spectrum(\"<%= spectrum.id %>\")'>remove</a>)", data: spectrum_<%= spectrum.id %>_data})
plot = $.plot($("#graph"),$W.data,flotoptions);
$W.init_hovers();
})
</script>
</tr>
<% end %>
</table>