diff --git a/appinfo/routes.php b/appinfo/routes.php index 1b0c0a5..7acdcba 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -5,16 +5,6 @@ $this->create('radio_index', '/') ->actionInclude('radio/index.php'); -/** return [ - 'resources' => [ - 'station' => ['url' => '/stations'], - ], - 'routes' => [ - ['name' => 'page#index', 'url' => '/', 'verb' => 'GET'], - ] -]; **/ - - return [ 'resources' => [ 'station' => ['url' => '/stations'], @@ -22,7 +12,9 @@ return [ ], 'routes' => [ ['name' => 'page#index', 'url' => '/', 'verb' => 'GET'], + ['name' => 'settings#getMenuState', 'url' => '/getMenuState', 'verb' => 'GET'], + ['name' => 'settings#saveMenuState', 'url' => '/saveMenuState', 'verb' => 'POST'], ['name' => 'station_api#preflighted_cors', 'url' => '/api/0.1/{path}', 'verb' => 'OPTIONS', 'requirements' => ['path' => '.+']] ] -]; \ No newline at end of file +]; diff --git a/js/main.js b/js/main.js index 64b7d43..94a2afc 100644 --- a/js/main.js +++ b/js/main.js @@ -305,8 +305,37 @@ $(function(){ }); }; + function load_menu_state() { + var menu_state = 0; + var baseUrl = OC.generateUrl('/apps/radio/getMenuState'); + $.get(baseUrl, function ( data ) { + if ("menu_state" in data) { + menu_state = data["menu_state"]; + } + switch_menu(menu_state); + return true; + }); + } + + function save_menu_state(menu_state) { + var baseUrl = OC.generateUrl('/apps/radio/saveMenuState'); + var settings = { + "menu_state": menu_state + }; + $.ajax({ + url: baseUrl, + method: 'POST', + contentType: 'application/json', + data: JSON.stringify(settings) + }).done(function(data){ + return true; + }); + } + function switch_menu(type) { + var state = Number(type); + $('#filestable').hide(); $('#emptycontent').addClass('hidden'); $('.nofilterresults').addClass('hidden'); @@ -316,7 +345,8 @@ $(function(){ searchTimeout = setTimeout(function(){ $('#app-navigation').find('li').removeClass("active"); $("tbody > tr").remove(); - switch (type) { + save_menu_state(state) + switch (state) { case 0: $('li.nav-files').addClass('active'); radio_query(1); @@ -357,5 +387,5 @@ $(function(){ }); // On app start, load top list - switch_menu(0); + load_menu_state(); }); diff --git a/templates/main.php b/templates/main.php index c2aa9a5..49a5316 100755 --- a/templates/main.php +++ b/templates/main.php @@ -1,8 +1,6 @@