better handling of comma-separated queues

This commit is contained in:
calzoneman 2013-06-19 23:20:56 -04:00
parent 4c38276f14
commit d3079a2b07
2 changed files with 46 additions and 21 deletions

View File

@ -1123,10 +1123,13 @@ Channel.prototype.tryQueue = function(user, data) {
if(!this.hasPermission(user, "playlistadd")) {
return;
}
if(data.pos == undefined || data.id == undefined) {
if(typeof data.pos !== "string") {
return;
}
if(data.type == undefined && !(data.id in this.library)) {
if(typeof data.id !== "string" && data.id !== false) {
return;
}
if(typeof data.type !== "string" && !(data.id in this.library)) {
return;
}
@ -1140,24 +1143,14 @@ Channel.prototype.tryQueue = function(user, data) {
return;
}
this.enqueue(data, user);
if(data.list)
this.enqueueList(data, user);
else
this.enqueue(data, user);
}
Channel.prototype.tryQueuePlaylist = function(user, data) {
if(!this.hasPermission(user, "playlistaddlist")) {
return;
}
if(typeof data.name != "string" ||
typeof data.pos != "string") {
return;
}
if(data.pos == "next" && !this.hasPermission(user, "playlistnext")) {
return;
}
var pl = Database.loadUserPlaylist(user.name, data.name);
Channel.prototype.enqueueList = function(data, user) {
var pl = data.list;
var chan = this;
// Queue in reverse order for qnext
if(data.pos == "next") {
@ -1184,6 +1177,25 @@ Channel.prototype.tryQueuePlaylist = function(user, data) {
}
}
Channel.prototype.tryQueuePlaylist = function(user, data) {
if(!this.hasPermission(user, "playlistaddlist")) {
return;
}
if(typeof data.name != "string" ||
typeof data.pos != "string") {
return;
}
if(data.pos == "next" && !this.hasPermission(user, "playlistnext")) {
return;
}
var pl = Database.loadUserPlaylist(user.name, data.name);
data.list = pl;
this.enqueueList(data, user);
}
Channel.prototype.setTemp = function(idx, temp) {
var med = this.queue[idx];
med.temp = temp;

View File

@ -190,6 +190,7 @@ function queue(pos) {
if(pos == "next") {
links = links.reverse();
}
var parsed = [];
links.forEach(function(link) {
var data = parseMediaLink(link);
if(data.id === null || data.type === null) {
@ -200,12 +201,24 @@ function queue(pos) {
else {
$("#mediaurl").val("");
}
socket.emit("queue", {
parsed.push({
id: data.id,
type: data.type,
pos: "end"
type: data.type
});
});
if(parsed.length > 1) {
socket.emit("queue", {
id: false,
list: parsed,
type: "list",
pos: pos
});
}
else {
parsed[0].pos = pos;
socket.emit("queue", parsed[0]);
}
}
$("#queue_next").click(function() {