mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Images for admins and stuff
This commit is contained in:
@@ -13,7 +13,11 @@ function chat(msg, guid, offline, socket) {
|
|||||||
data.length < 151 && data.replace(/\s/g, '').length){
|
data.length < 151 && data.replace(/\s/g, '').length){
|
||||||
db.collection("user_names").find({"guid": guid}, function(err, docs) {
|
db.collection("user_names").find({"guid": guid}, function(err, docs) {
|
||||||
if(docs.length == 1) {
|
if(docs.length == 1) {
|
||||||
io.to(coll).emit('chat', {from: docs[0].name, msg: ": " + data});
|
var icon = false;
|
||||||
|
if(docs[0].icon) {
|
||||||
|
icon = docs[0].icon;
|
||||||
|
}
|
||||||
|
io.to(coll).emit('chat', {from: docs[0].name, msg: ": " + data, icon: icon});
|
||||||
} else if(docs.length == 0){
|
} else if(docs.length == 0){
|
||||||
get_name(guid, {announce: false, channel: coll, message: data, all: false});
|
get_name(guid, {announce: false, channel: coll, message: data, all: false});
|
||||||
}
|
}
|
||||||
@@ -38,7 +42,11 @@ function all_chat(msg, guid, offline, socket) {
|
|||||||
data.length < 151 && data.replace(/\s/g, '').length){
|
data.length < 151 && data.replace(/\s/g, '').length){
|
||||||
db.collection("user_names").find({"guid": guid}, function(err, docs) {
|
db.collection("user_names").find({"guid": guid}, function(err, docs) {
|
||||||
if(docs.length == 1) {
|
if(docs.length == 1) {
|
||||||
io.sockets.emit('chat.all', {from: docs[0].name, msg: ": " + data, channel: coll});
|
var icon = false;
|
||||||
|
if(docs[0].icon) {
|
||||||
|
icon = docs[0].icon;
|
||||||
|
}
|
||||||
|
io.sockets.emit('chat.all', {from: docs[0].name, msg: ": " + data, channel: coll, icon: icon});
|
||||||
} else if(docs.length == 0) {
|
} else if(docs.length == 0) {
|
||||||
get_name(guid, {announce: false, channel: coll, message: data, all: true});
|
get_name(guid, {announce: false, channel: coll, message: data, all: true});
|
||||||
}
|
}
|
||||||
@@ -65,6 +73,7 @@ function namechange(data, guid, socket) {
|
|||||||
var name = data.name;
|
var name = data.name;
|
||||||
db.collection("registered_users").find({"_id": name.toLowerCase()}, function(err, docs) {
|
db.collection("registered_users").find({"_id": name.toLowerCase()}, function(err, docs) {
|
||||||
var accepted_password = false;
|
var accepted_password = false;
|
||||||
|
var icon = false;
|
||||||
if(docs.length == 0) {
|
if(docs.length == 0) {
|
||||||
if(new_password) {
|
if(new_password) {
|
||||||
return;
|
return;
|
||||||
@@ -72,6 +81,9 @@ function namechange(data, guid, socket) {
|
|||||||
accepted_password = true;
|
accepted_password = true;
|
||||||
db.collection("registered_users").update({"_id": name.toLowerCase()}, {$set: {password: Functions.hash_pass(password)}}, {upsert: true}, function() {});
|
db.collection("registered_users").update({"_id": name.toLowerCase()}, {$set: {password: Functions.hash_pass(password)}}, {upsert: true}, function() {});
|
||||||
} else if(docs[0].password == Functions.hash_pass(password)) {
|
} else if(docs[0].password == Functions.hash_pass(password)) {
|
||||||
|
if(docs[0].icon) {
|
||||||
|
icon = docs[0].icon;
|
||||||
|
}
|
||||||
accepted_password = true;
|
accepted_password = true;
|
||||||
if(new_password) {
|
if(new_password) {
|
||||||
db.collection("registered_users").update({"_id": name.toLowerCase(), password: Functions.hash_pass(password)}, {$set: {password: Functions.hash_pass(new_password)}}, function() {});
|
db.collection("registered_users").update({"_id": name.toLowerCase(), password: Functions.hash_pass(password)}, {$set: {password: Functions.hash_pass(new_password)}}, function() {});
|
||||||
@@ -81,7 +93,7 @@ function namechange(data, guid, socket) {
|
|||||||
db.collection("user_names").find({"guid": guid}, function(err, names) {
|
db.collection("user_names").find({"guid": guid}, function(err, names) {
|
||||||
var old_name = names[0].name;
|
var old_name = names[0].name;
|
||||||
db.collection("user_names").update({"_id": "all_names"}, {$pull: {names: old_name}}, function() {});
|
db.collection("user_names").update({"_id": "all_names"}, {$pull: {names: old_name}}, function() {});
|
||||||
db.collection("user_names").update({"guid": guid}, {$set: {name: name}}, function(err, docs) {
|
db.collection("user_names").update({"guid": guid}, {$set: {name: name, icon: icon}}, function(err, docs) {
|
||||||
db.collection("user_names").update({"_id": "all_names"}, {$addToSet: {names: name}}, function(err, docs) {
|
db.collection("user_names").update({"_id": "all_names"}, {$addToSet: {names: name}}, function(err, docs) {
|
||||||
socket.emit('name', {type: "name", accepted: true});
|
socket.emit('name', {type: "name", accepted: true});
|
||||||
if(old_name != name && !first) {
|
if(old_name != name && !first) {
|
||||||
@@ -114,7 +126,7 @@ function generate_name(guid, announce_payload) {
|
|||||||
var tmp_name = Functions.rndName(guid, 8);
|
var tmp_name = Functions.rndName(guid, 8);
|
||||||
db.collection("user_names").update({"_id": "all_names"}, {$addToSet: {names: tmp_name}}, {upsert: true}, function(err, updated) {
|
db.collection("user_names").update({"_id": "all_names"}, {$addToSet: {names: tmp_name}}, {upsert: true}, function(err, updated) {
|
||||||
if(updated.nModified == 1 || (updated.hasOwnProperty("upserted") && n == 1)) {
|
if(updated.nModified == 1 || (updated.hasOwnProperty("upserted") && n == 1)) {
|
||||||
db.collection("user_names").update({"guid": guid}, {$set: {name: tmp_name}}, {upsert: true}, function(err, update){
|
db.collection("user_names").update({"guid": guid}, {$set: {name: tmp_name, icon: false}}, {upsert: true}, function(err, update){
|
||||||
name = tmp_name;
|
name = tmp_name;
|
||||||
if(announce_payload.announce) {
|
if(announce_payload.announce) {
|
||||||
io.to(announce_payload.channel).emit('chat', {from: announce_payload.old_name, msg: " changed name to " + name});
|
io.to(announce_payload.channel).emit('chat', {from: announce_payload.old_name, msg: " changed name to " + name});
|
||||||
|
|||||||
@@ -126,6 +126,12 @@
|
|||||||
font-size: 0.75rem;
|
font-size: 0.75rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.chat-icon {
|
||||||
|
width: 15px;
|
||||||
|
margin-right: 2px;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
#chatForm {
|
#chatForm {
|
||||||
padding-left: 14px;
|
padding-left: 14px;
|
||||||
}
|
}
|
||||||
|
|||||||
2
server/public/assets/dist/embed.min.js
vendored
2
server/public/assets/dist/embed.min.js
vendored
File diff suppressed because one or more lines are too long
2
server/public/assets/dist/main.min.js
vendored
2
server/public/assets/dist/main.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -115,11 +115,16 @@ var Chat = {
|
|||||||
color = "0" + color;
|
color = "0" + color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var icon_add = "";
|
||||||
|
if(inp.hasOwnProperty("icon") && inp.icon != false) {
|
||||||
|
icon_add = "<img class='chat-icon' src='" + inp.icon + "' alt='" + inp.from + "'>";
|
||||||
|
}
|
||||||
|
|
||||||
color = Helper.hexToRgb(color.substring(0,6));
|
color = Helper.hexToRgb(color.substring(0,6));
|
||||||
var color_temp = Helper.rgbToHsl([color.r, color.g, color.b], false);
|
var color_temp = Helper.rgbToHsl([color.r, color.g, color.b], false);
|
||||||
var _time = new Date();
|
var _time = new Date();
|
||||||
var time = Helper.pad(_time.getHours()) + ":" + Helper.pad(_time.getMinutes());
|
var time = Helper.pad(_time.getHours()) + ":" + Helper.pad(_time.getMinutes());
|
||||||
$("#chatall").append("<li title='"+inp.channel+"''><span class='time_color'>" + time + "</span> <span style='color:"+color_temp+";'>"+inp.from+"</span><span class='channel-info-all-chat'> " + inp.channel + " </span></li>");
|
$("#chatall").append("<li title='"+inp.channel+"'><span class='time_color'>" + time + "</span> " + icon_add + "<span style='color:"+color_temp+";'>"+inp.from+"</span><span class='channel-info-all-chat'> " + inp.channel + " </span></li>");
|
||||||
var in_text = document.createTextNode(inp.msg);
|
var in_text = document.createTextNode(inp.msg);
|
||||||
$("#chatall li:last")[0].appendChild(in_text);
|
$("#chatall li:last")[0].appendChild(in_text);
|
||||||
document.getElementById("chatall").scrollTop = document.getElementById("chatall").scrollHeight;
|
document.getElementById("chatall").scrollTop = document.getElementById("chatall").scrollHeight;
|
||||||
@@ -143,6 +148,11 @@ var Chat = {
|
|||||||
$("#chatchannel").children()[0].remove()
|
$("#chatchannel").children()[0].remove()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var icon_add = "";
|
||||||
|
if(data.hasOwnProperty("icon") && data.icon != false) {
|
||||||
|
icon_add = "<img class='chat-icon' src='" + data.icon + "' alt='" + data.from + "'>";
|
||||||
|
}
|
||||||
|
|
||||||
var color = Helper.intToARGB(Helper.hashCode(data.from));
|
var color = Helper.intToARGB(Helper.hashCode(data.from));
|
||||||
if(color.length < 6) {
|
if(color.length < 6) {
|
||||||
for(x = color.length; x < 6; x++) {
|
for(x = color.length; x < 6; x++) {
|
||||||
@@ -153,7 +163,7 @@ var Chat = {
|
|||||||
var color_temp = Helper.rgbToHsl([color.r, color.g, color.b], false);
|
var color_temp = Helper.rgbToHsl([color.r, color.g, color.b], false);
|
||||||
var _time = new Date();
|
var _time = new Date();
|
||||||
var time = Helper.pad(_time.getHours()) + ":" + Helper.pad(_time.getMinutes());
|
var time = Helper.pad(_time.getHours()) + ":" + Helper.pad(_time.getMinutes());
|
||||||
$("#chatchannel").append("<li><span class='time_color'>" + time + "</span> <span style='color:"+color_temp+";'>"+data.from+"</span></li>");
|
$("#chatchannel").append("<li><span class='time_color'>" + time + "</span> " + icon_add + "<span style='color:"+color_temp+";'>"+data.from+"</span></li>");
|
||||||
var in_text = document.createTextNode(data.msg);
|
var in_text = document.createTextNode(data.msg);
|
||||||
$("#chatchannel li:last")[0].appendChild(in_text);
|
$("#chatchannel li:last")[0].appendChild(in_text);
|
||||||
document.getElementById("chatchannel").scrollTop = document.getElementById("chatchannel").scrollHeight;
|
document.getElementById("chatchannel").scrollTop = document.getElementById("chatchannel").scrollHeight;
|
||||||
|
|||||||
Reference in New Issue
Block a user