-
Notifications
You must be signed in to change notification settings - Fork 1
/
items.js
91 lines (62 loc) · 2.57 KB
/
items.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import {key1} from "./pwd.js"
const api = key1()
async function detail_display(name,location)
{
location.innerHTML = "";
location.style.cssText =
`border: transparent;
overflow-y: scroll;`;
try{
let response = await fetch(`https://www.omdbapi.com/?apikey=${api}&t="${name}"`)
let data = await response.json()
let {Actors,country,Director,Genre,Plot,Poster,Released,Runtime,Title,Writer,imdbRating} = data
let image = document.createElement("img")
image.src = Poster
let content = document.createElement("div")
let title = document.createElement("h2")
title.textContent = ` ${Title} `
let genre = document.createElement("h4")
genre.textContent = `Genre : ${Genre}`
let plot = document.createElement("h4")
plot.textContent = `Plot : ${Plot}`
let director = document.createElement("h4")
director.textContent = `Director : ${Director}`
let actors = document.createElement("h4")
actors.textContent = `Actors : ${Actors}`
let writer = document.createElement("h4")
writer.textContent = `Writer : ${Writer}`
let year = document.createElement("h4")
year.textContent = `Released Date : ${Released}`
let runtime = document.createElement("h4")
runtime.textContent = `Runtime : ${Runtime}`
let Country = document.createElement("h4")
Country.textContent = `Country : ${country}`
let Rating = document.createElement("h4")
Rating.textContent = `Rating : ${imdbRating}⭐`
content.append(title,genre,plot,director,actors,writer,year,runtime,Country,Rating)
location.append(image,content)
}
catch(error)
{
console.log(error)
}
}
function setdata(link,location)
{
link.then(function(res){
location.innerHTML = "";
res.forEach(({poster_path,title}) => {
let movie = document.createElement("div")
movie.addEventListener("click",function(){
location.style.transform = "translateY(500px)"
let div = document.querySelector("#details")
detail_display(title,div)
})
let image = document.createElement("img")
image.src = `https://image.tmdb.org/t/p/original${poster_path}`
movie.append(image)
location.append(movie)
});
})
}
export {setdata,detail_display}