publiclab/spectral-workbench

View on GitHub
app/views/spectrums/embed.html.erb

Summary

Maintainability
Test Coverage
<%= javascript_include_tag "analyze" %>
<%= javascript_include_tag "application" %>
<img width="<%= @width.to_i-20 %>px" height="<%= (@height/2).to_i-50 %>" src="<%= @spectrum.photo.url(:large) %>" />
<div id="graph" style="width:<%= @width.to_i-20 %>px;height:<%= (@height/2).to_i %>px;"></div>
<script type="text/javascript">
  <% if @spectrum.data == "" || @spectrum.data.nil? %>
    spectrum = <%= raw @spectrum.extract_data %>
  <% else %>
    spectrum = <%= raw @spectrum.data.chomp(",") %>
  <% end %>
    data = [{label: "<%= @spectrum.title %> = 0% ",data:[]}]
    scaled = true
    $.each(spectrum.lines,function(index,line) {
      if (line.wavelength == null) {
  line.wavelength = index
  scaled = false
      }
      data[0].data.push([line.wavelength,line.average/(2.55)])
    })
    flotoptions.xaxis.show = scaled
    flotoptions.grid.backgroundColor = "#eee"
    flotoptions.grid.color = "#444"
    flotoptions.colors[0] = "#666"
    plot = $.plot($("#graph"),data,flotoptions);
</script>

<b><a target="_blank" href="//spectralworkbench.org/spectra/show/<%= @spectrum.id %>"><%= @spectrum.title %></a></b>
<span style="text-align:right;">by <a target="_blank" href="//spectralworkbench.org/spectra/author/"><%= @spectrum.author %></a></span>
<span style="text-align:right;">on <img src="/images/spectralworkbench.png" /> <a target="_blank" href="//spectralworkbench.org">SpectralWorkbench.org</a></span>
<style>
html {
  font-family: lucida grande, lucida console, arial, sans-serif;
  font-size:11px;
}
body {
  margin:0;
}
b {
  padding:3px;
  font-size:13px;
}
#graph {
  color:#444;
  margin-top:8px;
}
</style>