Browse Source

adding movies page

master
rosh 4 years ago
parent
commit
91602dbb37
  1. 41
      movies.js
  2. 34
      moviesPage.html

41
movies.js

@ -72,25 +72,19 @@ async function search(e){
if(!results) return; if(!results) return;
var listItems = results.map(myfunction); var listItems = results.map(myfunction);
window.localStorage.setItem('movieID', (results.movieID));
var movieID=window.localStorage.getItem('movieID');
function myfunction(results){ function myfunction(result){
var x = document.createElement("li"); var x = document.createElement("li");
var a = document.createElement("a"); var a = document.createElement("a");
var t = document.createTextNode(results.title); var t = document.createTextNode(result.title);
x.appendChild(a); x.appendChild(a);
a.appendChild(t); a.appendChild(t);
a.setAttribute("href","https://mkr.thefeathers.in/movie/"+movieID); a.setAttribute("href","/moviesPage?movieId=" + result.movieId);
x.setAttribute("class","list"); x.setAttribute("class","list");
return x; return x;
} }
document.getElementById("slideContainer").append(...listItems); document.getElementById("slideContainer").append(...listItems);
$('.list').click(function(event){
moviePage(event);
});
} }
catch (err) { catch (err) {
//Failure //Failure
@ -98,35 +92,6 @@ 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');
}
}

34
moviesPage.html

@ -10,6 +10,38 @@
<body> <body>
<div class="header"> <div class="header">
<div id="Container"></div> <div id="Container"></div>
</div> </div>
<script>
async function moviePage(e){
var Token=window.localStorage.getItem('Token');
const searchParams = new URLSearchParams(window.location.search);
const movieId = searchParams.get("movieId");
try {
const response = await fetch('https://mkr.thefeathers.in/movie/'+movieId, {
method: 'GET',
headers: new Headers({'Authentication': Token }),
});
const data3 = await response.json();
//Success code goes here
alert(JSON.stringify(data3));
var results1 =data3.results;
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);
window.addEventListener("load", moviePage);
}
catch (err) {
//Failure
alert('Error');
}
}
</script>
</body> </body>
Loading…
Cancel
Save