app/views/match/_list_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 | <b>Tags:</b> <% spectrum.tags.each do |tag| %><a class="label label-info" href="/tag/<%= tag.name %>"><%= tag.name %></a> <% end %></td>
<!--<a class="" id="spectrum_btn_<%= spectrum.id %>" href="javascript:void(0);">Add +</a> <span id="scaledFlag_<%= spectrum.id %>"></span>-->
<% if @c %><td><a data-dismiss="modal" class="btn btn-primary" id="spectrum_btn_<%= spectrum.id %>" href="javascript:void(0)">Compare</a></td><% end %>
</tr>
<% end %>
</table>
<script type="text/javascript">
(function () {
$W.initialize({
spectrum_id:<%= @spectrum.id %>,
interface:"analyze",
title: "<%= @spectrum.title.gsub('"',"'") %>",
form_authenticity_token: "<%= form_authenticity_token %>",
spectrum_data: <%= raw @spectrum.data.gsub('"',"'") %>
})
spectra = [] // So that whenever we submit new fit value, spectra needs to be emptied,
//so that only new spectra can be saved as a set.
spectra.push(<%= @spectrum.id %>) // As we consider other spectra separately
<% @spectra.each do |spectrum| %>
if (<%= @spectrum.id %> != <%= spectrum.id %>){ // All spectra except the search spectra
spectra.push(<%= spectrum.id %>)
$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})
}
<% end %>
plot = $.plot($("#graph"),$W.data,flotoptions);
$W.init_hovers();
function remove_spectrum(id) {
$.each($W.data, function(index,s) {
if (s.id == id) {
$W.data.splice(index,1)
}
})
$.each(spectra,function(index,s) {
if (s == id) {
spectra.splice(index,1)
}
})
plot = $.plot($("#graph"),$W.data,flotoptions);
$W.init_hovers();
}
})()
</script>