Permalink
Browse files

update

  • Loading branch information...
1 parent ee4a6a7 commit 2ac1d0913ebfc7aebb014a89865cd6f798b16cd5 shu_0115 committed with Shun Matsumoto May 18, 2012
Showing with 17 additions and 5 deletions.
  1. +2 −1 app/controllers/top_controller.rb
  2. +15 −4 app/views/top/chat.html.erb
@@ -57,7 +57,8 @@ def create
# chat #
#------#
def chat
- Pusher['test_channel'].trigger( 'test_event', { test_text: params[:text] } )
+ @word = params[:word]
+ Pusher['word_channel'].trigger( 'word_event', { word: @word } )
end
end
@@ -1,15 +1,26 @@
<script src="http://js.pusher.com/1.11/pusher.min.js"></script>
<script type="text/javascript">
var pusher = new Pusher('<%= Pusher.key %>'); // uses your API KEY
- var channel = pusher.subscribe('test_channel');
+ var channel = pusher.subscribe('word_channel');
- channel.bind( 'test_event', function(data){
- document.getElementById('get_text').innerText = data.test_text;
+ channel.bind( 'word_event', function( data ){
+ document.getElementById('get_text').innerText = data.word;
+ document.getElementById('get_text').textContent = data.word; // Firefox用
} );
</script>
+<center>
+<br /><br /><br />
+
+<%# 検索フォーム %>
+<%= form_tag( action: "chat" ) do %>
+ <%= text_field_tag( :word ) %>
+ <%= submit_tag( "POST", disable_with: "POST" ) %>
+<% end %>
+
<br /><br />
-<span id="get_text">TEST</span><br />
+<span id="get_text"><%= @word %></span><br />
<br /><br />
+</center>

0 comments on commit 2ac1d09

Please sign in to comment.