From a5225dfc2e48877b28a13d3b35dab16f5172a34b Mon Sep 17 00:00:00 2001 From: Bas Stottelaar Date: Tue, 27 Jan 2015 21:44:14 +0100 Subject: [PATCH] Hide songkick if there are no events AFTER filtering --- data/interfaces/default/artist.html | 60 ++++++++++++++--------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/data/interfaces/default/artist.html b/data/interfaces/default/artist.html index 229cef67..3a145197 100644 --- a/data/interfaces/default/artist.html +++ b/data/interfaces/default/artist.html @@ -189,45 +189,45 @@ $.getJSON("https://api.songkick.com/api/3.0/artists/mbid:${artist['ArtistID']}/calendar.json?apikey=${headphones.CONFIG.SONGKICK_APIKEY}&jsoncallback=?", function(data){ if (data['resultsPage'].totalEntries >= 1) { - - if( ${songkick_filter_enabled} ) { + if (${songkick_filter_enabled}) { data.resultsPage.results.event = $.grep(data.resultsPage.results.event, function(element,index){ - return element.venue.metroArea.id == ${songkick_location}; - }); + return element.venue.metroArea.id == ${songkick_location}; + }); } - var tourDate; + if (data.resultsPage.results.event.length > 0) { + var tourDate; - calendarDomNode.show(); - $("#artistImg").addClass('on-tour'); + calendarDomNode.show(); + $("#artistImg").addClass('on-tour'); - jQuery.each( data['resultsPage'].results.event, function( i, event ) { - tourDate = template; - tourDate = tourDate.replace('URI',event.uri); - tourDate = tourDate.replace('NAME',event.displayName); - tourDate = tourDate.replace('LOC',event.location.city); + jQuery.each(data.resultsPage.results.event, function(i, event) { + tourDate = template; + tourDate = tourDate.replace('URI',event.uri); + tourDate = tourDate.replace('NAME',event.displayName); + tourDate = tourDate.replace('LOC',event.location.city); - calendarDomNode.append(tourDate); - }); + calendarDomNode.append(tourDate); + }); - calendarDomNode.append('
  • '); - - $(function() { - $("#artistCalendar").each(function() { - $("li:gt(4)", this).hide(); /* :gt() is zero-indexed */ - $("li:nth-child(5)", this).after("
  • More...
  • "); /* :nth-child() is one-indexed */ - }); - $("li.more a").live("click", function() { - var li = $(this).parents("li:first"); - li.parent().children().show(); - li.remove(); - return false; - }); - }); + calendarDomNode.append('
  • '); + $(function() { + $("#artistCalendar").each(function() { + $("li:gt(4)", this).hide(); /* :gt() is zero-indexed */ + $("li:nth-child(5)", this).after("
  • More...
  • "); /* :nth-child() is one-indexed */ + }); + $("li.more a").live("click", function() { + var li = $(this).parents("li:first"); + li.parent().children().show(); + li.remove(); + return false; + }); + }); + } } - // data is JSON response object - }); + } + ); } var loadingMessage = false;