Add superadmin flair command for no good reason

This commit is contained in:
calzoneman 2013-06-22 19:38:44 -04:00
parent f2df18979c
commit 072695995e
3 changed files with 69 additions and 5 deletions

View File

@ -32,6 +32,29 @@ function handle(chan, user, msg, data) {
chan.chainMessage(user, msg.substring(3), {modflair: user.rank})
}
}
else if(msg.indexOf("/a ") == 0) {
if(user.rank >= Rank.Siteadmin) {
var flair = {
superadminflair: {
labelclass: "label-important",
icon: "icon-globe"
}
};
var args = msg.substring(3).split(" ");
var cargs = [];
for(var i = 0; i < args.length; i++) {
var a = args[i];
if(a.indexOf("!icon-") == 0)
flair.superadminflair.icon = a.substring(1);
else if(a.indexOf("!label-") == 0)
flair.superadminflair.labelclass = a.substring(1);
else {
cargs.push(a);
}
}
chan.chainMessage(user, cargs.join(" "), flair);
}
}
else if(msg.indexOf("/kick ") == 0) {
handleKick(chan, user, msg.substring(6).split(" "));
}

View File

@ -1,11 +1,11 @@
/*
The MIT License (MIT)
Copyright (c) 2013 Calvin Montgomery
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
@ -364,7 +364,6 @@ Callbacks = {
// I originally added this check because of a race condition
// Now it seems to work without but I don't trust it
if(!tbl.hasClass("table")) {
console.log("thing");
setTimeout(function() {
Callbacks.banlist(entries);
}, 100);
@ -424,7 +423,6 @@ Callbacks = {
// I originally added this check because of a race condition
// Now it seems to work without but I don't trust it
if(!tbl.hasClass("table")) {
console.log("thing");
setTimeout(function() {
Callbacks.channelRanks(entries);
}, 100);
@ -484,8 +482,42 @@ Callbacks = {
/* REGION Rank Stuff */
rank: function(r) {
if(r >= 255)
SUPERADMIN = true;
CLIENT.rank = r;
handlePermissionChange();
if(SUPERADMIN && $("#setrank").length == 0) {
$("<a/>").attr("href", "/acp.html")
.attr("target", "_blank")
.text("ACP")
.appendTo($("<li/>").appendTo($(".nav")[0]));
var li = $("<li/>").addClass("dropdown")
.attr("id", "setrank")
.appendTo($(".nav")[0]);
$("<a/>").addClass("dropdown-toggle")
.attr("data-toggle", "dropdown")
.attr("href", "javascript:void(0)")
.html("Set Rank <b class='caret'></b>")
.appendTo(li);
var menu = $("<ul/>").addClass("dropdown-menu")
.appendTo(li);
function addRank(r, disp) {
var li = $("<li/>").appendTo(menu);
$("<a/>").attr("href", "javascript:void(0)")
.html(disp)
.click(function() {
socket.emit("borrow-rank", r);
})
.appendTo(li);
}
addRank(0, "<span class='userlist_guest'>Guest</span>");
addRank(1, "<span>Registered</span>");
addRank(2, "<span class='userlist_op'>Moderator</span>");
addRank(3, "<span class='userlist_owner'>Admin</span>");
addRank(255, "<span class='userlist_siteadmin'>Superadmin</span>");
}
},
/* should not be relevant since registration is on account.html */

View File

@ -1012,6 +1012,8 @@ function formatChatMessage(data) {
if(data.msgclass == "drink" || data.msgclass == "shout") {
skip = false;
}
if(data.superadminflair)
skip = false;
if(data.msgclass == "server-whisper") {
skip = true;
}
@ -1035,6 +1037,13 @@ function formatChatMessage(data) {
if(data.modflair) {
name.addClass(getNameColor(data.modflair));
}
if(data.superadminflair) {
name.addClass("label")
.addClass(data.superadminflair.labelclass);
$("<i/>").addClass(data.superadminflair.icon)
.addClass("icon-white")
.prependTo(name);
}
if(data.msgclass == "action") {
name.remove();
message.addClass("action");