From 658327565ba0a6d997c719838a0bc800d90d8dc8 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Tue, 25 Sep 2018 17:39:38 +0200 Subject: [PATCH] A lots of updates --- ChangeLog.md | 3 + README.md | 7 +- css/frame/SelectInfo.css | 20 +- css/frame/SelectInfo.scss | 18 ++ index.php | 1 + js/client.ts | 2 + js/connection.ts | 3 +- js/crypto/sha.ts | 393 ++++++++++++++++++++++++++++++- js/log.ts | 2 +- js/main.ts | 11 +- js/ui/frames/SelectedItemInfo.ts | 39 ++- js/ui/modal/ModalConnect.ts | 7 +- js/voice/AudioController.ts | 5 + js/voice/VoiceHandler.ts | 28 ++- templates.html | 84 ++++--- 15 files changed, 546 insertions(+), 77 deletions(-) create mode 100644 css/frame/SelectInfo.scss diff --git a/ChangeLog.md b/ChangeLog.md index 2be01c69..4497797e 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -4,6 +4,9 @@ - Added support for away messages * Fixed away display within information bar - Capturing last given address and nickname within connect modal + * Using random password field ids for server connect modal + + Improved forum not authenticated message within connect modal + - Added partitional MS Edge support * **24.09.18**: - Added server passwords within login modal diff --git a/README.md b/README.md index 8b71569c..89e413ff 100644 --- a/README.md +++ b/README.md @@ -11,4 +11,9 @@ Welcome here! This repository is created with two reasons: To **report an issue**, then find and push the **New Issue** button, fill all the fields you see in a template, and then click the **Submit new issue** button. -You can also ask questions here, if you have any. \ No newline at end of file +You can also ask questions here, if you have any. + +#Browser support: +MS Edge: + - Partitional + - No voice support (missing data channel support) \ No newline at end of file diff --git a/css/frame/SelectInfo.css b/css/frame/SelectInfo.css index a38c4a2f..593e5440 100644 --- a/css/frame/SelectInfo.css +++ b/css/frame/SelectInfo.css @@ -1,10 +1,12 @@ -.select_info_table { } -.select_info_table tr { } -.select_info_table tr td { -} - .select_info_table tr td:nth-child(1) { - font-weight: bold; - padding-right: 5px; - min-width: 20%; -} + font-weight: bold; + padding-right: 5px; + min-width: 20%; } + +.select_server { + display: inline-flex; + justify-content: space-between; } + .select_server .button-update { + width: 100%; } + +/*# sourceMappingURL=SelectInfo.css.map */ diff --git a/css/frame/SelectInfo.scss b/css/frame/SelectInfo.scss new file mode 100644 index 00000000..8797453e --- /dev/null +++ b/css/frame/SelectInfo.scss @@ -0,0 +1,18 @@ +.select_info_table { } +.select_info_table tr { } +.select_info_table tr td { } + +.select_info_table tr td:nth-child(1) { + font-weight: bold; + padding-right: 5px; + min-width: 20%; +} + +.select_server { + display: inline-flex; + justify-content: space-between; + + .button-update { + width: 100%; + } +} \ No newline at end of file diff --git a/index.php b/index.php index cd2863d3..1bf98999 100644 --- a/index.php +++ b/index.php @@ -59,6 +59,7 @@ spawnProperty('localhost_debug', $localhost ? "true" : "false"); spawnProperty('forum_user_data', $_COOKIE[$GLOBALS["COOKIE_NAME_USER_DATA"]]); spawnProperty('forum_user_sign', $_COOKIE[$GLOBALS["COOKIE_NAME_USER_SIGN"]]); + spawnProperty('forum_path', authPath()); ?> diff --git a/js/client.ts b/js/client.ts index 4ae1f27d..55abf53d 100644 --- a/js/client.ts +++ b/js/client.ts @@ -132,6 +132,8 @@ class TSClient { if(this.groups.serverGroups.length == 0) this.groups.requestGroups(); this.controlBar.updateProperties(); + if(!this.voiceConnection.current_encoding_supported()) + createErrorModal("Codec encode type not supported!", "Codec encode type " + VoiceConnectionType[this.voiceConnection.type] + " not supported by this browser!
Choose another one!").open(); } get connected() : boolean { diff --git a/js/connection.ts b/js/connection.ts index f56bfdbe..e8b4b6c7 100644 --- a/js/connection.ts +++ b/js/connection.ts @@ -77,11 +77,12 @@ class ServerConnection { const self = this; try { this._connectTimeoutHandler = setTimeout(() => { + console.log("Connect timeout triggered!"); this.disconnect(); this._client.handleDisconnect(DisconnectReason.CONNECT_FAILURE); }, timeout); let sockCpy; - this._socket = (sockCpy = new WebSocket('wss:' + address.host + ":" + address.port)); + this._socket = (sockCpy = new WebSocket('wss://' + address.host + ":" + address.port)); clearTimeout(this._connectTimeoutHandler); this._connectTimeoutHandler = null; if(this._socket != sockCpy) return; //Connect timeouted diff --git a/js/crypto/sha.ts b/js/crypto/sha.ts index 761b216e..a375f0aa 100644 --- a/js/crypto/sha.ts +++ b/js/crypto/sha.ts @@ -6,9 +6,398 @@ declare class TextEncoder { } */ namespace sha { + /* + * [js-sha1]{@link https://github.com/emn178/js-sha1} + * + * @version 0.6.0 + * @author Chen, Yi-Cyuan [emn178@gmail.com] + * @copyright Chen, Yi-Cyuan 2014-2017 + * @license MIT + */ + /*jslint bitwise: true */ + (function() { + 'use strict'; + + var root = typeof window === 'object' ? window : {}; + var NODE_JS = !root.JS_SHA1_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node; + if (NODE_JS) { + root = global; + } + var COMMON_JS = !root.JS_SHA1_NO_COMMON_JS && typeof module === 'object' && module.exports; + var AMD = typeof define === 'function' && define.amd; + var HEX_CHARS = '0123456789abcdef'.split(''); + var EXTRA = [-2147483648, 8388608, 32768, 128]; + var SHIFT = [24, 16, 8, 0]; + var OUTPUT_TYPES = ['hex', 'array', 'digest', 'arrayBuffer']; + + var blocks = []; + + var createOutputMethod = function (outputType) { + return function (message) { + return new Sha1(true).update(message)[outputType](); + }; + }; + + var createMethod = function () { + var method = createOutputMethod('hex'); + if (NODE_JS) { + method = nodeWrap(method); + } + method.create = function () { + return new Sha1(); + }; + method.update = function (message) { + return method.create().update(message); + }; + for (var i = 0; i < OUTPUT_TYPES.length; ++i) { + var type = OUTPUT_TYPES[i]; + method[type] = createOutputMethod(type); + } + return method; + }; + + var nodeWrap = function (method) { + var crypto = eval("require('crypto')"); + var Buffer = eval("require('buffer').Buffer"); + var nodeMethod = function (message) { + if (typeof message === 'string') { + return crypto.createHash('sha1').update(message, 'utf8').digest('hex'); + } else if (message.constructor === ArrayBuffer) { + message = new Uint8Array(message); + } else if (message.length === undefined) { + return method(message); + } + return crypto.createHash('sha1').update(new Buffer(message)).digest('hex'); + }; + return nodeMethod; + }; + + function Sha1(sharedMemory) { + if (sharedMemory) { + blocks[0] = blocks[16] = blocks[1] = blocks[2] = blocks[3] = + blocks[4] = blocks[5] = blocks[6] = blocks[7] = + blocks[8] = blocks[9] = blocks[10] = blocks[11] = + blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0; + this.blocks = blocks; + } else { + this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; + } + + this.h0 = 0x67452301; + this.h1 = 0xEFCDAB89; + this.h2 = 0x98BADCFE; + this.h3 = 0x10325476; + this.h4 = 0xC3D2E1F0; + + this.block = this.start = this.bytes = this.hBytes = 0; + this.finalized = this.hashed = false; + this.first = true; + } + + Sha1.prototype.update = function (message) { + if (this.finalized) { + return; + } + var notString = typeof(message) !== 'string'; + if (notString && message.constructor === root.ArrayBuffer) { + message = new Uint8Array(message); + } + var code, index = 0, i, length = message.length || 0, blocks = this.blocks; + + while (index < length) { + if (this.hashed) { + this.hashed = false; + blocks[0] = this.block; + blocks[16] = blocks[1] = blocks[2] = blocks[3] = + blocks[4] = blocks[5] = blocks[6] = blocks[7] = + blocks[8] = blocks[9] = blocks[10] = blocks[11] = + blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0; + } + + if(notString) { + for (i = this.start; index < length && i < 64; ++index) { + blocks[i >> 2] |= message[index] << SHIFT[i++ & 3]; + } + } else { + for (i = this.start; index < length && i < 64; ++index) { + code = message.charCodeAt(index); + if (code < 0x80) { + blocks[i >> 2] |= code << SHIFT[i++ & 3]; + } else if (code < 0x800) { + blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } else if (code < 0xd800 || code >= 0xe000) { + blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } else { + code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); + blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } + } + } + + this.lastByteIndex = i; + this.bytes += i - this.start; + if (i >= 64) { + this.block = blocks[16]; + this.start = i - 64; + this.hash(); + this.hashed = true; + } else { + this.start = i; + } + } + if (this.bytes > 4294967295) { + this.hBytes += this.bytes / 4294967296 << 0; + this.bytes = this.bytes % 4294967296; + } + return this; + }; + + Sha1.prototype.finalize = function () { + if (this.finalized) { + return; + } + this.finalized = true; + var blocks = this.blocks, i = this.lastByteIndex; + blocks[16] = this.block; + blocks[i >> 2] |= EXTRA[i & 3]; + this.block = blocks[16]; + if (i >= 56) { + if (!this.hashed) { + this.hash(); + } + blocks[0] = this.block; + blocks[16] = blocks[1] = blocks[2] = blocks[3] = + blocks[4] = blocks[5] = blocks[6] = blocks[7] = + blocks[8] = blocks[9] = blocks[10] = blocks[11] = + blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0; + } + blocks[14] = this.hBytes << 3 | this.bytes >>> 29; + blocks[15] = this.bytes << 3; + this.hash(); + }; + + Sha1.prototype.hash = function () { + var a = this.h0, b = this.h1, c = this.h2, d = this.h3, e = this.h4; + var f, j, t, blocks = this.blocks; + + for(j = 16; j < 80; ++j) { + t = blocks[j - 3] ^ blocks[j - 8] ^ blocks[j - 14] ^ blocks[j - 16]; + blocks[j] = (t << 1) | (t >>> 31); + } + + for(j = 0; j < 20; j += 5) { + f = (b & c) | ((~b) & d); + t = (a << 5) | (a >>> 27); + e = t + f + e + 1518500249 + blocks[j] << 0; + b = (b << 30) | (b >>> 2); + + f = (a & b) | ((~a) & c); + t = (e << 5) | (e >>> 27); + d = t + f + d + 1518500249 + blocks[j + 1] << 0; + a = (a << 30) | (a >>> 2); + + f = (e & a) | ((~e) & b); + t = (d << 5) | (d >>> 27); + c = t + f + c + 1518500249 + blocks[j + 2] << 0; + e = (e << 30) | (e >>> 2); + + f = (d & e) | ((~d) & a); + t = (c << 5) | (c >>> 27); + b = t + f + b + 1518500249 + blocks[j + 3] << 0; + d = (d << 30) | (d >>> 2); + + f = (c & d) | ((~c) & e); + t = (b << 5) | (b >>> 27); + a = t + f + a + 1518500249 + blocks[j + 4] << 0; + c = (c << 30) | (c >>> 2); + } + + for(; j < 40; j += 5) { + f = b ^ c ^ d; + t = (a << 5) | (a >>> 27); + e = t + f + e + 1859775393 + blocks[j] << 0; + b = (b << 30) | (b >>> 2); + + f = a ^ b ^ c; + t = (e << 5) | (e >>> 27); + d = t + f + d + 1859775393 + blocks[j + 1] << 0; + a = (a << 30) | (a >>> 2); + + f = e ^ a ^ b; + t = (d << 5) | (d >>> 27); + c = t + f + c + 1859775393 + blocks[j + 2] << 0; + e = (e << 30) | (e >>> 2); + + f = d ^ e ^ a; + t = (c << 5) | (c >>> 27); + b = t + f + b + 1859775393 + blocks[j + 3] << 0; + d = (d << 30) | (d >>> 2); + + f = c ^ d ^ e; + t = (b << 5) | (b >>> 27); + a = t + f + a + 1859775393 + blocks[j + 4] << 0; + c = (c << 30) | (c >>> 2); + } + + for(; j < 60; j += 5) { + f = (b & c) | (b & d) | (c & d); + t = (a << 5) | (a >>> 27); + e = t + f + e - 1894007588 + blocks[j] << 0; + b = (b << 30) | (b >>> 2); + + f = (a & b) | (a & c) | (b & c); + t = (e << 5) | (e >>> 27); + d = t + f + d - 1894007588 + blocks[j + 1] << 0; + a = (a << 30) | (a >>> 2); + + f = (e & a) | (e & b) | (a & b); + t = (d << 5) | (d >>> 27); + c = t + f + c - 1894007588 + blocks[j + 2] << 0; + e = (e << 30) | (e >>> 2); + + f = (d & e) | (d & a) | (e & a); + t = (c << 5) | (c >>> 27); + b = t + f + b - 1894007588 + blocks[j + 3] << 0; + d = (d << 30) | (d >>> 2); + + f = (c & d) | (c & e) | (d & e); + t = (b << 5) | (b >>> 27); + a = t + f + a - 1894007588 + blocks[j + 4] << 0; + c = (c << 30) | (c >>> 2); + } + + for(; j < 80; j += 5) { + f = b ^ c ^ d; + t = (a << 5) | (a >>> 27); + e = t + f + e - 899497514 + blocks[j] << 0; + b = (b << 30) | (b >>> 2); + + f = a ^ b ^ c; + t = (e << 5) | (e >>> 27); + d = t + f + d - 899497514 + blocks[j + 1] << 0; + a = (a << 30) | (a >>> 2); + + f = e ^ a ^ b; + t = (d << 5) | (d >>> 27); + c = t + f + c - 899497514 + blocks[j + 2] << 0; + e = (e << 30) | (e >>> 2); + + f = d ^ e ^ a; + t = (c << 5) | (c >>> 27); + b = t + f + b - 899497514 + blocks[j + 3] << 0; + d = (d << 30) | (d >>> 2); + + f = c ^ d ^ e; + t = (b << 5) | (b >>> 27); + a = t + f + a - 899497514 + blocks[j + 4] << 0; + c = (c << 30) | (c >>> 2); + } + + this.h0 = this.h0 + a << 0; + this.h1 = this.h1 + b << 0; + this.h2 = this.h2 + c << 0; + this.h3 = this.h3 + d << 0; + this.h4 = this.h4 + e << 0; + }; + + Sha1.prototype.hex = function () { + this.finalize(); + + var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4; + + return HEX_CHARS[(h0 >> 28) & 0x0F] + HEX_CHARS[(h0 >> 24) & 0x0F] + + HEX_CHARS[(h0 >> 20) & 0x0F] + HEX_CHARS[(h0 >> 16) & 0x0F] + + HEX_CHARS[(h0 >> 12) & 0x0F] + HEX_CHARS[(h0 >> 8) & 0x0F] + + HEX_CHARS[(h0 >> 4) & 0x0F] + HEX_CHARS[h0 & 0x0F] + + HEX_CHARS[(h1 >> 28) & 0x0F] + HEX_CHARS[(h1 >> 24) & 0x0F] + + HEX_CHARS[(h1 >> 20) & 0x0F] + HEX_CHARS[(h1 >> 16) & 0x0F] + + HEX_CHARS[(h1 >> 12) & 0x0F] + HEX_CHARS[(h1 >> 8) & 0x0F] + + HEX_CHARS[(h1 >> 4) & 0x0F] + HEX_CHARS[h1 & 0x0F] + + HEX_CHARS[(h2 >> 28) & 0x0F] + HEX_CHARS[(h2 >> 24) & 0x0F] + + HEX_CHARS[(h2 >> 20) & 0x0F] + HEX_CHARS[(h2 >> 16) & 0x0F] + + HEX_CHARS[(h2 >> 12) & 0x0F] + HEX_CHARS[(h2 >> 8) & 0x0F] + + HEX_CHARS[(h2 >> 4) & 0x0F] + HEX_CHARS[h2 & 0x0F] + + HEX_CHARS[(h3 >> 28) & 0x0F] + HEX_CHARS[(h3 >> 24) & 0x0F] + + HEX_CHARS[(h3 >> 20) & 0x0F] + HEX_CHARS[(h3 >> 16) & 0x0F] + + HEX_CHARS[(h3 >> 12) & 0x0F] + HEX_CHARS[(h3 >> 8) & 0x0F] + + HEX_CHARS[(h3 >> 4) & 0x0F] + HEX_CHARS[h3 & 0x0F] + + HEX_CHARS[(h4 >> 28) & 0x0F] + HEX_CHARS[(h4 >> 24) & 0x0F] + + HEX_CHARS[(h4 >> 20) & 0x0F] + HEX_CHARS[(h4 >> 16) & 0x0F] + + HEX_CHARS[(h4 >> 12) & 0x0F] + HEX_CHARS[(h4 >> 8) & 0x0F] + + HEX_CHARS[(h4 >> 4) & 0x0F] + HEX_CHARS[h4 & 0x0F]; + }; + + Sha1.prototype.toString = Sha1.prototype.hex; + + Sha1.prototype.digest = function () { + this.finalize(); + + var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4; + + return [ + (h0 >> 24) & 0xFF, (h0 >> 16) & 0xFF, (h0 >> 8) & 0xFF, h0 & 0xFF, + (h1 >> 24) & 0xFF, (h1 >> 16) & 0xFF, (h1 >> 8) & 0xFF, h1 & 0xFF, + (h2 >> 24) & 0xFF, (h2 >> 16) & 0xFF, (h2 >> 8) & 0xFF, h2 & 0xFF, + (h3 >> 24) & 0xFF, (h3 >> 16) & 0xFF, (h3 >> 8) & 0xFF, h3 & 0xFF, + (h4 >> 24) & 0xFF, (h4 >> 16) & 0xFF, (h4 >> 8) & 0xFF, h4 & 0xFF + ]; + }; + + Sha1.prototype.array = Sha1.prototype.digest; + + Sha1.prototype.arrayBuffer = function () { + this.finalize(); + + var buffer = new ArrayBuffer(20); + var dataView = new DataView(buffer); + dataView.setUint32(0, this.h0); + dataView.setUint32(4, this.h1); + dataView.setUint32(8, this.h2); + dataView.setUint32(12, this.h3); + dataView.setUint32(16, this.h4); + return buffer; + }; + + var exports = createMethod(); + + if (COMMON_JS) { + module.exports = exports; + } else { + root._sha1 = exports; + if (AMD) { + define(function () { + return exports; + }); + } + } + })(); + + export function encode_text(buffer: string) { + if (window.TextEncoder) { + return new TextEncoder().encode(buffer); + } + let utf8 = unescape(encodeURIComponent(buffer)); + let result = new Uint8Array(utf8.length); + for (let i = 0; i < utf8.length; i++) { + result[i] = utf8.charCodeAt(i); + } + return result; + } export function sha1(message: string | ArrayBuffer) : PromiseLike { - let buffer = message instanceof ArrayBuffer ? message : new TextEncoder().encode(message); - return crypto.subtle.digest("SHA-1", buffer); + let buffer = message instanceof ArrayBuffer ? message : encode_text(message as string); + + if(/Edge/.test(navigator.userAgent)) + return new Promise(resolve => { + resolve(_sha1.arrayBuffer(buffer)); + }); + else + return crypto.subtle.digest("SHA-1", buffer); } } \ No newline at end of file diff --git a/js/log.ts b/js/log.ts index cf6bedd5..144291fd 100644 --- a/js/log.ts +++ b/js/log.ts @@ -104,7 +104,7 @@ namespace log { } log(message: string, ...optionalParams: any[]) : this { - if(!this.initialized) { + if(!this.initialized && false) { if(this._collapsed && console.groupCollapsed) console.groupCollapsed(this.name, ...this.optionalParams); else diff --git a/js/main.ts b/js/main.ts index 4251a8f5..2e9735bd 100644 --- a/js/main.ts +++ b/js/main.ts @@ -90,6 +90,13 @@ function main() { } app.loadedListener.push(() => { - main(); - $(document).one('click', event => AudioController.initializeFromGesture()); + try { + main(); + if(!AudioController.initialized) { + console.log("Initialize audio controller later!"); + $(document).one('click', event => AudioController.initializeFromGesture()); + } + } catch (ex) { + displayCriticalError("Failed to invoke main function:
" + ex, false); + } }); \ No newline at end of file diff --git a/js/ui/frames/SelectedItemInfo.ts b/js/ui/frames/SelectedItemInfo.ts index 5775949b..477889c8 100644 --- a/js/ui/frames/SelectedItemInfo.ts +++ b/js/ui/frames/SelectedItemInfo.ts @@ -191,34 +191,33 @@ class ServerInfoManager extends InfoManager { let rendered = $("#tmpl_selected_server").renderTag([properties]); rendered.find("node").each((index, element) => { $(element).replaceWith(properties[$(element).attr("key")]); }); - html_tag.append(rendered); this.registerInterval(setInterval(() => { html_tag.find(".update_onlinetime").text(formatDate(server.calculateUptime())); }, 1000)); - let requestUpdate = $.spawn("button"); - requestUpdate.css("min-height", "16px"); - requestUpdate.css("bottom", 0); - requestUpdate.text("update info"); - if(server.shouldUpdateProperties()) - requestUpdate.css("color", "green"); - else { - requestUpdate.attr("disabled", "true"); - requestUpdate.css("color", "red"); + { + let requestUpdate = rendered.find(".btn_update"); + /* + let requestUpdate = $.spawn("button"); + requestUpdate.css("min-height", "16px"); + requestUpdate.css("bottom", 0); + requestUpdate.text("update info"); + */ + requestUpdate.prop("enabled", server.shouldUpdateProperties()); + + requestUpdate.click(() => { + server.updateProperties(); + this.triggerUpdate(); + }); + + this.registerTimer(setTimeout(function () { + requestUpdate.prop("enabled", true); + }, server.nextInfoRequest - Date.now())); } - html_tag.append(requestUpdate); - requestUpdate.click(() => { - server.updateProperties(); - this.triggerUpdate(); - }); - - this.registerTimer(setTimeout(function () { - requestUpdate.css("color", "green"); - requestUpdate.removeAttr("disabled"); - }, server.nextInfoRequest - new Date().getTime())); + html_tag.append(rendered); } available(object: V): boolean { diff --git a/js/ui/modal/ModalConnect.ts b/js/ui/modal/ModalConnect.ts index 0da566f4..fd044a5f 100644 --- a/js/ui/modal/ModalConnect.ts +++ b/js/ui/modal/ModalConnect.ts @@ -9,7 +9,10 @@ namespace Modals { return header; }, body: function () { - let tag = $("#tmpl_connect").renderTag(); + let tag = $("#tmpl_connect").renderTag({ + forum_path: settings.static("forum_path"), + forum_valid: !!forumIdentity + }); let updateFields = function () { if(connectIdentity) tag.find(".connect_nickname").attr("placeholder", connectIdentity.name()); @@ -107,8 +110,6 @@ namespace Modals { } { - if(!forumIdentity) - tag.find(".identity_config_" + IdentitifyType[IdentitifyType.TEAFORO]).html("You cant use your TeaSpeak forum account.
You're not connected!"); tag.find(".identity_config_" + IdentitifyType[IdentitifyType.TEAFORO]).on('shown', ev => { connectIdentity = forumIdentity; updateFields(); diff --git a/js/voice/AudioController.ts b/js/voice/AudioController.ts index fe67f1ba..584c9b7f 100644 --- a/js/voice/AudioController.ts +++ b/js/voice/AudioController.ts @@ -56,6 +56,10 @@ class AudioController { this._initialized_listener.pop_front()(); } + static initialized() : boolean { + return this.globalContext.state === "running"; + } + static on_initialized(callback: () => any) { if(this.globalContext) callback(); @@ -68,6 +72,7 @@ class AudioController { } static initializeAudioController() { + AudioController.globalContext; //Just test here //this._globalReplayScheduler = setInterval(() => { AudioController.invokeNextReplay(); }, 20); //Fix me } diff --git a/js/voice/VoiceHandler.ts b/js/voice/VoiceHandler.ts index 3d992f99..a3aab0da 100644 --- a/js/voice/VoiceHandler.ts +++ b/js/voice/VoiceHandler.ts @@ -162,7 +162,29 @@ class VoiceConnection { this.send_task = setInterval(this.sendNextVoicePacket.bind(this), 20); } + native_encoding_supported() : boolean { + if(!AudioContext.prototype.createMediaStreamDestination) return false; //Required, but not available within edge + return true; + } + + javascript_encoding_supported() : boolean { + if(!RTCPeerConnection.prototype.createDataChannel) return false; + return true; + } + + current_encoding_supported() : boolean { + switch (this._type) { + case VoiceConnectionType.JS_ENCODE: + return this.javascript_encoding_supported(); + case VoiceConnectionType.NATIVE_ENCODE: + return this.native_encoding_supported(); + } + return false; + } + private setup_native() { + if(!this.native_encoding_supported()) return; + this.voiceRecorder.on_data = undefined; let stream = this.voiceRecorder.get_output_stream(); @@ -174,6 +196,8 @@ class VoiceConnection { } private setup_js() { + if(!this.javascript_encoding_supported()) return; + this.voiceRecorder.on_data = this.handleVoiceData.bind(this); } @@ -199,7 +223,7 @@ class VoiceConnection { voice_send_support() : boolean { if(this.type == VoiceConnectionType.NATIVE_ENCODE) - return this.rtcPeerConnection.getLocalStreams().length > 0; + return this.native_encoding_supported() && this.rtcPeerConnection.getLocalStreams().length > 0; else return this.voice_playback_support(); } @@ -238,6 +262,8 @@ class VoiceConnection { createSession() { + if(!this.current_encoding_supported()) return false; + if(this.rtcPeerConnection) { this.dropSession(); } diff --git a/templates.html b/templates.html index f78c2659..f7e8da2f 100644 --- a/templates.html +++ b/templates.html @@ -425,7 +425,7 @@
Server password:
- +
@@ -452,14 +452,20 @@
- You're using your forum account as verification + {{if forum_valid}} + You're using your forum account as verification + {{else}} + You cant use your TeaSpeak forum account.
+ You're not connected!
+ Click here to login via the TeaSpeak forum. + {{/if}}
This is just for debug and uses the name as unique identifier
- + @@ -808,40 +814,44 @@