Created
August 23, 2016 22:46
-
-
Save xpollen8/24dc7dc6e748f80c8db5e9bba54e6b88 to your computer and use it in GitHub Desktop.
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> | |
<head> | |
<title>buh</title> | |
<script> | |
var gigs = [ | |
{ | |
"datetime": "1991-06-18 00:00:00", | |
"url": "/htdb/gigs/1991/Jun18.html", | |
"venue": { | |
"name": "The Mean Fiddler", | |
"city": "London", | |
"country": "England" | |
}, | |
"played": { | |
"warmups": [], | |
"sets": [ | |
{ | |
"num": "1", | |
"played": [ | |
{ | |
"ordinal": "1", | |
"song": "Still & All" | |
}, | |
{ | |
"ordinal": "2", | |
"song": "Honey" | |
}, | |
{ | |
"ordinal": "3", | |
"song": "Angels" | |
}, | |
{ | |
"ordinal": "4", | |
"song": "Pineapple Tuesday" | |
}, | |
{ | |
"ordinal": "5", | |
"song": "Girl-Go" | |
}, | |
{ | |
"ordinal": "6", | |
"song": "Sister Death" | |
}, | |
{ | |
"ordinal": "7", | |
"song": "Everybody's Talkin' (F. Neil)" | |
} | |
] | |
}, | |
null | |
], | |
"encores": [] | |
}, | |
"what": { | |
"recording_media": "Walkman", | |
"recording_quality": "6" | |
}, | |
"who": [ | |
{ | |
"name": "Pat Fish", | |
"link": "http://patfish.com" | |
}, | |
{ | |
"name": "Alex Green", | |
"link": "/htdb/people/alex_green.html" | |
}, | |
{ | |
"name": "Peter Crouch", | |
"link": "/htdb/people/peter_crouch.html" | |
} | |
], | |
"with": [ | |
{ | |
"artist": { | |
"name": "Peter Astor", | |
"link": "/htdb/people/peter_astor.html" | |
} | |
} | |
] | |
} , | |
]; | |
function json2div(g) { | |
if (!(g === null || g === undefined)) { | |
var type = typeof(g); | |
if (type === 'string') { | |
return g; | |
} else if (g.constructor === [].constructor) { // array | |
var res = '<ul>'; | |
Object.keys(g).forEach(function(k) { | |
if (g[k]) { | |
if (g[k].src) { res += "<a href='http://127.0.0.1" + g[k].src + "'>"; } | |
res += "<li>"+json2div(g[k])+"</li>"; | |
if (g[k].src) { res += "</a>"; } | |
} | |
}); | |
res += "</ul>"; | |
return res; | |
} else if (type === 'object') { | |
var res = ''; | |
Object.keys(g).forEach(function(k) { | |
if (k === 'credit' || k === 'name') { | |
if (g.link) { | |
var link = g.link; | |
if (link[0] === '/') { | |
link = 'http://127.0.0.1' + g.link; | |
} | |
res += "<a href='" + link + "'>"; | |
} | |
res += "<span class='credit'>" + g[k] + "</span>"; | |
if (g.link) { res += "</a>"; } | |
} else if (k === 'thumb') { | |
var thumb = g.thumb; | |
res += "<img src='http://127.0.0.1"+thumb.src+"' "; | |
if (thumb.alt) { res += "alt='"+thumb.alt+"' "; } | |
if (thumb.width) { res += "width='"+thumb.width+"' "; } | |
if (thumb.height) { res += "height='"+thumb.height+"' "; } | |
res += ">"; | |
} else if (k === 'src') { // ignore | |
} else if (k === 'link') { // ignore | |
} else { | |
res += "<div class='"+k+"'>"+json2div(g[k])+"</div>"; | |
} | |
}); | |
return res; | |
} | |
} | |
} | |
function loaded() { | |
gigs.sort(function(a, b) { | |
return (a.datetime < b.datetime) ? -1 : 1; | |
}); | |
for (var i = 0 ; i < gigs.length ; i++) { | |
var g = gigs[i]; | |
var id = g.datetime; | |
var div = document.getElementById('content'); | |
div.innerHTML += json2div(g); | |
} | |
} | |
</script> | |
<style> | |
#content { | |
border: solid; | |
border-width: 1px; | |
} | |
.datetime { | |
color: #00ff00; | |
} | |
.venue { | |
border: solid; | |
border-width: 1px; | |
max-width: 80%; | |
} | |
.setlists { | |
border: dashed; | |
border-width: 1px; | |
max-width: 80%; | |
} | |
.played { | |
border: dashed; | |
max-width: 80%; | |
border-width: 1px; | |
} | |
.played .item .song { | |
text-spacing: 10px; | |
} | |
</style> | |
</head> | |
<body onload="loaded()"> | |
<div id="content"> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment