Adding token on command
This commit is contained in:
parent
ebe635acd9
commit
2f6914a307
@ -25,11 +25,11 @@ $(document).ready(function() {
|
||||
$('#btn_play').click(function () {
|
||||
switch (state){
|
||||
case "PLAYING":
|
||||
sendCommand(JSON.stringify({ command: "PAUSE"}))
|
||||
sendCommand({ command: "PAUSE"})
|
||||
break;
|
||||
|
||||
case "PAUSE":
|
||||
sendCommand(JSON.stringify({ command: "PLAY"}))
|
||||
sendCommand({ command: "PLAY"})
|
||||
break;
|
||||
}
|
||||
|
||||
@ -38,10 +38,10 @@ $(document).ready(function() {
|
||||
|
||||
|
||||
$('#btn_next').click(function () {
|
||||
sendCommand(JSON.stringify({ command: "NEXT"}));
|
||||
sendCommand({ command: "NEXT"});
|
||||
});
|
||||
$('#btn_stop').click(function () {
|
||||
sendCommand(JSON.stringify({ command: "STOP"}));
|
||||
sendCommand({ command: "STOP"});
|
||||
});
|
||||
|
||||
$('.dropdown-button').dropdown({
|
||||
@ -85,7 +85,7 @@ $(document).ready(function() {
|
||||
var command = {
|
||||
command: "FLUSH"
|
||||
};
|
||||
sendCommand(JSON.stringify(command));
|
||||
sendCommand(command);
|
||||
});
|
||||
|
||||
$('#btn_add_top').click(function () {
|
||||
@ -96,7 +96,7 @@ $(document).ready(function() {
|
||||
onHead: true
|
||||
};
|
||||
$('#input_link').val('');
|
||||
sendCommand(JSON.stringify(command));
|
||||
sendCommand(command);
|
||||
});
|
||||
|
||||
$('#btn_add_bottom').click(function () {
|
||||
@ -108,7 +108,7 @@ $(document).ready(function() {
|
||||
onHead: false
|
||||
};
|
||||
$('#input_link').val('');
|
||||
sendCommand(JSON.stringify(command));
|
||||
sendCommand(command);
|
||||
});
|
||||
|
||||
$('#btn_ok_channel').click(function () {
|
||||
@ -117,7 +117,7 @@ $(document).ready(function() {
|
||||
command: "CONNECT",
|
||||
chanelId: $('input[name=vocalRadio]:checked').val()
|
||||
};
|
||||
sendCommand(JSON.stringify(command));
|
||||
sendCommand(command);
|
||||
});
|
||||
|
||||
})
|
||||
@ -144,27 +144,50 @@ function getCurentMusic() {
|
||||
$('#btn_info').addClass("determinate").removeClass("indeterminate");
|
||||
}
|
||||
$('#music_progress').width("0%");
|
||||
if(Cookies.get('token') != undefined){
|
||||
if (!$('#btn_stop').hasClass("disabled")) {
|
||||
$('#btn_stop').addClass("disabled");
|
||||
}
|
||||
if (!$('#btn_info').hasClass("disabled")) {
|
||||
$('#btn_info').addClass("disabled");
|
||||
}
|
||||
if ($('#add_btn').hasClass("disabled")) {
|
||||
$('#add_btn').removeClass("disabled");
|
||||
}
|
||||
if ($('#flush_btn').hasClass("disabled")) {
|
||||
$('#flush_btn').removeClass("disabled");
|
||||
}
|
||||
|
||||
if ($('#btn_play').hasClass("disabled")) {
|
||||
$('#btn_play').removeClass("disabled");
|
||||
}
|
||||
if ($('#btn_next').hasClass("disabled")) {
|
||||
$('#btn_next').removeClass("disabled");
|
||||
}
|
||||
}
|
||||
else{
|
||||
if (!$('#btn_stop').hasClass("disabled")) {
|
||||
$('#btn_stop').addClass("disabled");
|
||||
}
|
||||
if (!$('#btn_info').hasClass("disabled")) {
|
||||
$('#btn_info').addClass("disabled");
|
||||
}
|
||||
if (!$('#add_btn').hasClass("disabled")) {
|
||||
$('#add_btn').addClass("disabled");
|
||||
}
|
||||
if (!$('#flush_btn').hasClass("disabled")) {
|
||||
$('#flush_btn').addClass("disabled");
|
||||
}
|
||||
|
||||
if (!$('#btn_play').hasClass("disabled")) {
|
||||
$('#btn_play').addClass("disabled");
|
||||
}
|
||||
if (!$('#btn_next').hasClass("disabled")) {
|
||||
$('#btn_next').addClass("disabled");
|
||||
}
|
||||
}
|
||||
$('#btn_play').children().text("play_arrow");
|
||||
if (!$('#btn_stop').hasClass("disabled")) {
|
||||
$('#btn_stop').addClass("disabled");
|
||||
}
|
||||
if (!$('#btn_info').hasClass("disabled")) {
|
||||
$('#btn_info').addClass("disabled");
|
||||
}
|
||||
if ($('#add_btn').hasClass("disabled")) {
|
||||
$('#add_btn').removeClass("disabled");
|
||||
}
|
||||
if ($('#flush_btn').hasClass("disabled")) {
|
||||
$('#flush_btn').removeClass("disabled");
|
||||
}
|
||||
|
||||
if ($('#btn_play').hasClass("disabled")) {
|
||||
$('#btn_play').removeClass("disabled");
|
||||
}
|
||||
if ($('#btn_next').hasClass("disabled")) {
|
||||
$('#btn_next').removeClass("disabled");
|
||||
}
|
||||
|
||||
$('#music_img').attr("src","/img/no_music.jpg");
|
||||
$('#total_time').text("00:00");
|
||||
@ -206,6 +229,7 @@ function getCurentMusic() {
|
||||
$('#music_progress').width("0%");
|
||||
|
||||
$('#btn_play').children().text("play_arrow");
|
||||
|
||||
if (!$('#btn_play').hasClass("disabled")) {
|
||||
$('#btn_play').addClass("disabled");
|
||||
}
|
||||
@ -227,14 +251,16 @@ function getCurentMusic() {
|
||||
|
||||
|
||||
$('#music_img').attr("src","/img/disconnected.png");
|
||||
|
||||
if(!disconected){
|
||||
getChannels();
|
||||
disconected = true;
|
||||
if(Cookies.get('token') != undefined){
|
||||
if(!disconected){
|
||||
getChannels();
|
||||
disconected = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
getPlayList();
|
||||
@ -278,7 +304,7 @@ function getPlayList() {
|
||||
command: "DELL",
|
||||
url: $(this).attr("data_url")
|
||||
};
|
||||
sendCommand(JSON.stringify(command));
|
||||
sendCommand(command);
|
||||
|
||||
|
||||
});
|
||||
@ -334,30 +360,55 @@ function updateControl(data){
|
||||
$('#music_text').text(data.info.title);
|
||||
var percent = (data.currentPos / data.info.length) * 100;
|
||||
// console.log(percent)
|
||||
if (!$('#btn_info').hasClass("indeterminate")) {
|
||||
$('#btn_info').addClass("determinate").removeClass("indeterminate");
|
||||
if (!$('#music_progress').hasClass("indeterminate")) {
|
||||
$('#music_progress').addClass("determinate").removeClass("indeterminate");
|
||||
}
|
||||
$('#music_progress').width(percent + "%");
|
||||
|
||||
if ($('#btn_play').hasClass("disabled")) {
|
||||
$('#btn_play').removeClass("disabled");
|
||||
if(Cookies.get('token') != undefined){
|
||||
if ($('#btn_play').hasClass("disabled")) {
|
||||
$('#btn_play').removeClass("disabled");
|
||||
}
|
||||
if ($('#btn_stop').hasClass("disabled")) {
|
||||
$('#btn_stop').removeClass("disabled");
|
||||
}
|
||||
if ($('#btn_info').hasClass("disabled")) {
|
||||
$('#btn_info').removeClass("disabled");
|
||||
}
|
||||
if ($('#add_btn').hasClass("disabled")) {
|
||||
$('#add_btn').removeClass("disabled");
|
||||
}
|
||||
if ($('#flush_btn').hasClass("disabled")) {
|
||||
$('#flush_btn').removeClass("disabled");
|
||||
}
|
||||
|
||||
if ($('#btn_next').hasClass("disabled")) {
|
||||
$('#btn_next').removeClass("disabled");
|
||||
}
|
||||
}
|
||||
if ($('#btn_stop').hasClass("disabled")) {
|
||||
$('#btn_stop').removeClass("disabled");
|
||||
}
|
||||
if ($('#btn_info').hasClass("disabled")) {
|
||||
$('#btn_info').removeClass("disabled");
|
||||
}
|
||||
if ($('#add_btn').hasClass("disabled")) {
|
||||
$('#add_btn').removeClass("disabled");
|
||||
}
|
||||
if ($('#flush_btn').hasClass("disabled")) {
|
||||
$('#flush_btn').removeClass("disabled");
|
||||
else
|
||||
{
|
||||
if (!$('#btn_play').hasClass("disabled")) {
|
||||
$('#btn_play').addClass("disabled");
|
||||
}
|
||||
if (!$('#btn_stop').hasClass("disabled")) {
|
||||
$('#btn_stop').addClass("disabled");
|
||||
}
|
||||
if (!$('#btn_info').hasClass("disabled")) {
|
||||
$('#btn_info').addClass("disabled");
|
||||
}
|
||||
if (!$('#add_btn').hasClass("disabled")) {
|
||||
$('#add_btn').addClass("disabled");
|
||||
}
|
||||
if (!$('#flush_btn').hasClass("disabled")) {
|
||||
$('#flush_btn').addClass("disabled");
|
||||
}
|
||||
|
||||
if (!$('#btn_next').hasClass("disabled")) {
|
||||
$('#btn_next').addClass("disabled");
|
||||
}
|
||||
}
|
||||
|
||||
if ($('#btn_next').hasClass("disabled")) {
|
||||
$('#btn_next').removeClass("disabled");
|
||||
}
|
||||
|
||||
$('#music_img').attr("src","https://img.youtube.com/vi/"+data.info.identifier+"/hqdefault.jpg");
|
||||
// console.log(data);
|
||||
@ -366,13 +417,14 @@ function updateControl(data){
|
||||
updateModal(data);
|
||||
}
|
||||
|
||||
function sendCommand(commandStr){
|
||||
function sendCommand(command){
|
||||
command["token"] = Cookies.get('token');
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
url: "/api/music/command",
|
||||
data: commandStr,
|
||||
data: JSON.stringify(command),
|
||||
success: function (data) {
|
||||
console.log(data);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user