Skip to content

Commit

Permalink
redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
grobie committed Jun 17, 2011
1 parent dad0c94 commit 21a55a5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
9 changes: 1 addition & 8 deletions public/js/recorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,7 @@ function microphone_recorder_events() {
case "saved":
var name = arguments[1];
var data = $.parseJSON(arguments[2]);
if(data.saved) {
$('#upload_status').css({'color': '#0F0'}).text(name + " was saved");
} else {
$('#upload_status').css({'color': '#F00'}).text(name + " was not saved");
}
window.location.reload();
window.location.href = data.location;
break;

case "save_failed":
Expand All @@ -94,8 +89,6 @@ function microphone_recorder_events() {
var name = arguments[1];
var bytesLoaded = arguments[2];
var bytesTotal = arguments[3];
// $('#upload_status').css({'color': '#000'}).text(name + " progress: " + bytesLoaded + " / " + bytesTotal);
$('#upload_status').hide();
break;
}
}
Expand Down
7 changes: 3 additions & 4 deletions soundlock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ class Soundlock < Sinatra::Base
end

post "/record" do
upload(params[:file])

"saved"
lock = upload(params[:file])
"{\"location\": \"/lock/#{lock.id}\"}"
end

get "/lock/:id" do
Expand All @@ -48,7 +47,7 @@ class Soundlock < Sinatra::Base
post "/lock/:id" do
@lock = Echonest::Track.find(params[:id])
if @lock && (@solver = upload(params[:file], @lock)) && @solver.similar_to?(@lock)
erb :solved
"{\"location\": \"/solver/#{@solver.id}\"}"
else
erb :error
end
Expand Down
6 changes: 3 additions & 3 deletions views/index.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
<tr>
<th>#</th>
<th>at</th>
<th># solved</th>
<th>beats</th>
<th>solved / tries</th>
<th>important events at</th>
</tr>
<% @locks.sort_by(&:created_at).each do |lock| %>
<tr>
<td><a href="/lock/<%= lock.id %>"><%= lock.id %></a></td>
<td><%= lock.created_at.strftime("%Y-%m-%d %I:%M") %></td>
<td><%= lock.solvers.size %></td>
<td><%= "#{lock.solvers.select(&:valid?).size} / #{lock.solvers.size}" %></td>
<td><%= lock.beats.inspect %></td>
</tr>
<% end %>
Expand Down

0 comments on commit 21a55a5

Please sign in to comment.