Skip to content

ChatRoom Flow

kai edited this page Jan 9, 2018 · 8 revisions

local Thin server

bundle exec rackup private_pub.ru -s thin -E production

fuzzySearchResult_chatroom

ctrl.openRoom(room)

$ctrl.openRoom = function(room){ $rootScope.$broadcast("chatroom:ready", {room: room}); }

Detail Modal

object data="{{$ctrl.baseUrl}}/messages"

$ctrl.baseUrl = UserService.baseUrl;

in routes

resources :messages, module: 'chatroom'

GET /messages def index @messages = Message.all end

in index.html

<%= render "chatroom/messages/chatroom"

in chatroom.html

<%= show_communications(@messages).html_safe %>

messagehelper.rb

def show_communications(msgs=nil)

div class= container

say card-body

#{sanitize(msg.try(:html_content), tags: %w(br img span p i b a), attributes: %w(id class style src))}

jquery id selection

https://www.w3schools.com/jquery/sel_id.asp

$("#intro")

scroll to the bottom

    the following are equilvant statements
    $("html, body").animate({scrollTop: $("#chat")[0].scrollHeight}, "slow");
$("html").animate({scrollTop: $("#chat")[0].scrollHeight}, "slow");

    no animation
    $("html, body").scrollTop($("#chat")[0].scrollHeight);
$("html").scrollTop($("#chat")[0].scrollHeight);

# body does not scroll
$("body").scrollTop($("#chat")[0].scrollHeight);

Clone this wiki locally