Commit 386036fc authored by onny's avatar onny

working on category browser

parent 2af0acf5
## 0.6.4 – 2018-XX
## 0.6.5 - 2019-05
### Added
- Smooth audio fade-in/out when changing stations
[#80](https://git.project-insanity.org/onny/nextcloud-app-radio/issues/80) @onny
### Fixed
- Prevent list from jumping back to top when adding station to favorites
[#85](https://git.project-insanity.org/onny/nextcloud-app-radio/issues/85) @onny
## 0.6.4 – 2019-01
### Added
- Support for Nextcloud 15
[#82](https://git.project-insanity.org/onny/nextcloud-app-radio/issues/82) @onny
......
This diff is collapsed.
var MODULE = (function (radio) {
/* Click on menus */
$('a.nav-icon-files').click(function(e) {
$('#app-navigation ul a').click(function(e) {
e.preventDefault();
radio.switch_menu(0);
radio.action_navigate($(this).attr('href'));
});
$('a.nav-icon-recent').click(function(e) {
/* Click on a radio station (table entry) and play it */
$('body').on('click', '.filename', function(e) {
e.preventDefault();
radio.switch_menu(1);
});
$('a.nav-icon-favorites').click(function(e) {
e.preventDefault();
radio.switch_menu(2);
var entry_src = $(this).parent().attr('data-src');
if (entry_src.substring(0,9) == "#station/") {
var stationid = entry_src.substring(9);
var stationname = $(this).parent().find('.nametext').text();
radio.action_play(stationid, stationname);
} else {
radio.action_navigate(entry_src);
}
});
$('a.nav-icon-systemtagsfilter').click(function(e) {
/* Save station to favorites */
$('body').on('click', '.favorite', function(e) {
e.preventDefault();
radio.switch_menu(3);
var entry_src = $(this).parent().parent().attr('data-src');
var stationid = entry_src.substring(9);
radio.action_favorite(stationid);
});
radio.load_menu_state = function() {
var menu_state = 0;
radio.action_load_menu_state = function() {
var baseUrl = OC.generateUrl('/apps/radio/getMenuState');
$.get(baseUrl, function ( data ) {
if ("menu_state" in data) {
menu_state = data["menu_state"];
var hashurl = data["menu_state"];
}
radio.switch_menu(menu_state);
radio.action_navigate(hashurl);
return true;
});
}
radio.save_menu_state = function(menu_state) {
radio.action_save_menu_state = function(hashurl) {
var baseUrl = OC.generateUrl('/apps/radio/saveMenuState');
var settings = {
"menu_state": menu_state
"menu_state": hashurl
};
$.ajax({
url: baseUrl,
......@@ -48,67 +53,50 @@ var MODULE = (function (radio) {
});
}
radio.switch_menu = function(type) {
var state = Number(type);
radio.action_navigate = function(hashurl) {
$('#filestable').hide();
$('#emptycontent').addClass('hidden');
$('.nofilterresults').addClass('hidden');
$('.loading').removeClass('hidden');
$('#app-navigation').find('li').removeClass("active");
$("tbody > tr").remove();
history.pushState("", "", hashurl);
radio.action_save_menu_state(hashurl)
clearTimeout(searchTimeout);
searchTimeout = setTimeout(function(){
$('#app-navigation').find('li').removeClass("active");
$("tbody > tr").remove();
radio.save_menu_state(state)
switch (state) {
case 0:
history.pushState("", "", "#top");
clearTimeout(radio.searchTimeout);
radio.searchTimeout = setTimeout(function(){
switch (hashurl) {
case "#top":
$('li.nav-files').addClass('active');
radio.radio_query(1);
radio.radio_query(hashurl);
break;
case 1:
history.pushState("", "", "#recent");
case "#recent":
$('li.nav-recent').addClass('active');
radio.radio_query(2);
radio.radio_query(hashurl);
break;
case 2:
history.pushState("", "", "#favorites");
case "#favorites":
$('li.nav-favorites').addClass('active');
radio.action_load_favorites();
break;
case 3:
history.pushState("", "", "#categories");
case "#categories":
$('li.nav-categories').addClass('active');
radio.action_load_categories();
break;
case (hashurl.match(/^#categories/) || {}).input:
$('li.nav-categories').addClass('active');
radio.radio_query(hashurl);
break;
}
}, 500);
};
// On app start, load top list
if(window.location.hash) {
var hash = String(window.location.hash.replace('#',''));
switch(hash) {
case "top":
radio.switch_menu(0);
break;
case "recent":
radio.switch_menu(1);
break;
case "favorites":
radio.switch_menu(2);
break;
case "categories":
radio.switch_menu(3);
break;
default:
radio.switch_menu(0);
break;
}
var hashurl = window.location.hash;
radio.action_navigate(hashurl);
} else {
radio.load_menu_state();
radio.action_load_menu_state();
};
return radio;
......
......@@ -35,7 +35,21 @@ var MODULE = (function (radio) {
};
});
radio.action_play = function(stationid){
radio.action_play = function(stationid, stationname){
$('#playbutton').attr("class", "buffering");
$('#player').attr('data-id',stationid);
$("#station_metadata").html("Playing: "+stationname);
/* dirty fix missing background color for first td */
$('tbody tr').css("background-color", "white");
$(this).parent().css("background-color", "#f8f8f8");
var element = document.getElementById('station_metadata');
if (radio.isElementOverflowing(element)) {
radio.wrapContentsInMarquee(element);
};
if (!radio.scheduled){
radio.schedule_get_metadata(stationid);
};
if (typeof radio.sound !== "undefined") {
var volume_state = $('#volumeslider').slider('value');
radio.sound.fade(volume_state, 0, 500);
......
......@@ -31,7 +31,6 @@
</li>
</ul>
<div id="app-settings">
<audio id="player" src=""></audio>
<button id="playbutton" class="play"></button>
<div id="volumeicon" class="full"></div>
<div id="volumeslider"></div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment