From 003dc96ce101cfc7c74f0ea4e41463a92982f9c4 Mon Sep 17 00:00:00 2001 From: encrypt Date: Sun, 22 Mar 2020 21:12:12 +0100 Subject: [PATCH 01/11] mumble tokens basic implementation, connection dialog token is replaced with tokens --- app/index.html | 17 +++++++++++++-- app/index.js | 35 +++++++++++++++++++++++++------ themes/MetroMumbleLight/main.scss | 2 +- 3 files changed, 45 insertions(+), 9 deletions(-) diff --git a/app/index.html b/app/index.html index c46f71f..0e87642 100644 --- a/app/index.html +++ b/app/index.html @@ -41,9 +41,22 @@ - Token - + Tokens + + + + + + + + + + + + + + Username diff --git a/app/index.js b/app/index.js index 754e661..1126eee 100644 --- a/app/index.js +++ b/app/index.js @@ -52,7 +52,9 @@ function ConnectDialog () { var self = this self.address = ko.observable('') self.port = ko.observable('') - self.token = ko.observable('') + self.tokenToAdd = ko.observable('') + self.selectedTokens = ko.observableArray([]) + self.tokens = ko.observableArray([]) self.username = ko.observable('') self.password = ko.observable('') self.channelName = ko.observable('') @@ -62,7 +64,25 @@ function ConnectDialog () { self.hide = self.visible.bind(self.visible, false) self.connect = function () { self.hide() - ui.connect(self.username(), self.address(), self.port(), self.token(), self.password(), self.channelName()) + ui.connect(self.username(), self.address(), self.port(), self.tokens(), self.password(), self.channelName()) + } + + self.addToken = function() { + if ((self.tokenToAdd() != "") && (self.tokens.indexOf(self.tokenToAdd()) < 0)) { + self.tokens.push(self.tokenToAdd()) + } + self.tokenToAdd("") + } + + self.removeSelectedTokensKey = function(data, event) { + if (event.keyCode == 46) { + sefl.removeSelectedTokens() + } + } + self.removeSelectedTokens = function() { + console.log("gogog") + this.tokens.removeAll(this.selectedTokens()) + this.selectedTokens([]) } } @@ -332,7 +352,7 @@ class GlobalBindings { return '[' + new Date().toLocaleTimeString('en-US') + ']' } - this.connect = (username, host, port, token, password, channelName = "") => { + this.connect = (username, host, port, tokens = [], password, channelName = "") => { this.resetClient() this.remoteHost(host) @@ -347,7 +367,8 @@ class GlobalBindings { // TODO: token this.connector.connect(`wss://${host}:${port}`, { username: username, - password: password + password: password, + tokens: tokens }).done(client => { log('Connected!') @@ -364,7 +385,9 @@ class GlobalBindings { // Register all channels, recursively const registerChannel = (channel, channelPath) => { this._newChannel(channel) + console.log(channelPath) if(channelPath === channelName) { + console.log(channel) client.self.setChannel(channel) } channel.children.forEach(ch => registerChannel(ch, channelPath+"/"+ch.name)) @@ -894,8 +917,8 @@ window.onload = function () { } else { useJoinDialog = false } - if (queryParams.token) { - ui.connectDialog.token(queryParams.token) + if (queryParams.tokens) { + ui.connectDialog.tokens(queryParams.tokens.split(",")) } if (queryParams.username) { ui.connectDialog.username(queryParams.username) diff --git a/themes/MetroMumbleLight/main.scss b/themes/MetroMumbleLight/main.scss index 0f5e0c1..411f944 100644 --- a/themes/MetroMumbleLight/main.scss +++ b/themes/MetroMumbleLight/main.scss @@ -444,7 +444,7 @@ form { top: calc(50% - 10px); left: calc(50% - 100px); } -.connect-dialog input[type=text] { +.connect-dialog input[type=text], select { font-size: 15px; border: 1px $dialog-input-border-color solid; border-radius: 3px; From f30f6db786efc06c0f3422240898d4afe0245cff Mon Sep 17 00:00:00 2001 From: encrypt Date: Thu, 26 Mar 2020 17:36:42 +0100 Subject: [PATCH 02/11] remove debug log and little fix --- app/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/index.js b/app/index.js index 1126eee..b2b229b 100644 --- a/app/index.js +++ b/app/index.js @@ -76,11 +76,10 @@ function ConnectDialog () { self.removeSelectedTokensKey = function(data, event) { if (event.keyCode == 46) { - sefl.removeSelectedTokens() + self.removeSelectedTokens() } } self.removeSelectedTokens = function() { - console.log("gogog") this.tokens.removeAll(this.selectedTokens()) this.selectedTokens([]) } From a3312ec8ff0aab7e5312c698373275b03b085155 Mon Sep 17 00:00:00 2001 From: encrypt Date: Thu, 26 Mar 2020 17:56:21 +0100 Subject: [PATCH 03/11] append / to the beginning of channelName if it is not present --- app/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/index.js b/app/index.js index b2b229b..27c2414 100644 --- a/app/index.js +++ b/app/index.js @@ -382,6 +382,10 @@ class GlobalBindings { window.matrixWidget.setAlwaysOnScreen(true) // Register all channels, recursively + + if(channelName.indexOf("/") != 0) { + channelName = "/"+channelName; + } const registerChannel = (channel, channelPath) => { this._newChannel(channel) console.log(channelPath) From c54cf56a7b4a1bdbb60a502bb010da4cb92011d0 Mon Sep 17 00:00:00 2001 From: encrypt Date: Thu, 26 Mar 2020 18:01:08 +0100 Subject: [PATCH 04/11] handle both tokens and token in query --- app/index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/index.js b/app/index.js index 27c2414..8754aac 100644 --- a/app/index.js +++ b/app/index.js @@ -923,6 +923,9 @@ window.onload = function () { if (queryParams.tokens) { ui.connectDialog.tokens(queryParams.tokens.split(",")) } + if (queryParams.token) { + ui.connectDialog.token(queryParams.token.split(",")) + } if (queryParams.username) { ui.connectDialog.username(queryParams.username) } else { From e721e66e24e0434736b678991dc7f77d40b11263 Mon Sep 17 00:00:00 2001 From: encrypt Date: Thu, 26 Mar 2020 18:20:48 +0100 Subject: [PATCH 05/11] remove attempt to bind deletetoken event to del key --- app/index.html | 2 +- app/index.js | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/app/index.html b/app/index.html index 0e87642..3b3eff1 100644 --- a/app/index.html +++ b/app/index.html @@ -55,7 +55,7 @@ - + Username diff --git a/app/index.js b/app/index.js index 8754aac..0538f19 100644 --- a/app/index.js +++ b/app/index.js @@ -74,11 +74,6 @@ function ConnectDialog () { self.tokenToAdd("") } - self.removeSelectedTokensKey = function(data, event) { - if (event.keyCode == 46) { - self.removeSelectedTokens() - } - } self.removeSelectedTokens = function() { this.tokens.removeAll(this.selectedTokens()) this.selectedTokens([]) From 13150527562445d1e3a050f1309dd60672693de2 Mon Sep 17 00:00:00 2001 From: encrypt Date: Thu, 26 Mar 2020 18:28:14 +0100 Subject: [PATCH 06/11] s/token/tokens/ in query --- app/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/index.js b/app/index.js index 0538f19..5c9496f 100644 --- a/app/index.js +++ b/app/index.js @@ -919,7 +919,7 @@ window.onload = function () { ui.connectDialog.tokens(queryParams.tokens.split(",")) } if (queryParams.token) { - ui.connectDialog.token(queryParams.token.split(",")) + ui.connectDialog.tokens(queryParams.token.split(",")) } if (queryParams.username) { ui.connectDialog.username(queryParams.username) From 5b0e62ef3c34d8ff8935b6b7801172b9cd335f09 Mon Sep 17 00:00:00 2001 From: encrypt Date: Thu, 26 Mar 2020 21:45:33 +0100 Subject: [PATCH 07/11] fix indentation and remove debug log --- app/index.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/index.js b/app/index.js index 5c9496f..132f7da 100644 --- a/app/index.js +++ b/app/index.js @@ -362,7 +362,7 @@ class GlobalBindings { this.connector.connect(`wss://${host}:${port}`, { username: username, password: password, - tokens: tokens + tokens: tokens }).done(client => { log('Connected!') @@ -378,12 +378,11 @@ class GlobalBindings { // Register all channels, recursively - if(channelName.indexOf("/") != 0) { - channelName = "/"+channelName; - } + if(channelName.indexOf("/") != 0) { + channelName = "/"+channelName; + } const registerChannel = (channel, channelPath) => { this._newChannel(channel) - console.log(channelPath) if(channelPath === channelName) { console.log(channel) client.self.setChannel(channel) From da7a811dc937430490877333cc88905512e64068 Mon Sep 17 00:00:00 2001 From: encrypt Date: Thu, 26 Mar 2020 22:00:21 +0100 Subject: [PATCH 08/11] hide token list if there are no tokens --- app/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/index.html b/app/index.html index 3b3eff1..f6b2420 100644 --- a/app/index.html +++ b/app/index.html @@ -53,7 +53,7 @@ - + From 90b1222473a947a862d033d57a4254abfd512ff3 Mon Sep 17 00:00:00 2001 From: encrypt Date: Thu, 26 Mar 2020 22:04:11 +0100 Subject: [PATCH 09/11] move user and pass before token --- app/index.html | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/app/index.html b/app/index.html index f6b2420..ae47f65 100644 --- a/app/index.html +++ b/app/index.html @@ -40,6 +40,14 @@ Port + + Username + + + + Password + + Tokens @@ -48,22 +56,14 @@ - + - + - - - - - - Username - - - - Password - + + + Channel From ff89f541f7e36ff4d7f4986cc5123715ef2f930d Mon Sep 17 00:00:00 2001 From: encrypt Date: Thu, 26 Mar 2020 22:07:14 +0100 Subject: [PATCH 10/11] remove debug log --- app/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/app/index.js b/app/index.js index 132f7da..92e64e9 100644 --- a/app/index.js +++ b/app/index.js @@ -384,7 +384,6 @@ class GlobalBindings { const registerChannel = (channel, channelPath) => { this._newChannel(channel) if(channelPath === channelName) { - console.log(channel) client.self.setChannel(channel) } channel.children.forEach(ch => registerChannel(ch, channelPath+"/"+ch.name)) From bf134819f996f84a8f2ec837fd33bca4c9bda03f Mon Sep 17 00:00:00 2001 From: encrypt Date: Thu, 26 Mar 2020 22:36:13 +0100 Subject: [PATCH 11/11] splitting tokens replaced by native parsing of urllib --- app/index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/index.js b/app/index.js index 92e64e9..15737e9 100644 --- a/app/index.js +++ b/app/index.js @@ -376,8 +376,7 @@ class GlobalBindings { // Make sure we stay open if we're running as Matrix widget window.matrixWidget.setAlwaysOnScreen(true) - // Register all channels, recursively - + // Register all channels, recursively if(channelName.indexOf("/") != 0) { channelName = "/"+channelName; } @@ -913,11 +912,12 @@ window.onload = function () { } else { useJoinDialog = false } - if (queryParams.tokens) { - ui.connectDialog.tokens(queryParams.tokens.split(",")) - } if (queryParams.token) { - ui.connectDialog.tokens(queryParams.token.split(",")) + var tokens = queryParams.token + if (!Array.isArray(tokens)) { + tokens = [tokens] + } + ui.connectDialog.tokens(tokens) } if (queryParams.username) { ui.connectDialog.username(queryParams.username)