mirror of https://github.com/calzoneman/sync.git
Add /say and global announcements
This commit is contained in:
parent
755c4f49fd
commit
c50dbece97
|
@ -6,6 +6,11 @@ function handle(chan, user, msg) {
|
|||
chan.sendMessage(user.name, msg.substring(4), "action");
|
||||
else if(msg.indexOf("/sp ") == 0)
|
||||
chan.sendMessage(user.name, msg.substring(4), "spoiler");
|
||||
else if(msg.indexOf("/say ") == 0) {
|
||||
if(Rank.hasPermission(user, "shout")) {
|
||||
chan.sendMessage(user.name, msg.substring(5), "shout");
|
||||
}
|
||||
}
|
||||
else if(msg.indexOf("/kick ") == 0) {
|
||||
handleKick(chan, user, msg.substring(6).split(' '));
|
||||
}
|
||||
|
|
22
rank.js
22
rank.js
|
@ -13,16 +13,18 @@ exports.Owner = 3;
|
|||
exports.Siteadmin = 255;
|
||||
|
||||
var permissions = {
|
||||
acp: exports.Siteadmin,
|
||||
registerChannel: exports.Owner,
|
||||
queue: exports.Moderator,
|
||||
assignLeader: exports.Moderator,
|
||||
kick: exports.Moderator,
|
||||
promote: exports.Moderator,
|
||||
qlock: exports.Moderator,
|
||||
poll: exports.Moderator,
|
||||
search: exports.Guest,
|
||||
chat: exports.Guest,
|
||||
acp : exports.Siteadmin,
|
||||
announce : exports.Siteadmin,
|
||||
registerChannel : exports.Owner,
|
||||
queue : exports.Moderator,
|
||||
assignLeader : exports.Moderator,
|
||||
kick : exports.Moderator,
|
||||
promote : exports.Moderator,
|
||||
qlock : exports.Moderator,
|
||||
poll : exports.Moderator,
|
||||
shout : exports.Moderator,
|
||||
search : exports.Guest,
|
||||
chat : exports.Guest,
|
||||
};
|
||||
|
||||
// Check if someone has permission to do shit
|
||||
|
|
15
user.js
15
user.js
|
@ -23,6 +23,9 @@ var User = function(socket, ip) {
|
|||
this.name = "";
|
||||
|
||||
this.initCallbacks();
|
||||
if(Server.announcement != null) {
|
||||
this.socket.emit('announcement', Server.announcement);
|
||||
}
|
||||
};
|
||||
|
||||
// Set up socket callbacks
|
||||
|
@ -182,6 +185,18 @@ User.prototype.initCallbacks = function() {
|
|||
this.handleAdm(data);
|
||||
}
|
||||
}.bind(this));
|
||||
|
||||
this.socket.on('announce', function(data) {
|
||||
if(Rank.hasPermission(this, "announce")) {
|
||||
if(data.clear) {
|
||||
Server.announcement = null;
|
||||
}
|
||||
else {
|
||||
Server.io.sockets.emit('announcement', data);
|
||||
Server.announcement = data;
|
||||
}
|
||||
}
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
// Handle administration
|
||||
|
|
|
@ -56,6 +56,14 @@
|
|||
border-left: 0;
|
||||
}
|
||||
|
||||
#messagebuffer div {
|
||||
white-space: pre-wrap; /* css-3 */
|
||||
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
|
||||
white-space: -pre-wrap; /* Opera 4-6 */
|
||||
white-space: -o-pre-wrap; /* Opera 7 */
|
||||
word-wrap: break-word; /* Internet Explorer 5.5+ */
|
||||
}
|
||||
|
||||
#chatline {
|
||||
width: 456px;
|
||||
}
|
||||
|
@ -71,12 +79,12 @@
|
|||
}
|
||||
|
||||
.userlist_op {
|
||||
color: #00cc00;
|
||||
color: #00aa00;
|
||||
}
|
||||
|
||||
.action {
|
||||
font-style: italic;
|
||||
color: #aaaaaa;
|
||||
color: #888888;
|
||||
}
|
||||
|
||||
.spoiler {
|
||||
|
@ -92,6 +100,12 @@
|
|||
color: #789922; /* Color value directly from 4chan */
|
||||
}
|
||||
|
||||
.shout {
|
||||
color: #ff0000;
|
||||
font-weight: bold;
|
||||
font-size: 18pt;
|
||||
}
|
||||
|
||||
.option button {
|
||||
margin-right: 15px;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,10 @@ function initCallbacks() {
|
|||
showChannelRegistration();
|
||||
});
|
||||
|
||||
socket.on('announcement', function(data) {
|
||||
showAnnouncement(data.title, data.text);
|
||||
});
|
||||
|
||||
socket.on('registerChannel', function(data) {
|
||||
if(data.success) {
|
||||
$('#chregnotice').remove();
|
||||
|
|
|
@ -128,6 +128,8 @@ function formatChatMessage(data) {
|
|||
var name = document.createElement('span');
|
||||
var message = document.createElement('span');
|
||||
name.innerHTML = "<strong><" + data.username + "></strong> ";
|
||||
if(data.msgclass == "shout")
|
||||
$(name).addClass("shout");
|
||||
$(message).addClass(data.msgclass);
|
||||
message.innerHTML = data.msg;
|
||||
div.appendChild(name);
|
||||
|
@ -517,3 +519,13 @@ function showChannelRegistration() {
|
|||
socket.emit('registerChannel');
|
||||
});
|
||||
}
|
||||
|
||||
function showAnnouncement(title, text) {
|
||||
var div = $('<div/>').addClass('alert')
|
||||
.insertAfter($('.row')[0]);
|
||||
$('<button/>').addClass('close pull-right').text('×')
|
||||
.appendTo(div)
|
||||
.click(function() { div.remove(); });
|
||||
$('<h3/>').text(title).appendTo(div);
|
||||
$('<p/>').html(text).appendTo(div);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue