diff options
| author | RblSb <msrblsb@gmail.com> | 2025-04-09 23:36:52 +0300 |
|---|---|---|
| committer | RblSb <msrblsb@gmail.com> | 2025-04-09 23:36:52 +0300 |
| commit | 7cc0b485f2eed746ff638e14e137eabaebaf9312 (patch) | |
| tree | e945ebe3215a813aaff36f124598cced1a850f9c | |
| parent | 71160f8c35da6d40bad52cfecd7152c539dd85c6 (diff) | |
Trim spaces in message
| -rw-r--r-- | build/server.js | 2 | ||||
| -rw-r--r-- | res/client.js | 17 | ||||
| -rw-r--r-- | src/client/InputWithHistory.hx | 2 | ||||
| -rw-r--r-- | src/client/Main.hx | 3 | ||||
| -rw-r--r-- | src/client/Player.hx | 4 | ||||
| -rw-r--r-- | src/client/Utils.hx | 1 | ||||
| -rw-r--r-- | src/server/Main.hx | 2 |
7 files changed, 18 insertions, 13 deletions
diff --git a/build/server.js b/build/server.js index f4e8b91..2592fe8 100644 --- a/build/server.js +++ b/build/server.js @@ -5190,7 +5190,7 @@ server_Main.prototype = { if(!this.checkPermission(client,"writeChat")) { return; } - var text = data.message.text; + var text = StringTools.trim(data.message.text); if(text.length == 0) { return; } diff --git a/res/client.js b/res/client.js index 27b5f95..fcb6a89 100644 --- a/res/client.js +++ b/res/client.js @@ -1160,7 +1160,7 @@ client_InputWithHistory.prototype = { var key = e.keyCode; switch(key) { case 13: - var value = this.element.value; + var value = StringTools.trim(this.element.value); if(value.length == 0) { return; } @@ -1367,6 +1367,7 @@ var client_Main = function() { this.forceSyncNextTick = false; this.isSyncActive = true; var _gthis = this; + client_Main.instance = this; haxe_Log.trace = client_Utils.nativeTrace; this.player = new client_Player(this); this.host = $global.location.hostname; @@ -1395,7 +1396,7 @@ var client_Main = function() { }; client_Main.__name__ = true; client_Main.main = function() { - client_Main.instance = new client_Main(); + new client_Main(); }; client_Main.prototype = { onFirstInteraction: function() { @@ -1729,7 +1730,7 @@ client_Main.prototype = { var data = JSON.parse(e.data); if(this.config != null && this.config.isVerbose) { var t = data.type; - haxe_Log.trace("Event: " + data.type,{ fileName : "src/client/Main.hx", lineNumber : 477, className : "client.Main", methodName : "onMessage", customParams : [Reflect.field(data,t.charAt(0).toLowerCase() + HxOverrides.substr(t,1,null))]}); + haxe_Log.trace("Event: " + data.type,{ fileName : "src/client/Main.hx", lineNumber : 478, className : "client.Main", methodName : "onMessage", customParams : [Reflect.field(data,t.charAt(0).toLowerCase() + HxOverrides.substr(t,1,null))]}); } client_JsApi.fireEvents(data); switch(data.type) { @@ -2781,7 +2782,7 @@ var client_Player = function(main) { this.rawPlayer = new client_players_Raw(main,this); this.initItemButtons(); var resizeObserver = client_Utils.createResizeObserver(function(entries) { - if(_gthis.isLoaded) { + if(_gthis.isLoaded || _gthis.videoList.items.length == 0) { return; } client_Buttons.onViewportResize(); @@ -2790,7 +2791,7 @@ var client_Player = function(main) { resizeObserver.observe(this.playerEl); } else { new haxe_Timer(50).run = function() { - if(_gthis.isLoaded) { + if(_gthis.isLoaded || _gthis.videoList.items.length == 0) { return; } client_Buttons.onViewportResize(); @@ -3751,7 +3752,11 @@ client_Utils.saveFile = function(name,mime,data) { URL.revokeObjectURL(url); }; client_Utils.createResizeObserver = function(callback) { - return null; + var $window = window; + if($window.ResizeObserver == null) { + return null; + } + return new ResizeObserver(callback); }; client_Utils.createAudioContext = function() { var w = window; diff --git a/src/client/InputWithHistory.hx b/src/client/InputWithHistory.hx index e7dfe83..e41ec16 100644 --- a/src/client/InputWithHistory.hx +++ b/src/client/InputWithHistory.hx @@ -33,7 +33,7 @@ class InputWithHistory { final key:KeyCode = cast e.keyCode; switch (key) { case Return: - final value = element.value; + final value = element.value.trim(); if (value.length == 0) return; final isAdd = onEnter(value); if (isAdd) pushIfNotLast(history, value); diff --git a/src/client/Main.hx b/src/client/Main.hx index abc39f6..729658c 100644 --- a/src/client/Main.hx +++ b/src/client/Main.hx @@ -67,10 +67,11 @@ class Main { var msgBuf = getEl("#messagebuffer"); static function main():Void { - instance = new Main(); + new Main(); } function new() { + instance = this; haxe.Log.trace = Utils.nativeTrace; player = new Player(this); host = Browser.location.hostname; diff --git a/src/client/Player.hx b/src/client/Player.hx index cafb572..7fc021d 100644 --- a/src/client/Player.hx +++ b/src/client/Player.hx @@ -55,7 +55,7 @@ class Player { initItemButtons(); final resizeObserver = Utils.createResizeObserver(entries -> { - if (isLoaded) return; + if (isLoaded || videoList.length == 0) return; Buttons.onViewportResize(); }); if (resizeObserver != null) { @@ -63,7 +63,7 @@ class Player { } else { final timer = new Timer(50); timer.run = () -> { - if (isLoaded) return; + if (isLoaded || videoList.length == 0) return; Buttons.onViewportResize(); } } diff --git a/src/client/Utils.hx b/src/client/Utils.hx index f071b76..2234a1b 100644 --- a/src/client/Utils.hx +++ b/src/client/Utils.hx @@ -202,7 +202,6 @@ class Utils { public static function createResizeObserver(callback:(entries:Array<Dynamic>) -> Void):Null<{ observe:(el:Element) -> Void }> { - return null; final window = js.Browser.window; final observer = (window : Dynamic).ResizeObserver ?? return null; return js.Syntax.code("new ResizeObserver({0})", callback); diff --git a/src/server/Main.hx b/src/server/Main.hx index 61cb46b..8164922 100644 --- a/src/server/Main.hx +++ b/src/server/Main.hx @@ -639,7 +639,7 @@ class Main { case Message: if (!checkPermission(client, WriteChatPerm)) return; - var text = data.message.text; + var text = data.message.text.trim(); if (text.length == 0) return; if (text.length > config.maxMessageLength) { text = text.substr(0, config.maxMessageLength); |
