mirror of
https://github.com/fergalmoran/dss.git
synced 2026-01-03 15:34:00 +00:00
Changed chat to use logged in user.
This commit is contained in:
@@ -49,7 +49,7 @@ var AppRouter = Backbone.Router.extend({
|
||||
$('#site-content-fill').html('');
|
||||
this.sidebarView = new SidebarView();
|
||||
$('#sidebar').html(this.sidebarView.el);
|
||||
startChat($('#chat-messages', this.sidebarView.el), $('#input', this.sidebarView.el), $('#status', this.sidebarView.el));
|
||||
startChat($('#chat-messages', this.sidebarView.el), $('#input', this.sidebarView.el), $('#status', this.sidebarView.el), "Fergal Moran");
|
||||
|
||||
var data = type != undefined ? $.param({sort:type}) : null;
|
||||
mixList.fetch({
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
function startChat(content, input, status) {
|
||||
function startChat(content, input, status, user) {
|
||||
"use strict";
|
||||
|
||||
// for better performance - to avoid searching in DOM
|
||||
@@ -24,7 +24,12 @@ function startChat(content, input, status) {
|
||||
connection.onopen = function () {
|
||||
// first we want users to enter their names
|
||||
input.removeAttr('disabled');
|
||||
status.text('Choose name:');
|
||||
if (user) {
|
||||
myName = user;
|
||||
connection.send(user);
|
||||
} else {
|
||||
status.text('Choose name:');
|
||||
}
|
||||
};
|
||||
|
||||
connection.onerror = function (error) {
|
||||
@@ -109,7 +114,7 @@ function startChat(content, input, status) {
|
||||
function addMessage(author, message, color, dt) {
|
||||
content.append(
|
||||
'<tr><td style="color:' + color + '">' + author + '</td> <td>@ ' + +(dt.getHours() < 10 ? '0' + dt.getHours() : dt.getHours()) + ':'
|
||||
+ (dt.getMinutes() < 10 ? '0' + dt.getMinutes() : dt.getMinutes()) + "</td></tr>"
|
||||
+ '<tr><td colspan="2">' + message + '</td></tr>');
|
||||
+ (dt.getMinutes() < 10 ? '0' + dt.getMinutes() : dt.getMinutes()) + "</td></tr>"
|
||||
+ '<tr><td colspan="2">' + message + '</td></tr>');
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
<div id="chat-area">
|
||||
<span id="status">Connecting...</span>
|
||||
<input type="text" id="input" disabled="disabled"/>
|
||||
</div>
|
||||
<table id="chat-messages" class="table table-striped table-condensed table-hover">
|
||||
|
||||
</table>
|
||||
{% if user.is_authenticated %}
|
||||
<div id="chat-area">
|
||||
<span id="status">Connecting...</span>
|
||||
<input type="text" id="input" disabled="disabled"/>
|
||||
</div>
|
||||
<table id="chat-messages" class="table table-striped table-condensed table-hover">
|
||||
|
||||
</table>
|
||||
{% else %}
|
||||
<h3>Please <a href="/accounts/login/">login</a> to chat..</h3>
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user