Last active
February 10, 2016 10:32
-
-
Save WeeHorse/289514b5327898e50a64 to your computer and use it in GitHub Desktop.
example my buildings data structure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// see it at https://jsbin.com/mejoke/edit?html,js,console,output | |
var data = [ | |
{ | |
filename:'england', | |
path: 'england/', | |
children:[ | |
{ | |
filename:'1920', | |
path: 'england/1920/' , | |
children:[ | |
{ | |
filename: 'house.jpg', | |
path: 'england/1920/house.jpg' | |
}, | |
{ | |
filename: 'building.jpg', | |
path: 'england/1920/building.jpg' | |
} | |
] | |
}, | |
{ | |
filename:'1930', | |
path: 'england/1930', | |
children:[ | |
{ | |
filename: 'otherhouse.jpg', | |
path: 'england/1930/otherhouse.jpg' | |
}, | |
{ | |
filename: 'otherbuilding.jpg', | |
path: 'england/1930/otherbuilding.jpg' | |
} | |
] | |
} | |
] | |
}, | |
{ | |
filename:'france', | |
path: 'france/', | |
children:[ | |
{ | |
filename:'1800', | |
path: 'france/1800', | |
children:[ | |
{ | |
filename: 'maison.jpg', | |
path: 'france/1800/maison.jpg' | |
}, | |
{ | |
filename: 'chateux.jpg', | |
path: 'france/1800/chateux.jpg' | |
} | |
] | |
}, | |
{ | |
filename:'1930', | |
path: 'france/1930', | |
children:[ | |
{ | |
filename: 'autremaison.jpg', | |
path: 'france/1930/autremaison.jpg' | |
}, | |
{ | |
filename: 'autrechateux.jpg', | |
path: 'france/1930/autrechateux.jpg' | |
} | |
] | |
} | |
] | |
} | |
]; | |
// for(var i=0; i<data.length; i++){ | |
// console.log(data[i].filename, data[i].path); | |
// for(var j=0; j<data[i].children.length; j++){ | |
// console.log(data[i].children[j].filename, data[i].children[j].path); | |
// for(var k=0; k<data[i].children[j].children.length; k++){ | |
// console.log(data[i].children[j].children[k].filename, data[i].children[j].children[k].path); | |
// } | |
// } | |
// } | |
for(var i=0; i<data.length; i++){ | |
var country = data[i]; | |
console.log(country.filename, country.path); | |
for(var j=0; j<country.children.length; j++){ | |
var decade = country.children[j]; | |
console.log(decade.filename, decade.path); | |
for(var k=0; k<decade.children.length; k++){ | |
var building = decade.children[k]; | |
console.log(building.filename, building.path); | |
} | |
} | |
} | |
// jQuery(function(){ | |
// $.each(data, function(i, country){ | |
// console.log(country.filename, country.path); | |
// $.each(country.children, function(j, decade){ | |
// console.log(decade.filename, decade.path); | |
// $.each(decade.children, function(k, building){ | |
// console.log(building.filename, building.path); | |
// }); | |
// }); | |
// }); | |
// }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="https://code.jquery.com/jquery-1.9.1.js"></script> | |
<script src="example_my_buildings_data_structure.js"></script> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>example my buildings data structure</title> | |
</head> | |
<body> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment