forked from legalese/legalese.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfiles.html
48 lines (36 loc) · 1.07 KB
/
files.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
<html>
<head>
<script src="jquery-2.1.4.min.js"></script>
</head>
<body>
<p id="body"></p>
<script>
function searchObjectForKey(obj, key, result) {
if ($.isPlainObject(obj)) {
if (obj.hasOwnProperty(key)) {
result.push(obj[key]);
}
}
if ($.isPlainObject(obj) || $.isArray(obj)) {
for (var k in obj) {
if (obj.hasOwnProperty(k))
searchObjectForKey(obj[k], key, result);
}
}
}
console.log("getting JSON");
$.getJSON('https://github.com/legalese/legalese.com/blob/master/files.json',
function(data) {
var res = [];
console.log("inside getJSON");
searchObjectForKey(data, "url_download", res);
console.log("res has " + res.length + " elements");
$('<ul/>', {
'class': 'my-new-list',
'html': res.map(function(value) {
return '<li><a href="' + value + '">' + value + '</a></li>'; }).join('')
}).appendTo('body');
});
</script>
</body>
</html>