Commit c3cfcab9 authored by onny's avatar onny

remember menu state

parent 7a9341a9
......@@ -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
];
......@@ -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();
});
<?php
style('radio', 'main');
script('radio', 'main');
OC_Util::addScript('search', 'search', true);
OC_Util::addScript('search', 'searchprovider');
?>
<div id="content" class="app-files" role="main">
......
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