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 = '
'
- var result = data2.results;
- result.forEach(myfunction);
+ var results =data2.results;
+ if(!results) return;
+
+ var listItems = results.map(myfunction);
+ window.localStorage.setItem('movieID', (results.movieID));
+ var movieID=window.localStorage.getItem('movieID');
- function myfunction(slide){
- str += '- '+ slide + '
';
+ function myfunction(results){
+ var x = document.createElement("li");
+ var a = document.createElement("a");
+ var t = document.createTextNode(results.title);
+ x.appendChild(a);
+ a.appendChild(t);
+ a.setAttribute("href","https://mkr.thefeathers.in/movie/"+movieID);
+ x.setAttribute("class","list");
+ return x;
+
}
-
- 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