From e5a12f8d9996f59d1637df878098821570ead852 Mon Sep 17 00:00:00 2001 From: rosh Date: Thu, 6 Aug 2020 16:17:39 +0530 Subject: [PATCH] adding movies page --- movies.js | 66 +++++++++++++++++++++++++++++++++++++++++++++------------ moviesPage.html | 15 +++++++++++++ 2 files changed, 68 insertions(+), 13 deletions(-) create mode 100644 moviesPage.html diff --git a/movies.js b/movies.js index f253f74..38c6150 100644 --- a/movies.js +++ b/movies.js @@ -1,12 +1,8 @@ -var searchkey; + $(document).ready(function(){ $('.message a').click(function(){ $('form').animate({height: "toggle", opacity: "toggle"},"slow"); }); - -$('.search-btn').click(function() { - searchkey= $('.search-movies').val(); - }); }); async function submitForm(e){ @@ -61,6 +57,7 @@ async function submitForm1(e){ async function search(e){ e.preventDefault(); + var searchkey= $('.search-movies').val(); var Token=window.localStorage.getItem('Token'); try { const response = await fetch('https://mkr.thefeathers.in/search/'+searchkey, { @@ -71,16 +68,29 @@ async function search(e){ //Success code goes here //window.location = "searchmovies.html"; alert(JSON.stringify(data2)); - var str = ''; - document.getElementById("slideContainer").innerHTML = str; + document.getElementById("slideContainer").append(...listItems); + + $('.list').click(function(event){ + moviePage(event); + }); } catch (err) { //Failure @@ -88,5 +98,35 @@ async function search(e){ } } +async function moviePage(e){ + e.preventDefault(); + var Token=window.localStorage.getItem('Token'); + var movieID=window.localStorage.getItem('movieID'); + window.location = "searchmovies.html"; + try { + const response = await fetch('https://mkr.thefeathers.in/movie/'+movieID, { + method: 'GET', + headers: new Headers({'content-type': 'application/json', 'Authentication': Token }), + }); + const data3 = await response.json(); + //Success code goes here + alert(JSON.stringify(data3)); + var results1 =data2.results; + + window.location = "moviesPage.html"; + document.getElementById("Container").append(results1.movieID); + document.getElementById("Container").append(results1.title); + document.getElementById("Container").append(results1.overview); + document.getElementById("Container").append(results1.poster); + document.getElementById("Container").append(results1.release); + document.getElementById("Container").append(results1.watchStatus); + document.getElementById("Container").append(results1.rating); + + } + catch (err) { + //Failure + alert('Error'); + } +} \ No newline at end of file diff --git a/moviesPage.html b/moviesPage.html new file mode 100644 index 0000000..e0786a0 --- /dev/null +++ b/moviesPage.html @@ -0,0 +1,15 @@ + + + + Search Movies + + + + + + +
+
+ +
+ \ No newline at end of file