diff --git a/user.js b/user.js index 5fc1bd24..c9de7bf7 100644 --- a/user.js +++ b/user.js @@ -108,6 +108,12 @@ User.prototype.initCallbacks = function() { this.playerReady = true; }.bind(this)); + this.socket.on("requestPlaylist", function() { + if(this.channel != null) { + this.channel.sendPlaylist(this); + } + }.bind(this)); + this.socket.on("queue", function(data) { if(this.channel != null) { this.channel.tryQueue(this, data); diff --git a/www/assets/js/client.js b/www/assets/js/client.js index cd9b0ea6..09fe46c3 100644 --- a/www/assets/js/client.js +++ b/www/assets/js/client.js @@ -80,8 +80,7 @@ if(params["channel"] == undefined) { var label = $("").text("Enter Channel:").appendTo(div); var entry = $("").attr("type", "text").appendTo(div); entry.keydown(function(ev) { - if(ev.keyCode == 13) { - document.location = document.location + "?channel=" + entry.val(); + if(ev.keyCode == 13) { document.location = document.location + "?channel=" + entry.val(); socket.emit("joinChannel", { name: entry.val() }); @@ -274,6 +273,64 @@ $("#chatline").keydown(function(ev) { $("#messagebuffer").mouseenter(function() { SCROLLCHAT = false; }); $("#messagebuffer").mouseleave(function() { SCROLLCHAT = true; }); +$("#getplaylist").click(function() { + var callback = function(data) { + socket.listeners("playlist").splice( + socket.listeners("playlist").indexOf(callback)); + var list = []; + for(var i = 0; i < data.pl.length; i++) { + var entry; + switch(data.pl[i].type) { + case "yt": + entry = "http://youtube.com/watch?v="+data.pl[i].id; + break; + case "vi": + entry = "http://vimeo.com/"+data.pl[i].id; + break; + case "dm": + entry = "http://dailymotion.com/video/"+data.pl[i].id; + break; + case "sc": + entry = data.pl[i].id; + break; + case "li": + entry = "http://livestream.com/"+data.pl[i].id; + break; + case "tw": + entry = "http://twitch.tv/"+data.pl[i].id; + break; + case "rt": + entry = data.pl[i].id; + break; + default: + break; + } + list.push(entry); + } + var urls = list.join(","); + + var modal = $("
").addClass("modal hide fade") + .appendTo($("body")); + var head = $("").addClass("modal-header") + .appendTo(modal); + $("").addClass("close") + .attr("data-dismiss", "modal") + .attr("aria-hidden", "true") + .appendTo(head)[0].innerHTML = "×"; + $("").text("Playlist URLs").appendTo(head); + var body = $("").addClass("modal-body").appendTo(modal); + $("").attr("type", "text") + .val(urls) + .appendTo(body); + $("").addClass("modal-footer").appendTo(modal); + modal.on("hidden", function() { + modal.remove(); + }); + modal.modal(); + } + socket.on("playlist", callback); + socket.emit("requestPlaylist"); +}); $("#opt_submit").click(function() { var ptitle = $("#opt_pagetitle").val(); diff --git a/www/index.html b/www/index.html index a60aa5a7..1c49076f 100644 --- a/www/index.html +++ b/www/index.html @@ -86,6 +86,7 @@