working on category browser
This commit is contained in:
parent
386036fc4c
commit
479254e75e
81
js/main.js
81
js/main.js
@ -13,16 +13,10 @@ var MODULE = (function (radio) {
|
|||||||
if ( ( $(window).scrollTop() + $(window).height() ) == $(document).height() ) {
|
if ( ( $(window).scrollTop() + $(window).height() ) == $(document).height() ) {
|
||||||
if(!station_list.data("didfire")) {
|
if(!station_list.data("didfire")) {
|
||||||
station_list.data("didfire", true);
|
station_list.data("didfire", true);
|
||||||
if ($('li.nav-files').hasClass('active')){
|
|
||||||
radio.radio_query(1, "");
|
var hashurl = window.location.hash;
|
||||||
} else if ($('li.nav-recent').hasClass('active')) {
|
radio.radio_query(hashurl);
|
||||||
radio.radio_query(2, "");
|
|
||||||
} else if ($('li.nav-favorites').hasClass('active')) {
|
|
||||||
console.log("todo");
|
|
||||||
} else {
|
|
||||||
var query = $('#searchbox').val();
|
|
||||||
radio.radio_query(0, query);
|
|
||||||
};
|
|
||||||
var ref = station_list;
|
var ref = station_list;
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
ref.data("didfire", false);
|
ref.data("didfire", false);
|
||||||
@ -112,14 +106,22 @@ var MODULE = (function (radio) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
$.each(data, function(i, station) {
|
$.each(data, function(i, station) {
|
||||||
var isstarred = false;
|
if (typeof station['id'] == "undefined") {
|
||||||
for (var fav_station in fav_stations) {
|
var entry_type = "folder";
|
||||||
if (fav_stations[fav_station]["stationid"] == station['id']) {
|
var isstarred = false;
|
||||||
isstarred = true;
|
var hashurl = window.location.hash + "/" + station['name'];
|
||||||
break;
|
} else {
|
||||||
}
|
var entry_type = "station";
|
||||||
};
|
var isstarred = false;
|
||||||
radio.render_entry("station", isstarred, '#station/'+station['id'], station['favicon'], station['name']);
|
for (var fav_station in fav_stations) {
|
||||||
|
if (fav_stations[fav_station]["stationid"] == station['id']) {
|
||||||
|
isstarred = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var hashurl = '#station/'+station['id'];
|
||||||
|
}
|
||||||
|
radio.render_entry(entry_type, isstarred, hashurl, station['favicon'], station['name']);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -178,7 +180,6 @@ var MODULE = (function (radio) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
radio.radio_query = function(hashurl){
|
radio.radio_query = function(hashurl){
|
||||||
console.log(hashurl);
|
|
||||||
var offset = $('tbody > tr').length;
|
var offset = $('tbody > tr').length;
|
||||||
var query = "";
|
var query = "";
|
||||||
var api_baseurl = "https://www.radio-browser.info/webservice/json/";
|
var api_baseurl = "https://www.radio-browser.info/webservice/json/";
|
||||||
@ -189,24 +190,32 @@ var MODULE = (function (radio) {
|
|||||||
case "#recent":
|
case "#recent":
|
||||||
var query_url = "stations/lastchange";
|
var query_url = "stations/lastchange";
|
||||||
break;
|
break;
|
||||||
case "#categories/countries":
|
case (hashurl.match(/^#categories/) || {}).input:
|
||||||
var query_url = "countries";
|
var query_url = hashurl.substring(12);
|
||||||
break;
|
if (query_url.split("/").length == 2) {
|
||||||
case "#categories/states":
|
var subcategory = query_url.split("/")[1];
|
||||||
var query_url = "states";
|
switch (query_url.split("/")[0]) {
|
||||||
break;
|
case "countries":
|
||||||
case "#categories/languages":
|
var query_url = "stations/bycountryexact/"+subcategory;
|
||||||
var query_url = "languages";
|
break;
|
||||||
break;
|
case "states":
|
||||||
case "#categories/tags":
|
var query_url = "stations/bystateexact/"+subcategory;
|
||||||
var query_url = "tags";
|
break;
|
||||||
|
case "languages":
|
||||||
|
var query_url = "stations/bylanguageexact/"+subcategory;
|
||||||
|
break;
|
||||||
|
case "tags":
|
||||||
|
var query_url = "stations/bytagsexact/"+subcategory;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case (hashurl.match(/^#search/) || {}).input:
|
case (hashurl.match(/^#search/) || {}).input:
|
||||||
var query_url = "stations/search";
|
var query_url = "stations/search";
|
||||||
var query = hashurl.substring(8);
|
var query = hashurl.substring(8);
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
console.log(api_baseurl + query_url, query);
|
console.log(query_url);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: api_baseurl + query_url,
|
url: api_baseurl + query_url,
|
||||||
@ -218,7 +227,9 @@ var MODULE = (function (radio) {
|
|||||||
},
|
},
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
}).success( function(data){
|
}).success( function(data){
|
||||||
radio.parse_results(data);
|
if (data.length) {
|
||||||
|
radio.parse_results(data);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -226,9 +237,11 @@ var MODULE = (function (radio) {
|
|||||||
new OCA.Search(function (query) {
|
new OCA.Search(function (query) {
|
||||||
$('#app-navigation').find('li').removeClass("active");
|
$('#app-navigation').find('li').removeClass("active");
|
||||||
$("tbody > tr").remove();
|
$("tbody > tr").remove();
|
||||||
radio.radio_query("#search/"+query);
|
var hashurl = "#search/"+query;
|
||||||
|
history.pushState("", "", hashurl);
|
||||||
|
radio.radio_query(hashurl);
|
||||||
}, function (arg) {
|
}, function (arg) {
|
||||||
radio.switch_menu(0);
|
console.log("quit search dialog");
|
||||||
});
|
});
|
||||||
|
|
||||||
radio.render_entry = function(entry_type, starred, hashurl, iconurl, title){
|
radio.render_entry = function(entry_type, starred, hashurl, iconurl, title){
|
||||||
|
@ -87,6 +87,9 @@ var MODULE = (function (radio) {
|
|||||||
$('li.nav-categories').addClass('active');
|
$('li.nav-categories').addClass('active');
|
||||||
radio.radio_query(hashurl);
|
radio.radio_query(hashurl);
|
||||||
break;
|
break;
|
||||||
|
case (hashurl.match(/^#search/) || {}).input:
|
||||||
|
radio.radio_query(hashurl);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}, 500);
|
}, 500);
|
||||||
};
|
};
|
||||||
@ -99,5 +102,11 @@ var MODULE = (function (radio) {
|
|||||||
radio.action_load_menu_state();
|
radio.action_load_menu_state();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
window.addEventListener('hashchange', function(event) {
|
||||||
|
var hashurl = "#" + event.newURL.split("#")[1];
|
||||||
|
console.log(hashurl);
|
||||||
|
radio.action_navigate(hashurl);
|
||||||
|
}, false);
|
||||||
|
|
||||||
return radio;
|
return radio;
|
||||||
}(MODULE || {}));
|
}(MODULE || {}));
|
||||||
|
Loading…
Reference in New Issue
Block a user