diff --git a/.htaccess~ b/.htaccess~ new file mode 100755 index 00000000..9a9ef505 --- /dev/null +++ b/.htaccess~ @@ -0,0 +1,22 @@ +Options +FollowSymLinks +RewriteEngine on +RewriteBase / +RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] +RewriteRule ^(.*)$ http://%1/$1 [R=301,L] + +#Comment out the two folling lines when running server locally to fix issues with localhost +#RewriteCond %{HTTPS} !=on +#RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L] + + +RewriteRule (?i)^remote/(.*) php/controller.php?id=$1 [L] +RewriteRule (?i)^remote php/controller.php [L] + +RewriteCond %{REQUEST_URI} !(/$|\.) +RewriteRule (.*) %{REQUEST_URI}/ [R=301,L] + +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule /(.*)$ /$1 [L] + +Options -Indexes diff --git a/static/js/suggestions.js b/static/js/suggestions.js new file mode 100644 index 00000000..7eda9352 --- /dev/null +++ b/static/js/suggestions.js @@ -0,0 +1,57 @@ +var Suggestions = { + + catchUserSuggests: function(suggested){ + + }, + + fetchYoutubeSuggests: function(id){ + + var get_url = "https://www.googleapis.com/youtube/v3/search?part=snippet&relatedToVideoId="+id+"&type=video&key="+api_key; + var video_urls = "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+api_key+"&id="; + + $.ajax({ + type: "GET", + url: get_url, + dataType:"jsonp", + success: function(response) + { + $.each(response.items.slice(0,5), function(i,data){ + video_urls += data.id.videoId+","; + }); + + $.ajax({ + type: "GET", + url: video_urls, + dataType: "jsonp", + success: function(response) + { + $("#suggest-song-html").empty(); + + $.each(response.items, function(i,song) + { + var duration = song.contentDetails.duration; + var secs = Search.durationToSeconds(duration); + var video_id = song.id; + var video_title = song.snippet.title; + var suggest_song = $("
" + $(suggest_html).html() + "
"); + + duration = duration.replace("PT","").replace("H","h ").replace("M","m ").replace("S","s") + + window.suggest_song = suggest_song; + suggest_song.find(".suggest_thumb").attr("src", "//img.youtube.com/vi/"+video_id+"/mqdefault.jpg") + suggest_song.find(".suggest_title").text(video_title); + suggest_song.find(".duration-song").text(duration); + suggest_song.find(".accept").attr("data-video-id", video_id); + suggest_song.find(".accept").attr("data-video-title", video_title); + suggest_song.find(".accept").attr("data-video-length", secs); + suggest_song.find(".decline").attr("data-video-id", video_id); + + $("#suggest-song-html").append(List.generateSong({id: song.id, title: song.snippet.title, length: secs, duration: duration}, false, false, false)); + }); + } + }); + } + }); + } + +} \ No newline at end of file