fixed repetitive channel names

This commit is contained in:
WolverinDEV 2019-02-17 13:29:51 +01:00
parent b640adaef3
commit 7b5eecbc2d
3 changed files with 30 additions and 13 deletions

View file

@ -98,6 +98,9 @@
justify-content: left; justify-content: left;
max-width: 100%; /* important for the repetitive channel name! */
overflow: hidden;
&.align-right { &.align-right {
justify-content: right; justify-content: right;
} }

View file

@ -562,26 +562,38 @@ class ChannelEntry {
if(this._channel_name_formatted !== undefined) { if(this._channel_name_formatted !== undefined) {
tag_container_name.addClass(this._channel_name_alignment); tag_container_name.addClass(this._channel_name_alignment);
if(this._channel_name_alignment == "*") { if(this._channel_name_alignment == "align-repetitive") {
let lastSuccess = ""; if(tag_name.parent().width() != 0) {
let index = 6; let lastSuccess = "";
let index = 6;
let name = this.formattedChannelName(); let name = this._channel_name_formatted;
while(index-- > 0) if(name.length < 1) throw "invalid name!";
name = name + name;
tag_name.text(name); while(index-- > 0)
do { name = name + name;
tag_name.text(name = name + name); tag_name.text(name);
} while (tag_name.parent().width() >= tag_name.width() && ++index < 64); do {
if(index == 64) console.warn(LogCategory.CHANNEL, tr("Repeating spacer took too much repeats!")); tag_name.text(name = name + name);
if(lastSuccess.length > 0) { if(name.length > 1024 * 8)
tag_name.text(lastSuccess); index = 63;
} while (tag_name.parent().width() >= tag_name.width() && ++index < 64);
if(index == 64)
console.warn(LogCategory.CHANNEL, tr("Repeating spacer took too much repeats!"));
if(lastSuccess.length > 0) {
tag_name.text(lastSuccess);
}
} }
} }
} }
console.log(tr("Align: %s"), this._channel_name_alignment); console.log(tr("Align: %s"), this._channel_name_alignment);
} }
recalculate_repetitive_name() {
if(this._channel_name_alignment == "align-repetitive")
this.__updateChannelName();
}
updateVariables(...variables: {key: string, value: string}[]) { updateVariables(...variables: {key: string, value: string}[]) {
let group = log.group(log.LogType.DEBUG, LogCategory.CHANNEL_PROPERTIES, tr("Update properties (%i) of %s (%i)"), variables.length, this.channelName(), this.getChannelId()); let group = log.group(log.LogType.DEBUG, LogCategory.CHANNEL_PROPERTIES, tr("Update properties (%i) of %s (%i)"), variables.length, this.channelName(), this.getChannelId());

View file

@ -75,6 +75,8 @@ class ChannelTree {
show_channel_tree() { show_channel_tree() {
this._tree_detached = false; this._tree_detached = false;
this.htmlTree.appendTo(this.htmlTree_parent); this.htmlTree.appendTo(this.htmlTree_parent);
this.channels.forEach(e => e.recalculate_repetitive_name());
} }
showContextMenu(x: number, y: number, on_close: () => void = undefined) { showContextMenu(x: number, y: number, on_close: () => void = undefined) {