mirror of https://github.com/calzoneman/sync.git
Work on user ranks
This commit is contained in:
parent
9306200a87
commit
2fadd70297
|
@ -1404,7 +1404,6 @@ Channel.prototype.handleQueue = function (user, data) {
|
||||||
maxlength: this.hasPermission(user, "exceedmaxlength") ? 0 : this.opts.maxlength
|
maxlength: this.hasPermission(user, "exceedmaxlength") ? 0 : this.opts.maxlength
|
||||||
}, function (err, media) {
|
}, function (err, media) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
|
||||||
user.socket.emit("queueFail", {
|
user.socket.emit("queueFail", {
|
||||||
msg: err,
|
msg: err,
|
||||||
link: link
|
link: link
|
||||||
|
@ -2539,20 +2538,42 @@ Channel.prototype.handleSetRank = function (user, data) {
|
||||||
|
|
||||||
var updateDB = function () {
|
var updateDB = function () {
|
||||||
self.getRank(name, function (err, oldrank) {
|
self.getRank(name, function (err, oldrank) {
|
||||||
if (self.dead || err) {
|
if (self.dead) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (err) {
|
||||||
|
user.socket.emit("channelRankFail", {
|
||||||
|
msg: "Updating user rank failed: " + err
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldrank >= user.rank) {
|
if (oldrank >= user.rank) {
|
||||||
|
user.socket.emit("channelRankFail", {
|
||||||
|
msg: "Updating user rank failed: " + name + " has equal or higher " +
|
||||||
|
"rank than you"
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
db.channels.setRank(self.name, name, rank, function (err, res) {
|
db.channels.setRank(self.name, name, rank, function (err, res) {
|
||||||
if (self.dead || err) {
|
if (self.dead) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (err) {
|
||||||
|
user.socket.emit("channelRankFail", {
|
||||||
|
msg: "Updating user rank failed: " + err
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.logger.log("*** " + user.name + " set " + name + "'s rank to " + rank);
|
self.logger.log("*** " + user.name + " set " + name + "'s rank to " + rank);
|
||||||
|
self.sendAll("setUserRank", {
|
||||||
|
name: name,
|
||||||
|
rank: rank
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -2565,11 +2586,6 @@ Channel.prototype.handleSetRank = function (user, data) {
|
||||||
if (receiver.loggedIn) {
|
if (receiver.loggedIn) {
|
||||||
updateDB();
|
updateDB();
|
||||||
}
|
}
|
||||||
|
|
||||||
self.sendAll("setUserRank", {
|
|
||||||
name: name,
|
|
||||||
rank: rank
|
|
||||||
});
|
|
||||||
} else if (self.registered) {
|
} else if (self.registered) {
|
||||||
updateDB();
|
updateDB();
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,7 +167,7 @@ html(lang="en")
|
||||||
li: a(href="#cs-motdeditor", data-toggle="tab", tabindex="-1") Edit MOTD
|
li: a(href="#cs-motdeditor", data-toggle="tab", tabindex="-1") Edit MOTD
|
||||||
li: a(href="#cs-csseditor", data-toggle="tab", tabindex="-1") Edit CSS
|
li: a(href="#cs-csseditor", data-toggle="tab", tabindex="-1") Edit CSS
|
||||||
li: a(href="#cs-jseditor", data-toggle="tab", tabindex="-1") Edit Javascript
|
li: a(href="#cs-jseditor", data-toggle="tab", tabindex="-1") Edit Javascript
|
||||||
li: a(href="#cs-chanranks", data-toggle="tab", tabindex="-1", onclick="javascript:socket.emit('requestChannelRanks')") Edit user ranks
|
li: a(href="#cs-chanranks", data-toggle="tab", tabindex="-1", onclick="javascript:socket.emit('requestChannelRanks')") Edit moderators
|
||||||
li: a(href="#cs-banlist", data-toggle="tab", tabindex="-1", onclick="javascript:socket.emit('requestBanlist')") Ban list
|
li: a(href="#cs-banlist", data-toggle="tab", tabindex="-1", onclick="javascript:socket.emit('requestBanlist')") Ban list
|
||||||
.modal-body
|
.modal-body
|
||||||
.tab-content
|
.tab-content
|
||||||
|
|
|
@ -92,6 +92,12 @@ mixin recentjoins
|
||||||
|
|
||||||
mixin chanranks
|
mixin chanranks
|
||||||
#cs-chanranks.tab-pane
|
#cs-chanranks.tab-pane
|
||||||
|
form.form-inline(action="javascript:void(0)", role="form")
|
||||||
|
.input-group
|
||||||
|
input#cs-chanranks-name.form-control(type="text", placeholder="Name")
|
||||||
|
span.input-group-btn
|
||||||
|
button#cs-chanranks-mod.btn.btn-success +Mod
|
||||||
|
button#cs-chanranks-adm.btn.btn-info +Admin
|
||||||
table.table.table-striped
|
table.table.table-striped
|
||||||
thead
|
thead
|
||||||
tr
|
tr
|
||||||
|
|
|
@ -505,7 +505,7 @@ Callbacks = {
|
||||||
});
|
});
|
||||||
|
|
||||||
entries.forEach(function (entry) {
|
entries.forEach(function (entry) {
|
||||||
var tr = $("<tr/>");
|
var tr = $("<tr/>").addClass("cs-chanrank-tr-" + entry.name);
|
||||||
var name = $("<td/>").text(entry.name).appendTo(tr);
|
var name = $("<td/>").text(entry.name).appendTo(tr);
|
||||||
name.addClass(getNameColor(entry.rank));
|
name.addClass(getNameColor(entry.rank));
|
||||||
var rankwrap = $("<td/>");
|
var rankwrap = $("<td/>");
|
||||||
|
@ -523,6 +523,7 @@ Callbacks = {
|
||||||
rankedit.hide();
|
rankedit.hide();
|
||||||
rank.hide();
|
rank.hide();
|
||||||
editbox = $("<input/>").addClass("form-control")
|
editbox = $("<input/>").addClass("form-control")
|
||||||
|
.attr("type", "text")
|
||||||
.attr("placeholder", entry.rank)
|
.attr("placeholder", entry.rank)
|
||||||
.appendTo(rankwrap)
|
.appendTo(rankwrap)
|
||||||
.focus();
|
.focus();
|
||||||
|
@ -553,6 +554,10 @@ Callbacks = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
channelRankFail: function (data) {
|
||||||
|
makeAlert("Error", data.msg, "alert-danger").prependTo($("#cs-chanranks"));
|
||||||
|
},
|
||||||
|
|
||||||
setChannelRank: function(data) {
|
setChannelRank: function(data) {
|
||||||
var ents = $("#channelranks").data("entries");
|
var ents = $("#channelranks").data("entries");
|
||||||
if(typeof ents === "undefined" || ents === null)
|
if(typeof ents === "undefined" || ents === null)
|
||||||
|
@ -752,6 +757,11 @@ Callbacks = {
|
||||||
},
|
},
|
||||||
|
|
||||||
setUserRank: function (data) {
|
setUserRank: function (data) {
|
||||||
|
var tr = $(".cs-chanrank-tr-" + data.name);
|
||||||
|
var tds = tr.find("td");
|
||||||
|
$(tds[0]).removeClass().addClass(getNameColor(data.rank));
|
||||||
|
$(tds[1]).find("span").text(data.rank);
|
||||||
|
|
||||||
var user = findUserlistItem(data.name);
|
var user = findUserlistItem(data.name);
|
||||||
if (user === null) {
|
if (user === null) {
|
||||||
return;
|
return;
|
||||||
|
@ -764,8 +774,9 @@ Callbacks = {
|
||||||
}
|
}
|
||||||
formatUserlistItem(user);
|
formatUserlistItem(user);
|
||||||
addUserDropdown(user);
|
addUserDropdown(user);
|
||||||
if(USEROPTS.sort_rank)
|
if (USEROPTS.sort_rank) {
|
||||||
sortUserlist();
|
sortUserlist();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
setUserIcon: function (data) {
|
setUserIcon: function (data) {
|
||||||
|
|
|
@ -490,3 +490,22 @@ if (location.protocol === "https:") {
|
||||||
makeAlert(title, text, "alert-warning")
|
makeAlert(title, text, "alert-warning")
|
||||||
.appendTo($("#announcements"));
|
.appendTo($("#announcements"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* channel ranks stuff */
|
||||||
|
$("#cs-chanranks-mod").click(function () {
|
||||||
|
var name = $("#cs-chanranks-name").val();
|
||||||
|
var rank = 2;
|
||||||
|
socket.emit("setChannelRank", {
|
||||||
|
user: name,
|
||||||
|
rank: rank
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#cs-chanranks-adm").click(function () {
|
||||||
|
var name = $("#cs-chanranks-name").val();
|
||||||
|
var rank = 3;
|
||||||
|
socket.emit("setChannelRank", {
|
||||||
|
user: name,
|
||||||
|
rank: rank
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue