Add an in-place MOTD editor

This commit is contained in:
calzoneman 2013-11-13 22:36:43 -06:00
parent 436df375c7
commit d09d7ad64e
6 changed files with 48 additions and 2 deletions

View File

@ -1,3 +1,16 @@
Wed Nov 13 22:35 2013 CDT
* www/assets/js/util.js, www/assets/js/ui.js,
www/assets/js/callbacks.js, www/channel.html:
Add an in-place MOTD editor
Sun Nov 10 22:24 2013 CDT
* www/assets/js/util.js: Add queueMessage function for displaying
warnings/errors
* lib/get-info.js: Add warning for videos blocked in certain
countries (ytv2)
* lib/user.js: If channel search turns up no results, youtube search
instead
Fri Nov 08 20:44 2013 CDT
* lib/channel.js, lib/chatcommand.js: Implement basic shadow mute
command

View File

@ -171,7 +171,11 @@ Callbacks = {
setMotd: function(data) {
CHANNEL.motd = data.html;
CHANNEL.motd_text = data.motd;
$("#motd").html(data.html);
if ($("#motdwrap").find(".motdeditor").length > 0) {
$("#motdwrap .motdeditor").val(CHANNEL.motd_text);
} else {
$("#motd").html(CHANNEL.motd);
}
$("#motdtext").val(CHANNEL.motd_text);
if(data.motd != "") {
$("#motdwrap").show();

View File

@ -45,6 +45,8 @@ generateToggle("#librarytoggle", "#librarywrap");
generateToggle("#userpltoggle", "#userplaylistwrap");
generateToggle("#playlisttoggle", "#playlist_controls");
$("#editmotd").click(showMOTDEditor);
$("#togglemotd").click(function () {
var hidden = $("#motd").css("display") === "none";
$("#motd").toggle();

View File

@ -1034,6 +1034,7 @@ function handleModPermissions() {
$("#csstext").val(CHANNEL.css);
$("#jstext").val(CHANNEL.js);
$("#motdtext").val(CHANNEL.motd_text);
setVisible("#editmotd", hasPermission("motdedit"));
setVisible("#permedit_tab", CLIENT.rank >= 3);
setVisible("#banlist_tab", hasPermission("ban"));
setVisible("#motdedit_tab", hasPermission("motdedit"));
@ -1812,3 +1813,26 @@ function queueMessage(data, type) {
.addClass("span12 qfalert qf-" + type)
.appendTo($("#queuefail"));
}
function showMOTDEditor() {
var motd = $("#motd");
motd.html("");
var text = $("<textarea/>")
.addClass("motdeditor input-block-level")
.attr("rows", "10")
.val(CHANNEL.motd_text)
.css("width", "100%")
.css("height", "100%")
.appendTo($("#motdwrap"))
.blur(function () {
socket.emit("setMotd", {
motd: text.val()
});
$("#motdwrap .motdeditor").remove();
$("#editmotd").show();
$("#togglemotd").show();
})
.focus();
$("#editmotd").hide();
$("#togglemotd").hide();
}

View File

@ -55,7 +55,8 @@
<!-- top row (MOTD, drink count) -->
<div class="row-fluid" id="toprow">
<div class="well" id="motdwrap">
<button class="close pull-right" id="togglemotd"><i class="icon-minus"></i></button>
<button class="close pull-right" id="togglemotd"><i class="icon-minus" title="Show/Hide MOTD"></i></button>
<button class="close pull-right" id="editmotd" style="display: none"><i class="icon-file" title="Edit MOTD"></i></button>
<div id="motd"></div>
</div>
<div id="drinkbar">

View File

@ -110,6 +110,8 @@
<div id="permedit" class="span12">
</div>
<div id="motdedit" class="span12">
<strong>Notice:</strong>
The MOTD can now be edited in-place by clicking the small page icon next to the minus/plus icon. This editor is left in place for legacy purposes.
<textarea rows="10" id="motdtext"></textarea>
<button class="btn btn-primary" id="save_motd">Save</button>
</div>