aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/client.js6
-rw-r--r--src/client/JsApi.hx14
-rw-r--r--src/client/Main.hx4
3 files changed, 21 insertions, 3 deletions
diff --git a/res/client.js b/res/client.js
index 6f01550..a40cdd8 100644
--- a/res/client.js
+++ b/res/client.js
@@ -945,6 +945,12 @@ client_JsApi.forceSyncNextTick = $hx_exports["client"]["JsApi"]["forceSyncNextTi
client_JsApi.setVideoSrc = $hx_exports["client"]["JsApi"]["setVideoSrc"] = function(src) {
client_JsApi.player.changeVideoSrc(src);
};
+client_JsApi.getLocalIp = $hx_exports["client"]["JsApi"]["getLocalIp"] = function() {
+ return client_JsApi.main.host;
+};
+client_JsApi.getGlobalIp = $hx_exports["client"]["JsApi"]["getGlobalIp"] = function() {
+ return client_JsApi.main.globalIp;
+};
client_JsApi.once = $hx_exports["client"]["JsApi"]["once"] = function(type,func) {
client_JsApi.onceListeners.push({ type : type, func : func});
};
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);
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage