-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
68 lines (48 loc) · 1.82 KB
/
script.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
$(document).ready( () =>{
$('#content').css('display', 'none')
$('#searchbtn').click(( e ) =>{
e.preventDefault()
let searchItem = $('#item').val()
if ( searchItem == '' || searchItem == null || searchItem == undefined ) {
// alert("enter valid entry")
$('.modal').show(500)
$('.close, .btn').click(() =>{
$('.modal').hide(500)
})
return
} else {
callCrawl( searchItem )
$('#content').css('display', '')
}
})
})
const callCrawl = ( param ) => {
$.ajax({
type: 'GET',
datatype: 'json',
async: true,
url:'https://www.omdbapi.com/?apikey=df308db8&t='+param,
success: (response) =>{
console.log(response)
$('#plot').text(response.Plot)
$('#awards').text(response.Awards)
$('#imdbid').text(response.imdbID).attr('title', 'imdbID')
$('#released').text(response.Released).attr('title', 'Released Date')
$('#review').text(response.Response).attr('title','Response')
$('#season').text(response.totalSeasons).attr('title', 'totalSeasons')
$('#metascore').text(response.Metascore).attr('title', 'Metascore')
$('#imdbVotes').text(response.imdbVotes).attr('title', 'imdbVotes')
$('#poster').attr('src',response.Poster)
$('#title').html(response.Title)
$('#rated').text(response.Rated).attr('title', 'Rated')
$('#runtime').text(response.Runtime).attr('title', 'Runtime')
$('#genre').text(response.Genre).attr('title', 'Genre')
$('#year').text(response.Type +' ('+response.Year+')')
$('#rating').text(response.imdbRating).attr('title',response.Ratings[0].Source)
$('.table').html('<tr><td>'+ response.Title +'</td><td><img src="'+response.Poster+'"></td></tr>')
$('#writers').html('<b>Writers : </b>'+response.Writer)
$('#actors').html('<b>Actors : </b>'+response.Actors)
$('#directors').html('<b>Director : </b>'+response.Director)
}
})
}