Cleaning out a bunch more cruft, getting map choice by click working
This commit is contained in:
parent
70d0a835ed
commit
a1aa03451f
@ -22,7 +22,7 @@ class MapsController < ApplicationController
|
||||
File.open(dest, 'w') do |f|
|
||||
f.write(image)
|
||||
end
|
||||
send_file(dest)
|
||||
send_file(dest, :type => 'image/png')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -26,6 +26,7 @@ class MashesController < ApplicationController
|
||||
def create
|
||||
mash_params = params[:mash]
|
||||
mash_params[:requester] = request.remote_ip
|
||||
logger.info("Got mash params: #{mash_params.inspect}")
|
||||
@mash = Mash.new(mash_params)
|
||||
|
||||
respond_to do |format|
|
||||
|
@ -1,17 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
|
||||
<title>Maps: <%= controller.action_name %></title>
|
||||
<%= stylesheet_link_tag 'scaffold' %>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p style="color: green"><%= flash[:notice] %></p>
|
||||
|
||||
<%= yield %>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -4,8 +4,11 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
|
||||
<title>Mashes: <%= controller.action_name %></title>
|
||||
<title>Map Mash</title>
|
||||
<%= stylesheet_link_tag 'styles' %>
|
||||
<%= stylesheet_link_tag 'scaffold' %>
|
||||
<%= javascript_include_tag 'jquery.min' %>
|
||||
<%= yield :head_js %>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
@ -1,28 +0,0 @@
|
||||
<h1>Editing mash</h1>
|
||||
|
||||
<% form_for(@mash) do |f| %>
|
||||
<%= f.error_messages %>
|
||||
|
||||
<p>
|
||||
<%= f.label :requester %><br />
|
||||
<%= f.text_field :requester %>
|
||||
</p>
|
||||
<p>
|
||||
<%= f.label :map_a %><br />
|
||||
<%= f.text_field :map_a %>
|
||||
</p>
|
||||
<p>
|
||||
<%= f.label :map_b %><br />
|
||||
<%= f.text_field :map_b %>
|
||||
</p>
|
||||
<p>
|
||||
<%= f.label :winner %><br />
|
||||
<%= f.text_field :winner %>
|
||||
</p>
|
||||
<p>
|
||||
<%= f.submit 'Update' %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<%= link_to 'Show', @mash %> |
|
||||
<%= link_to 'Back', mashes_path %>
|
@ -1,26 +0,0 @@
|
||||
<h1>Listing mashes</h1>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Requester</th>
|
||||
<th>Map a</th>
|
||||
<th>Map b</th>
|
||||
<th>Winner</th>
|
||||
</tr>
|
||||
|
||||
<% @mashes.each do |mash| %>
|
||||
<tr>
|
||||
<td><%=h mash.requester %></td>
|
||||
<td><%=h mash.map_a %></td>
|
||||
<td><%=h mash.map_b %></td>
|
||||
<td><%=h mash.winner %></td>
|
||||
<td><%= link_to 'Show', mash %></td>
|
||||
<td><%= link_to 'Edit', edit_mash_path(mash) %></td>
|
||||
<td><%= link_to 'Destroy', mash, :confirm => 'Are you sure?', :method => :delete %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
|
||||
<%= link_to 'New mash', new_mash_path %>
|
@ -1,25 +1,32 @@
|
||||
<% content_for :head_js do %>
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
$('.mash-image').click(function(elem) {
|
||||
$('#mash_winner').val($(elem.target).attr('data-map-id'));
|
||||
$('#new_mash').submit();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<% end %>
|
||||
|
||||
<h1>Mash the Maps!</h1>
|
||||
<p>Choose your fave.</p>
|
||||
|
||||
<% form_for(@mash) do |f| %>
|
||||
<%= f.error_messages %>
|
||||
|
||||
<div id="map_a" class="mash-image">
|
||||
<%= f.label 'A' %><br />
|
||||
<%= f.hidden_field :map_a, :value => @map_a.id %>
|
||||
<image src="<%= url_for @map_a %>.png" />
|
||||
<div id="maps">
|
||||
<div id="map_a" class="mash-image">
|
||||
<image src="<%= url_for @map_a %>.png" data-map-id="<%= @map_a.id %>" />
|
||||
</div>
|
||||
<div id="map_b" class="mash-image">
|
||||
<image src="<%= url_for @map_b %>.png" data-map-id="<%= @map_b.id %>" />
|
||||
</div>
|
||||
</div>
|
||||
<div id="map_b" class="mash-image">
|
||||
<%= f.label 'B' %><br />
|
||||
<%= f.hidden_field :map_b, :value => @map_b.id %>
|
||||
<image src="<%= url_for @map_b %>.png" />
|
||||
</div>
|
||||
<p>
|
||||
<%= f.select :winner, [['A', @map_a.id], ['B', @map_b.id]] %>
|
||||
</p>
|
||||
<p>
|
||||
<%= f.submit 'Mash' %>
|
||||
</p>
|
||||
|
||||
<%= f.hidden_field :map_a, :value => @map_a.id %>
|
||||
<%= f.hidden_field :map_b, :value => @map_b.id %>
|
||||
<%= f.hidden_field :winner, :value => -1 %>
|
||||
<% end %>
|
||||
|
||||
<%= link_to 'Back', mashes_path %>
|
||||
|
@ -1,23 +0,0 @@
|
||||
<p>
|
||||
<b>Requester:</b>
|
||||
<%=h @mash.requester %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Map a:</b>
|
||||
<%=h @mash.map_a %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Map b:</b>
|
||||
<%=h @mash.map_b %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Winner:</b>
|
||||
<%=h @mash.winner %>
|
||||
</p>
|
||||
|
||||
|
||||
<%= link_to 'Edit', edit_mash_path(@mash) %> |
|
||||
<%= link_to 'Back', mashes_path %>
|
@ -12,7 +12,7 @@ class GoogleMapLocationFetcher
|
||||
def initialize
|
||||
@base_map_url = [
|
||||
'http://maps.googleapis.com/maps/api/staticmap',
|
||||
'?zoom=15',
|
||||
'?zoom=12',
|
||||
'&sensor=false',
|
||||
'&size=512x512',
|
||||
'&maptype=satellite',
|
||||
|
9266
rails/map-mash/public/javascripts/jquery.js
vendored
Normal file
9266
rails/map-mash/public/javascripts/jquery.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
4
rails/map-mash/public/javascripts/jquery.min.js
vendored
Normal file
4
rails/map-mash/public/javascripts/jquery.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
8
rails/map-mash/public/stylesheets/styles.css
Normal file
8
rails/map-mash/public/stylesheets/styles.css
Normal file
@ -0,0 +1,8 @@
|
||||
div.mash-image {
|
||||
display: inline;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#maps {
|
||||
display: block;
|
||||
}
|
Loading…
Reference in New Issue
Block a user