diff --git a/channel.js b/channel.js index 8cdb474b..a261fe4d 100644 --- a/channel.js +++ b/channel.js @@ -819,6 +819,21 @@ Channel.prototype.tryMove = function(user, data) { /* REGION Polls */ +Channel.prototype.tryOpenPoll = function(user, data) { + if(!Rank.hasPermission(user, "poll") && this.leader != user) { + return; + } + + if(!data.title || !data.opts) { + return; + } + + var poll = new Poll(user.name, data.title, data.opts); + this.poll = poll; + this.broadcastPoll(); + this.logger.log("*** " + user.name + " Opened Poll: '" + poll.title + "'"); +} + Channel.prototype.tryClosePoll = function(user) { if(!Rank.hasPermission(user, "poll") && this.leader != user) { return; diff --git a/user.js b/user.js index c9de7bf7..d6de6ce2 100644 --- a/user.js +++ b/user.js @@ -101,6 +101,12 @@ User.prototype.initCallbacks = function() { } }.bind(this)); + this.socket.on("newPoll", function(data) { + if(this.channel != null) { + this.channel.tryOpenPoll(this, data); + } + }.bind(this)); + this.socket.on("playerReady", function() { if(this.channel != null) { this.channel.sendMediaUpdate(this); diff --git a/www/assets/js/client.js b/www/assets/js/client.js index 09fe46c3..36342c70 100644 --- a/www/assets/js/client.js +++ b/www/assets/js/client.js @@ -213,9 +213,15 @@ $("#register").click(function() { $("#chatline").keydown(function(ev) { if(ev.keyCode == 13 && $("#chatline").val() != "") { - socket.emit("chatMsg", { - msg: $("#chatline").val() - }); + if($("#chatline").val().trim() == "/poll") { + newPollMenu(); + $("#chatline").val(""); + } + else { + socket.emit("chatMsg", { + msg: $("#chatline").val() + }); + } CHATHIST.push($("#chatline").val()); if(CHATHIST.length > 10) CHATHIST.shift(); diff --git a/www/assets/js/functions.js b/www/assets/js/functions.js index b76fd7bb..2a5c041b 100644 --- a/www/assets/js/functions.js +++ b/www/assets/js/functions.js @@ -730,3 +730,68 @@ function enableBerrymotes() { monkeyPatchChat(); }); } + +function newPollMenu() { + var modal = $("
").addClass("modal hide fade") + .appendTo($("body")); + var head = $("
").addClass("modal-header") + .appendTo(modal); + $("
+ +
/poll
(no parameters) + Moderators + A poll editor is popped up allowing for easy creation of the poll, and allowing commas in the poll title and options +

There are also some other chat features. When your name appears in a message, the message will be highlighted. If you type the beginning of someone's name in chat, pressing tab will attempt to autocomplete the name.