diff options
| author | RblSb <msrblsb@gmail.com> | 2021-02-10 05:03:56 +0300 |
|---|---|---|
| committer | RblSb <msrblsb@gmail.com> | 2021-02-10 05:03:56 +0300 |
| commit | 5b4d9c6257f7563ef685ab383037906355fbf054 (patch) | |
| tree | fcedd11a16df8d77aee1f157311fd0381b80eafd /src/client | |
| parent | 71d2415a7992c7142200656857ecee3512b238a4 (diff) | |
Api: getLocalIp / getGlobalIp
Diffstat (limited to 'src/client')
| -rw-r--r-- | src/client/JsApi.hx | 14 | ||||
| -rw-r--r-- | src/client/Main.hx | 4 |
2 files changed, 15 insertions, 3 deletions
diff --git a/src/client/JsApi.hx b/src/client/JsApi.hx index 66d0516..b0938f8 100644 --- a/src/client/JsApi.hx +++ b/src/client/JsApi.hx @@ -48,7 +48,7 @@ class JsApi { @:expose public static function addScriptToHead(url:String, ?onLoaded:()->Void):Void { - var script = document.createScriptElement(); + final script = document.createScriptElement(); script.type = "text/javascript"; script.onload = onLoaded; script.src = url; @@ -88,6 +88,18 @@ class JsApi { player.changeVideoSrc(src); } + /** Returns current page hostname (domain without protocol) **/ + @:expose + static function getLocalIp():String { + return main.host; + } + + /** Returns server global ip. **/ + @:expose + static function getGlobalIp():String { + return main.globalIp; + } + @:expose public static function once(type:WsEventType, func:OnceEventFunc):Void { onceListeners.push({type: type, func: func}); diff --git a/src/client/Main.hx b/src/client/Main.hx index ad614c5..78b3504 100644 --- a/src/client/Main.hx +++ b/src/client/Main.hx @@ -32,8 +32,8 @@ class Main { public var forceSyncNextTick = false; final clients:Array<Client> = []; var pageTitle = document.title; - final host:String; - var globalIp = ""; + public final host:String; + public var globalIp(default, null) = ""; var config:Null<Config>; final filters:Array<{regex:EReg, replace:String}> = []; var personal = new Client("Unknown", 0); |
