From 45239549bf2659998dcf9196d86974b0b625912e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sat, 23 Jan 2016 18:31:58 +0100 Subject: Finalise the join in a network and add the ability to quit it --- public/javascripts/index.js | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) (limited to 'public') diff --git a/public/javascripts/index.js b/public/javascripts/index.js index c0388c55a..5d42f02e0 100644 --- a/public/javascripts/index.js +++ b/public/javascripts/index.js @@ -31,6 +31,10 @@ makeFriends() }) + $('#panel_quit_friends').on('click', function () { + quitFriends() + }) + $('#search-video').on('keyup', function (e) { var search = $(this).val() @@ -60,6 +64,17 @@ }) } + function quitFriends () { + $.ajax({ + url: '/api/v1/pods/quitfriends', + type: 'GET', + dataType: 'json', + success: function () { + alert('Quit friends!') + } + }) + } + function printVideos (videos) { $content.empty() @@ -72,8 +87,21 @@ var $video_name = $('').addClass('video_name').text(video.name) var $video_pod = $('').addClass('video_pod_url').text(video.podUrl) - var $remove = $('').addClass('span_action glyphicon glyphicon-remove') - var $header = $('
').append([ $video_name, $video_pod, $remove ]) + var $header = $('
').append([ $video_name, $video_pod ]) + + if (video.namePath !== null) { + var $remove = $('').addClass('span_action glyphicon glyphicon-remove') + + // Remove the video + $remove.on('click', function () { + // TODO + if (!confirm('Are you sure ?')) return + + removeVideo(video) + }) + + $header.append($remove) + } var $video_description = $('
').addClass('video_description').text(video.description) @@ -82,14 +110,6 @@ getVideo(video) }) - // Remove the video - $remove.on('click', function () { - // TODO - if (!confirm('Are you sure ?')) return - - removeVideo(video) - }) - if (!video.magnetUri) { $remove.css('display', 'none') } -- cgit v1.2.3