Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
moved default room from js to rails
Browse files Browse the repository at this point in the history
  • Loading branch information
majofi committed Aug 26, 2014
1 parent fa0847d commit 1999bac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions app/helpers/wive_helper.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module WiveHelper

def wive username, opts = {}
room_name = opts[:room_name].blank? ? "window.location.hostname + window.location.pathname" : "'#{opts[:room_name]}'"
room_name = opts[:room_name].blank? ? "#{request.host}/#{request.path}" : "#{opts[:room_name]}"
link_url = opts[:link_url]
image_url = opts[:image_url]
if image_url.blank?
image_url = image_url("letter-#{username.first}.png", class: "icon")
image_url = image_url("letter-#{username.first.downcase}.png", class: "icon")
end

render :partial => 'shared/wive', locals: {username: username, room_name: room_name, link_url: link_url, image_url: image_url}
Expand Down
14 changes: 8 additions & 6 deletions app/views/shared/_wive.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,19 @@
var element = '<a href="{{link_url}}" title="{{username}}"> <img class="icon" alt="{{username}}" src="{{image_url}}"> </a>';
var socket = io.connect('<%= Wive.server %>');

socket.emit('user_and_room', '<%= username%>', <%= room_name %>, '<%= image_url %>', '<%= link_url%>');
socket.emit('user_and_room', '<%= username%>', '<%= room_name %>', '<%= image_url %>', '<%= link_url%>');

socket.on('room_update', function(users){
$('#participants-list').empty();

$.each(users, function(index, value){
element = element.replace('{{link_url}}', value['link_url']);
element = element.replace('{{username}}', value['username']);
element = element.replace('{{username}}', value['username']);
element = element.replace('{{image_url}}', value['image_url']);
$('#participants-list').append($('<li>').html(element));
if('<%= username %>' != value['username'] ){
element = element.replace('{{link_url}}', value['link_url']);
element = element.replace('{{username}}', value['username']);
element = element.replace('{{username}}', value['username']);
element = element.replace('{{image_url}}', value['image_url']);
$('#participants-list').append($('<li>').html(element));
}
});
});

Expand Down

0 comments on commit 1999bac

Please sign in to comment.