app/views/spectrums/new.html.erb
<div class="container-fluid" style="clear:both;">
<div class="">
<h1>Upload a spectrum</h1>
</div>
<div class="row">
<form id="upload" action="/spectrums/create" class="form well span10" enctype="multipart/form-data" method="post">
<% if !params[:webrtc].nil? && params[:webrtc] == 'false' %>
<div class="alert alert-error">
Your browser <a href="http://caniuse.com/#search=webrtc">doesn't support live capture via USB</a>, so we've redirected you to the Upload page; if you believe you're seeing this message in error, please <a href="https://publiclab.org/wiki/issues">file an issue</a>.
</div>
<% end %>
<% if @spectrum.errors.any? %>
<div class="alert alert-error">
<h3>There were errors with your data.</h3>
<ul>
<% @spectrum.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="row-fluid">
<div class="span6">
<input name="spectrum[data_type]" type="hidden" id="spectrum_upload_type" value="image" />
<ul class="nav nav-tabs nav-upload-types">
<li class="active"><a data-upload-type="image" href="#tab-image" data-toggle="tab"><i class="fa fa-camera"></i> Choose an image</a></li>
<li> <a data-upload-type="json" href="#tab-json" data-toggle="tab"><i class="fa fa-code"></i> Upload json (beta)</a></li>
<li> <a data-upload-type="csv" href="#tab-csv" data-toggle="tab"><i class="fa fa-code"></i> Upload csv (beta)</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tab-image">
<%= render partial: 'spectrums/new_image' %>
</div>
<div class="tab-pane" id="tab-json">
<h4>Paste in valid JSON data</h4>
<p>Please use <a href="https://publiclab.org/wiki/spectral-workbench-api#Uploading+data">this format</a>.</p>
<textarea class="spectrum-json" name="spectrum[json]" style="width:90%;height:200px;" placeholder='[
{ "average": 64.3333, "r": 69, "g": 46, "b": 78, "wavelength":269.089 },
{ "average": 35, "r": 33, "g": 19, "b": 41, "wavelength":432.241 },
{ "average": 31, "r": 33, "g": 19, "b": 41, "wavelength":958.521 }
]'></textarea>
</div>
<div class="tab-pane" id="tab-csv">
<h4>Paste in valid CSV data</h4>
<p>Please use <code>wavelength (in nanometers),intensity (0-255)</code> as <a href="https://publiclab.org/wiki/spectral-workbench-api#Uploading+data">shown here</a>.</p>
<textarea class="spectrum-csv" name="spectrum[csv]" style="width:90%;height:200px;" placeholder='400,24
410,44
420,42
430,45
440,20'></textarea>
</div>
</div>
</div>
<div class="span6">
<h3>Describe your spectrum</h3>
<div class="control-group" id="title">
<input name="spectrum[title]" type="text" id="inputTitle" placeholder="Title">
<span class="help-inline"></span>
</div>
<div>
<textarea name="spectrum[notes]" id="textareaNotes" cols="8" rows="6" placeholder="Notes: where, what, why"></textarea>
</div>
<label for="device">If possible, identify your device:</label>
<select name="device" id="device">
<option value="none">- choose a device -</option>
<option value="device:dsk3">Desktop Spectrometry Kit v3</option>
<option value="device:dsk2">Desktop Spectrometry Kit v2</option>
<option value="device:dsk1">Desktop Spectrometry Kit v1</option>
<option value="device:foldable">Foldable Mini-Spectrometer</option>
<option value="device:countertop">Countertop Spectrometer</option>
<option value="device:smartphone">Smartphone Spectrometer</option>
<option value="device:custom">custom design</option>
</select>
</div>
<div class="row-fluid">
<p>
<% if logged_in? && current_user.calibrations.length > 0 %>
<label for="calibration_id">Use or create a calibration (<a href="//publiclab.org/wiki/spectral-workbench-calibration">Learn more</a>):</label>
<select name="spectrum[calibration_id]" id="calibration_id">
<% current_user.tag('calibration',20).each do |spectrum| %>
<option value="<%= spectrum.id %>"><%= spectrum.title %> (<%= time_ago_in_words(spectrum.created_at) %> ago)</option>
<% end %>
<option value="calibration">[+] New calibration</option>
</select>
<% end %>
</p>
<input type='hidden' name='authenticity_token' value="<%= form_authenticity_token %>"/>
<input name="upload" id="upload" value="true" />
<input name="geotag" id="geotag" value="<%= params[:geotag] %>" />
<input name="lat" id="lat" value="<%= params[:lat] %>" />
<input name="lon" id="lon" value="<%= params[:lon] %>" />
<a href="#" data-loading-text="Saving..." id="uploadBtn" class="btn btn-primary btn-large" onClick="$W.save(true)">Upload with selected calibration</a>
<a href="#" data-loading-text="Saving..." id="uploadUncalibrated" class="btn btn-large" onClick="$W.save(false)">Upload & calibrate later</a>
<label rel="tooltip" title="Detect your location and tag this data?" class="checkbox inline" style="margin-left:10px;">
<input type="checkbox" style="display:none;" id="geotagInput" value="geotag" checked="true" /> Geotag
</label>
</div>
<hr />
<p>By uploading your data, you agree to release it under the <a href="http://creativecommons.org/publicdomain/zero/1.0/">Creative Commons Zero license</a></p>
</div>
</form>
</div>
<%= javascript_include_tag "upload" %>