Add mute function, tweak playlist button display

This commit is contained in:
calzoneman 2013-04-11 12:51:08 -05:00
parent a9b3319e3d
commit d5ce1020b2
3 changed files with 138 additions and 109 deletions

View File

@ -124,6 +124,9 @@ function initCallbacks() {
}); });
socket.on("chatMsg", function(data) { socket.on("chatMsg", function(data) {
if(IGNORED.indexOf(data.username) != -1) {
return;
}
var div = formatChatMessage(data); var div = formatChatMessage(data);
div.appendTo($("#messagebuffer")); div.appendTo($("#messagebuffer"));
// Cap chatbox at most recent 100 messages // Cap chatbox at most recent 100 messages

View File

@ -27,6 +27,7 @@ var PAGETITLE = "Sync";
var TITLE_BLINK; var TITLE_BLINK;
var VWIDTH = "670"; var VWIDTH = "670";
var VHEIGHT = "377"; var VHEIGHT = "377";
var IGNORED = [];
var uname = readCookie("sync_uname"); var uname = readCookie("sync_uname");
var pw = readCookie("sync_pw"); var pw = readCookie("sync_pw");

View File

@ -22,8 +22,7 @@ function addUser(name, rank, leader) {
var flair = $("<span/>").appendTo(div); var flair = $("<span/>").appendTo(div);
var nametag = $("<span/>").text(name).appendTo(div); var nametag = $("<span/>").text(name).appendTo(div);
fmtUserlistItem(div[0], rank, leader); fmtUserlistItem(div[0], rank, leader);
if(RANK >= Rank.Moderator) addUserDropdown(div, name);
addUserDropdown(div, name);
var users = $("#userlist").children(); var users = $("#userlist").children();
for(var i = 0; i < users.length; i++) { for(var i = 0; i < users.length; i++) {
var othername = users[i].children[1].innerHTML; var othername = users[i].children[1].innerHTML;
@ -58,66 +57,90 @@ function fmtUserlistItem(div, rank, leader) {
// Adds a dropdown with user actions (promote/demote/leader) // Adds a dropdown with user actions (promote/demote/leader)
function addUserDropdown(entry, name) { function addUserDropdown(entry, name) {
$(entry).find("dropdown").remove();
var div = $("<div />").addClass("dropdown").appendTo(entry); var div = $("<div />").addClass("dropdown").appendTo(entry);
var ul = $("<ul />").addClass("dropdown-menu").appendTo(div); var ul = $("<ul />").addClass("dropdown-menu").appendTo(div);
ul.attr("role", "menu"); ul.attr("role", "menu");
ul.attr("aria-labelledby", "dropdownMenu"); ul.attr("aria-labelledby", "dropdownMenu");
var makeLeader = $("<li />").appendTo(ul); var ignore = $("<li />").appendTo(ul);
var a = $("<a />").attr("tabindex", "-1").attr("href", "#").appendTo(makeLeader); var a = $("<a />").attr("tabindex", "-1").attr("href", "javascript:void(0);").appendTo(ignore);
a.text("Make Leader"); if(IGNORED.indexOf(name) != -1) {
a.text("Unignore User");
}
else {
a.text("Ignore User");
}
a.click(function() { a.click(function() {
socket.emit("assignLeader", { if(IGNORED.indexOf(name) != -1) {
name: name IGNORED.splice(IGNORED.indexOf(name), 1);
}); a.text("Ignore User");
}
else {
IGNORED.push(name);
a.text("Unignore User");
}
}); });
var takeLeader = $("<li />").appendTo(ul); if(RANK >= Rank.Moderator) {
var a = $("<a />").attr("tabindex", "-1").attr("href", "#").appendTo(takeLeader); $("<li />").addClass("divider").appendTo(ul);
a.text("Take Leader");
a.click(function() {
socket.emit("assignLeader", {
name: ""
});
});
var kick = $("<li />").appendTo(ul); var makeLeader = $("<li />").appendTo(ul);
var a = $("<a />").attr("tabindex", "-1").attr("href", "#").appendTo(kick); var a = $("<a />").attr("tabindex", "-1").attr("href", "javascript:void(0);").appendTo(makeLeader);
a.text("Kick"); a.text("Make Leader");
a.click(function() { a.click(function() {
socket.emit("chatMsg", { socket.emit("assignLeader", {
msg: "/kick " + name name: name
});
}); });
});
var ban = $("<li />").appendTo(ul); var takeLeader = $("<li />").appendTo(ul);
var a = $("<a />").attr("tabindex", "-1").attr("href", "#").appendTo(ban); var a = $("<a />").attr("tabindex", "-1").attr("href", "javascript:void(0);").appendTo(takeLeader);
a.text("IP Ban"); a.text("Take Leader");
a.click(function() { a.click(function() {
socket.emit("chatMsg", { socket.emit("assignLeader", {
msg: "/ban " + name name: ""
});
}); });
});
$("<li />").addClass("divider").appendTo(ul); var kick = $("<li />").appendTo(ul);
var a = $("<a />").attr("tabindex", "-1").attr("href", "javascript:void(0);").appendTo(kick);
var promote = $("<li />").appendTo(ul); a.text("Kick");
var a = $("<a />").attr("tabindex", "-1").attr("href", "#").appendTo(promote); a.click(function() {
a.text("Promote"); socket.emit("chatMsg", {
a.click(function() { msg: "/kick " + name
socket.emit("promote", { });
name: name
}); });
});
var demote = $("<li />").appendTo(ul); var ban = $("<li />").appendTo(ul);
var a = $("<a />").attr("tabindex", "-1").attr("href", "#").appendTo(demote); var a = $("<a />").attr("tabindex", "-1").attr("href", "javascript:void(0);").appendTo(ban);
a.text("Demote"); a.text("IP Ban");
a.click(function() { a.click(function() {
socket.emit("demote", { socket.emit("chatMsg", {
name: name msg: "/ban " + name
});
}); });
});
$("<li />").addClass("divider").appendTo(ul);
var promote = $("<li />").appendTo(ul);
var a = $("<a />").attr("tabindex", "-1").attr("href", "javascript:void(0);").appendTo(promote);
a.text("Promote");
a.click(function() {
socket.emit("promote", {
name: name
});
});
var demote = $("<li />").appendTo(ul);
var a = $("<a />").attr("tabindex", "-1").attr("href", "javascript:void(0);").appendTo(demote);
a.text("Demote");
a.click(function() {
socket.emit("demote", {
name: name
});
});
}
$(entry).click(function() { $(entry).click(function() {
if(ul.css("display") == "none") { if(ul.css("display") == "none") {
@ -193,36 +216,70 @@ function makeQueueEntry(video) {
// Add buttons to a queue list entry // Add buttons to a queue list entry
function addQueueButtons(li) { function addQueueButtons(li) {
if(RANK < Rank.Moderator && !LEADER) {
if(!CHANNELOPTS.qopen_allow_delete
&& !CHANNELOPTS.qopen_allow_move
&& !CHANNELOPTS.qopen_allow_qnext) {
return;
}
}
var fullperms = LEADER || RANK >= Rank.Moderator;
var btnstrip = $("<div />").attr("class", "btn-group qe_buttons").prependTo(li); var btnstrip = $("<div />").attr("class", "btn-group qe_buttons").prependTo(li);
var btnMove = $("<button />").addClass("btn qe_btn").appendTo(btnstrip); if(CHANNELOPTS.qopen_allow_move || fullperms) {
$("<i />").addClass("icon-resize-vertical").appendTo(btnMove); var btnMove = $("<button />").addClass("btn qe_btn").appendTo(btnstrip);
$("<i />").addClass("icon-resize-vertical").appendTo(btnMove);
// Callback time
btnMove.mousedown(function() {
GRABBEDLI = li;
OLDINDEX = $("#queue").children().index(li);
});
var btnRemove = $("<button />").attr("class", "btn btn-danger qe_btn").appendTo(btnstrip); btnMove.mousemove(function() {
$("<i />").attr("class", "icon-remove").appendTo(btnRemove); if(GRABBEDLI != null) {
var idx = $("#queue").children().index(li);
var lidx = $("#queue").children().index(GRABBEDLI);
if(idx != lidx)
moveVideo(lidx, idx, true);
}
});
}
var btnPlay = $("<button />").attr("class", "btn btn-success qe_btn").appendTo(btnstrip); if(CHANNELOPTS.qopen_allow_delete || fullperms) {
$("<i />").attr("class", "icon-play").appendTo(btnPlay); var btnRemove = $("<button />").attr("class", "btn btn-danger qe_btn").appendTo(btnstrip);
$("<i />").attr("class", "icon-remove").appendTo(btnRemove);
var btnNext = $("<button />").attr("class", "btn qe_btn").appendTo(btnstrip); $(btnRemove).click(function() {
//$("<i />").attr("class", "icon-play").appendTo(btnNext); btnstrip.remove();
btnNext.text("Next");
// Callback time
btnMove.mousedown(function() {
GRABBEDLI = li;
OLDINDEX = $("#queue").children().index(li);
});
btnMove.mousemove(function() {
if(GRABBEDLI != null) {
var idx = $("#queue").children().index(li); var idx = $("#queue").children().index(li);
var lidx = $("#queue").children().index(GRABBEDLI); socket.emit("unqueue", { pos: idx });
if(idx != lidx) });
moveVideo(lidx, idx, true); }
}
}); if(CHANNELOPTS.qopen_allow_playnext || fullperms) {
var btnPlay = $("<button />").attr("class", "btn btn-success qe_btn").appendTo(btnstrip);
$("<i />").attr("class", "icon-play").appendTo(btnPlay);
$(btnPlay).click(function() {
var idx = $("#queue").children().index(li);
socket.emit("jumpTo", {
pos: idx
});
});
}
if(CHANNELOPTS.qopen_allow_qnext || fullperms) {
var btnNext = $("<button />").attr("class", "btn qe_btn").appendTo(btnstrip);
btnNext.text("Next");
$(btnNext).click(function() {
var idx = $("#queue").children().index(li);
var dest = idx < POSITION ? POSITION : POSITION + 1;
socket.emit("moveMedia", {
src: idx,
dest: dest
});
});
}
$(document).mouseup(function() { $(document).mouseup(function() {
if(GRABBEDLI != null) { if(GRABBEDLI != null) {
@ -235,38 +292,6 @@ function addQueueButtons(li) {
}); });
} }
}); });
$(btnRemove).click(function() {
btnstrip.remove();
var idx = $("#queue").children().index(li);
socket.emit("unqueue", { pos: idx });
});
$(btnPlay).click(function() {
var idx = $("#queue").children().index(li);
socket.emit("jumpTo", {
pos: idx
});
});
$(btnNext).click(function() {
var idx = $("#queue").children().index(li);
var dest = idx < POSITION ? POSITION : POSITION + 1;
socket.emit("moveMedia", {
src: idx,
dest: dest
});
});
if(RANK < Rank.Moderator && !LEADER) {
if(!CHANNELOPTS.qopen_allow_delete)
$(btnRemove).attr("disabled", true);
if(!CHANNELOPTS.qopen_allow_move)
$(btnMove).attr("disabled", true);
if(!CHANNELOPTS.qopen_allow_qnext)
$(btnNext).attr("disabled", true);
$(btnPlay).attr("disabled", true);
}
} }
function rebuildPlaylist() { function rebuildPlaylist() {