diff --git a/auth.js b/auth.js index 8ec8d080..06a9520f 100644 --- a/auth.js +++ b/auth.js @@ -55,7 +55,7 @@ exports.register = function(name, pw) { return false; } var hash = bcrypt.hashSync(pw, 10); - var query = "INSERT INTO registrations VALUES (NULL, '{1}', '{2}', 0)" + var query = "INSERT INTO registrations VALUES (NULL, '{1}', '{2}', 1)" .replace(/\{1\}/, name) .replace(/\{2\}/, hash); var results = db.querySync(query); diff --git a/channel.js b/channel.js index 70e012b9..8cdb474b 100644 --- a/channel.js +++ b/channel.js @@ -999,20 +999,22 @@ Channel.prototype.filterMessage = function(msg) { return msg; } -Channel.prototype.sendMessage = function(username, msg, msgclass) { +Channel.prototype.sendMessage = function(username, msg, msgclass, data) { // I don't want HTML from strangers msg = msg.replace(//g, ">"); msg = this.filterMessage(msg); - this.sendAll("chatMsg", { + var msgobj = { username: username, msg: msg, msgclass: msgclass - }); - this.chatbuffer.push({ - username: username, - msg: msg, - msgclass: msgclass - }); + }; + if(data) { + for(var key in data) { + msgobj[key] = data[key]; + } + } + this.sendAll("chatMsg", msgobj); + this.chatbuffer.push(msgobj); if(this.chatbuffer.length > 15) this.chatbuffer.shift(); this.logger.log("<" + username + "." + msgclass + "> " + msg); diff --git a/chatcommand.js b/chatcommand.js index 92bcf37a..f6aba1e9 100644 --- a/chatcommand.js +++ b/chatcommand.js @@ -23,6 +23,13 @@ function handle(chan, user, msg) { chan.sendMessage(user.name, msg.substring(5), "shout"); } } + else if(msg.indexOf("/m ") == 0) { + if(user.rank >= Rank.Moderator) { + chan.sendMessage(user.name, msg.substring(3), "modflair", { + modflair: user.rank + }); + } + } else if(msg.indexOf("/kick ") == 0) { handleKick(chan, user, msg.substring(6).split(" ")); } diff --git a/www/assets/css/ytsync.css b/www/assets/css/ytsync.css index 101575e8..272b84e4 100644 --- a/www/assets/css/ytsync.css +++ b/www/assets/css/ytsync.css @@ -83,7 +83,7 @@ } .userlist_guest { - color: #aaaaaa; + color: #888888; } .action { diff --git a/www/assets/js/callbacks.js b/www/assets/js/callbacks.js index b4a24d61..57ae0946 100644 --- a/www/assets/js/callbacks.js +++ b/www/assets/js/callbacks.js @@ -178,7 +178,7 @@ function initCallbacks() { var name = users[i].children[1].innerHTML; // Reformat user if(name == data.name) { - fmtUserlistItem(users[i], data.rank, data.leader); + formatUserlistItem(users[i], data.rank, data.leader); } } }); diff --git a/www/assets/js/functions.js b/www/assets/js/functions.js index 6dc14382..b30c0e5f 100644 --- a/www/assets/js/functions.js +++ b/www/assets/js/functions.js @@ -23,7 +23,7 @@ function addUser(name, rank, leader) { var div = $("
").attr("class", "userlist_item"); var flair = $("").appendTo(div); var nametag = $("").text(name).appendTo(div); - fmtUserlistItem(div[0], rank, leader); + formatUserlistItem(div[0], rank, leader); addUserDropdown(div, name); var users = $("#userlist").children(); for(var i = 0; i < users.length; i++) { @@ -37,15 +37,10 @@ function addUser(name, rank, leader) { } // Format a userlist entry based on a person"s rank -function fmtUserlistItem(div, rank, leader) { +function formatUserlistItem(div, rank, leader) { var name = div.children[1]; $(name).removeClass(); - if(rank >= Rank.Siteadmin) - $(name).attr("class", "userlist_siteadmin"); - else if(rank >= Rank.Owner) - $(name).attr("class", "userlist_owner"); - else if(rank >= Rank.Moderator) - $(name).attr("class", "userlist_op"); + $(name).addClass(getNameColor(rank)); var flair = div.children[0]; // denote current leader with a star @@ -57,6 +52,19 @@ function fmtUserlistItem(div, rank, leader) { } } +function getNameColor(rank) { + if(rank >= Rank.Siteadmin) + return "userlist_siteadmin"; + else if(rank >= Rank.Owner) + return "userlist_owner"; + else if(rank >= Rank.Moderator) + return "userlist_op"; + else if(rank == Rank.Guest) + return "userlist_guest"; + else + return ""; +} + // Adds a dropdown with user actions (promote/demote/leader) function addUserDropdown(entry, name) { $(entry).find(".dropdown").remove(); @@ -191,30 +199,24 @@ function formatChatMessage(data) { } } } + var name = $("").appendTo(div); + $("").text("<" + data.username + "> ").appendTo(name); + var message = $("").appendTo(div); + message[0].innerHTML = data.msg; if(data.msgclass == "action") { - var message = $("") - .addClass("action") - .appendTo(div); + name.remove(); + message.addClass("action"); message[0].innerHTML = data.username + " " + data.msg; } - else if(data.msgclass == "drink") { + if(data.msgclass == "drink") { div.addClass("drink"); - var name = $(""); - $("").text("<" + data.username + "> ").appendTo(name); - var message = $(""); - message[0].innerHTML = data.msg; - name.appendTo(div); - message.appendTo(div); } - else { - var name = $(""); - $("").text("<" + data.username + "> ").appendTo(name); - if(data.msgclass == "shout") - name.addClass("shout"); - var message = $("").addClass(data.msgclass); - message[0].innerHTML = data.msg; - name.appendTo(div); - message.appendTo(div); + if(data.msgclass == "shout") { + message.addClass("shout"); + name.addClass("shout"); + } + if(data.modflair) { + name.addClass(getNameColor(data.modflair)); } return div; }