Nicer names

This commit is contained in:
Nicolas A. Tonne
2015-05-09 03:34:47 +02:00
parent 5f99071325
commit 005d014d16
2 changed files with 23 additions and 3 deletions

View File

@@ -38,7 +38,7 @@ io.on('connection', function(socket){
socket.on('chat', function (data) {
if(data != "" && data !== undefined && data !== null && data.length < 151 && data.replace(/\s/g, '').length)
io.sockets.emit('chat,'+coll, guid + ": " + data);
io.sockets.emit('chat,'+coll, rndName(guid) + ": " + data);
});
socket.on('frontpage_lists', function()
@@ -371,14 +371,14 @@ io.on('connection', function(socket){
{
change_song(coll);
socket.emit("toast", "skip");
io.sockets.emit('chat,'+coll, guid + " skipped");
io.sockets.emit('chat,'+coll, rndName(guid) + " skipped");
}else if(get_time() - docs[0]["startTime"] < 10 && lists[coll].length == 2 && !error)
{
socket.emit("toast", "notyetskip");
}else if(!contains(docs[0]["skips"], guid) && get_time() - docs[0]["startTime"] >= 30){
db.collection(coll).update({views:{$exists:true}}, {$push:{skips:guid}}, function(err, d){
socket.emit("toast", (Math.ceil(lists[coll].length/2) - docs[0]["skips"].length-1) + " more are needed to skip!");
io.sockets.emit('chat,'+coll, guid + " tried to skip!");
io.sockets.emit('chat,'+coll, rndName(guid) + " tried to skip!");
});
}else{
socket.emit("toast", "alreadyskip");
@@ -666,3 +666,19 @@ function contains(a, obj) {
}
return false;
}
function rndName(seed) {
var vowels = ['a', 'e', 'i', 'o', 'u', 'ö'];
consts = ['b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z', 'tt', 'ch', 'sh'];
len = 8;
word = '';
is_vowel = false;
var arr;
for (var i = 0; i < len; i++) {
if (is_vowel) arr = vowels
else arr = consts
is_vowel = !is_vowel;
word += arr[(seed[i%seed.length].charCodeAt()+i) % arr.length-1];
}
return word.substring(0,8)
}

View File

@@ -212,6 +212,10 @@ ul #chat-log{
padding: 0px 0px 0px 11px !important;
}
#chat-log li{
margin-left: 5px;
}
#chat-input{
background-color: rgba(0,0,0,0.1);
}