-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
65 lines (53 loc) · 1.93 KB
/
script.js
File metadata and controls
65 lines (53 loc) · 1.93 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
58
59
60
61
62
63
64
65
$(document).ready(function() {
$('.order').click(function(e){
e.preventDefault(); //stop default action of the link
order = $(this).attr("href"); //get category from URL
loadAJAX(order); //load AJAX and parse JSON file
});
});
function loadAJAX(order)
{
$.ajax({
type: "GET",
dataType: "json",
url: "api.php?order=" + order,
success: parksJSON,
//success: toConsole,
});
$('#seattleParks').html('');//clear data
}
//function toConsole(data)
//{//return data to console for JSON examination
// console.log(data); //to view,use Chrome console, ctrl + shift + j
//}
function parksJSON(data){
//$('#output').text(JSON.stringify(data)); //uncomment to view raw output
var header = data.title;
$('#resultsTitle').html(header);
$.each(data.parks, function(i,item){
var text = '<div class="picWrap"><img class="picItem" src="images/historic/' + item.Image + '" /></div>';
//var text = '<b>Name</b>: ' + item.Name + '<br />';
text += '<div class="parkDesc"><h3>' + item.Name + '</h3>';
text += '<p>' + item.Address + '</p>';
text += '<p>' + item.Neighborhood + ' neighborhood</p>';
text += '<p>' + item.Acreage + ' acres</p>';
text += '<p><span>Year Established</span>: ' + item.YearEst + '</p>';
text += '<h4>Description</h4>'
text += '<p>' + item.ParkDescription + '<a href="' + item.Website + '"> Read more...</a> </p>';
text += '<p class="imgCredit">Image Credit: ' + item.HstImgCredit + '</p> </div>';
//text += '<div id="pic"><img src="images/historic/' + item.HistoricImage + '" /></div>';
//append text to #parks div
$('<div class="parkItem"></div>').html(text).appendTo('#seattleParks');
});
var images = $('div.pic image');
console.log(images);
//$('img.pic').click(function(){
//alert("success!");
//console.log
//var source = $('img').attr("src");
//console.log(source);
//source = source.replace("/historic", "");
//console.log(source);
//$('img').attr("src", source);
//});
}