-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
231 lines (189 loc) · 6.97 KB
/
index.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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<link
rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
crossorigin="anonymous"
/>
<link rel="stylesheet" href="styles.css" />
<title>Movies!</title>
</head>
<body>
<div class="header_input m-auto">
<h1 class="text-center mt-3 bg-dark p-2 mb-5" id="header">
Movie Pedia
</h1>
<form autocomplete="off" id="movie-form">
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text" id="basic-addon3">Enter Title</span>
</div>
<input
type="text"
class="form-control"
id="movie-input"
aria-describedby="basic-addon3"
autofocus
/>
</div>
</form>
<div id="tooltip" class="tootltip alert alert-info alert-dismissible fade show" role="alert">
Now you can click on Poster to check summary!
<button type="button" id="close-tooltip" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
</div>
<div class="error">
<div class="alert alert-warning alert-dismissible fade show" role="alert">
<strong>Movie Not Found!</strong> Please Try typing the full Movie
Title,<span id="red_color">
<strong>Remember Spaces are also considered</strong></span
>
<button
type="button"
class="close"
data-dismiss="alert"
aria-label="Close"
>
<span aria-hidden="true">×</span>
</button>
</div>
</div>
<div class="empty_input d-none">
<div class="alert alert-warning alert-dismissible fade show" role="alert">
<strong>Title Can't Be Empty
<button
type="button"
class="close"
data-dismiss="alert"
aria-label="Close"
>
<span aria-hidden="true">×</span>
</button>
</div>
</div>
<div class="anim"></div>
<div class="output_container">
<div id="rating"></div>
<div id="result"></div>
<div class="modal" id="modal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Summary</h5>
<button
type="button"
class="close"
data-dismiss="modal"
aria-label="Close"
>
<span aria-hidden="true" id="close-x" class="close-x">X</span>
</button>
</div>
<div class="modal-body" id="modal-body"></div>
<div class="modal-footer">
<button
type="button"
id="close-btn"
class="btn btn-secondary"
data-dismiss="modal"
>
Close
</button>
</div>
</div>
</div>
</div>
</div>
<script>
$("#close-tooltip").click(function(){
$("#tooltip").fadeOut();
})
setTimeout(function(){
$('.tootltip').remove();
}, 5000);
$body = $("body");
$(document).on({
ajaxStart: function () {
$body.addClass("loading");
},
ajaxStop: function () {
$body.removeClass("loading");
},
});
// preventing form default submission
$("form").keypress(function (e) {
//Enter key
if (e.which == 13) {
return false;
}
});
// close alert
$(".close").click(function () {
$(".error").fadeOut();
// $(".alert").fadeOut();
});
$(".error").css("display", "none");
$(document).ready(function () {
$("#movie-input").on("keyup", function () {
var apiKey = config.ApiKey;
var movie = $("#movie-input").val();
if (movie) {
var result = "";
var url = "https://www.omdbapi.com/?apikey=" + apiKey;
$.ajax({
method: "GET",
url: url + "&t=" + movie,
success: function (data) {
if (data.Title == undefined) {
$(".output_container").css("display", "none");
console.log("nope");
$(".error").css("display", "block");
} else {
$(".error").css("display", "none");
$(".output_container").css("display", "block");
var rating = `
<h2 style="margin:0 auto" class="w-30 p-3 mb-3 border border-warning rounded">${data.Title}</h2>
<p class="badge badge-pill badge-dark p-2" >imdb Rating : ${data.imdbRating}</p>
<p class="badge badge-pill badge-secondary p-2">imdb votes : ${data.imdbVotes}</p>
`;
result = `
<img id="poster" alt = "image not available" class="img-thumbnail mb-2 mx-auto rounded d-block mr-2" src="${data.Poster}"></img>
<ul class="list-group mt-2 mb-3">
<li class="list-group-item"><strong>Actors </strong>: ${data.Actors}</li>
<li class="list-group-item"><strong>Genre </strong> : ${data.Genre}</li>
<li class="list-group-item"><strong>Type </strong>: ${data.Type}</li>
<li class="list-group-item"><strong>Runtime </strong>: ${data.Runtime}</li>
<li class="list-group-item"><strong>Language </strong>: ${data.Language}</li>
<li class="list-group-item"><strong>Release Date </strong>: ${data.Released}</li>
<li class="list-group-item"><strong>Awards </strong>: ${data.Awards}</li>
<li class="list-group-item"><strong>Writers </strong>: ${data.Writer}</li>
<li class="list-group-item"><strong>Country </strong>: ${data.Country}</li>
</ul>
`;
var plot = `
<p>${data.Plot}</p>
`;
$("#result").html(result);
$("#rating").html(rating);
$("#poster").click(function () {
$("#modal-body").html(plot);
$("#modal").css("display", "block");
});
}
},
});
}
});
});
</script>
<script type="text/javascript" src="config.js"></script>
<script type="text/javascript" src="main.js"></script>
</body>
</html>