TeaWeb/shared/js/ui/modal/ModalCreateChannel.ts

389 lines
21 KiB
TypeScript
Raw Normal View History

2019-04-04 21:47:52 +02:00
/// <reference path="../../ui/elements/modal.ts" />
2018-03-07 19:06:52 +01:00
namespace Modals {
2019-04-04 21:47:52 +02:00
export function createChannelModal(connection: ConnectionHandler, channel: ChannelEntry | undefined, parent: ChannelEntry | undefined, permissions: PermissionManager, callback: (properties?: ChannelProperties, permissions?: PermissionValue[]) => any) {
2018-04-16 20:38:35 +02:00
let properties: ChannelProperties = { } as ChannelProperties; //The changes properties
2018-03-07 19:06:52 +01:00
const modal = createModal({
header: channel ? tr("Edit channel") : tr("Create channel"),
2018-03-07 19:06:52 +01:00
body: () => {
2019-03-25 20:04:04 +01:00
const render_properties = {};
Object.assign(render_properties, channel ? channel.properties : {
2018-11-04 00:39:29 +01:00
channel_flag_maxfamilyclients_unlimited: true,
2019-03-25 20:04:04 +01:00
channel_flag_maxclients_unlimited: true,
});
render_properties["channel_icon_tab"] = connection.fileManager.icons.generateTag(channel ? channel.properties.channel_icon_id : 0);
render_properties["channel_icon_general"] = connection.fileManager.icons.generateTag(channel ? channel.properties.channel_icon_id : 0);
2019-03-25 20:04:04 +01:00
let template = $("#tmpl_channel_edit").renderTag(render_properties);
2018-04-16 20:38:35 +02:00
return template.tabify();
2018-03-07 19:06:52 +01:00
},
footer: () => {
let footer = $.spawn("div");
footer.addClass("modal-button-group");
2018-04-16 20:38:35 +02:00
footer.css("margin", "5px");
2018-03-07 19:06:52 +01:00
let buttonCancel = $.spawn("button");
buttonCancel.text(tr("Cancel")).addClass("button_cancel");
2018-03-07 19:06:52 +01:00
let buttonOk = $.spawn("button");
buttonOk.text(tr("Ok")).addClass("button_ok");
2018-03-07 19:06:52 +01:00
footer.append(buttonCancel);
footer.append(buttonOk);
return footer;
},
width: 500
});
2018-04-16 20:38:35 +02:00
2019-04-04 21:47:52 +02:00
applyGeneralListener(connection, properties, modal.htmlTag.find(".general_properties"), modal.htmlTag.find(".button_ok"), channel);
applyStandardListener(connection, properties, modal.htmlTag.find(".settings_standard"), modal.htmlTag.find(".button_ok"), parent, !channel);
applyPermissionListener(connection, properties, modal.htmlTag.find(".settings_permissions"), modal.htmlTag.find(".button_ok"), permissions, channel);
applyAudioListener(connection, properties, modal.htmlTag.find(".container-channel-settings-audio"), modal.htmlTag.find(".button_ok"), channel);
applyAdvancedListener(connection, properties, modal.htmlTag.find(".settings_advanced"), modal.htmlTag.find(".button_ok"), channel);
2018-04-16 20:38:35 +02:00
2018-07-03 12:33:31 +02:00
let updated: PermissionValue[] = [];
2018-04-16 20:38:35 +02:00
modal.htmlTag.find(".button_ok").click(() => {
2018-07-03 12:33:31 +02:00
modal.htmlTag.find(".settings_permissions").find("input[permission]").each((index, _element) => {
let element = $(_element);
if(!element.prop("changed")) return;
let permission = permissions.resolveInfo(element.attr("permission"));
if(!permission) {
log.error(LogCategory.PERMISSIONS, tr("Failed to resolve channel permission for name %o"), element.attr("permission"));
2018-07-03 12:33:31 +02:00
element.prop("disabled", true);
return;
}
updated.push(new PermissionValue(permission, element.val()));
});
console.log(tr("Updated permissions %o"), updated);
2018-07-03 12:33:31 +02:00
}).click(() => {
2018-04-16 20:38:35 +02:00
modal.close();
2018-08-10 21:30:58 +02:00
callback(properties, updated); //First may create the channel
2018-04-16 20:38:35 +02:00
});
modal.htmlTag.find(".button_cancel").click(() => {
modal.close();
callback();
});
modal.open();
2018-11-04 00:39:29 +01:00
if(!channel)
modal.htmlTag.find(".channel_name").focus();
2018-04-16 20:38:35 +02:00
}
2019-04-04 21:47:52 +02:00
function applyGeneralListener(connection: ConnectionHandler, properties: ChannelProperties, tag: JQuery, button: JQuery, channel: ChannelEntry | undefined) {
2018-04-16 20:38:35 +02:00
let updateButton = () => {
2019-06-22 12:39:09 +02:00
const status = tag.find(".input_error").length != 0;
console.log("Disabled: %o", status);
button.prop("disabled", status);
2018-04-16 20:38:35 +02:00
};
2019-06-22 12:39:09 +02:00
{
const channel_name = tag.find(".channel_name");
tag.find(".channel_name").on('change keyup', function (this: HTMLInputElement) {
properties.channel_name = this.value;
2018-04-16 20:38:35 +02:00
2019-06-22 12:39:09 +02:00
channel_name.toggleClass("input_error", this.value.length < 1 || this.value.length > 40);
updateButton();
}).prop("disabled", channel && !connection.permissions.neededPermission(PermissionType.B_CHANNEL_MODIFY_NAME).granted(1));
}
2019-03-25 20:04:04 +01:00
tag.find(".button-select-icon").on('click', event => {
2019-04-04 21:47:52 +02:00
Modals.spawnIconSelect(connection, id => {
2019-03-25 20:04:04 +01:00
const icon_node = tag.find(".button-select-icon").find(".icon-node");
icon_node.empty();
2019-04-04 21:47:52 +02:00
icon_node.append(connection.fileManager.icons.generateTag(id));
2019-03-25 20:04:04 +01:00
console.log("Selected icon ID: %d", id);
properties.channel_icon_id = id;
}, channel ? channel.properties.channel_icon_id : 0);
});
2018-04-16 20:38:35 +02:00
2019-06-22 12:39:09 +02:00
{
const channel_password = tag.find(".channel_password");
tag.find(".channel_password").change(function (this: HTMLInputElement) {
properties.channel_flag_password = this.value.length != 0;
if(properties.channel_flag_password)
helpers.hashPassword(this.value).then(pass => properties.channel_password = pass);
channel_password.removeClass("input_error");
if(!properties.channel_flag_password)
if(connection.permissions.neededPermission(PermissionType.B_CHANNEL_CREATE_MODIFY_WITH_FORCE_PASSWORD).granted(1))
channel_password.addClass("input_error");
updateButton();
}).prop("disabled", !connection.permissions.neededPermission(!channel ? PermissionType.B_CHANNEL_CREATE_WITH_PASSWORD : PermissionType.B_CHANNEL_MODIFY_PASSWORD).granted(1));
}
2018-04-16 20:38:35 +02:00
tag.find(".channel_topic").change(function (this: HTMLInputElement) {
properties.channel_topic = this.value;
2019-04-04 21:47:52 +02:00
}).prop("disabled", !connection.permissions.neededPermission(!channel ? PermissionType.B_CHANNEL_CREATE_WITH_TOPIC : PermissionType.B_CHANNEL_MODIFY_TOPIC).granted(1));
2018-04-16 20:38:35 +02:00
tag.find(".channel_description").change(function (this: HTMLInputElement) {
properties.channel_description = this.value;
2019-04-04 21:47:52 +02:00
}).prop("disabled", !connection.permissions.neededPermission(!channel ? PermissionType.B_CHANNEL_CREATE_WITH_DESCRIPTION : PermissionType.B_CHANNEL_MODIFY_DESCRIPTION).granted(1));
2018-04-16 20:38:35 +02:00
2019-03-25 20:04:04 +01:00
if(!channel) {
2018-11-04 00:39:29 +01:00
setTimeout(() => {
tag.find(".channel_name").trigger("change");
tag.find(".channel_password").trigger('change');
}, 0);
2018-04-16 20:38:35 +02:00
}
}
2019-04-04 21:47:52 +02:00
function applyStandardListener(connection: ConnectionHandler, properties: ChannelProperties, tag: JQuery, button: JQuery, parent: ChannelEntry, create: boolean) {
2018-04-16 20:38:35 +02:00
tag.find("input[name=\"channel_type\"]").change(function (this: HTMLInputElement) {
switch(this.value) {
case "semi":
properties.channel_flag_permanent = false;
properties.channel_flag_semi_permanent = true;
break;
case "perm":
properties.channel_flag_permanent = true;
properties.channel_flag_semi_permanent = false;
break;
default:
properties.channel_flag_permanent = false;
properties.channel_flag_semi_permanent = false;
break;
}
});
tag.find("input[name=\"channel_type\"][value=\"temp\"]")
2019-04-04 21:47:52 +02:00
.prop("disabled", !connection.permissions.neededPermission(create ? PermissionType.B_CHANNEL_CREATE_TEMPORARY : PermissionType.B_CHANNEL_MODIFY_MAKE_TEMPORARY).granted(1));
2018-04-16 20:38:35 +02:00
tag.find("input[name=\"channel_type\"][value=\"semi\"]")
2019-04-04 21:47:52 +02:00
.prop("disabled", !connection.permissions.neededPermission(create ? PermissionType.B_CHANNEL_CREATE_SEMI_PERMANENT : PermissionType.B_CHANNEL_MODIFY_MAKE_SEMI_PERMANENT).granted(1));
2018-04-16 20:38:35 +02:00
tag.find("input[name=\"channel_type\"][value=\"perm\"]")
2019-04-04 21:47:52 +02:00
.prop("disabled", !connection.permissions.neededPermission(create ? PermissionType.B_CHANNEL_CREATE_PERMANENT : PermissionType.B_CHANNEL_MODIFY_MAKE_PERMANENT).granted(1));
2018-07-03 12:33:31 +02:00
if(create)
tag.find("input[name=\"channel_type\"]:not(:disabled)").last().prop("checked", true).trigger('change');
2018-04-16 20:38:35 +02:00
tag.find("input[name=\"channel_default\"]").change(function (this: HTMLInputElement) {
console.log(this.checked);
properties.channel_flag_default = this.checked;
let elements = tag.find("input[name=\"channel_type\"]");
Implemented the Material Design and fixed some bugs (#33) * cleaned up some files * Fundamental style update * Redesigned some style * fixed hostbanner popup * Removed old identity stuff * fixed close listener * Fixed changelog date * fixed release chat icons * fixed url * Fixed hostbanner * Uploaded missing images * Improved update handling * Improved script files * Fixed loading error and icon error * fixed Yes/No modal * Fixed loader issues with MS Edge * fixed modal style bug * Fixed control bar overflow for small devices * Improved error handling on identity creation * Logging generate error to terminal * fixed possible php error * fixed some possible loading errors when other files have'nt been already loaded. * removed debug message * Changed emsrcypten flags * Improved codec error handling * removed webassembly as required dependency * Improved and fixed channel tree issues * Improved the sliders * Removed unneeded files * fixed loader versions cache * second slight performance improved (dont animate elements anymore if they are not shown) * Fixed query visibility setting * not showing useless client infos for query clients * Added an auto reconnect system * Added a canceled message and increased reconnect interval * removed implemented todo * fixed repetitive channel names * Reworked the channel tree selected lines * Fixed channel tree names * Fixed name alignment * fixed the native client * added min width to the server select groups to avoid a disappearing effect on shrink * fixed bugged downloaded icons
2019-02-17 16:08:10 +01:00
elements.prop("disabled", this.checked);
2018-04-16 20:38:35 +02:00
if(this.checked) {
elements.prop("checked", false);
tag.find("input[name=\"channel_type\"][value=\"perm\"]").prop("checked", true).trigger("change");
Implemented the Material Design and fixed some bugs (#33) * cleaned up some files * Fundamental style update * Redesigned some style * fixed hostbanner popup * Removed old identity stuff * fixed close listener * Fixed changelog date * fixed release chat icons * fixed url * Fixed hostbanner * Uploaded missing images * Improved update handling * Improved script files * Fixed loading error and icon error * fixed Yes/No modal * Fixed loader issues with MS Edge * fixed modal style bug * Fixed control bar overflow for small devices * Improved error handling on identity creation * Logging generate error to terminal * fixed possible php error * fixed some possible loading errors when other files have'nt been already loaded. * removed debug message * Changed emsrcypten flags * Improved codec error handling * removed webassembly as required dependency * Improved and fixed channel tree issues * Improved the sliders * Removed unneeded files * fixed loader versions cache * second slight performance improved (dont animate elements anymore if they are not shown) * Fixed query visibility setting * not showing useless client infos for query clients * Added an auto reconnect system * Added a canceled message and increased reconnect interval * removed implemented todo * fixed repetitive channel names * Reworked the channel tree selected lines * Fixed channel tree names * Fixed name alignment * fixed the native client * added min width to the server select groups to avoid a disappearing effect on shrink * fixed bugged downloaded icons
2019-02-17 16:08:10 +01:00
}
2018-04-16 20:38:35 +02:00
}).prop("disabled",
2019-04-04 21:47:52 +02:00
!connection.permissions.neededPermission(create ? PermissionType.B_CHANNEL_CREATE_PERMANENT : PermissionType.B_CHANNEL_MODIFY_MAKE_PERMANENT).granted(1) ||
!connection.permissions.neededPermission(create ? PermissionType.B_CHANNEL_CREATE_WITH_DEFAULT : PermissionType.B_CHANNEL_MODIFY_MAKE_DEFAULT).granted(1));
2018-04-16 20:38:35 +02:00
tag.find("input[name=\"talk_power\"]").change(function (this: HTMLInputElement) {
properties.channel_needed_talk_power = parseInt(this.value);
2019-04-04 21:47:52 +02:00
}).prop("disabled", !connection.permissions.neededPermission(create ? PermissionType.B_CHANNEL_CREATE_WITH_NEEDED_TALK_POWER : PermissionType.B_CHANNEL_MODIFY_NEEDED_TALK_POWER).granted(1));
2018-04-16 20:38:35 +02:00
let orderTag = tag.find(".order_id");
2019-04-04 21:47:52 +02:00
for(let channel of (parent ? parent.children() : connection.channelTree.rootChannel()))
2018-04-16 20:38:35 +02:00
$.spawn("option").attr("channelId", channel.channelId.toString()).text(channel.channelName()).appendTo(orderTag);
orderTag.change(function (this: HTMLSelectElement) {
let selected = $(this.options.item(this.selectedIndex));
properties.channel_order = parseInt(selected.attr("channelId"));
2019-04-04 21:47:52 +02:00
}).prop("disabled", !connection.permissions.neededPermission(create ? PermissionType.B_CHANNEL_CREATE_WITH_SORTORDER : PermissionType.B_CHANNEL_MODIFY_SORTORDER).granted(1));
2018-04-16 20:38:35 +02:00
orderTag.find("option").last().prop("selected", true);
2018-03-07 19:06:52 +01:00
}
2018-07-03 12:33:31 +02:00
2019-04-04 21:47:52 +02:00
function applyPermissionListener(connection: ConnectionHandler, properties: ChannelProperties, tag: JQuery, button: JQuery, permissions: PermissionManager, channel?: ChannelEntry) {
2018-07-03 12:33:31 +02:00
let apply_permissions = (channel_permissions: PermissionValue[]) => {
console.log(tr("Got permissions: %o"), channel_permissions);
2018-07-03 12:33:31 +02:00
let required_power = -2;
for(let cperm of channel_permissions)
if(cperm.type.name == PermissionType.I_CHANNEL_NEEDED_MODIFY_POWER) {
required_power = cperm.value;
Implemented the Material Design and fixed some bugs (#33) * cleaned up some files * Fundamental style update * Redesigned some style * fixed hostbanner popup * Removed old identity stuff * fixed close listener * Fixed changelog date * fixed release chat icons * fixed url * Fixed hostbanner * Uploaded missing images * Improved update handling * Improved script files * Fixed loading error and icon error * fixed Yes/No modal * Fixed loader issues with MS Edge * fixed modal style bug * Fixed control bar overflow for small devices * Improved error handling on identity creation * Logging generate error to terminal * fixed possible php error * fixed some possible loading errors when other files have'nt been already loaded. * removed debug message * Changed emsrcypten flags * Improved codec error handling * removed webassembly as required dependency * Improved and fixed channel tree issues * Improved the sliders * Removed unneeded files * fixed loader versions cache * second slight performance improved (dont animate elements anymore if they are not shown) * Fixed query visibility setting * not showing useless client infos for query clients * Added an auto reconnect system * Added a canceled message and increased reconnect interval * removed implemented todo * fixed repetitive channel names * Reworked the channel tree selected lines * Fixed channel tree names * Fixed name alignment * fixed the native client * added min width to the server select groups to avoid a disappearing effect on shrink * fixed bugged downloaded icons
2019-02-17 16:08:10 +01:00
break;
2018-07-03 12:33:31 +02:00
}
tag.find("input[permission]").each((index, _element) => {
let element = $(_element);
let permission = permissions.resolveInfo(element.attr("permission"));
if(!permission) {
log.error(LogCategory.PERMISSIONS, tr("Failed to resolve channel permission for name %o"), element.attr("permission"));
2018-07-03 12:33:31 +02:00
element.prop("disabled", true);
return;
}
let old_value: number = 0;
element.on("click keyup", () => {
console.log(tr("Permission triggered! %o"), element.val() != old_value);
2018-07-03 12:33:31 +02:00
element.prop("changed", element.val() != old_value);
});
for(let cperm of channel_permissions)
if(cperm.type == permission) {
element.val(old_value = cperm.value);
return;
}
element.val(0);
});
if(!permissions.neededPermission(PermissionType.I_CHANNEL_MODIFY_POWER).granted(required_power, false)) {
Implemented the Material Design and fixed some bugs (#33) * cleaned up some files * Fundamental style update * Redesigned some style * fixed hostbanner popup * Removed old identity stuff * fixed close listener * Fixed changelog date * fixed release chat icons * fixed url * Fixed hostbanner * Uploaded missing images * Improved update handling * Improved script files * Fixed loading error and icon error * fixed Yes/No modal * Fixed loader issues with MS Edge * fixed modal style bug * Fixed control bar overflow for small devices * Improved error handling on identity creation * Logging generate error to terminal * fixed possible php error * fixed some possible loading errors when other files have'nt been already loaded. * removed debug message * Changed emsrcypten flags * Improved codec error handling * removed webassembly as required dependency * Improved and fixed channel tree issues * Improved the sliders * Removed unneeded files * fixed loader versions cache * second slight performance improved (dont animate elements anymore if they are not shown) * Fixed query visibility setting * not showing useless client infos for query clients * Added an auto reconnect system * Added a canceled message and increased reconnect interval * removed implemented todo * fixed repetitive channel names * Reworked the channel tree selected lines * Fixed channel tree names * Fixed name alignment * fixed the native client * added min width to the server select groups to avoid a disappearing effect on shrink * fixed bugged downloaded icons
2019-02-17 16:08:10 +01:00
tag.find("input[permission]").prop("disabled", false); //No permissions
2018-07-03 12:33:31 +02:00
}
};
if(channel) {
permissions.requestChannelPermissions(channel.getChannelId()).then(apply_permissions).catch((error) => {
Implemented the Material Design and fixed some bugs (#33) * cleaned up some files * Fundamental style update * Redesigned some style * fixed hostbanner popup * Removed old identity stuff * fixed close listener * Fixed changelog date * fixed release chat icons * fixed url * Fixed hostbanner * Uploaded missing images * Improved update handling * Improved script files * Fixed loading error and icon error * fixed Yes/No modal * Fixed loader issues with MS Edge * fixed modal style bug * Fixed control bar overflow for small devices * Improved error handling on identity creation * Logging generate error to terminal * fixed possible php error * fixed some possible loading errors when other files have'nt been already loaded. * removed debug message * Changed emsrcypten flags * Improved codec error handling * removed webassembly as required dependency * Improved and fixed channel tree issues * Improved the sliders * Removed unneeded files * fixed loader versions cache * second slight performance improved (dont animate elements anymore if they are not shown) * Fixed query visibility setting * not showing useless client infos for query clients * Added an auto reconnect system * Added a canceled message and increased reconnect interval * removed implemented todo * fixed repetitive channel names * Reworked the channel tree selected lines * Fixed channel tree names * Fixed name alignment * fixed the native client * added min width to the server select groups to avoid a disappearing effect on shrink * fixed bugged downloaded icons
2019-02-17 16:08:10 +01:00
tag.find("input[permission]").prop("disabled", true);
console.log("Failed to receive channel permissions (%o)", error);
2018-07-03 12:33:31 +02:00
});
} else apply_permissions([]);
}
2018-08-13 17:50:55 +02:00
2019-04-04 21:47:52 +02:00
function applyAudioListener(connection: ConnectionHandler, properties: ChannelProperties, tag: JQuery, button: JQuery, channel?: ChannelEntry) {
2018-08-13 17:50:55 +02:00
let update_template = () => {
let codec = properties.channel_codec;
if(!codec && channel)
codec = channel.properties.channel_codec;
if(!codec) return;
let quality = properties.channel_codec_quality;
if(!quality && channel)
quality = channel.properties.channel_codec_quality;
if(!quality) return;
if(codec == 4 && quality == 4)
tag.find("input[name=\"voice_template\"][value=\"voice_mobile\"]").prop("checked", true);
else if(codec == 4 && quality == 6)
tag.find("input[name=\"voice_template\"][value=\"voice_desktop\"]").prop("checked", true);
else if(codec == 5 && quality == 6)
tag.find("input[name=\"voice_template\"][value=\"music\"]").prop("checked", true);
else
tag.find("input[name=\"voice_template\"][value=\"custom\"]").prop("checked", true);
};
let change_codec = codec => {
if(properties.channel_codec == codec) return;
tag.find(".voice_codec option").prop("selected", false).eq(codec).prop("selected", true);
properties.channel_codec = codec;
update_template();
};
let quality_slider = tag.find(".voice_quality_slider");
let quality_number = tag.find(".voice_quality_number");
let change_quality = (quality: number) => {
if(properties.channel_codec_quality == quality) return;
properties.channel_codec_quality = quality;
if(quality_slider.val() != quality)
quality_slider.val(quality);
if(parseInt(quality_number.text()) != quality)
quality_number.text(quality);
update_template();
};
tag.find("input[name=\"voice_template\"]").change(function (this: HTMLInputElement) {
switch(this.value) {
case "custom":
break;
case "music":
change_codec(5);
change_quality(6);
break;
case "voice_desktop":
change_codec(4);
change_quality(6);
break;
case "voice_mobile":
change_codec(4);
change_quality(4);
break;
}
});
tag.find("input[name=\"voice_template\"][value=\"voice_mobile\"]")
2019-04-04 21:47:52 +02:00
.prop("disabled", !connection.permissions.neededPermission(PermissionType.B_CHANNEL_CREATE_MODIFY_WITH_CODEC_OPUSVOICE).granted(1));
2018-08-13 17:50:55 +02:00
tag.find("input[name=\"voice_template\"][value=\"voice_desktop\"]")
2019-04-04 21:47:52 +02:00
.prop("disabled", !connection.permissions.neededPermission(PermissionType.B_CHANNEL_CREATE_MODIFY_WITH_CODEC_OPUSVOICE).granted(1));
2018-08-13 17:50:55 +02:00
tag.find("input[name=\"voice_template\"][value=\"music\"]")
2019-04-04 21:47:52 +02:00
.prop("disabled", !connection.permissions.neededPermission(PermissionType.B_CHANNEL_CREATE_MODIFY_WITH_CODEC_OPUSMUSIC).granted(1));
2018-08-13 17:50:55 +02:00
let codecs = tag.find(".voice_codec option");
2019-04-04 21:47:52 +02:00
codecs.eq(0).prop("disabled", !connection.permissions.neededPermission(PermissionType.B_CHANNEL_CREATE_MODIFY_WITH_CODEC_SPEEX8).granted(1));
codecs.eq(1).prop("disabled", !connection.permissions.neededPermission(PermissionType.B_CHANNEL_CREATE_MODIFY_WITH_CODEC_SPEEX16).granted(1));
codecs.eq(2).prop("disabled", !connection.permissions.neededPermission(PermissionType.B_CHANNEL_CREATE_MODIFY_WITH_CODEC_SPEEX32).granted(1));
codecs.eq(3).prop("disabled", !connection.permissions.neededPermission(PermissionType.B_CHANNEL_CREATE_MODIFY_WITH_CODEC_CELTMONO48).granted(1));
codecs.eq(4).prop("disabled", !connection.permissions.neededPermission(PermissionType.B_CHANNEL_CREATE_MODIFY_WITH_CODEC_OPUSVOICE).granted(1));
codecs.eq(5).prop("disabled", !connection.permissions.neededPermission(PermissionType.B_CHANNEL_CREATE_MODIFY_WITH_CODEC_OPUSMUSIC).granted(1));
2018-08-13 17:50:55 +02:00
tag.find(".voice_codec").change(function (this: HTMLSelectElement) {
if($(this.item(this.selectedIndex)).prop("disabled")) return false;
change_codec(this.selectedIndex);
});
if(!channel) {
change_codec(4);
change_quality(6);
} else {
change_codec(channel.properties.channel_codec);
change_quality(channel.properties.channel_codec_quality);
}
update_template();
quality_slider.on('input', event => change_quality(parseInt(quality_slider.val() as string)));
}
2019-04-04 21:47:52 +02:00
function applyAdvancedListener(connection: ConnectionHandler, properties: ChannelProperties, tag: JQuery, button: JQuery, channel?: ChannelEntry) {
2018-08-13 17:50:55 +02:00
tag.find(".channel_name_phonetic").change(function (this: HTMLInputElement) {
properties.channel_topic = this.value;
});
tag.find(".channel_delete_delay").change(function (this: HTMLInputElement) {
properties.channel_delete_delay = parseInt(this.value);
2019-04-04 21:47:52 +02:00
}).prop("disabled", !connection.permissions.neededPermission(PermissionType.B_CHANNEL_MODIFY_TEMP_DELETE_DELAY).granted(1));
2018-08-13 17:50:55 +02:00
tag.find(".channel_codec_is_unencrypted").change(function (this: HTMLInputElement) {
properties.channel_codec_is_unencrypted = parseInt(this.value) == 0;
2019-04-04 21:47:52 +02:00
}).prop("disabled", !connection.permissions.neededPermission(PermissionType.B_CHANNEL_MODIFY_MAKE_CODEC_ENCRYPTED).granted(1));
2018-08-13 17:50:55 +02:00
{
let tag_infinity = tag.find("input[name=\"max_users\"][value=\"infinity\"]");
let tag_limited = tag.find("input[name=\"max_users\"][value=\"limited\"]");
let tag_limited_value = tag.find(".channel_maxclients");
2019-04-04 21:47:52 +02:00
if(!connection.permissions.neededPermission(!channel ? PermissionType.B_CHANNEL_CREATE_WITH_MAXCLIENTS : PermissionType.B_CHANNEL_MODIFY_MAXCLIENTS).granted(1)) {
2018-08-13 17:50:55 +02:00
tag_infinity.prop("disabled", true);
tag_limited.prop("disabled", true);
tag_limited_value.prop("disabled", true);
} else {
tag.find("input[name=\"max_users\"]").change(function (this: HTMLInputElement) {
console.log(this.value);
let infinity = this.value == "infinity";
tag_limited_value.prop("disabled", infinity);
properties.channel_flag_maxclients_unlimited = infinity;
});
tag_limited_value.change(event => properties.channel_maxclients = parseInt(tag_limited_value.val() as string));
tag.find("input[name=\"max_users\"]:checked").trigger('change');
}
}
{
let tag_inherited = tag.find("input[name=\"max_users_family\"][value=\"inherited\"]");
let tag_infinity = tag.find("input[name=\"max_users_family\"][value=\"infinity\"]");
let tag_limited = tag.find("input[name=\"max_users_family\"][value=\"limited\"]");
let tag_limited_value = tag.find(".channel_maxfamilyclients");
2019-04-04 21:47:52 +02:00
if(!connection.permissions.neededPermission(!channel ? PermissionType.B_CHANNEL_CREATE_WITH_MAXCLIENTS : PermissionType.B_CHANNEL_MODIFY_MAXCLIENTS).granted(1)) {
2018-08-13 17:50:55 +02:00
tag_inherited.prop("disabled", true);
tag_infinity.prop("disabled", true);
tag_limited.prop("disabled", true);
tag_limited_value.prop("disabled", true);
} else {
tag.find("input[name=\"max_users_family\"]").change(function (this: HTMLInputElement) {
console.log(this.value);
tag_limited_value.prop("disabled", this.value != "limited");
properties.channel_flag_maxfamilyclients_unlimited = this.value == "infinity";
properties.channel_flag_maxfamilyclients_inherited = this.value == "inherited";
});
tag_limited_value.change(event => properties.channel_maxfamilyclients = parseInt(tag_limited_value.val() as string));
tag.find("input[name=\"max_users_family\"]:checked").trigger('change');
}
}
}
2018-03-07 19:06:52 +01:00
}