diff --git a/channel.js b/channel.js index 0366464e..b0a8a6c6 100644 --- a/channel.js +++ b/channel.js @@ -1155,10 +1155,15 @@ Channel.prototype.tryQueue = function(user, data) { if(user.rank < Rank.Moderator && this.leader != user - && user.noflood("queue", 1.5)) { + && user.noflood("queue", 3)) { return; } + if(user.rank < Rank.Moderator && this.playlist.count(data.id) > 10) { + user.socket.emit("queueFail", "That video is already on the " + + "playlist 10 times."); + } + data.queueby = user ? user.name : ""; data.temp = !this.hasPermission(user, "addnontemp"); diff --git a/playlist.js b/playlist.js index c91de926..99d4968e 100644 --- a/playlist.js +++ b/playlist.js @@ -450,6 +450,15 @@ Playlist.prototype.clear = function() { clearInterval(this._leadInterval); } +Playlist.prototype.count = function (id) { + var count = 0; + this.items.forEach(function (i) { + if(i.media.id === id) + count++; + }); + return count; +} + Playlist.prototype.lead = function(lead) { this.leading = lead; var pl = this; diff --git a/ullist.js b/ullist.js index 4538c4b0..9314fb9e 100644 --- a/ullist.js +++ b/ullist.js @@ -161,4 +161,13 @@ ULList.prototype.toArray = function(pack) { return arr; } +/* iterate across the playlist */ +ULList.prototype.forEach = function (fn) { + var item = this.first; + while(item !== null) { + fn(item); + item = item.next; + } +}; + exports.ULList = ULList; diff --git a/www/assets/js/callbacks.js b/www/assets/js/callbacks.js index 04f9928c..974c6bbc 100644 --- a/www/assets/js/callbacks.js +++ b/www/assets/js/callbacks.js @@ -757,7 +757,7 @@ Callbacks = { } makeAlert("Error", data, "alert-error") .addClass("span12") - .insertAfter($("#mediaurl").parent()); + .insertBefore($("#extended_controls")); }, setTemp: function(data) {