Skip to content
Permalink
Browse files

Color and me

  • Loading branch information...
Depado committed Dec 22, 2014
1 parent f0e7b92 commit f6514f7baabb35202d71edc18359391fb534923b
Showing with 19 additions and 3 deletions.
  1. +5 −0 app.js
  2. +12 −2 static/custom.js
  3. +2 −1 static_data.js
5 app.js
@@ -55,6 +55,11 @@ io.sockets.on('connection', function (socket) {
}
};
var arr = data.split(" ");
if (arr[0] === "/me") {
arr.splice(0, 1);
io.sockets.emit('server-message', socket.username + " " + arr.join(" "));
break;
}
for (var i=0; i<arr.length; i++) {
if (validUrl.isUri(arr[i])){
var re = new RegExp(/\.(jpeg|jpg|gif|png)$/);
@@ -15,6 +15,10 @@ function errorNotify (message) {
}, 2000);
}

function generateRandomColor() {
return '#'+Math.floor(Math.random()*16777215).toString(16);
}

var isActive;
var notify_on_server = false,
notify_on_hl = false,
@@ -25,13 +29,16 @@ window.onblur = function () { isActive = false; };

var selfusername = undefined;

var users = {}

var socket = io.connect(window.location.protocol+'//'+window.location.hostname+':'+window.location.port);

socket.on('updatechat', function (username, data) {
var d = new Date();
$('#conversation').append(
'<li class="left"><div class="chat-body"><p>['
+ d.getHours() + ':' + (d.getMinutes()<10?'0':'') + d.getMinutes() + '] ' + username + ' > ' + data
+ d.getHours() + ':' + (d.getMinutes()<10?'0':'') + d.getMinutes() + '] <span style="color: ' + users[username]['color'] + '">'
+ username + '</span> > ' + data
+ '</p></div></li>'
);
titleNotify(isActive);
@@ -97,7 +104,10 @@ socket.on('error', function (data) {
socket.on('updateusers', function(data) {
$('#users').empty();
$.each(data['usernames'], function(key, value) {
$('#users').append('<div>' + key + '</div>');
if(!(key in users)) {
users[key] = {'color': generateRandomColor()};
}
$('#users').append('<div style="color: '+ users[key]['color'] +'">' + key + '</div>');
});
$('#users').append('<div>Anonymous users : ' + data['anon'] + '</div>');
});
@@ -15,7 +15,8 @@ var emotes = {
'image': '//i.imgur.com/T0OBJQ1.gif'
},
'(pigarmor)': {
'image': '/custom/images/pig-armor.jpg'
'image': '/custom/images/pig-armor.jpg',
'height': '80px'
}
};

0 comments on commit f6514f7

Please sign in to comment.
You can’t perform that action at this time.