From d17b7720ced885d327ec5f74c066ef1862b49bd6 Mon Sep 17 00:00:00 2001 From: Jonas Heinrich Date: Fri, 25 Aug 2017 22:16:36 +0200 Subject: [PATCH] fix loading favorites --- js/main.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/js/main.js b/js/main.js index 5ae880a..ccf89d4 100644 --- a/js/main.js +++ b/js/main.js @@ -232,6 +232,7 @@ $(function(){ function action_load_favorites(){ var stations = [] var baseUrl = OC.generateUrl('/apps/radio'); + $.get(baseUrl + '/stations', function ( data ) { for (var station in data) { stations.push(data[station]["stationid"]); @@ -248,18 +249,22 @@ $(function(){ function query_stations(station_ids){ var station_array = []; - for (stationid in station_ids){ + + station_ids.forEach(function (station_id, idx) { + $.ajax({ method: "GET", - url: "https://www.radio-browser.info/webservice/json/stations/byid/"+station_ids[stationid], + url: "https://www.radio-browser.info/webservice/json/stations/byid/"+station_ids[idx], dataType: 'json', }).success( function(data){ station_array = station_array.concat(data); - if (station_array.length == station_ids.length){ + if (station_ids.length == (idx+1)){ render_results(station_array); }; }); - }; + + }); + }; function radio_query(type, query){