diff --git a/channel.js b/channel.js index 4213e8eb..867246be 100644 --- a/channel.js +++ b/channel.js @@ -916,7 +916,7 @@ Channel.prototype.broadcastVoteskipUpdate = function() { } Channel.prototype.broadcastMotd = function() { - this.sendAll("updateMotd", this.motd); + this.sendAll("setMotd", this.motd); } Channel.prototype.broadcastDrinks = function() { @@ -1150,7 +1150,7 @@ Channel.prototype.trySetTemp = function(user, data) { } -Channel.prototype.dequeue = function(position) { +Channel.prototype.dequeue = function(position, removeonly) { if(position < 0 || position >= this.queue.length) { return; } @@ -1161,6 +1161,9 @@ Channel.prototype.dequeue = function(position) { }); this.broadcastPlaylistMeta(); + if(removeonly) + return; + // If you remove the currently playing video, play the next one if(position == this.position) { this.position--; @@ -1223,7 +1226,7 @@ Channel.prototype.jumpTo = function(pos) { var old = this.position; if(this.media && this.media.temp && old != pos) { - this.dequeue({pos: old, removeonly: true}); + this.dequeue(old, true); if(pos > old && pos > 0) { pos--; } @@ -1293,9 +1296,9 @@ Channel.prototype.shufflequeue = function() { this.queue.splice(i, 1); } this.queue = n; - for(var i = 0; i < this.users.length; i++) { - this.sendPlaylist(this.users[i]); - } + this.sendAll("playlist", this.queue); + this.sendAll("setPosition", this.position); + this.sendAll("setPlaylistMeta", this.plmeta); } Channel.prototype.tryShufflequeue = function(user) { @@ -1343,13 +1346,16 @@ Channel.prototype.move = function(data, user) { var media = this.queue[data.from]; var to = data.to > data.from ? data.to + 1 : data.to; var from = data.to > data.from ? data.from : data.from + 1; + var moveby = user && user.name ? user.name : null; + if(typeof data.moveby !== "undefined") + moveby = data.moveby; this.queue.splice(to, 0, media); this.queue.splice(from, 1); this.sendAll("moveVideo", { from: data.from, to: data.to, - moveby: user ? user.name : "" + moveby: moveby }); // Account for moving things around the active video @@ -1369,11 +1375,11 @@ Channel.prototype.tryMove = function(user, data) { return; } - if(data.src == undefined || data.dest == undefined) { + if(typeof data.from !== "number" || typeof data.to !== "number") { return; } - this.move(data); + this.move(data, user); } /* REGION Polls */ diff --git a/user.js b/user.js index f333f50b..870d273d 100644 --- a/user.js +++ b/user.js @@ -236,13 +236,13 @@ User.prototype.initCallbacks = function() { } }.bind(this)); - this.socket.on("clearqueue", function() { + this.socket.on("clearPlaylist", function() { if(this.channel != null) { this.channel.tryClearqueue(this); } }.bind(this)); - this.socket.on("shufflequeue", function() { + this.socket.on("shufflePlaylist", function() { if(this.channel != null) { this.channel.tryShufflequeue(this); } @@ -262,7 +262,7 @@ User.prototype.initCallbacks = function() { this.socket.on("searchMedia", function(data) { if(this.channel != null) { - if(data.yt) { + if(data.source == "yt") { var callback = function(vids) { this.socket.emit("searchResults", { results: vids @@ -373,7 +373,7 @@ User.prototype.initCallbacks = function() { } }.bind(this)); - this.socket.on("updateMotd", function(data) { + this.socket.on("setMotd", function(data) { if(this.channel != null) { this.channel.tryUpdateMotd(this, data); } diff --git a/www/assets/css/darkstrap.css b/www/assets/css/darkstrap.css index 849228b9..5aadc62b 100644 --- a/www/assets/css/darkstrap.css +++ b/www/assets/css/darkstrap.css @@ -153,7 +153,7 @@ textarea::-webkit-input-placeholder { /* line 18, ../bootstrap/bootstrap/_sprites.scss */ [class^="icon-"], [class*=" icon-"] { - background-image: url("../img/glyphicons-halflings.png"); + background-image: url("../img/glyphicons-halflings-white.png"); } /* White icons with optional class, or on hover/active states of certain elements */ @@ -946,6 +946,20 @@ select:focus:invalid:focus { color: #ff9900; } +#usercountwrap, #currenttitle, #videowrap, +#librarytoggle, #userpltoggle, #playlisttoggle { + background-color: #2f2f2f; +} + +.queue_entry { + background-color: #111111; +} + +.queue_active { + border-color: #ff9900; + background-color: #332200; +} + #plmeta { background-color: rgba(0, 0, 0, 0.3); } diff --git a/www/assets/css/semidark.css b/www/assets/css/semidark.css new file mode 100644 index 00000000..2ffd3315 --- /dev/null +++ b/www/assets/css/semidark.css @@ -0,0 +1,37 @@ +body, #videowrap { + background-color: #2f2f2f; +} + +.queue_entry { + background-color: #111111; +} + +.queue_active { + border-color: #ff9900; + background-color: #332200; +} + +#userpltoggle, #librarytoggle, #playlisttoggle { + color: #cccccc; + background-color: #2f2f2f; +} + +#currenttitle { + color: #cccccc; +} + +.qe_time { + color: #cccccc; +} + +#userpltoggle i[class^="icon-"], #userpltoggle i[class*=" icon-"], +#librarytoggle i[class^="icon-"], #librarytoggle i[class*=" icon-"], +#playlisttoggle i[class^="icon-"], #playlisttoggle i[class*=" icon-"] { + background-image: url("../img/glyphicons-halflings-white.png"); +} + +#plmeta { + color: #cccccc; + background-color: #2f2f2f; + background-color: rgba(0, 0, 0, 0.3); +} diff --git a/www/assets/css/ytsync.css b/www/assets/css/ytsync.css index 0026fc93..969da0b5 100644 --- a/www/assets/css/ytsync.css +++ b/www/assets/css/ytsync.css @@ -101,8 +101,11 @@ html, body { margin-bottom: 0; } -.queue_entry { +.queue_sortable li { cursor: row-resize; +} + +.queue_entry { background-color: #ffffff; margin: 2px 0 0 auto; padding: 2px; @@ -114,6 +117,11 @@ html, body { background-image: url(../img/stripe-diagonal.png); } +.queue_active { + background-color: #d9edf7; + border-color: #bce8f1; +} + #plmeta { border: 1px solid #aaaaaa; border-top: 0; @@ -286,6 +294,17 @@ html, body { padding: 5px; } +.user-dropdown { + z-index: 9999; + position: absolute; + border: 1px solid #aaaaaa; + border-radius: 5px; + background-color: #ffffff; + color: #000000; + max-width: 200px; + padding: 5px; +} + .profile-image { width: 80px; height: 80px; diff --git a/www/assets/js/callbacks.js b/www/assets/js/callbacks.js index d2faf96e..78103597 100644 --- a/www/assets/js/callbacks.js +++ b/www/assets/js/callbacks.js @@ -502,7 +502,7 @@ Callbacks = { }, queue: function(data) { - var li = makeQueueEntry(data.media); + var li = makeQueueEntry(data.media, true); li.hide(); addQueueButtons(li); var idx = data.pos; @@ -551,17 +551,25 @@ Callbacks = { moveVideo: function(data) { if(data.moveby != CLIENT.name) - playlistMove(data.src, data.dest); + playlistMove(data.from, data.to); }, - setPosition: function(data) { + setPosition: function(position) { $("#queue li").each(function() { $(this).removeClass("queue_active"); }); - if(data.position < 0) + if(position < 0) return; - POSITION = data.position; + POSITION = position; var linew = $("#queue").children()[POSITION]; + // jQuery UI's sortable thingy kinda fucks this up initially + // Wait until it's done + if(!$(linew).hasClass("queue_entry")) { + setTimeout(function() { + Callbacks.setPosition(position); + }, 100); + return; + } $(linew).addClass("queue_active"); $("#queue").scrollTop(0); @@ -643,7 +651,7 @@ Callbacks = { .appendTo($("#messagebuffer")); scrollChat(); - var poll = $("
").addClass("well active").prependTo($("#pollcontainer")); + var poll = $("").addClass("well active").prependTo($("#pollwrap")); $("").addClass("close pull-right").html("×") .appendTo(poll) .click(function() { poll.remove(); }); @@ -687,8 +695,8 @@ Callbacks = { }, closePoll: function() { - if($("#pollcontainer .active").length != 0) { - var poll = $("#pollcontainer .active"); + if($("#pollwrap .active").length != 0) { + var poll = $("#pollwrap .active"); poll.removeClass("active").addClass("muted"); poll.find(".option button").each(function() { $(this).attr("disabled", true); diff --git a/www/assets/js/data.js b/www/assets/js/data.js index 042863fb..9140247f 100644 --- a/www/assets/js/data.js +++ b/www/assets/js/data.js @@ -51,9 +51,9 @@ function getOrDefault(k, def) { return true; if(v === "false") return false; - if(v.match(/[0-9]+/)) + if(v.match(/^[0-9]+$/)) return parseInt(v); - if(v.match(/[0-9\.]+/)) + if(v.match(/^[0-9\.]+$/)) return parseFloat(v); return v; } diff --git a/www/assets/js/ui.js b/www/assets/js/ui.js index ceedf207..af17e87f 100644 --- a/www/assets/js/ui.js +++ b/www/assets/js/ui.js @@ -157,23 +157,21 @@ $("#userpl_save").click(function() { /* playlist controls */ -$(function() { - $("#queue").sortable({ - start: function(ev, ui) { - PL_FROM = ui.item.prevAll().length; - }, - update: function(ev, ui) { - PL_TO = ui.item.prevAll().length; - if(PL_TO != PL_FROM) { - socket.emit("moveMedia", { - from: PL_FROM, - to: PL_TO - }); - } +$("#queue").sortable({ + start: function(ev, ui) { + PL_FROM = ui.item.prevAll().length; + }, + update: function(ev, ui) { + PL_TO = ui.item.prevAll().length; + if(PL_TO != PL_FROM) { + socket.emit("moveMedia", { + from: PL_FROM, + to: PL_TO + }); } - }); - $("#queue").disableSelection(); + } }); +$("#queue").disableSelection(); function queue(pos) { var links = $("#mediaurl").val().split(","); @@ -210,13 +208,13 @@ $("#qlockbtn").click(function() { $("#getplaylist").click(function() { var callback = function(data) { + PLAYER.hide(); socket.listeners("playlist").splice( socket.listeners("playlist").indexOf(callback) ); var list = []; - for(var i = 0; i < data.pl.length; i++) { - var entry = formatURL(data.pl[i]); - // TODO formatURL in util.js + for(var i = 0; i < data.length; i++) { + var entry = formatURL(data[i]); list.push(entry); } var urls = list.join(","); @@ -238,6 +236,7 @@ $("#getplaylist").click(function() { $("").addClass("modal-footer").appendTo(modal); modal.on("hidden", function() { modal.remove(); + PLAYER.unhide(); }); modal.modal(); } @@ -253,8 +252,8 @@ $("#clearplaylist").click(function() { }); $("#shuffleplaylist").click(function() { - var clear = confirm("Are you sure you want to shuffle the playlist?"); - if(clear) { + var shuffle = confirm("Are you sure you want to shuffle the playlist?"); + if(shuffle) { socket.emit("shufflePlaylist"); } }); diff --git a/www/assets/js/util.js b/www/assets/js/util.js index 977c3594..845bb0aa 100644 --- a/www/assets/js/util.js +++ b/www/assets/js/util.js @@ -103,126 +103,73 @@ function getNameColor(rank) { return ""; } -function addUserDropdown(entry, name) { - // TODO change this - entry.find(".dropdown").remove(); - entry.unbind(); - var div = $("").addClass("dropdown").appendTo(entry); - var ul = $("