-
+
+
+
+
-
-
-
+
+
+
+
+ {{if property_client_away}}
+
+ {{/if}}
+
{{if !property_client_output_hardware}}
+
+
+
+
+
+
+
-
+
-
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/js/client.ts b/js/client.ts
index c4cc837b..4ae1f27d 100644
--- a/js/client.ts
+++ b/js/client.ts
@@ -216,5 +216,6 @@ class TSClient {
this.channelTree.reset();
this.voiceConnection.dropSession();
if(this.serverConnection) this.serverConnection.disconnect();
+ this.controlBar.update_connection_state();
}
}
\ No newline at end of file
diff --git a/js/connection.ts b/js/connection.ts
index e4d39bfb..f56bfdbe 100644
--- a/js/connection.ts
+++ b/js/connection.ts
@@ -120,6 +120,7 @@ class ServerConnection {
updateConnectionState(state: ConnectionState) {
this._connectionState = state;
+ this._client.controlBar.update_connection_state();
}
disconnect() : boolean {
diff --git a/js/ui/frames/ControlBar.ts b/js/ui/frames/ControlBar.ts
index d9652acc..d7227121 100644
--- a/js/ui/frames/ControlBar.ts
+++ b/js/ui/frames/ControlBar.ts
@@ -31,11 +31,35 @@ class ControlBar {
initialise() {
this.htmlTag.find(".btn_connect").on('click', this.onConnect.bind(this));
- this.htmlTag.find(".btn_client_away").on('click', this.onAway.bind(this));
+ this.htmlTag.find(".btn_disconnect").on('click', this.onDisconnect.bind(this));
this.htmlTag.find(".btn_mute_input").on('click', this.onInputMute.bind(this));
this.htmlTag.find(".btn_mute_output").on('click', this.onOutputMute.bind(this));
this.htmlTag.find(".btn_open_settings").on('click', this.onOpenSettings.bind(this));
+ {
+ let tokens = this.htmlTag.find(".btn_token");
+ tokens.find(".button-dropdown").on('click', () => {
+ tokens.find(".dropdown").addClass("displayed");
+ });
+ tokens.on('mouseleave', () => {
+ tokens.find(".dropdown").removeClass("displayed");
+ });
+
+ tokens.find(".btn_token_use").on('click', this.on_token_use.bind(this));
+ tokens.find(".btn_token_list").on('click', this.on_token_list.bind(this));
+ }
+ {
+ let away = this.htmlTag.find(".btn_away");
+ away.find(".button-dropdown").on('click', () => {
+ away.find(".dropdown").addClass("displayed");
+ });
+ away.on('mouseleave', () => {
+ away.find(".dropdown").removeClass("displayed");
+ });
+
+ away.find(".btn_away_toggle").on('click', this.on_away_toggle.bind(this));
+ away.find(".btn_away_message").on('click', this.on_away_set_message.bind(this));
+ }
//Need an initialise
this.muteInput = settings.global("mute_input") == "1";
@@ -43,10 +67,18 @@ class ControlBar {
}
- onAway() {
+ on_away_toggle() {
+ this._awayMessage = "";
this.away = !this._away;
}
+ on_away_set_message() {
+ createInputModal("Set away message", "Please enter the away message", message => true, message => {
+ if(message)
+ this.away = message;
+ }).open();
+ }
+
onInputMute() {
this.muteInput = !this._muteInput;
}
@@ -114,13 +146,11 @@ class ControlBar {
this._away = true;
}
- let tag = this.htmlTag.find(".btn_client_away");
+ let tag = this.htmlTag.find(".btn_away_toggle");
if( this._away) {
- if(!tag.hasClass("activated"))
- tag.addClass("activated");
+ tag.addClass("activated");
} else {
- if(tag.hasClass("activated"))
- tag.removeClass("activated");
+ tag.removeClass("activated");
}
if(this.handle.serverConnection.connected)
@@ -180,4 +210,41 @@ class ControlBar {
private onConnect() {
Modals.spawnConnectModal(settings.static("connect_default_host", "ts.TeaSpeak.de"));
}
+
+ update_connection_state() {
+ switch (this.handle.serverConnection ? this.handle.serverConnection._connectionState : ConnectionState.UNCONNECTED) {
+ case ConnectionState.CONNECTED:
+ case ConnectionState.CONNECTING:
+ case ConnectionState.INITIALISING:
+ this.htmlTag.find(".btn_disconnect").show();
+ this.htmlTag.find(".btn_connect").hide();
+ break;
+ default:
+ this.htmlTag.find(".btn_disconnect").hide();
+ this.htmlTag.find(".btn_connect").show();
+ }
+ }
+
+ private onDisconnect() {
+ this.handle.handleDisconnect(DisconnectReason.REQUESTED); //TODO message?
+ this.update_connection_state();
+ }
+
+ private on_token_use() {
+ createInputModal("Use token", "Please enter your token/priviledge key", message => message.length > 0, result => {
+ if(!result) return;
+ if(this.handle.serverConnection.connected)
+ this.handle.serverConnection.sendCommand("tokenuse", {
+ token: result
+ }).then(() => {
+ createInfoModal("Use token", "Toke successfully used!").open();
+ }).catch(error => {
+ createErrorModal("Use token", "Failed to use token: " + (error instanceof CommandResult ? error.message : error)).open();
+ });
+ }).open();
+ }
+
+ private on_token_list() {
+ createErrorModal("Not implemented", "Token list is not implemented yet!").open();
+ }
}
\ No newline at end of file
diff --git a/js/ui/modal/ModalConnect.ts b/js/ui/modal/ModalConnect.ts
index 536759d5..0da566f4 100644
--- a/js/ui/modal/ModalConnect.ts
+++ b/js/ui/modal/ModalConnect.ts
@@ -19,10 +19,12 @@ namespace Modals {
let field_address = tag.find(".connect_address");
let address = field_address.val().toString();
+ settings.changeGlobal("connect_address", address);
let flag_address = !!address.match(Regex.IP_V4) || !!address.match(Regex.DOMAIN);
let field_nickname = tag.find(".connect_nickname");
let nickname = field_nickname.val().toString();
+ settings.changeGlobal("connect_name", nickname);
let flag_nickname = (nickname.length == 0 && connectIdentity && connectIdentity.name().length > 0) || nickname.length >= 3 && nickname.length <= 32;
if(flag_address) {
@@ -48,7 +50,8 @@ namespace Modals {
}
};
- tag.find(".connect_address").val(defaultHost);
+ tag.find(".connect_nickname").val(settings.static_global("connect_name", undefined));
+ tag.find(".connect_address").val(settings.static_global("connect_address", defaultHost));
tag.find(".connect_address").on("keyup", () => updateFields());
tag.find(".connect_nickname").on("keyup", () => updateFields());
diff --git a/js/utils/modal.ts b/js/utils/modal.ts
index ca1a7b09..bcea0e18 100644
--- a/js/utils/modal.ts
+++ b/js/utils/modal.ts
@@ -219,5 +219,19 @@ function createErrorModal(header: BodyCreator, message: BodyCreator, props: Moda
props.body = ModalFunctions.divify(ModalFunctions.jqueriefy(message));
props.footer = ModalFunctions.divify(ModalFunctions.jqueriefy(""));
+ return createModal(props);
+}
+
+function createInfoModal(header: BodyCreator, message: BodyCreator, props: ModalProperties | any = { footer: "" }) {
+ props = ModalFunctions.warpProperties(props);
+
+ let head = $.spawn("div");
+ head.addClass("modal-head-info");
+ ModalFunctions.divify(ModalFunctions.jqueriefy(header)).appendTo(head);
+ props.header = head;
+
+ props.body = ModalFunctions.divify(ModalFunctions.jqueriefy(message));
+ props.footer = ModalFunctions.divify(ModalFunctions.jqueriefy(""));
+
return createModal(props);
}
\ No newline at end of file
diff --git a/templates.html b/templates.html
index 7a255340..f78c2659 100644
--- a/templates.html
+++ b/templates.html
@@ -696,6 +696,18 @@
+
+
+
+