diff --git a/changelog b/changelog
index 619997e8..4402b180 100644
--- a/changelog
+++ b/changelog
@@ -1,3 +1,9 @@
+Sun Oct 06 01:42 2013 CDT
+ * lib/channel.js, www/assets/js/callbacks.js: Include the link that
+ failed with the queueFail packet. Clicking the "+ n more" tag
+ shows all links that failed for stacked messages
+ * lib/utilities.js: Add a formatLink function
+
Sat Oct 05 20:41 2013 CDT
* lib/user.js: Fix a bug where duplicate guestnames were allowed with
different capitalizations
diff --git a/lib/channel.js b/lib/channel.js
index d1d71204..e1567b11 100644
--- a/lib/channel.js
+++ b/lib/channel.js
@@ -1332,7 +1332,10 @@ Channel.prototype.tryQueue = function(user, data) {
}
if (user.queueLimiter.throttle(limit)) {
- user.socket.emit("queueFail", "You are adding videos too quickly");
+ user.socket.emit("queueFail", {
+ msg: "You are adding videos too quickly",
+ link: null
+ });
return;
}
@@ -1370,20 +1373,29 @@ Channel.prototype.addMedia = function(data, user) {
var self = this;
if(data.type === "yp" &&
!self.hasPermission(user, "playlistaddlist")) {
- user.socket.emit("queueFail", "You don't have permission to add " +
- "playlists");
+ user.socket.emit("queueFail", {
+ msg: "You don't have permission to add " +
+ "playlists",
+ link: $util.formatLink(data.id, data.type)
+ });
return;
}
if(data.type === "cu" &&
!self.hasPermission(user, "playlistaddcustom")) {
- user.socket.emit("queueFail", "You don't have permission to add " +
- "custom embeds");
+ user.socket.emit("queueFail", {
+ msg: "You don't have permission to add " +
+ "custom embeds",
+ link: null
+ });
return;
}
if(isLive(data.type) &&
!self.hasPermission(user, "playlistaddlive")) {
- user.socket.emit("queueFail", "You don't have " +
- "permission to add livestreams");
+ user.socket.emit("queueFail", {
+ msg: "You don't have " +
+ "permission to add livestreams",
+ link: $util.formatLink(data.id, data.type)
+ });
return;
}
data.temp = data.temp || isLive(data.type);
@@ -1403,8 +1415,10 @@ Channel.prototype.addMedia = function(data, user) {
var afterData = function (q, c, m) {
if (data.maxlength && m.seconds > data.maxlength) {
- user.socket.emit("queueFail",
- "Media is too long!");
+ user.socket.emit("queueFail", {
+ msg: "Media is too long!",
+ link: $util.formatLink(m.id, m.type)
+ });
q.release();
return;
}
@@ -1414,7 +1428,10 @@ Channel.prototype.addMedia = function(data, user) {
m.temp = data.temp;
var res = self.playlist.addMedia(m);
if (res.error) {
- user.socket.emit("queueFail", res.error);
+ user.socket.emit("queueFail", {
+ msg: res.error,
+ link: $util.formatLink(m.id, m.type)
+ });
q.release();
return;
}
@@ -1449,7 +1466,10 @@ Channel.prototype.addMedia = function(data, user) {
self.server.infogetter.getMedia(data.id, data.type,
function (e, vids) {
if (e) {
- user.socket.emit("queueFail", e);
+ user.socket.emit("queueFail", {
+ msg: e,
+ link: $util.formatLink(data.id, data.type)
+ });
q.release();
return;
}
@@ -1483,7 +1503,10 @@ Channel.prototype.addMedia = function(data, user) {
if (self.dead)
return;
if (e) {
- user.socket.emit("queueFail", e);
+ user.socket.emit("queueFail", {
+ msg: e,
+ link: $util.formatLink(data.id, data.type)
+ });
q.release();
return;
}
@@ -1498,13 +1521,19 @@ Channel.prototype.addMedia = function(data, user) {
return;
if (err) {
- user.socket.emit("queueFail", "Internal error: " + err);
+ user.socket.emit("queueFail", {
+ msg: "Internal error: " + err,
+ link: $util.formatLink(data.id, data.type)
+ });
return;
}
if (item !== null) {
if (data.maxlength && item.seconds > data.maxlength) {
- user.socket.emit("queueFail", "Media is too long!");
+ user.socket.emit("queueFail", {
+ msg: "Media is too long!",
+ link: $util.formatLink(item.id, item.type)
+ });
return;
}
@@ -1522,7 +1551,10 @@ Channel.prototype.addMedia = function(data, user) {
if (self.dead)
return;
if (e) {
- user.socket.emit("queueFail", e);
+ user.socket.emit("queueFail", {
+ msg: e,
+ link: $util.formatLink(data.id, data.type)
+ });
q.release();
return;
}
diff --git a/lib/utilities.js b/lib/utilities.js
index 6e4f3ac9..04ab6118 100644
--- a/lib/utilities.js
+++ b/lib/utilities.js
@@ -98,5 +98,34 @@ module.exports = {
return false;
}
};
+ },
+
+ formatLink: function (id, type) {
+ switch (type) {
+ case "yt":
+ return "http://youtu.be/" + id;
+ case "vi":
+ return "http://vimeo.com/" + id;
+ case "dm":
+ return "http://dailymotion.com/video/" + id;
+ case "sc":
+ return id;
+ case "li":
+ return "http://livestream.com/" + id;
+ case "tw":
+ return "http://twitch.tv/" + id;
+ case "jt":
+ return "http://justin.tv/" + id;
+ case "rt":
+ return id;
+ case "jw":
+ return id;
+ case "im":
+ return "http://imgur.com/a/" + id;
+ case "us":
+ return "http://ustream.tv/" + id;
+ default:
+ return "";
+ }
}
};
diff --git a/www/assets/js/callbacks.js b/www/assets/js/callbacks.js
index 5c451ea4..578acabf 100644
--- a/www/assets/js/callbacks.js
+++ b/www/assets/js/callbacks.js
@@ -802,8 +802,10 @@ Callbacks = {
});
},
- queueFail: function(data) {
- if (!data || data === true) {
+ queueFail: function (data) {
+ if (!data)
+ data = { link: null };
+ if (!data.msg || data.msg === true) {
data = "Queue failed. Check your link to make sure it is valid.";
}
var alerts = $(".qfalert");
@@ -811,21 +813,44 @@ Callbacks = {
var al = $(alerts[i]);
var cl = al.clone();
cl.children().remove();
- if (cl.text() === data) {
+ if (cl.text() === data.msg) {
var tag = al.find(".label-important");
if (tag.length > 0) {
+ var morelinks = al.find(".qflinks");
+ $("").attr("href", data.link)
+ .attr("target", "_blank")
+ .text(data.link)
+ .appendTo(morelinks);
+ $("
").appendTo(morelinks);
var count = parseInt(tag.text().match(/\d+/)[0]) + 1;
tag.text(tag.text().replace(/\d+/, ""+count));
} else {
- $("")
- .addClass("label label-important pull-right")
+ var tag = $("")
+ .addClass("label label-important pull-right pointer")
.text("+ 1 more")
.appendTo(al);
+ var morelinks = $("