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,7 +22,6 @@ 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++) {
@ -58,13 +57,36 @@ 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 ignore = $("<li />").appendTo(ul);
var a = $("<a />").attr("tabindex", "-1").attr("href", "javascript:void(0);").appendTo(ignore);
if(IGNORED.indexOf(name) != -1) {
a.text("Unignore User");
}
else {
a.text("Ignore User");
}
a.click(function() {
if(IGNORED.indexOf(name) != -1) {
IGNORED.splice(IGNORED.indexOf(name), 1);
a.text("Ignore User");
}
else {
IGNORED.push(name);
a.text("Unignore User");
}
});
if(RANK >= Rank.Moderator) {
$("<li />").addClass("divider").appendTo(ul);
var makeLeader = $("<li />").appendTo(ul); var makeLeader = $("<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(makeLeader);
a.text("Make Leader"); a.text("Make Leader");
a.click(function() { a.click(function() {
socket.emit("assignLeader", { socket.emit("assignLeader", {
@ -73,7 +95,7 @@ function addUserDropdown(entry, name) {
}); });
var takeLeader = $("<li />").appendTo(ul); var takeLeader = $("<li />").appendTo(ul);
var a = $("<a />").attr("tabindex", "-1").attr("href", "#").appendTo(takeLeader); var a = $("<a />").attr("tabindex", "-1").attr("href", "javascript:void(0);").appendTo(takeLeader);
a.text("Take Leader"); a.text("Take Leader");
a.click(function() { a.click(function() {
socket.emit("assignLeader", { socket.emit("assignLeader", {
@ -82,7 +104,7 @@ function addUserDropdown(entry, name) {
}); });
var kick = $("<li />").appendTo(ul); var kick = $("<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(kick);
a.text("Kick"); a.text("Kick");
a.click(function() { a.click(function() {
socket.emit("chatMsg", { socket.emit("chatMsg", {
@ -91,7 +113,7 @@ function addUserDropdown(entry, name) {
}); });
var ban = $("<li />").appendTo(ul); var ban = $("<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(ban);
a.text("IP Ban"); a.text("IP Ban");
a.click(function() { a.click(function() {
socket.emit("chatMsg", { socket.emit("chatMsg", {
@ -102,7 +124,7 @@ function addUserDropdown(entry, name) {
$("<li />").addClass("divider").appendTo(ul); $("<li />").addClass("divider").appendTo(ul);
var promote = $("<li />").appendTo(ul); var promote = $("<li />").appendTo(ul);
var a = $("<a />").attr("tabindex", "-1").attr("href", "#").appendTo(promote); var a = $("<a />").attr("tabindex", "-1").attr("href", "javascript:void(0);").appendTo(promote);
a.text("Promote"); a.text("Promote");
a.click(function() { a.click(function() {
socket.emit("promote", { socket.emit("promote", {
@ -111,13 +133,14 @@ function addUserDropdown(entry, name) {
}); });
var demote = $("<li />").appendTo(ul); var demote = $("<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(demote);
a.text("Demote"); a.text("Demote");
a.click(function() { a.click(function() {
socket.emit("demote", { socket.emit("demote", {
name: name name: name
}); });
}); });
}
$(entry).click(function() { $(entry).click(function() {
if(ul.css("display") == "none") { if(ul.css("display") == "none") {
@ -193,22 +216,21 @@ 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);
if(CHANNELOPTS.qopen_allow_move || fullperms) {
var btnMove = $("<button />").addClass("btn qe_btn").appendTo(btnstrip); var btnMove = $("<button />").addClass("btn qe_btn").appendTo(btnstrip);
$("<i />").addClass("icon-resize-vertical").appendTo(btnMove); $("<i />").addClass("icon-resize-vertical").appendTo(btnMove);
var btnRemove = $("<button />").attr("class", "btn btn-danger qe_btn").appendTo(btnstrip);
$("<i />").attr("class", "icon-remove").appendTo(btnRemove);
var btnPlay = $("<button />").attr("class", "btn btn-success qe_btn").appendTo(btnstrip);
$("<i />").attr("class", "icon-play").appendTo(btnPlay);
var btnNext = $("<button />").attr("class", "btn qe_btn").appendTo(btnstrip);
//$("<i />").attr("class", "icon-play").appendTo(btnNext);
btnNext.text("Next");
// Callback time // Callback time
btnMove.mousedown(function() { btnMove.mousedown(function() {
GRABBEDLI = li; GRABBEDLI = li;
@ -223,6 +245,41 @@ function addQueueButtons(li) {
moveVideo(lidx, idx, true); moveVideo(lidx, idx, true);
} }
}); });
}
if(CHANNELOPTS.qopen_allow_delete || fullperms) {
var btnRemove = $("<button />").attr("class", "btn btn-danger qe_btn").appendTo(btnstrip);
$("<i />").attr("class", "icon-remove").appendTo(btnRemove);
$(btnRemove).click(function() {
btnstrip.remove();
var idx = $("#queue").children().index(li);
socket.emit("unqueue", { pos: idx });
});
}
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() {