added function to menu entries

This commit is contained in:
Jonas Heinrich 2017-01-06 10:52:12 +01:00
parent 7bb389d210
commit 0907a573b0
2 changed files with 46 additions and 29 deletions

View File

@ -6,7 +6,7 @@ $(window).on('load', function(){
$('#player').trigger('play');
});
function show_result(data){
function render_result(data){
$("tbody > tr").remove();
$.each(data, function(i, station) {
$('tbody').append('<tr data-src='+station['url']+' data-id='+station['id']+'>\
@ -26,20 +26,58 @@ $(window).on('load', function(){
});
}
function search(query){
function radio_query(type, query){
switch (type) {
case 0:
var url = "https://www.radio-browser.info/webservice/json/stations/search";
break;
case 1:
var url = "https://www.radio-browser.info/webservice/json/stations/topclick/20";
break;
case 2:
var url = "https://www.radio-browser.info/webservice/json/stations/lastchange/20";
break;
};
$.ajax({
method: "POST",
url: 'https://www.radio-browser.info/webservice/json/stations/search',
url: url,
data: {
name: query
},
dataType: 'json',
success: show_result
success: render_result
});
};
function switch_menu(type) {
$('#app-navigation').find('li').removeClass("active");;
switch (type) {
case 0:
$('li.nav-files').addClass('active');
radio_query(1);
break;
case 1:
$('li.nav-recent').addClass('active');
radio_query(2);
break;
case 2:
$('li.nav-favorite').addClass('active');
break;
}
}
$('#radiosearch').submit(function() {
var query = $('#radioquery').val();
search(query);
radio_query(0, query);
});
$('a.nav-icon-files').click(function() {
switch_menu(0);
});
$('a.nav-icon-recent').click(function() {
switch_menu(1);
});
switch_menu(0);
});

View File

@ -33,13 +33,6 @@
<form id="radiosearch" action="javascript:void(0);">
<input id="radioquery" placeholder="Search for name" autofocus required></input>
</form>
<div id="files-setting-showhidden">
<input class="checkbox" id="showhiddenfilesToggle" checked="checked" type="checkbox">
<label for="showhiddenfilesToggle">Show hidden files</label>
</div>
<label for="webdavurl">WebDAV</label>
<input id="webdavurl" type="text" readonly="readonly" value="http://127.0.0.1/remote.php/webdav/" />
<em>Use this address to <a href="https://docs.nextcloud.com/server/11/go.php?to=user-webdav" target="_blank" rel="noreferrer">access your Files via WebDAV</a></em>
</div>
</div>
</div>
@ -56,23 +49,9 @@
</tr>
</thead>
<tbody id="fileList">
<tr>
<td class="filename">
<a href="#" class="action action-favorite " data-original-title="" title="">
<span class="icon icon-star"></span>
<span class="hidden-visually">Favorite</span>
</a>
<label for="select-files-3">
<div class="thumbnail" style="background-image:url('http://www.swr.de/static/favicons/SWR1/favicons/SWR1_96.png'); background-size: 32px;"></div>
</label>
<a class="name" href="#">
<span class="nametext"><span class="innernametext">Radio 3</span></span>
</a>
</td>
</tr>
</tbody>
<tfoot>
</tfoot>
</tbody>
<tfoot>
</tfoot>
</table>
</div>
</div>