From 4e0cceb508c3def1be334f010e37bb05b657ebcd Mon Sep 17 00:00:00 2001 From: BrokenFire Date: Fri, 12 Jan 2018 23:50:13 +0100 Subject: [PATCH] Correct Playlist order when added on top --- src/main/java/net/Broken/audio/AudioM.java | 5 +++++ src/main/resources/static/js/init.js | 13 ++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/Broken/audio/AudioM.java b/src/main/java/net/Broken/audio/AudioM.java index 51f45e2..c51d971 100644 --- a/src/main/java/net/Broken/audio/AudioM.java +++ b/src/main/java/net/Broken/audio/AudioM.java @@ -22,6 +22,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.util.ArrayList; +import java.util.Collections; import java.util.List; public class AudioM { @@ -108,6 +109,10 @@ public class AudioM { public void playListLoader(AudioPlaylist playlist,int playlistLimit, boolean onHead){ int i = 0; + List tracks = playlist.getTracks(); + if(onHead) + Collections.reverse(tracks); + for(AudioTrack track : playlist.getTracks()){ play(guild, playedChanel, musicManager, track, onHead); i++; diff --git a/src/main/resources/static/js/init.js b/src/main/resources/static/js/init.js index e836857..5983666 100644 --- a/src/main/resources/static/js/init.js +++ b/src/main/resources/static/js/init.js @@ -10,10 +10,9 @@ $(document).ready(function() { $('#modalAdd').modal(); $('#modalChanels').modal({ - dismissible: false, // Modal can be dismissed by clicking outside of the modal - }) + dismissible: false // Modal can be dismissed by clicking outside of the modal + }); - $('#modalChanels').modal('open'); $('.button-collapse-1').sideNav({ @@ -22,7 +21,6 @@ $(document).ready(function() { closeOnClick: false, // Closes side-nav on clicks, useful for Angular/Meteor draggable: true // Choose whether you can drag to open on touch screens, }); - var height = $( window ).height(); $('#btn_play').click(function () { switch (state){ @@ -35,14 +33,14 @@ $(document).ready(function() { break; } - }) + }); $('#btn_next').click(function () { sendCommand(JSON.stringify({ command: "NEXT"})); - }) + }); $('#btn_stop').click(function () { sendCommand(JSON.stringify({ command: "STOP"})); - }) + }); $('.dropdown-button').dropdown({ inDuration: 300, @@ -74,6 +72,7 @@ $(document).ready(function() { } } }); + $('#modalChanels').change(function () { if ($('#btn_ok_channel').hasClass("disabled")) { $('#btn_ok_channel').removeClass("disabled");