Сообщение от tk.stas
|
и с сортировкой по дате.
|
???
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$(function() {
var data ={
"events" : {
"prop1" : {
"simple1" : [
{
"title" : "Заголовок1_1",
"date" : "Дата1_1"
},
{
"title" : "Заголовок1_2",
"date" : "Дата1_2"
}
],
"simple2" : [ {
"title" : "Заголовок2",
"date" : "Дата2"
} ]
},
"prop2" : {
"simp1" : [ {
"title" : "Заголовок3",
"type" : "Тип1",
"date" : "Дата3"
} ],
"simp2" : [ {
"title" : "Заголовок4",
"type" : "Тип2",
"date" : "Дата4"
} ]
}
}
}
function fn(a) {
var c = [];
Object.keys(a).forEach(function(d) {
"title" == d ? c.push(a) : "object" == typeof a[d] && (c = c.concat(fn(a[d])))
});
return c
}
fn(data).
//.sort() неизвестно как сортировать
forEach(function(a, c) {
a = Object.keys(a).map(function(c) {
return a[c]
}).join("-");
$("<li>", {
text: a
}).appendTo("ol")
});
});
</script>
</head>
<body>
<ol>
</ol>
</body>
</html>