From be9e7db154132f6d004f6b3d55d4c163e074d33f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Sat, 31 Jan 2015 17:33:54 +0100 Subject: [PATCH] Added adding of youtube playlists --- js/search.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/js/search.js b/js/search.js index e11771fe..c9c41aa2 100755 --- a/js/search.js +++ b/js/search.js @@ -19,8 +19,8 @@ $(document).ready(function() $(".search_input").focus(); $(".search_input").keyup(function(event) { + var search_input = $(this).val(); if (event.keyCode != 40 && event.keyCode != 38 && event.keyCode != 13 && event.keyCode != 39 && event.keyCode != 37) { - var search_input = $(this).val(); if(search_input.length < 3){$("#results").html("");} if(event.keyCode == 13){ search(search_input); @@ -32,6 +32,28 @@ $(document).ready(function() i = 0; timer=100; } + }else if(event.keyCode == 13) + { + //console.log(search_input); + //console.log(search_input.split("list=")[1]); + pId = search_input.split("list="); + if(pId.length > 1) + { + pListUrl = "http://gdata.youtube.com/feeds/api/playlists/"+pId[1]+"/?format=5&max-results=25&v=2&alt=jsonc"; + $.ajax({ + type: "GET", + url: pListUrl, + dataType:"jsonp", + success: function(response) + { + console.log(response.data.items); + $.each(response.data.items, function(i,data) + { + submit(data.video.id, data.video.title, true); + }); + } + }); + } }