$('#panel-heading').text("Search: "+searchstr);
});
-
this.get(/\#\/dirble\/(\d+)\/(\d+)/, function() {
prepare();
current_app = 'dirble';
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';
dirble_stations = false;
- if(dirble_api_token) {
- dirble_load_categories();
- } else {
- getDirbleApiToken();
- }
+ if (dirble_api_token) { dirble_load_categories(); }
});
this.get("/", function(context) {
add_filter();
});
-
function webSocketConnect() {
if (typeof MozWebSocket != "undefined") {
socket = new MozWebSocket(get_appropriate_ws_url());
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) {
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':
$('.top-right').notify({
default:
break;
}
-
-
}
+
socket.onclose = function(){
console.log("disconnected");
$('.top-right').notify({
$('#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');