Web clean up + download fontawesome + 404 bug

This commit is contained in:
Sebastien 2018-09-25 14:15:12 +03:00
parent 011359c4ea
commit 3a7197207f
9 changed files with 3776 additions and 76 deletions

File diff suppressed because one or more lines are too long

View File

@ -14,10 +14,10 @@ var switchAutoFlow;
var loadingFlag = false; var loadingFlag = false;
var guild; var guild;
$(document).ready(function() { $(document).ready(function () {
if(Cookies.get('guild') != undefined) { if (Cookies.get('guild') != undefined) {
guild = Cookies.get('guild') guild = Cookies.get('guild');
btn_play = $('#btn_play'); btn_play = $('#btn_play');
btn_stop = $('#btn_stop'); btn_stop = $('#btn_stop');
btn_next = $('#btn_next'); btn_next = $('#btn_next');
@ -60,7 +60,10 @@ $(document).ready(function() {
function getCurentMusic() { function getCurentMusic() {
$.get("api/music/currentMusicInfo?guild=" + guild, function (data) { $.get("api/music/currentMusicInfo?guild=" + guild, function (data) {
}).done(function (data) { }).done(function (data) {
if (error) {
error = false;
M.Toast.dismissAll();
}
state = data.state; state = data.state;
switch (data.state) { switch (data.state) {
case "STOP": case "STOP":
@ -72,7 +75,7 @@ function getCurentMusic() {
$('#btn_info').addClass("determinate").removeClass("indeterminate"); $('#btn_info').addClass("determinate").removeClass("indeterminate");
} }
$('#music_progress').width("0%"); $('#music_progress').width("0%");
if(Cookies.get('token') != undefined){ if (Cookies.get('token') != undefined) {
disableBtn(btn_stop); disableBtn(btn_stop);
disableBtn(btn_info); disableBtn(btn_info);
enableBtn(btn_add); enableBtn(btn_add);
@ -81,7 +84,7 @@ function getCurentMusic() {
enableBtn(btn_next); enableBtn(btn_next);
enableBtn(btn_disconnect); enableBtn(btn_disconnect);
} }
else{ else {
disableBtn(btn_play); disableBtn(btn_play);
disableBtn(btn_stop); disableBtn(btn_stop);
disableBtn(btn_info); disableBtn(btn_info);
@ -91,7 +94,7 @@ function getCurentMusic() {
disableBtn(btn_disconnect); disableBtn(btn_disconnect);
} }
btn_play.children().text("play_arrow"); btn_play.children().text("play_arrow");
$('#music_img').attr("src","/img/no_music.jpg"); $('#music_img').attr("src", "/img/no_music.jpg");
$('#total_time').text("00:00"); $('#total_time').text("00:00");
$('#current_time').text("00:00"); $('#current_time').text("00:00");
btn_play.removeClass("amber"); btn_play.removeClass("amber");
@ -145,45 +148,49 @@ function getCurentMusic() {
disableBtn(btn_next); disableBtn(btn_next);
disableBtn(btn_disconnect); disableBtn(btn_disconnect);
$('#music_img').attr("src","/img/disconnected.png"); $('#music_img').attr("src", "/img/disconnected.png");
if(Cookies.get('token') != undefined){ if (Cookies.get('token') != undefined) {
if(!disconected){ if (!disconected) {
getChannels(); getChannels();
disconected = true; disconected = true;
} }
} }
break; break;
} }
if(switchAutoFlow.is(':checked') != data.autoflow) if (switchAutoFlow.is(':checked') != data.autoflow)
switchAutoFlow.prop('checked', data.autoflow); switchAutoFlow.prop('checked', data.autoflow);
getPlayList(); getPlayList();
}) })
.fail(function (data) { .fail(function (data) {
if(!error){ if (!error) {
console.error("Connection lost, I keep trying to refresh!"); error = true;
error = true; console.error("Connection lost, I keep trying to refresh!");
} M.toast({
html: " <i class=\"material-icons\" style='margin-right: 10px'>warning</i> Connection Lost!",
classes: 'red',
displayLength: 99999999
});
}) }
})
} }
function getPlayList() { function getPlayList() {
$.get("api/music/getPlaylist?guild=" + guild, function (data) { $.get("api/music/getPlaylist?guild=" + guild, function (data) {
}).done(function (data) { }).done(function (data) {
data = data.list; data = data.list;
if(data != null && data.length != 0){ if (data != null && data.length != 0) {
var noUpdate = comparePlaylist(data, savedPlaylist); var noUpdate = comparePlaylist(data, savedPlaylist);
// console.log("List up to date : "+noUpdate); // console.log("List up to date : "+noUpdate);
if(!noUpdate){ if (!noUpdate) {
savedPlaylist = data; savedPlaylist = data;
$('#playlist_list').empty(); $('#playlist_list').empty();
data.forEach(function(element){ data.forEach(function (element) {
var template = $('#playlist_template').clone(); var template = $('#playlist_template').clone();
template.removeAttr("id"); template.removeAttr("id");
template.removeAttr("style"); template.removeAttr("style");
@ -210,22 +217,26 @@ function getPlayList() {
}); });
} }
} }
else{ else {
$('#playlist_list').empty(); $('#playlist_list').empty();
savedPlaylist = {}; savedPlaylist = {};
} }
if(loadingFlag){ if (loadingFlag) {
modal_loading.modal('close'); modal_loading.modal('close');
loadingFlag = false; loadingFlag = false;
} }
}).fail(function (data) { }).fail(function (data) {
if(!error){ if (!error) {
alert("Comunication error, please refresh."); M.toast({
html: " <i class=\"material-icons\" style='margin-right: 10px'>warning</i> Connection Lost!",
classes: 'red',
displayLength: 99999999
});
error = true; error = true;
} }
if(loadingFlag){ if (loadingFlag) {
modal_loading.modal('close'); modal_loading.modal('close');
loadingFlag = false; loadingFlag = false;
} }
@ -234,12 +245,12 @@ function getPlayList() {
} }
function getChannels(){ function getChannels() {
$.get("api/music/getChanel?guild=" + guild, function (data) { $.get("api/music/getChanel?guild=" + guild, function (data) {
}).done(function (data) { }).done(function (data) {
console.log(data); console.log(data);
$('#channelForm').empty(); $('#channelForm').empty();
data.forEach(function(element){ data.forEach(function (element) {
var template = $('#radioTemplate').clone(); var template = $('#radioTemplate').clone();
template.removeAttr("id"); template.removeAttr("id");
template.removeAttr("style"); template.removeAttr("style");
@ -254,27 +265,31 @@ function getChannels(){
$('#modalChanels').modal('open'); $('#modalChanels').modal('open');
}).fail(function (data) { }).fail(function (data) {
if(!error){ if (!error) {
alert("Com error, please refresh."); M.toast({
html: " <i class=\"material-icons\" style='margin-right: 10px'>warning</i> Connection Lost!",
classes: 'red',
displayLength: 99999999
});
error = true; error = true;
} }
}); });
} }
function updateModal(data){ function updateModal(data) {
$('#modal_title').text("Title: "+ data.info.audioTrackInfo.title); $('#modal_title').text("Title: " + data.info.audioTrackInfo.title);
$('#modal_author').text("Author: "+ data.info.audioTrackInfo.author); $('#modal_author').text("Author: " + data.info.audioTrackInfo.author);
$('#modal_lenght').text("Duration: "+ msToTime(data.info.audioTrackInfo.length)); $('#modal_lenght').text("Duration: " + msToTime(data.info.audioTrackInfo.length));
$('#modal_url').html("<div>URL: <a target=\"_blank\" href=\""+ data.info.audioTrackInfo.uri + "\">" + data.info.audioTrackInfo.uri + "</a></div>"); $('#modal_url').html("<div>URL: <a target=\"_blank\" href=\"" + data.info.audioTrackInfo.uri + "\">" + data.info.audioTrackInfo.uri + "</a></div>");
// //
$('#modal_submit').text("Submitted by: "+ data.info.user); $('#modal_submit').text("Submitted by: " + data.info.user);
} }
function updateControl(data){ function updateControl(data) {
$('#music_text').text(data.info.audioTrackInfo.title); $('#music_text').text(data.info.audioTrackInfo.title);
var percent = (data.currentPos / data.info.audioTrackInfo.length) * 100; var percent = (data.currentPos / data.info.audioTrackInfo.length) * 100;
// console.log(percent) // console.log(percent)
@ -283,7 +298,7 @@ function updateControl(data){
} }
$('#music_progress').width(percent + "%"); $('#music_progress').width(percent + "%");
if(Cookies.get('token') != undefined){ if (Cookies.get('token') != undefined) {
enableBtn(btn_play); enableBtn(btn_play);
enableBtn(btn_stop); enableBtn(btn_stop);
enableBtn(btn_info); enableBtn(btn_info);
@ -292,8 +307,7 @@ function updateControl(data){
enableBtn(btn_next); enableBtn(btn_next);
enableBtn(btn_disconnect); enableBtn(btn_disconnect);
} }
else else {
{
disableBtn(btn_play); disableBtn(btn_play);
disableBtn(btn_stop); disableBtn(btn_stop);
disableBtn(btn_info); disableBtn(btn_info);
@ -304,14 +318,14 @@ function updateControl(data){
} }
$('#music_img').attr("src","https://img.youtube.com/vi/"+data.info.audioTrackInfo.identifier+"/hqdefault.jpg"); $('#music_img').attr("src", "https://img.youtube.com/vi/" + data.info.audioTrackInfo.identifier + "/hqdefault.jpg");
// console.log(data); // console.log(data);
$('#total_time').text(msToTime(data.info.audioTrackInfo.length)); $('#total_time').text(msToTime(data.info.audioTrackInfo.length));
$('#current_time').text(msToTime(data.currentPos)); $('#current_time').text(msToTime(data.currentPos));
updateModal(data); updateModal(data);
} }
function sendCommand(command){ function sendCommand(command) {
modal_loading.modal('open'); modal_loading.modal('open');
console.log(command); console.log(command);
$.ajax({ $.ajax({
@ -319,7 +333,7 @@ function sendCommand(command){
dataType: 'json', dataType: 'json',
contentType: 'application/json', contentType: 'application/json',
url: "/api/music/command?guild=" + guild, url: "/api/music/command?guild=" + guild,
data: JSON.stringify(command), data: JSON.stringify(command),
success: function (data) { success: function (data) {
console.log(data); console.log(data);
loadingFlag = true; loadingFlag = true;
@ -331,7 +345,7 @@ function sendCommand(command){
console.log(data); console.log(data);
alert(data.responseJSON.Message); alert(data.responseJSON.Message);
modal_loading.modal('close'); modal_loading.modal('close');
if(data.responseJSON.error === "token"){ if (data.responseJSON.error === "token") {
Cookies.remove('token'); Cookies.remove('token');
Cookies.remove('name'); Cookies.remove('name');
location.reload(); location.reload();
@ -339,33 +353,33 @@ function sendCommand(command){
}); });
} }
function comparePlaylist(list1, list2){ function comparePlaylist(list1, list2) {
if(list1 == null || list2 == null){ if (list1 == null || list2 == null) {
return false; return false;
} }
if(list1.length != list2.length){ if (list1.length != list2.length) {
return false; return false;
} }
for(var i = 0; i++; i < list1.length){ for (var i = 0; i++; i < list1.length) {
if(list1[i].uri != list2[i].uri) if (list1[i].uri != list2[i].uri)
return false return false
} }
return true; return true;
} }
function msToTime(duration) { function msToTime(duration) {
var milliseconds = parseInt((duration%1000)/100) var milliseconds = parseInt((duration % 1000) / 100)
, seconds = parseInt((duration/1000)%60) , seconds = parseInt((duration / 1000) % 60)
, minutes = parseInt((duration/(1000*60))%60) , minutes = parseInt((duration / (1000 * 60)) % 60)
, hours = parseInt((duration/(1000*60*60))%24); , hours = parseInt((duration / (1000 * 60 * 60)) % 24);
hours = (hours < 10) ? "0" + hours : hours; hours = (hours < 10) ? "0" + hours : hours;
minutes = (minutes < 10) ? "0" + minutes : minutes; minutes = (minutes < 10) ? "0" + minutes : minutes;
seconds = (seconds < 10) ? "0" + seconds : seconds; seconds = (seconds < 10) ? "0" + seconds : seconds;
if(hours > 0 ) if (hours > 0)
return hours + ":" + minutes + ":" + seconds; return hours + ":" + minutes + ":" + seconds;
else else
return minutes + ":" + seconds; return minutes + ":" + seconds;
@ -375,32 +389,32 @@ function listeners() {
$('#btn_play').click(function () { $('#btn_play').click(function () {
switch (state){ switch (state) {
case "PLAYING": case "PLAYING":
sendCommand({ command: "PAUSE"}) sendCommand({command: "PAUSE"});
break; break;
case "PAUSE": case "PAUSE":
sendCommand({ command: "PLAY"}) sendCommand({command: "PLAY"});
break; break;
default: default:
sendCommand({command: "PLAY"}) sendCommand({command: "PLAY"});
} }
}); });
$('#btn_next').click(function () { $('#btn_next').click(function () {
sendCommand({ command: "NEXT"}); sendCommand({command: "NEXT"});
}); });
$('#btn_stop').click(function () { $('#btn_stop').click(function () {
sendCommand({ command: "STOP"}); sendCommand({command: "STOP"});
}); });
$('#input_link').on("input", function () { $('#input_link').on("input", function () {
if($('#input_link').val() == ""){ if ($('#input_link').val() == "") {
disableBtn($('#btn_add')); disableBtn($('#btn_add'));
} }
else{ else {
enableBtn($('#btn_add')); enableBtn($('#btn_add'));
} }
}); });
@ -440,12 +454,12 @@ function listeners() {
}); });
$('#btn_disconnect').click(function () { $('#btn_disconnect').click(function () {
sendCommand({command : "DISCONNECT"}) sendCommand({command: "DISCONNECT"})
}); });
switchAutoFlow.click(function () { switchAutoFlow.click(function () {
console.log(switchAutoFlow.is(':checked')) console.log(switchAutoFlow.is(':checked'))
if(switchAutoFlow.is(':checked')){ if (switchAutoFlow.is(':checked')) {
sendCommand({command: 'AUTOFLOWON'}) sendCommand({command: 'AUTOFLOWON'})
} }
else else
@ -459,7 +473,7 @@ function disableBtn(btn) {
} }
} }
function enableBtn(btn){ function enableBtn(btn) {
if (btn.hasClass("disabled")) { if (btn.hasClass("disabled")) {
btn.removeClass("disabled"); btn.removeClass("disabled");
} }

View File

@ -20,7 +20,6 @@ if(discordToken !== ""){
console.log(data); console.log(data);
Cookies.set('token',data.token, { expires: 31 }); Cookies.set('token',data.token, { expires: 31 });
Cookies.set('name', data.name, { expires: 31 }); Cookies.set('name', data.name, { expires: 31 });
debugger;
window.location = "/"; window.location = "/";
} }

View File

@ -20,7 +20,7 @@
<body class="blue-grey lighten-5" > <body class="blue-grey lighten-5" >
<div th:replace="header :: header ('home',${guild_name},${redirect_url})">...</div> <div th:replace="header :: header ('home',${guild_name},${redirect_url}, ${guild_name})">...</div>
@ -50,15 +50,12 @@
<script>
var needLogin = true;
</script>
<!-- Scripts--> <!-- Scripts-->
<script th:src="@{/js/jquery-3.3.1.min.js}"></script> <script th:src="@{/js/jquery-3.3.1.min.js}"></script>
<script th:src="@{/js/materialize.js}"></script> <script th:src="@{/js/materialize.js}"></script>
<script th:src="@{/js/navabar.js}"></script> <script th:src="@{/js/navabar.js}"></script>
<script th:src="@{/js/js.cookie.js}"></script> <script th:src="@{/js/js.cookie.js}"></script>
<script src="https://use.fontawesome.com/releases/v5.3.1/js/all.js" crossorigin="anonymous"></script> <script th:src="@{/js/fontawesome.js}"></script>
<script th:src="@{/js/workerRegister.js}"></script> <script th:src="@{/js/workerRegister.js}"></script>

View File

@ -38,7 +38,7 @@
<script th:src="@{/js/materialize.js}"></script> <script th:src="@{/js/materialize.js}"></script>
<script th:src="@{/js/navabar.js}"></script> <script th:src="@{/js/navabar.js}"></script>
<script th:src="@{/js/js.cookie.js}"></script> <script th:src="@{/js/js.cookie.js}"></script>
<script src="https://use.fontawesome.com/releases/v5.3.1/js/all.js" crossorigin="anonymous"></script> <script th:src="@{/js/fontawesome.js}"></script>
<script th:src="@{/js/workerRegister.js}"></script> <script th:src="@{/js/workerRegister.js}"></script>

View File

@ -20,7 +20,6 @@
<body class="blue-grey lighten-5" > <body class="blue-grey lighten-5" >
<div th:replace="header :: header ('music',${guild_name},${redirect_url}, ${isAdmin})">...</div> <div th:replace="header :: header ('music',${guild_name},${redirect_url}, ${isAdmin})">...</div>
<div class="section no-pad-bot main" id="index-banner"> <div class="section no-pad-bot main" id="index-banner">
<div class="row"> <div class="row">
<div class="col l8 s12 m12"> <div class="col l8 s12 m12">
@ -313,6 +312,8 @@
<script th:src="@{/js/navabar.js}"></script> <script th:src="@{/js/navabar.js}"></script>
<script th:src="@{/js/js.cookie.js}"></script> <script th:src="@{/js/js.cookie.js}"></script>
<script th:src="@{/js/workerRegister.js}"></script> <script th:src="@{/js/workerRegister.js}"></script>
<script th:src="@{/js/fontawesome.js}"></script>
</body> </body>

View File

@ -50,6 +50,8 @@
<script th:src="@{/js/navabar.js}"></script> <script th:src="@{/js/navabar.js}"></script>
<script th:src="@{/js/js.cookie.js}"></script> <script th:src="@{/js/js.cookie.js}"></script>
<script th:src="@{/js/oauthCallback.js}"></script> <script th:src="@{/js/oauthCallback.js}"></script>
<script th:src="@{/js/fontawesome.js}"></script>
<script src="https://use.fontawesome.com/releases/v5.3.1/js/all.js" crossorigin="anonymous"></script> <script src="https://use.fontawesome.com/releases/v5.3.1/js/all.js" crossorigin="anonymous"></script>

View File

@ -101,6 +101,8 @@
<script th:src="@{/js/navabar.js}"></script> <script th:src="@{/js/navabar.js}"></script>
<script th:src="@{/js/js.cookie.js}"></script> <script th:src="@{/js/js.cookie.js}"></script>
<script th:src="@{/js/workerRegister.js}"></script> <script th:src="@{/js/workerRegister.js}"></script>
<script th:src="@{/js/fontawesome.js}"></script>

View File

@ -147,7 +147,7 @@
<script th:src="@{/js/js.cookie.js}"></script> <script th:src="@{/js/js.cookie.js}"></script>
<script th:src="@{/js/settings.js}"></script> <script th:src="@{/js/settings.js}"></script>
<script src="https://use.fontawesome.com/releases/v5.3.1/js/all.js" crossorigin="anonymous"></script> <script th:src="@{/js/fontawesome.js}"></script>
<script th:src="@{/js/workerRegister.js}"></script> <script th:src="@{/js/workerRegister.js}"></script>