Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

manual image flip in More Tools, alpha macro console now in Analyze i…

…nterface
  • Loading branch information...
commit bcc2018111136f5e65334b4fbff964d232b508c8 1 parent 34f93c8
@jywarren authored
View
3  .gitignore
@@ -1,5 +1,8 @@
*.swp
*.swo
+*.db
+*.pid.lock
+*.log
.DS_Store
webserver/log/
webserver/tmp/*
View
18 webserver/app/controllers/spectrums_controller.rb
@@ -39,7 +39,6 @@ def anonymous
def show
@spectrum = Spectrum.find(params[:id])
# eventually move this to "create" once they're all fixed:
- @spectrum.correct_reversed_image
if @spectrum.data == "" || @spectrum.data.nil?
@spectrum.extract_data
@spectrum.save
@@ -205,6 +204,7 @@ def create
@spectrum.lon = params[:lon]
end
+ @spectrum.correct_reversed_image
@spectrum.save!
flash[:notice] = 'Spectrum was successfully created.'
@@ -296,8 +296,8 @@ def comment
def calibrate
@spectrum = Spectrum.find(params[:id])
if logged_in? && @spectrum.user_id == current_user.id
- if request.post?
- @spectrum.calibrate(params[:x1],params[:w1],params[:x2],params[:w2]).save
+ if true#request.post?
+ @spectrum.calibrate(params[:x1],params[:w1],params[:x2],params[:w2])
@spectrum.save
tag = @spectrum.tag('calibration',current_user.id)
end
@@ -449,4 +449,16 @@ def rotate
redirect_to "/analyze/spectrum/"+@spectrum.id.to_s
end
+ # Just reverses the image, not the data.
+ def reverse
+ @spectrum = Spectrum.find params[:id]
+ if logged_in? && (@spectrum.user_id == current_user.id || current_user.role == "admin")
+ @spectrum.reverse
+ @spectrum.save
+ else
+ flash[:error] = "You must be logged in and own this spectrum to do this."
+ end
+ redirect_to "/analyze/spectrum/"+@spectrum.id.to_s
+ end
+
end
View
29 webserver/app/views/analyze/_macros.html.erb
@@ -0,0 +1,29 @@
+<div class="modal hide fade" id="macrosmodal">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
+ <b>Write and run macros to manipulate your data</b>
+ </div>
+ <div class="modal-body">
+ <p>Use the in-development <a target="_blank" href="http://publiclaboratory.org/wiki/spectral-workbench-api">Spectral Workbench API</a> to run scripts (macros).</p>
+
+ <textarea rows="6" style="width:95%;font-size:11px;font-family:courier,sans-serif;" id="code">setup: function() {
+ // code to run on startup
+ window.open($W.canvas.toDataURL(),'_newtab').focus() // this may not work if popups are blocked
+},
+draw: function() {
+ // code to run every frame
+}</textarea>
+
+ </div>
+ <div class="modal-footer">
+ <a data-dismiss="modal" class="btn" href="javascript:void();">Cancel</a>
+ <a id="run" data-dismiss="modal" class="btn btn-primary" href="javascript:void();">Run</a>
+ </div>
+</div>
+
+<script>
+ $('#run').click(function() {
+ eval("$W.macro = {"+$('#code').val()+"}")
+ $W.macro.setup()
+ })
+</script>
View
7 webserver/app/views/analyze/spectrum.html.erb
@@ -1,6 +1,8 @@
<script src="/javascripts/show.js"> </script>
+<script src="/javascripts/api.js"> </script>
<script src="/javascripts/analyze.js"> </script>
<%= render :partial => "clone" %>
+<%= render :partial => "macros" %>
<%= render :partial => "calibrate" %>
<%= render :partial => "select_row" %>
<%= render :partial => "compare" %>
@@ -21,7 +23,7 @@
<div class="row-fluid" id="display">
- <img style="width:95%;height:100px;padding:0 1% 0 4%;background:black;" id="image" src="<%= @spectrum.photo.url(:original) %>" />
+ <img style="width:95%;height:100px;padding:0 1% 0 4%;background:black;" id="image" src="<%= @spectrum.photo.url(:original) %>?<%= DateTime.now.to_i %>" />
<div id="graph" style="width:98%;height:200px;"></div>
<div class="navbar navbar-inverse navbar-static-bottom" style="margin:0;">
@@ -34,7 +36,7 @@
<a class="btn btn-inverse hidden-phone" id="createSet" href="javascript:void(0);"><i class="icon icon-white icon-list"></i><span class="hidden-phone"> Save as set</span></a>
<a data-toggle="modal" class="btn btn-inverse" href="#comparemodal"><i class="icon icon-white icon-align-left"></i><span class="hidden-phone"> Compare</span></a>
- <a rel="popover" data-placement="left" class="pull-right btn btn-inverse" data-content='<ul class="nav nav-list"><li><a onClick="$W.units()">Toggle units</a></li><li><a onClick="$W.toggle_mode()">Toggle RGB</a></li><li><a onClick="$W.extract()"><i class="icon icon-refresh"></i> Re-extract from photo</a></li><li><a href="#selectrowmodal" data-toggle="modal">Set sample row</a></li><li><a href="/spectra/rotate/<%= @spectrum.id %>">Rotate image</a></li><li><a href="/spectra/find_brightest_row/<%= @spectrum.id %>">Auto-detect brightest spectrum</a></li></ul>'><i class="icon icon-white icon-briefcase"></i><span class="hidden-phone"> More tools</span></a>
+ <a rel="popover" data-placement="left" class="pull-right btn btn-inverse" data-content='<ul class="nav nav-list"><li><a onClick="$W.units()">Toggle units</a></li><li><a onClick="$W.toggle_mode()">Toggle RGB</a></li><li><a onClick="$W.extract()"><i class="icon icon-refresh"></i> Re-extract from photo</a></li><li><a href="#selectrowmodal" data-toggle="modal">Set sample row</a></li><li><a href="/spectra/rotate/<%= @spectrum.id %>">Rotate image</a></li><li><a href="/spectra/reverse/<%= @spectrum.id %>"><i class="icon icon-resize-horizontal"></i> Flip image horizontally</a></li><li><a href="/spectra/find_brightest_row/<%= @spectrum.id %>">Auto-detect brightest spectrum</a></li><li><a href="#macrosmodal" data-toggle="modal"><i class="icon icon-forward"></i> Macros/scripting</a></li></ul>'><i class="icon icon-white icon-briefcase"></i><span class="hidden-phone"> More tools</span></a>
<b class="pull-right" style="padding-top:10px;margin-right:10px;"><span id="wavelength"></span> <span id="#unit_label">nm</span></b>
</div>
@@ -150,6 +152,7 @@
$W.initialize({
spectrum_id:<%= @spectrum.id %>,
+ interface:"analyze",
title: "<%= @spectrum.title.gsub('"',"'") %>",
form_authenticity_token: "<%= form_authenticity_token %>",
spectrum_data: <%= @spectrum.data.gsub('"',"'") %>
View
5 webserver/app/views/capture/index-mobile-alt.html.erb
@@ -1,6 +1,7 @@
<script src="/javascripts/getUserMedia.js"> </script>
<script src="/javascripts/jquery.min.js"> </script>
<script src="/javascripts/capture.js"> </script>
+<script src="/javascripts/api.js"> </script>
<script language="javascript" type="text/javascript" src="/javascripts/flot/jquery.flot.js"></script>
<script language="javascript" type="text/javascript" src="/javascripts/flot/jquery.flot.crosshair.js"></script>
<script language="javascript" type="text/javascript" src="/javascripts/flot/jquery.flot.threshold.min.js"></script>
@@ -105,7 +106,9 @@
<script> (function () {
$W.initialize({
calibrated:<%= !@calibration.nil? %>,
- mobile:true
+ interface:"capture",
+ mobile:true,
+ spectrum_id:<%= @spectrum.id %>
})
setInterval($W.getRow,100)
<% if @calibration %>
View
13 webserver/public/javascripts/api.js
@@ -0,0 +1,13 @@
+$W.calibrate = function(id,x1,w1,x2,w2) {
+ if ($W.interface == "analyze") {
+ window.location = "/spectra/calibrate/"+$W.spectrum_id+"?x1="+x1+"&w1="+w1+"&x2="+x2+"&w2="+w2
+ } else {
+ $.ajax({
+ url: "/spectra/calibrate/"+$W.spectrum_id+"?x1="+x1+"&w1="+w1+"&x2="+x2+"&w2="+w2,
+ type: "GET",
+ success: function(result) {
+ $W.notify('The spectrum with id '+id+' was calibrated successfully.')
+ }
+ })
+ }
+}
View
11 webserver/public/javascripts/capture.js
@@ -26,6 +26,7 @@ $W = {
initialize: function(args) {
this.mobile = args['mobile'] || false
+ this.interface = args['interface'] || false
this.calibrated = args['calibrated'] || false
if (args['height']) {
this.options.height = args['height']
@@ -280,16 +281,6 @@ $W = {
$('#lat').val('')
},
- calibrate: function(id,x1,w1,x2,w2) {
- $.ajax({
- url: "/spectra/calibrate/"+$W.spectrum_id+"?x1="+x1+"&w1="+w1+"&x2="+x2+"&w2="+w2,
- type: "POST",
- success: function(result) {
- $W.notify('The spectrum with id '+id+' was calibrated successfully.')
- }
- })
- },
-
match: function() {
cols = []
$.each($W.full_data,function(i,datum) {
View
3  webserver/public/javascripts/show.js
@@ -11,6 +11,7 @@ $W = {
initialize: function(args) {
this.spectrum_id = args['spectrum_id']
this.form_authenticity_token = args['form_authenticity_token']
+ this.interface = args['interface'] || false
this.title = args['title']
this.spectrum = args['spectrum_data']
this.data = [{label: $W.title+" = 0% ",data:[]}]
@@ -275,6 +276,8 @@ $W = {
window.location = '/spectrums/setsamplerow/'+$W.spectrum_id+'?row='+e.offsetY
})
}
+
+
}
Please sign in to comment.
Something went wrong with that request. Please try again.