mirror of https://github.com/calzoneman/sync.git
Implement #185
This commit is contained in:
parent
a2036e4383
commit
ec035bd93f
|
@ -59,6 +59,7 @@ var Channel = function(name) {
|
|||
playlistjump: 1.5,
|
||||
playlistaddlist: 1.5,
|
||||
playlistaddlive: 1.5,
|
||||
exceedmaxlength: 2,
|
||||
addnontemp: 2,
|
||||
settemp: 2,
|
||||
playlistgeturl: 1.5,
|
||||
|
@ -78,6 +79,7 @@ var Channel = function(name) {
|
|||
allow_voteskip: true,
|
||||
voteskip_ratio: 0.5,
|
||||
pagetitle: this.name,
|
||||
maxlength: 0,
|
||||
externalcss: "",
|
||||
externaljs: "",
|
||||
chat_antiflood: false,
|
||||
|
@ -1194,9 +1196,15 @@ Channel.prototype.tryQueue = function(user, data) {
|
|||
Channel.prototype.addMedia = function(data, user) {
|
||||
data.temp = isLive(data.type) || !this.hasPermission(user, "addnontemp");
|
||||
data.queueby = user ? user.name : "";
|
||||
data.maxlength = this.hasPermission(user, "exceedmaxlength") ? 0 : this.opts.maxlength;
|
||||
var chan = this;
|
||||
if(data.id in this.library) {
|
||||
var m = this.library[data.id].dup();
|
||||
if(data.maxlength && m.seconds > data.maxlength) {
|
||||
user.socket.emit("queueFail", "Media is too long!");
|
||||
return;
|
||||
}
|
||||
|
||||
data.media = m;
|
||||
this.playlist.addCachedMedia(data, function (err, item) {
|
||||
if(err) {
|
||||
|
|
|
@ -216,6 +216,12 @@ Playlist.prototype.addMedia = function(data, callback) {
|
|||
return;
|
||||
}
|
||||
|
||||
if(data.maxlength && media.seconds > data.maxlength) {
|
||||
action.expire = 0;
|
||||
callback("Media is too long!", null);
|
||||
return;
|
||||
}
|
||||
|
||||
it.media = media;
|
||||
it.temp = data.temp;
|
||||
it.queueby = data.queueby;
|
||||
|
|
|
@ -49,9 +49,21 @@
|
|||
genPermissionsEditor();
|
||||
|
||||
$("#chanopts_submit").click(function() {
|
||||
var hms = $("#opt_maxlength").val().split(":");
|
||||
var len = 0;
|
||||
if(hms.length == 3) {
|
||||
len = parseInt(hms[0]) * 3600 + parseInt(hms[1]) * 60 + parseInt(hms[2]);
|
||||
}
|
||||
else if(hms.length == 2) {
|
||||
len = parseInt(hms[0]) * 60 + parseInt(hms[1]);
|
||||
}
|
||||
else {
|
||||
len = parseInt(hms[0]);
|
||||
}
|
||||
socket.emit("setOptions", {
|
||||
allow_voteskip: $("#opt_allow_voteskip").prop("checked"),
|
||||
voteskip_ratio: parseFloat($("#opt_voteskip_ratio").val()),
|
||||
maxlength: len,
|
||||
pagetitle: $("#opt_pagetitle").val() || CHANNEL.name,
|
||||
externalcss: $("#opt_externalcss").val(),
|
||||
externaljs: $("#opt_externaljs").val(),
|
||||
|
|
|
@ -800,6 +800,22 @@ function handleModPermissions() {
|
|||
$("#opt_enable_link_regex").prop("checked", CHANNEL.opts.enable_link_regex);
|
||||
$("#opt_allow_voteskip").prop("checked", CHANNEL.opts.allow_voteskip);
|
||||
$("#opt_voteskip_ratio").val(CHANNEL.opts.voteskip_ratio);
|
||||
(function() {
|
||||
if(typeof CHANNEL.opts.maxlength != "number") {
|
||||
$("#opt_maxlength").val("");
|
||||
return;
|
||||
}
|
||||
var h = parseInt(CHANNEL.opts.maxlength / 3600);
|
||||
h = ""+h;
|
||||
if(h.length < 2) h = "0" + h;
|
||||
var m = parseInt((CHANNEL.opts.maxlength % 3600) / 60);
|
||||
m = ""+m;
|
||||
if(m.length < 2) m = "0" + m;
|
||||
var s = parseInt(CHANNEL.opts.maxlength % 60);
|
||||
s = ""+s;
|
||||
if(s.length < 2) s = "0" + s;
|
||||
$("#opt_maxlength").val(h + ":" + m + ":" + s);
|
||||
})();
|
||||
$("#csstext").val(CHANNEL.css);
|
||||
$("#jstext").val(CHANNEL.js);
|
||||
$("#motdtext").val(CHANNEL.motd_text);
|
||||
|
@ -1388,6 +1404,7 @@ function genPermissionsEditor() {
|
|||
makeOption("Jump to video", "playlistjump", standard, CHANNEL.perms.playlistjump+"");
|
||||
makeOption("Queue playlist", "playlistaddlist", standard, CHANNEL.perms.playlistaddlist+"");
|
||||
makeOption("Queue livestream", "playlistaddlive", standard, CHANNEL.perms.playlistaddlive+"");
|
||||
makeOption("Exceed maximum media length", "exceedmaxlength", standard, CHANNEL.perms.exceedmaxlength+"");
|
||||
makeOption("Add nontemporary media", "addnontemp", standard, CHANNEL.perms.addnontemp+"");
|
||||
makeOption("Temp/untemp playlist item", "settemp", standard, CHANNEL.perms.settemp+"");
|
||||
makeOption("Shuffle playlist", "playlistshuffle", standard, CHANNEL.perms.playlistshuffle+"");
|
||||
|
|
|
@ -49,6 +49,13 @@
|
|||
<input type="text" id="opt_voteskip_ratio" placeholder="0.5">
|
||||
</div>
|
||||
</div>
|
||||
<!-- max video length -->
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="opt_maxlength">Maximum Video Length</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="opt_maxlength" placeholder="HH:MM:SS">
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<strong>Admin-Only Controls</strong>
|
||||
<!-- page title -->
|
||||
|
|
Loading…
Reference in New Issue