Browse Source

adding movies page

master
rosh 4 years ago
parent
commit
e5a12f8d99
  1. 66
      movies.js
  2. 15
      moviesPage.html

66
movies.js

@ -1,12 +1,8 @@
var searchkey;
$(document).ready(function(){ $(document).ready(function(){
$('.message a').click(function(){ $('.message a').click(function(){
$('form').animate({height: "toggle", opacity: "toggle"},"slow"); $('form').animate({height: "toggle", opacity: "toggle"},"slow");
}); });
$('.search-btn').click(function() {
searchkey= $('.search-movies').val();
});
}); });
async function submitForm(e){ async function submitForm(e){
@ -61,6 +57,7 @@ async function submitForm1(e){
async function search(e){ async function search(e){
e.preventDefault(); e.preventDefault();
var searchkey= $('.search-movies').val();
var Token=window.localStorage.getItem('Token'); var Token=window.localStorage.getItem('Token');
try { try {
const response = await fetch('https://mkr.thefeathers.in/search/'+searchkey, { const response = await fetch('https://mkr.thefeathers.in/search/'+searchkey, {
@ -71,16 +68,29 @@ async function search(e){
//Success code goes here //Success code goes here
//window.location = "searchmovies.html"; //window.location = "searchmovies.html";
alert(JSON.stringify(data2)); alert(JSON.stringify(data2));
var str = '<ul>' var results =data2.results;
var result = data2.results; if(!results) return;
result.forEach(myfunction);
var listItems = results.map(myfunction);
window.localStorage.setItem('movieID', (results.movieID));
var movieID=window.localStorage.getItem('movieID');
function myfunction(slide){ function myfunction(results){
str += '<li>'+ slide + '</li>'; 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;
} }
document.getElementById("slideContainer").append(...listItems);
str += '</ul>';
document.getElementById("slideContainer").innerHTML = str; $('.list').click(function(event){
moviePage(event);
});
} }
catch (err) { catch (err) {
//Failure //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');
}
}

15
moviesPage.html

@ -0,0 +1,15 @@
<html>
<head>
<title>
Search Movies
</title>
<!--<link rel="stylesheet" href="searchstyle.css">-->
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="movies.js"></script>
</head>
<body>
<div class="header">
<div id="Container"></div>
</div>
</body>
Loading…
Cancel
Save