mirror of
https://github.com/SuperBFG7/ympd
synced 2024-11-26 06:47:17 +00:00
Hide Dirble app, if no API token is given/available
This commit is contained in:
parent
b091e47d2f
commit
b3037d6117
@ -110,7 +110,6 @@ var app = $.sammy(function() {
|
||||
$('#panel-heading').text("Search: "+searchstr);
|
||||
});
|
||||
|
||||
|
||||
this.get(/\#\/dirble\/(\d+)\/(\d+)/, function() {
|
||||
prepare();
|
||||
current_app = 'dirble';
|
||||
@ -134,14 +133,9 @@ var app = $.sammy(function() {
|
||||
|
||||
dirble_stations = true;
|
||||
|
||||
if(dirble_api_token) {
|
||||
dirble_load_stations();
|
||||
} else {
|
||||
getDirbleApiToken();
|
||||
}
|
||||
if (dirble_api_token) { dirble_load_stations(); }
|
||||
});
|
||||
|
||||
|
||||
this.get(/\#\/dirble\//, function() {
|
||||
prepare();
|
||||
current_app = 'dirble';
|
||||
@ -157,11 +151,7 @@ var app = $.sammy(function() {
|
||||
|
||||
dirble_stations = false;
|
||||
|
||||
if(dirble_api_token) {
|
||||
dirble_load_categories();
|
||||
} else {
|
||||
getDirbleApiToken();
|
||||
}
|
||||
if (dirble_api_token) { dirble_load_categories(); }
|
||||
});
|
||||
|
||||
this.get("/", function(context) {
|
||||
@ -199,7 +189,6 @@ $(document).ready(function(){
|
||||
add_filter();
|
||||
});
|
||||
|
||||
|
||||
function webSocketConnect() {
|
||||
if (typeof MozWebSocket != "undefined") {
|
||||
socket = new MozWebSocket(get_appropriate_ws_url());
|
||||
@ -217,7 +206,9 @@ function webSocketConnect() {
|
||||
|
||||
app.run();
|
||||
/* emit initial request for output names */
|
||||
socket.send("MPD_API_GET_OUTPUTS");
|
||||
socket.send('MPD_API_GET_OUTPUTS');
|
||||
/* emit initial request for dirble api token */
|
||||
socket.send('MPD_API_GET_DIRBLEAPITOKEN');
|
||||
}
|
||||
|
||||
socket.onmessage = function got_packet(msg) {
|
||||
@ -567,10 +558,14 @@ function webSocketConnect() {
|
||||
case 'dirbleapitoken':
|
||||
dirble_api_token = obj.data;
|
||||
|
||||
if(dirble_stations) {
|
||||
dirble_load_stations();
|
||||
if (dirble_api_token) {
|
||||
$('#dirble').removeClass('hide');
|
||||
|
||||
if (dirble_stations) { dirble_load_stations(); }
|
||||
else { dirble_load_categories(); }
|
||||
|
||||
} else {
|
||||
dirble_load_categories();
|
||||
$('#dirble').addClass('hide');
|
||||
}
|
||||
break;
|
||||
case 'error':
|
||||
@ -581,9 +576,8 @@ function webSocketConnect() {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
socket.onclose = function(){
|
||||
console.log("disconnected");
|
||||
$('.top-right').notify({
|
||||
@ -775,10 +769,6 @@ function getHost() {
|
||||
$('#mpd_pw_con').keypress(onEnter);
|
||||
}
|
||||
|
||||
function getDirbleApiToken() {
|
||||
socket.send('MPD_API_GET_DIRBLEAPITOKEN');
|
||||
}
|
||||
|
||||
$('#search').submit(function () {
|
||||
app.setLocation("#/search/"+$('#search > div > input').val());
|
||||
$('#wait').modal('show');
|
||||
|
Loading…
Reference in New Issue
Block a user