var songkickpageContainer = document.querySelector('article'), songkickpageShowTemplate = songkickpageContainer.querySelector('.template').innerHTML, songkickpageShowHTML = '', songkickpageShowDate, songkickpageShowDateSplit, songkickpageMonth, songkickpageDay, songkickpageVenue, songkickpageDetails, songkickpageticketUrl, songkickpageMonths = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'July', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] ; function songkickpageTourDates(response) { console.log(response); for(var i = 0, n = response.resultsPage.results.event.length; i < n; i++) { songkickpageShowDateSplit = response.resultsPage.results.event[i].start.date.split("-") songkickpageShowDate = new Date(songkickpageMonths[songkickpageShowDateSplit[1] - 1] + " " + songkickpageShowDateSplit[2] + ", " + songkickpageShowDateSplit[0]); songkickpageMonth = songkickpageShowDate.getUTCMonth(); songkickpageDay = songkickpageShowDate.getUTCDate(); songkickpageVenue = response.resultsPage.results.event[i].venue.displayName; songkickpageDetails = response.resultsPage.results.event[i].location.city; songkickpageticketUrl = response.resultsPage.results.event[i].uri; songkickpageShowHTML = songkickpageShowTemplate; songkickpageShowHTML = songkickpageShowHTML.replace('{month}', songkickpageMonths[songkickpageMonth]) songkickpageShowHTML = songkickpageShowHTML.replace('{day}', songkickpageDay) songkickpageShowHTML = songkickpageShowHTML.replace('{venue}', songkickpageVenue) songkickpageShowHTML = songkickpageShowHTML.replace('{details}', songkickpageDetails) songkickpageShowHTML = songkickpageShowHTML.replace('{ticket_uri}', songkickpageticketUrl) songkickpageContainer.innerHTML += songkickpageShowHTML; } }