Permalink
Browse files

Initial Commit

  • Loading branch information...
0 parents commit e598f16743491a94b4092fb70a6656966b57321f @joshsten committed Oct 26, 2010
@@ -0,0 +1,3 @@
+= j_chat
+
+Description goes here
@@ -0,0 +1,16 @@
+class ChatController < ApplicationController
+ unloadable
+ def index
+ @chats = Chat.find_by_sql(["SELECT chats.*, u.firstName FROM chats INNER JOIN users u on chats.user = u.id ORDER BY sendDate DESC" ])
+ end
+ def send_chat
+ Chat.create(:message => params[:msg], :user => User.current.id)
+ #@chat.chatMessage(params[:msg],"test")
+ #@chat.save
+ end
+ def receive_chat
+ @user = User.current
+ @chats = Chat.find_by_sql(["SELECT chats.*, u.firstName FROM chats INNER JOIN users u on chats.user = u.id ORDER BY sendDate DESC LIMIT 15" ])
+ render :partial => 'chat/receive_chat.erb'
+ end
+end
@@ -0,0 +1,2 @@
+module ChatHelper
+end
@@ -0,0 +1,5 @@
+class Chat < ActiveRecord::Base
+ unloadable
+ def chatMessage(msg,user)
+ end
+end
@@ -0,0 +1,20 @@
+<% @chats.reverse.each do |chat| %>
+<div class='chatMessage' title="<%= chat[:id] %>">
+<% @user = User.find(chat[:user]) %>
+<div style="float: left; display: inline-block; padding: 3px; border-bottom: thin solid #DDDDEE;"><%= avatar @user, :size => "20" %></div>
+
+<div style="float: left; width:105px; display: inline; border-bottom: thin dotted #DDDDEE;border-right: thin dotted #DDDDEE; height: 32px;"><b style="font-size: 14px;"><%= chat[:firstName] %></b>
+<br/><span style='font-size: 10px;'>says</span> </div>
+
+<%
+ msgTime = chat[:sendDate]
+ #msgTime = Time.parse(chat[:sendDate])
+ msgTime=msgTime.strftime("%I:%M %p - %a %d/%d/%Y")
+%>
+
+<div onclick="location.href='/chat'" class='chatTime'><%= msgTime %></div>
+<div style="clear:both; padding-top: 3px;"><%= chat[:message] %></div></div>
+<% end %>
+<!--<% User.all.each do |u| %>
+[<%= u.logged? %>]
+<% end %>-->
@@ -0,0 +1,5 @@
+<h2>Chat Transcripts</h2>
+<% @chats.each do |chat| %>
+<div class='chatMessage' title="<%= chat[:id] %>"><b><%= chat[:firstName] %></b> <span style='font-size: 10px;'>says</span> <div class='chatTime'><%= chat[:sendDate] %></div>
+<div><%= chat[:message] %></div></div>
+<% end %>
@@ -0,0 +1 @@
+<h2>Chat#send</h2>
@@ -0,0 +1,49 @@
+<style>
+#footer {
+ position:fixed;
+ text-align:center;
+ bottom:0;
+ height:25px;
+ width:150px;
+ right:0;
+ background-color:#CCCCCC;
+ cursor:pointer;
+}
+#chatArea
+{
+ position:fixed;
+ text-align:center;
+ bottom:25px;;
+ right:0;
+ height:195px;
+ width:300px;
+ background-color:#BCB1C7;
+ padding:2px;
+}
+</style>
+
+<script>
+var hidden= true;
+function expandChat()
+{
+ hidden = false;
+ $("chatArea").hide();
+}
+function collapseChat()
+{
+ hidden = true;
+ $("chatArea").show();
+}
+function toggleChat()
+{
+ if (hidden)
+ expandChat();
+ else
+ collapseChat();
+}
+</script>
+<div id="footer" onclick="toggleChat();">Chat</div>
+<div id="chatArea">
+<div id="messages" style="height:150px; width:100%; border:thin solid #999999; text-align:left; padding:5px; background:#FEFEFE">Josh: hello</div>
+<input type="text" style="width:100%; padding:5px;" />
+</div>
@@ -0,0 +1,238 @@
+<!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">
+<head>
+
+<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<title><%=h html_title %></title>
+<meta name="description" content="<%= Redmine::Info.app_name %>" />
+<meta name="keywords" content="issue,bug,tracker" />
+<%= favicon %>
+<%= stylesheet_link_tag 'application', :media => 'all' %>
+<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
+<%= javascript_include_tag :defaults %>
+<%= heads_for_wiki_formatter %>
+<!--[if IE]>
+ <style type="text/css">
+ * html body{ width: expression( document.documentElement.clientWidth < 900 ? '900px' : '100%' ); }
+ body {behavior: url(<%= stylesheet_path "csshover.htc" %>);}
+ </style>
+<![endif]-->
+<%= call_hook :view_layouts_base_html_head %>
+<!-- page specific tags -->
+<%= yield :header_tags -%>
+
+
+<% if User.current.logged? %>
+<style>
+#chatFooter {
+ position:fixed;
+ text-align:center;
+ bottom:0;
+ height:15px;
+ width:160px;
+ right:0;
+ valign: center;
+ font-weight: bold;
+ padding: 5px;
+ background-color:#DDDDDD;
+ cursor:pointer;
+ -moz-border-radius-topleft: 10px 10px;
+ border-top-left-radius: 10px 10px;
+}
+#chatFooter:hover
+{
+ background-color: #FFFFFF;
+}
+#chatArea
+{
+ position:fixed;
+ text-align:center;
+ color: #666666;
+ bottom:25px;
+ right:0;
+ height:440px;
+ width:400px;
+ background-color:#DEDDDE;
+ padding:2px;
+}
+#chatMessages
+{
+ overflow:auto;
+ height:400px;
+ width:97%;
+ border:thin solid #999999;
+ text-align:left;
+ padding:5px;
+ background:#FEFEFE;
+}
+#chatMessages:hover
+{
+ background-color:#FBFBFB;
+}
+.chatMessage
+{
+ padding: 10px;
+ border-top: solid thin #EEEEEE;
+}
+.chatMessage:hover
+{
+ background-color: #EFEEEF;
+}
+.chatTime
+{
+float:right; position: relative;
+font-weight = bold;
+color: #bcb191; //#ada280;
+border-bottom: thin solid #DDDDDD;
+cursor: pointer;
+}
+</style>
+
+<script language="javascript">
+var chatVisible= true;
+var latestId = 0;
+function expandChat()
+{
+ chatVisible = true;
+ $("chatArea").hide();
+}
+function collapseChat()
+{
+ chatVisible = false;
+ $("chatArea").show();
+}
+function toggleChat()
+{
+ if (!chatVisible) expandChat();
+ else collapseChat();
+}
+
+function init()
+{
+//window.setInterval('refreshChat()', 10000);
+refreshChat();
+$('txtMsg').observe('keypress', function(event){
+ var key = event.which || event.keyCode;
+ switch (key) {
+ default:
+ break;
+ case Event.KEY_RETURN:
+ submitMsg();
+ break;
+ }
+});
+
+}
+function submitMsg()
+{
+ text=$('txtMsg').value;
+ var myAjax = new Ajax.Request(
+ '/chat/send_chat',
+ {method: 'post', parameters: {msg: text}});
+ $('txtMsg').value="";
+ new Ajax.Updater('chatMessages', '/chat/receive_chat',
+ {
+ method: 'get',
+ //parameters: {lId: $$('div:[class=chatMessage]')[$$('div:[class=chatMessage]').length-1].title},
+ //insertion:Insertion.Bottom,
+ //frequency: 5,
+ //decay: 1,
+ onSuccess: function(){window.setTimeout('refreshScroll()','50');}
+ });
+//alert(text);
+}
+function refreshChat()
+{
+ //var d = new Date();
+ //var t = d.getHours() + ":" + d.getMinutes();
+ //var Message = "This is a test message that will hopefully wrap. Tralalala.... Please work....";
+ //$('chatMessages').innerHTML=$('chatMessages').innerHTML+
+
+ new Ajax.PeriodicalUpdater('chatMessages', '/chat/receive_chat',
+ {
+ method: 'get',
+ //parameters: {lId: $$('div:[class=chatMessage]')[$$('div:[class=chatMessage]').length-1].title},
+ //insertion:Insertion.Bottom,
+ frequency: 5,
+ decay: 1,
+ onSuccess: function(){window.setTimeout('refreshScroll()','50');}
+ });
+//"<div class='chatMessage'><b>Josh</b> <span style='font-size: 10px;'>says</span> <div class='chatTime'>"+t+"</div><div>" + Message+"</div></div>";
+}
+function refreshScroll()
+{
+ $('chatMessages').scrollTop = $('chatMessages').scrollHeight;
+}
+</script>
+<% end %>
+
+</head>
+<body onload="$('chatArea').hide();" class="<%= body_css_classes %>">
+<div id="wrapper">
+<div id="wrapper2">
+<div id="top-menu">
+ <div id="account">
+ <%= render_menu :account_menu -%>
+ </div>
+ <%= content_tag('div', "#{l(:label_logged_as)} #{link_to_user(User.current, :format => :username)}", :id => 'loggedas') if User.current.logged? %>
+ <%= render_menu :top_menu -%>
+</div>
+
+<div id="header">
+ <div id="quick-search">
+ <% form_tag({:controller => 'search', :action => 'index', :id => @project}, :method => :get ) do %>
+ <%= hidden_field_tag(controller.default_search_scope, 1, :id => nil) if controller.default_search_scope %>
+ <%= link_to l(:label_search), {:controller => 'search', :action => 'index', :id => @project}, :accesskey => accesskey(:search) %>:
+ <%= text_field_tag 'q', @question, :size => 20, :class => 'small', :accesskey => accesskey(:quick_search) %>
+ <% end %>
+ <%= render_project_jump_box %>
+ </div>
+
+ <h1><%= page_header_title %></h1>
+
+ <% if display_main_menu?(@project) %>
+ <div id="main-menu">
+ <%= render_main_menu(@project) %>
+ </div>
+ <% end %>
+</div>
+
+<%= tag('div', {:id => 'main', :class => (has_content?(:sidebar) ? '' : 'nosidebar')}, true) %>
+ <div id="sidebar">
+ <%= yield :sidebar %>
+ <%= call_hook :view_layouts_base_sidebar %>
+ </div>
+
+ <div id="content">
+ <%= render_flash_messages %>
+ <%= yield %>
+ <%= call_hook :view_layouts_base_content %>
+ <div style="clear:both;"></div>
+ </div>
+</div>
+
+<div id="ajax-indicator" style="display:none;"><span><%= l(:label_loading) %></span></div>
+
+<div id="footer">
+ <div class="bgl"><div class="bgr">
+ Powered by <%= link_to Redmine::Info.app_name, Redmine::Info.url %> &copy; 2006-2010 Jean-Philippe Lang - Enhanced
+ </div></div>
+</div>
+</div>
+</div>
+<%= call_hook :view_layouts_base_body_bottom %>
+
+<%
+ numOnline=""
+%>
+
+<div id="chatFooter" onclick="toggleChat();">Chat (<%= numOnline %>) </div>
+<div id="chatArea">
+<div id="chatMessages" class="chatMessage" title="0">This is a work in progress <%= User.current.logged? %>, just ignore it for now.</div>
+<input type="text" id="txtMsg" style="width:100%; padding:5px; color: #220022;" />
+</div>
+
+
+<script>init();</script>
+</body>
+</html>
@@ -0,0 +1,3 @@
+# English strings go here for Rails i18n
+en:
+ my_label: "My label"
@@ -0,0 +1,13 @@
+class CreateChats < ActiveRecord::Migration
+ def self.up
+ create_table :chats do |t|
+ t.column :message, :string
+ t.column :user, :integer
+ t.column :sendDate, :timestamp
+ end
+ end
+
+ def self.down
+ drop_table :chats
+ end
+end
@@ -0,0 +1,8 @@
+require 'redmine'
+
+Redmine::Plugin.register :redmine_j_chat do
+ name 'Redmine JChat'
+ author 'Joshua Enfield'
+ description 'Provides a team chat similiar to Google\'s/Facebooks chat.'
+ version '0.0.1'
+end
@@ -0,0 +1,2 @@
+# English strings go here
+my_label: "My label"
@@ -0,0 +1,11 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+one:
+ id: 1
+ message: MyString
+ user: 1
+ sendDate: 2010-10-22 11:44:28
+two:
+ id: 2
+ message: MyString
+ user: 1
+ sendDate: 2010-10-22 11:44:28
@@ -0,0 +1,8 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class ChatControllerTest < ActionController::TestCase
+ # Replace this with your real tests.
+ def test_truth
+ assert true
+ end
+end
Oops, something went wrong.

0 comments on commit e598f16

Please sign in to comment.