Added channel description bbcode
parent
7d5f8b068a
commit
c6e1e28713
|
@ -8,3 +8,6 @@
|
|||
[submodule "asm/libraries/tommath"]
|
||||
path = asm/libraries/tommath
|
||||
url = http://git.mcgalaxy.de:8090/WolverinDEV/tommath.git
|
||||
[submodule "vendor/bbcode"]
|
||||
path = vendor/bbcode
|
||||
url = https://github.com/WolverinDEV/Extendible-BBCode-Parser.git
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
<link rel="stylesheet" href="css/loader.css" type="text/css">
|
||||
<link rel="stylesheet" href="css/music/info_plate.css" type="text/css">
|
||||
<link rel="stylesheet" href="css/frame/SelectInfo.css" type="text/css">
|
||||
<link rel="stylesheet" href="vendor/bbcode/xbbcode.css" type="text/css">
|
||||
|
||||
<!-- https://localhost:9987/?forward_url=http%3A%2F%2Flocalhost%3A63344%2FWeb-Client%2Findex.php%3F_ijt%3D82b1uhmnh0a5l1n35nnjps5eid%26loader_ignore_age%3D1%26connect_default_host%3Dlocalhost%26default_connect_type%3Dforum%26default_connect_url%3Dtrue%26default_connect_type%3Dteamspeak%26default_connect_url%3Dlocalhost%253A9987 -->
|
||||
<!-- PHP generated properies -->
|
||||
|
|
|
@ -20,7 +20,6 @@ class ChannelProperties {
|
|||
channel_topic: string = "";
|
||||
|
||||
channel_password: string = "";
|
||||
channel_description: string = "";
|
||||
|
||||
channel_codec: number = 4;
|
||||
channel_codec_quality: number = 0;
|
||||
|
@ -60,6 +59,10 @@ class ChannelEntry {
|
|||
private _tag_channel: JQuery<HTMLElement>;
|
||||
|
||||
private _cachedPassword: string;
|
||||
private _cached_channel_description: string = undefined;
|
||||
private _cached_channel_description_promise: Promise<string> = undefined;
|
||||
private _cached_channel_description_promise_resolve: any = undefined;
|
||||
private _cached_channel_description_promise_reject: any = undefined;
|
||||
|
||||
constructor(channelId, channelName, parent = null, prevChannel = null) {
|
||||
this.properties = new ChannelProperties();
|
||||
|
@ -81,6 +84,20 @@ class ChannelEntry {
|
|||
return this._formatedChannelName ? this._formatedChannelName : this.properties.channel_name;
|
||||
}
|
||||
|
||||
getChannelDescription() : Promise<string> {
|
||||
if(this._cached_channel_description) return new Promise<string>(resolve => resolve(this._cached_channel_description));
|
||||
if(this._cached_channel_description_promise) return this._cached_channel_description_promise;
|
||||
|
||||
this.channelTree.client.serverConnection.sendCommand("channelgetdescription", {cid: this.channelId}).catch(error => {
|
||||
this._cached_channel_description_promise_reject(error);
|
||||
});
|
||||
|
||||
return this._cached_channel_description_promise = new Promise<string>((resolve, reject) => {
|
||||
this._cached_channel_description_promise_resolve = resolve;
|
||||
this._cached_channel_description_promise_reject = reject;
|
||||
});
|
||||
}
|
||||
|
||||
parentChannel() { return this.parent; }
|
||||
hasParent(){ return this.parent != null; }
|
||||
getChannelId(){ return this.channelId; }
|
||||
|
@ -461,6 +478,14 @@ class ChannelEntry {
|
|||
(this.properties.channel_flag_password ? $.fn.show : $.fn.hide).apply(this.channelTag().find(".icons .icon_password"));
|
||||
else if(key == "channel_needed_talk_power")
|
||||
(this.properties.channel_needed_talk_power > 0 ? $.fn.show : $.fn.hide).apply(this.channelTag().find(".icons .icon_moderated"));
|
||||
else if(key == "channel_description") {
|
||||
this._cached_channel_description = undefined;
|
||||
if(this._cached_channel_description_promise_resolve)
|
||||
this._cached_channel_description_promise_resolve(value);
|
||||
this._cached_channel_description_promise = undefined;
|
||||
this._cached_channel_description_promise_resolve = undefined;
|
||||
this._cached_channel_description_promise_reject = undefined;
|
||||
}
|
||||
if(key == "channel_maxclients" || key == "channel_maxfamilyclients" || key == "channel_flag_private" || key == "channel_flag_password")
|
||||
this.updateChannelTypeIcon();
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/// <reference path="../../client.ts" />
|
||||
/// <reference path="../../../vendor/bbcode/xbbcode.ts" />
|
||||
|
||||
abstract class InfoManagerBase {
|
||||
private timers: NodeJS.Timer[] = [];
|
||||
|
@ -244,6 +245,22 @@ class ChannelInfoManager extends InfoManager<ChannelEntry> {
|
|||
for(let key in channel.properties)
|
||||
properties["property_" + key] = channel.properties[key];
|
||||
|
||||
let tag_channel_description = $.spawn("div");
|
||||
properties["bbcode_channel_description"] = tag_channel_description;
|
||||
|
||||
channel.getChannelDescription().then(description => {
|
||||
let result = XBBCODE.process({
|
||||
text: description,
|
||||
escapeHtml: true,
|
||||
addInLineBreaks: true
|
||||
});
|
||||
if(result.error) {
|
||||
console.log("BBCode parse error: %o", result.errorQueue);
|
||||
}
|
||||
|
||||
tag_channel_description.html(result.html);
|
||||
});
|
||||
|
||||
let rendered = $("#tmpl_selected_channel").renderTag([properties]);
|
||||
rendered.find("node").each((index, element) => { $(element).replaceWith(properties[$(element).attr("key")]); });
|
||||
html_tag.append(rendered);
|
||||
|
|
|
@ -701,11 +701,9 @@
|
|||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
{{if property_channel_description }}
|
||||
<div>
|
||||
<node key="bbcode_channel_description"></node>
|
||||
</div>
|
||||
{{/if}}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue