-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
57 lines (48 loc) · 2.11 KB
/
Copy pathscript.js
File metadata and controls
57 lines (48 loc) · 2.11 KB
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
$(document).ready(function() {
$("#getResults").on("click", function() {
var SearchVal = $('#getText').val()
if (SearchVal === "") {
return;
}
select();
});
function select() {
var Miles = $('#miles').val();
var SearchVal = $('#getText').val()
var searchCity = "&q=" + SearchVal;
var res = {
"async": true,
"crossDomain": true,
"url": "https://developers.zomato.com/api/v2.1/search?entity_id=" + valueDropdown + "&entity_type=city" + searchCity + "&count=5",
"method": "GET",
"headers": {
"user-key": "d710754ce67200fb6fb9b5e26139f50e",
'Content-Type': 'application/x-www-form-urlencoded'
}
}
$.getJSON(res, function(data) {
data = data.restaurants;
var html = "";
$.each(data, function(index, value) {
var x = data[index];
$.each(x, function(index, value) {
var location = x.restaurant.location;
var userRating = x.restaurant.user_rating;
html += "<div class='data'>";
html += "<div class='rating'>";
html += "<span title='" + userRating.rating_text + "'><p style='color:white;background-color:#" + userRating.rating_color + ";border-radius:4px;border:none;padding:2px 10px 2px 10px;text-align: center;text-decoration:none;display:inline-block;font-size:16px;float:right;'><strong>" + userRating.aggregate_rating + "</strong></p></span><br>";
html += " <strong class='text-info'>" + userRating.votes + " votes</strong>";
html += "</div>";
html += "<img class='resimg img-rounded' src=" + value.thumb + " alt='Restaurant Image' height='150' width='185'>";
html += "<a href=" + value.url + " target='_blank' class='action_link'><h3 style='color:#cb202d;'><strong>" + value.name + "</strong></h3></a>";
html += " <strong class='text-primary'>" + location.locality + "</strong><br>";
html += " <h6 style='color:grey;'><strong>" + location.address + "</strong></h6>";
html += " <strong>Cuisines</strong>: " + value.cuisines + "<br>";
html += " <strong>Cost For Two</strong>: " + value.currency + value.average_cost_for_two + "<br>";
html += "</div><br>";
});
});
$(".results").html(html);
});
}
});