This commit is contained in:
calzoneman 2013-05-19 12:56:13 -04:00
parent 3e2683642e
commit 01fc746334
7 changed files with 82 additions and 52 deletions

View File

@ -42,6 +42,8 @@ var Channel = function(name) {
this.poll = false;
this.voteskip = false;
this.opts = {
qopen_allow_anon: false,
qopen_allow_guest: true,
qopen_allow_qnext: false,
qopen_allow_move: false,
qopen_allow_playnext: false,
@ -793,9 +795,14 @@ Channel.prototype.enqueue = function(data, user) {
}
Channel.prototype.tryQueue = function(user, data) {
if(!Rank.hasPermission(user, "queue") &&
this.leader != user &&
!this.openqueue) {
var anon = (user.name == "");
var guest = (user.name != "" && !user.loggedIn);
var canqueue = (anon && this.opts.qopen_allow_anon) ||
(guest && this.opts.qopen_allow_guest) ||
(!anon && !guest);
canqueue = canqueue && this.openqueue;
canqueue = canqueue || this.leader == user || Rank.hasPermission(user, "queue");
if(!canqueue) {
return;
}
if(data.pos == undefined || data.id == undefined) {

View File

@ -2,7 +2,7 @@
"author": "Calvin Montgomery",
"name": "CyTube",
"description": "Online media synchronizer and chat",
"version": "1.8.0",
"version": "1.8.1",
"repository": {
"url": "http://github.com/calzoneman/sync"
},

View File

@ -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.8.0";
const VERSION = "1.8.1";
var fs = require("fs");
var Logger = require("./logger.js");

View File

@ -182,6 +182,8 @@ Callbacks = {
},
channelOpts: function(opts) {
$("#opt_qopen_allow_anon").prop("checked", opts.qopen_allow_anon);
$("#opt_qopen_allow_guest").prop("checked", opts.qopen_allow_guest);
$("#opt_qopen_allow_qnext").prop("checked", opts.qopen_allow_qnext);
$("#opt_qopen_allow_move").prop("checked", opts.qopen_allow_move);
$("#opt_qopen_allow_delete").prop("checked", opts.qopen_allow_delete);
@ -226,7 +228,7 @@ Callbacks = {
$("#voteskip").attr("disabled", false);
else
$("#voteskip").attr("disabled", true);
rebuildPlaylist();
handleRankChange();
},
channelCSSJS: function(data) {

View File

@ -346,6 +346,8 @@ $("#opt_submit").click(function() {
var css = $("#opt_customcss").val();
var ratio = +$("#opt_voteskip_ratio").val() || 0.5;
opts = {
qopen_allow_anon: $("#opt_qopen_allow_anon").prop("checked"),
qopen_allow_guest: $("#opt_qopen_allow_guest").prop("checked"),
qopen_allow_qnext: $("#opt_qopen_allow_qnext").prop("checked"),
qopen_allow_move: $("#opt_qopen_allow_move").prop("checked"),
qopen_allow_delete: $("#opt_qopen_allow_delete").prop("checked"),

View File

@ -387,7 +387,7 @@ function addQueueButtons(li) {
function rebuildPlaylist() {
$("#queue li").each(function() {
$(this).find(".btn-group").remove();
if(RANK >= Rank.Moderator || LEADER || OPENQUEUE)
if(RANK >= Rank.Moderator || LEADER || canQueue())
addQueueButtons(this);
});
}
@ -599,24 +599,28 @@ function closePoll() {
}
}
function canQueue() {
var anon = !uname;
var guest = (uname && !session);
var canqueue = (!guest && !anon) ||
(guest && CHANNELOPTS.qopen_allow_guest) ||
(anon && CHANNELOPTS.qopen_allow_anon);
canqueue = canqueue && OPENQUEUE;
return canqueue;
}
function handleRankChange() {
rebuildPlaylist();
if(RANK >= Rank.Moderator || LEADER) {
$("#playlist_controls").css("display", "block");
$("#playlist_controls button").each(function() {
$(this).attr("disabled", false);
});
$("#pollcontainer .active").each(function() {
var btns = $(this).find(".btn-danger");
if(btns.length == 0) {
$("<button/>").addClass("btn btn-danger pull-right")
.text("End Poll")
.insertAfter($(this).find(".close"))
.click(function() {
socket.emit("closePoll")
});
}
});
if(RANK >= 10) {
$("#drop_channel").parent().css("display", "");
}
if(RANK >= Rank.Owner) {
$("#show_jseditor").parent().css("display", "");
$("#show_csseditor").parent().css("display", "");
}
else {
$("#show_jseditor").parent().css("display", "none");
$("#show_csseditor").parent().css("display", "none");
}
if(RANK >= Rank.Moderator) {
$("#qlockbtn").css("display", "block");
@ -640,40 +644,47 @@ function handleRankChange() {
$("#show_filtereditor").attr("disabled", val);
$("#show_acl").attr("disabled", val);
}
else if(!LEADER) {
if(OPENQUEUE) {
if(CHANNELOPTS.qopen_allow_qnext)
$("#queue_next").attr("disabled", false);
else
$("#queue_next").attr("disabled", true);
if(CHANNELOPTS.qopen_allow_playnext)
$("#play_next").attr("disabled", false);
else
$("#play_next").attr("disabled", true);
}
else {
$("#playlist_controls").css("display", "none");
}
else {
if(!LEADER) {
if(canQueue()) {
$("#playlist_controls").css("display", "");
if(CHANNELOPTS.qopen_allow_qnext)
$("#queue_next").attr("disabled", false);
else
$("#queue_next").attr("disabled", true);
if(CHANNELOPTS.qopen_allow_playnext)
$("#play_next").attr("disabled", false);
else
$("#play_next").attr("disabled", true);
}
else {
$("#playlist_controls").css("display", "none");
}
$("#pollcontainer .active").each(function() {
$(this).find(".btn-danger").remove();
});
}
if(RANK < Rank.Moderator) {
$("#pollcontainer .active").each(function() {
$(this).find(".btn-danger").remove();
});
}
$("#getplaylist").css("width", "100%");
$("#clearplaylist").css("display", "none");
$("#shuffleplaylist").css("display", "none");
}
if(RANK >= Rank.Owner) {
$("#show_jseditor").parent().css("display", "");
$("#show_csseditor").parent().css("display", "");
}
else {
$("#show_jseditor").parent().css("display", "none");
$("#show_csseditor").parent().css("display", "none");
}
if(RANK >= 10) {
$("#drop_channel").parent().css("display", "");
if(RANK >= Rank.Moderator || LEADER) {
$("#playlist_controls").css("display", "block");
$("#playlist_controls button").each(function() {
$(this).attr("disabled", false);
});
$("#pollcontainer .active").each(function() {
var btns = $(this).find(".btn-danger");
if(btns.length == 0) {
$("<button/>").addClass("btn btn-danger pull-right")
.text("End Poll")
.insertAfter($(this).find(".close"))
.click(function() {
socket.emit("closePoll")
});
}
});
}
}

View File

@ -160,6 +160,14 @@
<fieldset>
<div class="span5">
<label>When the queue is open:</label>
<label class="checkbox">
<input type="checkbox" id="opt_qopen_allow_anon">
Allow anonymous users to add videos
</label>
<label class="checkbox">
<input type="checkbox" id="opt_qopen_allow_guest">
Allow guest users to add videos
</label>
<label class="checkbox">
<input type="checkbox" id="opt_qopen_allow_qnext">
Allow anyone to Queue Next