Last active
August 29, 2015 14:00
-
-
Save egorvinogradov/11027632 to your computer and use it in GitHub Desktop.
This file contains 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
// http://instagram.com/<username>/media | |
function handleInstagramJSON(json){ | |
var html = []; | |
if ( json.items && json.items.length ) { | |
json.items.forEach(function(item){ | |
var img = '<img width="300" src="' + item.images.standard_resolution.url + '">'; | |
var imgLink = '<a href="' + item.link + '" target="_blank">' + img + '</a>'; | |
var date; | |
if ( item.caption && item.caption.created_time ) { | |
date = new Date(+item.caption.created_time * 1000).toString(); | |
} | |
var mapLink, | |
lat, | |
lng; | |
if ( item.location ) { | |
lng = item.location.longitude; | |
lat = item.location.latitude; | |
mapLink = '<a href="https://www.google.com/maps/place/' + lat + ',' + lng + '/@' + lat + ',' + lng + ',13z" target="_blank">Find on map</a>'; | |
} | |
html.push('<li><div>' + imgLink + '<br>' + ( date || 'No date' ) + '<br>' + ( mapLink || 'No map' ) + '<br> ' + '</div></li>'); | |
}); | |
document.body.innerHTML = '<ol style="text-align: left;">' + html.join('\n') + '</ol>'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment