-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSPA-omdb.html
165 lines (164 loc) · 6 KB
/
SPA-omdb.html
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Exelia Movie Omdb Task</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="http://cdn.asimplify.com/lightboxgallery/css/lightboxgallery.css">
<link rel="stylesheet" href="http://cdn.asimplify.com/lightboxgallery/css/lightboxgallery-min.css">
<script>
angular.module('MovieApp', [])
.controller("MovieAppCtrl",
[
'$http', '$scope',
function($http, $scope) {
$scope.MovieData = [];
$scope.Search = null;
$scope.GetMoviesData = function() {
try {
$http({
url: 'http://www.omdbapi.com/?apikey=81d3b711&s='+$scope.Search,
method: "GET",
}).then(
function(payload) {
$scope.MovieData = payload.data;
},
function(){
alert("Something is wrong. Please try again.");
});
} catch (error) {
alert("Exception occured while fetching movie data.");
}
}
}
]);
angular.element(function() {
angular.bootstrap(document, ['MovieApp']);
});
</script>
<style>
@import url('https://fonts.googleapis.com/css?family=Open+Sans:300,400,600&display=swap');
</style>
<style>
body{
font-size: 14px;
font-family: 'Open Sans', sans-serif;
margin:0px;
line-height: 1.4;
}
.movieContainer{
background: #006381;
margin-top: 40px;
-webkit-box-shadow: 0px 0px 16px 4px rgba(35,31,32,0.2);
-moz-box-shadow: 0px 0px 16px 4px rgba(35,31,32,0.2);
box-shadow: 0px 0px 16px 4px rgba(35,31,32,0.2);
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;
}
.movieContainer input, .movieContainer button{
width:60%;
margin:0 auto;
}
.movieContainer input{
padding:12px;
height: 46px;
}
.movieContainer h2{
text-align: center;
color:white;
margin-top:30px;
margin-bottom:30px;
font-weight: 600;
}
.movieContainer button{
background-color: #179ec7;
border-color: #179ec7;
color: white;
padding: 12px;
}
.lightboxgallery-gallery{
margin-top:20px;
}
.lightboxgallery-gallery-item-content {
background: #006381;
color: white;
padding: 10px;
margin-top: 12px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}
.lightboxgallery-gallery a{
text-align: center;
-webkit-box-shadow: 0px 0px 16px 4px rgba(35,31,32,0.2);
-moz-box-shadow: 0px 0px 16px 4px rgba(35,31,32,0.2);
box-shadow: 0px 0px 16px 4px rgba(35,31,32,0.2);
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;
padding: 20px 10px 10px;
width: 32.33% !important;
margin-right: 1.5% !important;
display:inline-block;
}
.lightboxgallery-gallery a img{
max-height: 350px;
}
.lightboxgallery-gallery a:last-child{
margin-right:0 !important;
}
.lightboxgallery-gallery a .col-md-4{
width:100%;
}
</style>
</head>
<body ng-controller='MovieAppCtrl'>
<div class="container movieContainer">
<h2>Please enter movie name in text box given below.</h2>
<div class="row">
<div class="form-group" style="text-align:center;">
<div class="col-md-auto">
<input type="name" class="form-control" placeholder="Enter movie name" ng-model="Search">
</div>
</div>
<div class="form-group" style="text-align:center;">
<div class="col-md-auto">
<button type="submit" class="btn btn-default" ng-click="GetMoviesData()">Submit</button>
</div>
</div>
</div>
<div ng-hide="MovieData.Search && MovieData.Search.Response !=='True' " class="col-md-auto alert alert-info" style="margin-top:10px; text-align: center;">
<strong>Alert!</strong> No data found.
</div>
</div>
<div class="container" style="margin-top:10px;">
<div class="lightboxgallery-gallery clearfix">
<a ng-repeat="movie in MovieData.Search | limitTo:3" class="lightboxgallery-gallery-item" target="_blank" ng-href="{{movie.Poster}}" data-title="{{movie.Title}}" data-link="http://www.imdb.com/title/{{movie.imdbID}}" data-alt="{{movie.Title}}">
<div class="col-md-4">
<img ng-src="{{movie.Poster}}" title="{{movie.Title}}" alt="{{movie.Title}}">
<div class="lightboxgallery-gallery-item-content">
<span class="lightboxgallery-gallery-item-title">{{movie.Title}}</span>
</div>
</div>
</a>
</div>
</div>
<script src="http://cdn.asimplify.com/lightboxgallery/js/lightboxjs-custom.js"></script>
<script type="text/javascript">
jQuery(function($) {
$(document).on('click', '.lightboxgallery-gallery-item', function(event) {
event.preventDefault();
$(this).lightboxgallery({
showCounter: true,
showTitle: true,
showDescription: true
});
});
});
</script>
</body>
</html>