publiclab/spectral-workbench

View on GitHub
app/views/capture/_search.html.erb

Summary

Maintainability
Test Coverage
<div data-role="page" id="search" data-theme="a">
  <div data-theme="a" data-role="header">
    <h3 style="text-align:left;margin-left:15px;">Search for spectra</h3>
  </div>
  <div data-role="content" class="content" style="padding: 15px">
  
    <form id="search_form" action="javascript:void(0);" method='get'>
      <input id='search_term' class='text' type='text' name='q' value=''/>
      <a data-inline="true" style="width:200px;" data-role="button" data-theme="b" onClick="$('#search_form').submit()">Search</a>
      <a data-inline="true" style="width:200px;" data-role="button" data-transition="fade" data-theme="d" href="#capture" data-panel="main">&laquo; Back</a>
      <% if logged_in? %>
      <label for="baseline-toggle">Use as baseline for absorption spectroscopy</label>
      <input data-theme="a" type="checkbox" name="baseline-toggle" id="baseline-toggle" type="checkbox" />
      <% end %>
    </form>

    <div id="results">
    <h3>Recent spectra (<a href="javascript:void()" id="refresh_recent">refresh</a>)</h3>
    <%= render :partial => "results" %>  
    </div>

    <script> 
      $('#search_form').submit(function() {
        $('#results').load("/spectra/search/"+$('#search_term').val()+"?capture=true")
      })
      $('#refresh_recent').click(function() {
        $('#results').load("/spectra/recent/?capture=true")
      })
    </script>
  </div>
</div>