diff --git a/channel.js b/channel.js index 7a2b0122..3a0472d6 100644 --- a/channel.js +++ b/channel.js @@ -81,7 +81,10 @@ Channel.prototype.loadDump = function() { data = JSON.parse(data); for(var i = 0; i < data.queue.length; i++) { var e = data.queue[i]; - this.queue.push(new Media(e.id, e.title, e.seconds, e.type)); + var m = new Media(e.id, e.title, e.seconds, e.type); + m.queueby = data.queue[i].queueby ? data.queue[i].queueby + : ""; + this.queue.push(m); } this.sendAll("playlist", { pl: this.queue @@ -572,14 +575,16 @@ function mediaUpdate(chan, id) { setTimeout(function() { mediaUpdate(chan, id); }, 1000); } -Channel.prototype.enqueue = function(data) { +Channel.prototype.enqueue = function(data, user) { var idx = data.pos == "next" ? this.position + 1 : this.queue.length; // Prefer cache over looking up new data if(data.id in this.library) { - this.queue.splice(idx, 0, this.library[data.id]); + var media = this.library[data.id]; + media.queueby = user ? user.name : ""; + this.queue.splice(idx, 0, media); this.sendAll("queue", { - media: this.library[data.id].pack(), + media: media.pack(), pos: idx }); this.logger.log("*** Queued from cache: id=" + data.id); @@ -592,6 +597,7 @@ Channel.prototype.enqueue = function(data) { case "dm": case "sc": InfoGetter.getMedia(data.id, data.type, function(media) { + media.queueby = user ? user.name : ""; this.queue.splice(idx, 0, media); this.sendAll("queue", { media: media.pack(), @@ -603,7 +609,8 @@ Channel.prototype.enqueue = function(data) { }.bind(this)); break; case "li": - var media = new Media(data.id, "Livestream ~ " + data.id, "--:--", "li"); + var media = new Media(data.id, "Livestream - " + data.id, "--:--", "li"); + media.queueby = user ? user.name : ""; this.queue.splice(idx, 0, media); this.sendAll("queue", { media: media.pack(), @@ -611,7 +618,8 @@ Channel.prototype.enqueue = function(data) { }); break; case "tw": - var media = new Media(data.id, "Twitch ~ " + data.id, "--:--", "tw"); + var media = new Media(data.id, "Twitch - " + data.id, "--:--", "tw"); + media.queueby = user ? user.name : ""; this.queue.splice(idx, 0, media); this.sendAll("queue", { media: media.pack(), @@ -620,6 +628,7 @@ Channel.prototype.enqueue = function(data) { break; case "rt": var media = new Media(data.id, "Livestream", "--:--", "rt"); + media.queueby = user ? user.name : ""; this.queue.splice(idx, 0, media); this.sendAll("queue", { media: media.pack(), @@ -656,7 +665,7 @@ Channel.prototype.tryQueue = function(user, data) { return; } - this.enqueue(data); + this.enqueue(data, user); } Channel.prototype.dequeue = function(data) { diff --git a/media.js b/media.js index 45c1fae4..a480300a 100644 --- a/media.js +++ b/media.js @@ -46,6 +46,7 @@ var Media = function(id, title, seconds, type) { this.seconds = seconds; this.duration = formatTime(this.seconds); this.type = type; + this.queueby = ""; } // Returns an object containing the data in this Media but not the @@ -56,7 +57,8 @@ Media.prototype.pack = function() { title: this.title, seconds: this.seconds, duration: this.duration, - type: this.type + type: this.type, + queueby: this.queueby }; } @@ -69,7 +71,8 @@ Media.prototype.packupdate = function() { seconds: this.seconds, duration: this.duration, type: this.type, - currentTime: this.currentTime + currentTime: this.currentTime, + queueby: this.queueby }; } diff --git a/package.json b/package.json index 5f16a9aa..3f49d3e7 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Calvin Montgomery", "name": "CyTube", "description": "Online media synchronizer and chat", - "version": "1.2.5", + "version": "1.2.6", "repository": { "url": "http://github.com/calzoneman/sync" }, diff --git a/server.js b/server.js index a4129c76..8896753d 100644 --- a/server.js +++ b/server.js @@ -9,7 +9,7 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -const VERSION = "1.2.5"; +const VERSION = "1.2.6"; var fs = require("fs"); var Logger = require("./logger.js"); diff --git a/www/assets/js/callbacks.js b/www/assets/js/callbacks.js index 5c3eaa50..9d763aea 100644 --- a/www/assets/js/callbacks.js +++ b/www/assets/js/callbacks.js @@ -246,6 +246,9 @@ function initCallbacks() { var li = makeQueueEntry(data.pl[i]); if(RANK >= Rank.Moderator || OPENQUEUE || LEADER) addQueueButtons(li); + $(li).attr("title", data.pl[i].queueby + ? ("Added by: " + data.pl[i].queueby) + : "Added by: Unknown"); $(li).appendTo(ul); } }); @@ -257,6 +260,9 @@ function initCallbacks() { $(li).css("display", "none"); var idx = data.pos; var ul = $("#queue")[0]; + $(li).attr("title", data.media.queueby + ? ("Added by: " + data.media.queueby) + : "Added by: Unknown"); $(li).appendTo(ul); if(idx < ul.children.length - 1) moveVideo(ul.children.length - 1, idx);