Start working on room passwords

This commit is contained in:
calzoneman 2013-11-25 16:20:15 -06:00
parent 0945fc0d7b
commit d006099fc7
6 changed files with 120 additions and 36 deletions

View file

@ -46,6 +46,9 @@ Callbacks = {
socket.emit("joinChannel", {
name: CHANNEL.name
});
if (CHANNEL.opts.password) {
socket.emit("channelPassword", CHANNEL.opts.password);
}
if(NAME && SESSION) {
socket.emit("login", {
name: NAME,
@ -127,26 +130,44 @@ Callbacks = {
scrollChat();
},
needPassword: function (wrongpw) {
var div = $("<div/>");
$("<strong/>").text("Channel Password")
.appendTo(div);
if (wrongpw) {
$("<br/>").appendTo(div);
$("<span/>").addClass("text-error")
.text("Wrong Password")
.appendTo(div);
}
var pwbox = $("<input/>").addClass("input-block-level")
.attr("type", "password")
.appendTo(div);
var submit = $("<button/>").addClass("btn btn-mini btn-block")
.text("Submit")
.appendTo(div);
var parent = chatDialog(div);
parent.attr("id", "needpw");
var sendpw = function () {
socket.emit("channelPassword", pwbox.val());
parent.remove();
};
submit.click(sendpw);
pwbox.keydown(function (ev) {
if (ev.keyCode == 13) {
sendpw();
}
});
pwbox.focus();
},
cancelNeedPassword: function () {
$("#needpw").remove();
},
chatCooldown: function (time) {
time = time + 200;
/*
var msg = $("#chat-cooldown-msg");
if (msg.length > 0) {
var timer = msg.data("timer");
if (timer) {
clearTimeout(timer);
}
} else {
msg = $("<div/>")
.addClass("server-msg-disconnect")
.attr("id", "chat-cooldown-msg")
.text("Chat rate limit exceeded, please wait before sending another message")
.appendTo($("#messagebuffer"));
}
if (SCROLLCHAT) {
scrollChat();
}
*/
$("#chatline").css("color", "#ff0000");
if (CHATTHROTTLE && $("#chatline").data("throttle_timer")) {
clearTimeout($("#chatline").data("throttle_timer"));
@ -155,12 +176,6 @@ Callbacks = {
$("#chatline").data("throttle_timer", setTimeout(function () {
CHATTHROTTLE = false;
$("#chatline").css("color", "");
/*
msg.remove();
if (SCROLLCHAT) {
scrollChat();
}
*/
}, time));
},

View file

@ -84,6 +84,7 @@
sustained: $("#opt_chat_antiflood_sustained").val()
},
show_public: $("#opt_show_public").prop("checked"),
password: $("#opt_password").val(),
enable_link_regex: $("#opt_enable_link_regex").prop("checked"),
afk_timeout: parseInt($("#opt_afktimeout").val())
});

View file

@ -1010,10 +1010,14 @@ function handleModPermissions() {
$("#opt_externaljs").val(CHANNEL.opts.externaljs);
$("#opt_externaljs").attr("disabled", CLIENT.rank < 3);
$("#opt_chat_antiflood").prop("checked", CHANNEL.opts.chat_antiflood);
$("#opt_chat_antiflood_burst").val(CHANNEL.opts.chat_antiflood_params.burst);
$("#opt_chat_antiflood_sustained").val(CHANNEL.opts.chat_antiflood_params.sustained);
if ("chat_antiflood_parans" in CHANNEL.opts) {
$("#opt_chat_antiflood_burst").val(CHANNEL.opts.chat_antiflood_params.burst);
$("#opt_chat_antiflood_sustained").val(CHANNEL.opts.chat_antiflood_params.sustained);
}
$("#opt_show_public").prop("checked", CHANNEL.opts.show_public);
$("#opt_show_public").attr("disabled", CLIENT.rank < 3);
$("#opt_password").val(CHANNEL.opts.password || "");
$("#opt_password").attr("disabled", CLIENT.rank < 3);
$("#opt_enable_link_regex").prop("checked", CHANNEL.opts.enable_link_regex);
$("#opt_afktimeout").val(CHANNEL.opts.afk_timeout);
$("#opt_allow_voteskip").prop("checked", CHANNEL.opts.allow_voteskip);
@ -1758,6 +1762,22 @@ function unhidePlayer() {
.attr("height", PLAYER.size.height);
}
function chatDialog(div) {
var parent = $("<div/>").addClass("profile-box")
.css("padding", "10px")
.appendTo($("body"));
div.appendTo(parent);
var cw = $("#chatwrap").width();
var ch = $("#chatwrap").height();
var cp = $("#chatwrap").offset();
var x = cp.left + cw/2 - parent.width()/2;
var y = cp.top + ch/2 - parent.height()/2;
parent.css("left", x + "px");
parent.css("top", y + "px");
return parent;
}
function errDialog(err) {
var div = $("<div/>").addClass("profile-box")
.css("padding", "10px")