From 3af35cb268cf96ae89ffaa3b35313938c1704d8e Mon Sep 17 00:00:00 2001 From: calzoneman Date: Sun, 12 May 2013 11:41:14 -0400 Subject: [PATCH] Add links to playlist entries and the index page --- api.js | 2 +- package.json | 2 +- server.js | 2 +- www/assets/js/client.js | 27 +----------------------- www/assets/js/functions.js | 37 +++++++++++++++++++++++++++++++-- www/channellist.html | 42 ++++++++++++++++++++++++++++++++++++-- www/index.html | 41 ++++++++++++++++++++++++++++++++++++- 7 files changed, 119 insertions(+), 34 deletions(-) diff --git a/api.js b/api.js index 344d23ff..d7cedf8d 100644 --- a/api.js +++ b/api.js @@ -117,7 +117,7 @@ function handleChannelData(params, req, res) { if(d.loaded) { var chan = Server.channels[cname]; - d.title = chan.media ? chan.media.title : "-"; + d.media = chan.media ? chan.media.pack() : {}; d.usercount = chan.users.length; d.users = []; for(var i = 0; i < chan.users.length; i++) { diff --git a/package.json b/package.json index 08714c3e..e4009515 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Calvin Montgomery", "name": "CyTube", "description": "Online media synchronizer and chat", - "version": "1.6.3", + "version": "1.6.4", "repository": { "url": "http://github.com/calzoneman/sync" }, diff --git a/server.js b/server.js index 86fe85f1..85c65ea1 100644 --- a/server.js +++ b/server.js @@ -9,7 +9,7 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -const VERSION = "1.6.3"; +const VERSION = "1.6.4"; var fs = require("fs"); var Logger = require("./logger.js"); diff --git a/www/assets/js/client.js b/www/assets/js/client.js index 538f714e..b497e466 100644 --- a/www/assets/js/client.js +++ b/www/assets/js/client.js @@ -322,32 +322,7 @@ $("#getplaylist").click(function() { 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; - } + var entry = idToURL(data.pl[i]); list.push(entry); } var urls = list.join(","); diff --git a/www/assets/js/functions.js b/www/assets/js/functions.js index 390becd3..53038ba0 100644 --- a/www/assets/js/functions.js +++ b/www/assets/js/functions.js @@ -246,8 +246,10 @@ function makeQueueEntry(video) { .css("clear", "both") .appendTo(li); } - var title = $("").addClass("qe_title").appendTo(li); - title.text(video.title); + var title = $("").addClass("qe_title").appendTo(li) + .text(video.title) + .attr("href", idToURL(video)) + .attr("target", "_blank"); var time = $("").addClass("qe_time").appendTo(li); time.text(video.duration); var clear = $("
").addClass("qe_clear").appendTo(li); @@ -941,3 +943,34 @@ function applyOpts() { $("#videodiv").remove(); } } + +function idToURL(data) { + var entry = ""; + switch(data.type) { + case "yt": + entry = "http://youtube.com/watch?v="+data.id; + break; + case "vi": + entry = "http://vimeo.com/"+data.id; + break; + case "dm": + entry = "http://dailymotion.com/video/"+data.id; + break; + case "sc": + entry = data.id; + break; + case "li": + entry = "http://livestream.com/"+data.id; + break; + case "tw": + entry = "http://twitch.tv/"+data.id; + break; + case "rt": + case "jw": + entry = data.id; + break; + default: + break; + } + return entry; +} diff --git a/www/channellist.html b/www/channellist.html index 80ba7943..683075a5 100644 --- a/www/channellist.html +++ b/www/channellist.html @@ -73,11 +73,40 @@ p = "name=" + uname + "&session=" + session; } }); - refresh(); setInterval(refresh, 5000); }); + function idToURL(data) { + var entry = ""; + switch(data.type) { + case "yt": + entry = "http://youtube.com/watch?v="+data.id; + break; + case "vi": + entry = "http://vimeo.com/"+data.id; + break; + case "dm": + entry = "http://dailymotion.com/video/"+data.id; + break; + case "sc": + entry = data.id; + break; + case "li": + entry = "http://livestream.com/"+data.id; + break; + case "tw": + entry = "http://twitch.tv/"+data.id; + break; + case "rt": + case "jw": + entry = data.id; + break; + default: + break; + } + return entry; + } function refresh() { $.getJSON(IO_URL+"/api/json/listloaded?"+p+"&callback=?", function(data) { var host = document.location + ""; @@ -107,8 +136,17 @@ .text(d.name) .appendTo(name); $("").text(d.usercount || 0).appendTo(tr); + var title = $("").appendTo(tr); + if(d.media.id) { + $("").appendTo(title) + .text(d.media.title) + .attr("href", idToURL(d.media)) + .attr("target", "_blank"); + } + else { + title.text("-"); + } total += (d.usercount || 0); - $("").text(d.title || "-").appendTo(tr); } var tr = $("").appendTo($("#channeldata")); diff --git a/www/index.html b/www/index.html index a82a67db..584ca91d 100644 --- a/www/index.html +++ b/www/index.html @@ -94,6 +94,36 @@ host = "http://" + host; setInterval(refresh, 10000); refresh(); + function idToURL(data) { + var entry = ""; + switch(data.type) { + case "yt": + entry = "http://youtube.com/watch?v="+data.id; + break; + case "vi": + entry = "http://vimeo.com/"+data.id; + break; + case "dm": + entry = "http://dailymotion.com/video/"+data.id; + break; + case "sc": + entry = data.id; + break; + case "li": + entry = "http://livestream.com/"+data.id; + break; + case "tw": + entry = "http://twitch.tv/"+data.id; + break; + case "rt": + case "jw": + entry = data.id; + break; + default: + break; + } + return entry; + } function refresh() { $.getJSON(IO_URL+"/api/json/listloaded?filter=public&callback=?", function(data) { $("#channeldata").find("tbody").remove(); @@ -115,7 +145,16 @@ .text(d.name) .appendTo(name); $("").text(d.usercount || 0).appendTo(tr); - $("").text(d.title || "-").appendTo(tr); + var title = $("").appendTo(tr); + if(d.media.id) { + $("").appendTo(title) + .text(d.media.title) + .attr("href", idToURL(d.media)) + .attr("target", "_blank"); + } + else { + title.text("-"); + } } }); }