From 24781df78f8e460f4fe968ce4c7b93fc1fb84868 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Thu, 16 Jan 2014 11:53:34 -0600 Subject: [PATCH] Work on channel settings --- lib/channel-new.js | 8 +- lib/user.js | 4 +- templates/channel.jade | 8 +- templates/channeloptions.jade | 52 ++++++++++-- www/assets/js/callbacks.js | 152 +--------------------------------- www/assets/js/ui.js | 44 +++++++++- www/assets/js/util.js | 75 ++++++++++++++++- www/css/cytube.css | 12 ++- 8 files changed, 187 insertions(+), 168 deletions(-) diff --git a/lib/channel-new.js b/lib/channel-new.js index c6977846..22bf7f67 100644 --- a/lib/channel-new.js +++ b/lib/channel-new.js @@ -954,7 +954,7 @@ Channel.prototype.sendChatFilters = function (users) { return; } - u.socket.emit("chatFilters", f); + u.socket.emit("chatFilters", pkt); }); }; @@ -2751,7 +2751,9 @@ Channel.prototype.search = function (query, callback) { /** * Sends the result of readLog() to a user if the user has sufficient permission */ -Channel.prototype.tryReadLog = function (user) { +Channel.prototype.handleReadLog = function (user) { + var self = this; + if (user.rank < 3) { user.kick("Attempted readChanLog with insufficient permission"); return; @@ -2766,7 +2768,7 @@ Channel.prototype.tryReadLog = function (user) { } var filterIp = user.global_rank < 255; - this.readLog(filterIp, function (err, data) { + self.readLog(filterIp, function (err, data) { if (err) { user.socket.emit("readChanLog", { success: false, diff --git a/lib/user.js b/lib/user.js index d09fa97a..beedf05a 100644 --- a/lib/user.js +++ b/lib/user.js @@ -360,7 +360,7 @@ User.prototype.initChannelCallbacks = function () { }); wrapTypecheck("setMotd", function (data) { - self.channel.handleUpdateMotd(self, data); + self.channel.handleSetMotd(self, data); }); wrapTypecheck("updateFilter", function (data) { @@ -385,7 +385,7 @@ User.prototype.initChannelCallbacks = function () { self.channel.sendChannelRanks([self]); }); - wrap("requestChatFilter", function () { + wrap("requestChatFilters", function () { self.channel.sendChatFilters([self]); }); diff --git a/templates/channel.jade b/templates/channel.jade index b8dfaeb3..9a4a3a85 100644 --- a/templates/channel.jade +++ b/templates/channel.jade @@ -166,8 +166,10 @@ html(lang="en") button.close(data-dismiss="modal", aria-hidden="true") × h4 Channel Settings ul.nav.nav-tabs - li: a(href="#cs-miscoptions" data-toggle="tab") General Settings - li: a(href="#cs-adminoptions" data-toggle="tab") Admin Settings + li: a(href="#cs-miscoptions", data-toggle="tab") General Settings + li: a(href="#cs-adminoptions", data-toggle="tab") Admin Settings + li: a(href="#cs-chanlog", data-toggle="tab", onclick="javascript:socket.emit('readChanLog')") Channel Log + li: a(href="#cs-chatfilters", data-toggle="tab", onclick="javascript:socket.emit('requestChatFilters')") Chat Filters li.dropdown a#cs-edit-dd-toggle(href="#", data-toggle="dropdown") Edit span.caret @@ -188,6 +190,8 @@ html(lang="en") mixin banlist() mixin recentjoins() mixin chanranks() + mixin chatfilters() + mixin chanlog() .modal-footer button.btn.btn-default(type="button", data-dismiss="modal") Close include footer diff --git a/templates/channeloptions.jade b/templates/channeloptions.jade index 149e6d95..4ffd77a9 100644 --- a/templates/channeloptions.jade +++ b/templates/channeloptions.jade @@ -30,9 +30,12 @@ mixin miscoptions mixin textbox("cs-voteskip_ratio", "Voteskip ratio", "0.5") mixin textbox("cs-maxlength", "Max video length", "HH:MM:SS") mixin textbox("cs-afk_timeout", "Auto-AFK Delay", "0 (disabled)") + mixin rcheckbox("cs-chat_antiflood", "Throttle chat") + mixin textbox("cs-chat_antiflood_burst", "# of messages allowed before throttling") + mixin textbox("cs-chat_antiflood_sustained", "# of messages (after burst) allowed per second") .form-group .col-sm-8.col-sm-offset-4 - button.btn.btn-default#cs-miscoptionssubmit Save + span.text-info Changes are automatically saved. mixin adminoptions #cs-adminoptions.tab-pane @@ -46,28 +49,28 @@ mixin adminoptions mixin rcheckbox("cs-show_public", "List channel publicly") .form-group .col-sm-8.col-sm-offset-4 - button.btn.btn-default#cs-adminoptionssubmit Save + span.text-info Changes are automatically saved. mixin motdeditor #cs-motdeditor.tab-pane h4 MOTD editor p The MOTD can be formatted using a subset of HTML. Tags which attempt to execute Javascript will be removed. textarea.form-control#cs-motdtext(rows="10") - button.btn.btn-primary.pull-right#cs-motdsubmit Save MOTD + button.btn.btn-primary#cs-motdsubmit Save MOTD mixin csseditor #cs-csseditor.tab-pane h4 CSS editor p Maximum size 20KB. If more space is required, use the External CSS option under General Settings to link to an externally hosted stylesheet. textarea.form-control#cs-csstext(rows="10") - button.btn.btn-primary.pull-right#cs-csssubmit Save CSS + button.btn.btn-primary#cs-csssubmit Save CSS mixin jseditor #cs-jseditor.tab-pane h4 JS editor p Maximum size 20KB. If more space is required, use the External JS option under General Settings to link to an externally hosted stylesheet. textarea.form-control#cs-jstext(rows="10") - button.btn.btn-primary.pull-right#cs-jssubmit Save JS + button.btn.btn-primary#cs-jssubmit Save JS mixin banlist #cs-banlist.tab-pane @@ -105,3 +108,42 @@ mixin chanranks tr th Name th Rank + +mixin chatfilters + #cs-chatfilters.tab-pane + h4 Chat Filters + table.table.table-striped.table-condensed + thead + tr + th Control + th Name + th Active + +mixin chanlog + #cs-chanlog.tab-pane + h4 Channel Log + strong Filter Log: + form(role="form", action="javscript:void(0)") + .checkbox + label Everything + input#filter_all(type="checkbox", checked="checked") + .checkbox + label Chat + input#filter_chat(type="checkbox") + .checkbox + label Polls + input#filter_polls(type="checkbox") + .checkbox + label Playlist actions + input#filter_queue(type="checkbox") + .checkbox + label Bans + input#filter_bans(type="checkbox") + .checkbox + label Channel settings + input#filter_channelsettings(type="checkbox") + .checkbox + label Join/Quit messages + input#filter_joinquit(type="checkbox") + pre#chanlog_contents(style="max-height: 400px; overflow-y: scroll") + button.btn.btn-default#chanlog_refresh Refresh diff --git a/www/assets/js/callbacks.js b/www/assets/js/callbacks.js index ad5005cc..8f99d2f3 100644 --- a/www/assets/js/callbacks.js +++ b/www/assets/js/callbacks.js @@ -235,155 +235,9 @@ Callbacks = { }, chatFilters: function(entries) { - var tbl = $("#filteredit table"); - if(!tbl.hasClass("table")) { - setTimeout(function() { - Callbacks.chatFilters(entries); - }, 100); - return; - } - tbl.find(".filter-row").remove(); - for(var i = 0; i < entries.length; i++) { - var f = entries[i]; - var tr = $("").appendTo(tbl).addClass("filter-row"); - var remove = $("