diff options
| author | RblSb <msrblsb@gmail.com> | 2020-04-25 02:03:49 +0300 |
|---|---|---|
| committer | RblSb <msrblsb@gmail.com> | 2020-04-25 02:03:49 +0300 |
| commit | 40589f8e8ee75485ba241777f3b26cd35d8a05ea (patch) | |
| tree | 198ab3ab16272bbc0269b887c1f5089d2f5da3ab /src/client/JsApi.hx | |
| parent | ec15079f99724cc0ad40f550687fcca2735c9afc (diff) | |
VideoRemove api event
Diffstat (limited to 'src/client/JsApi.hx')
| -rw-r--r-- | src/client/JsApi.hx | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/client/JsApi.hx b/src/client/JsApi.hx index 810e2f2..2df9c57 100644 --- a/src/client/JsApi.hx +++ b/src/client/JsApi.hx @@ -5,18 +5,18 @@ import js.Browser.document; private typedef VideoChangeFunc = (item:VideoItem)->Void; - class JsApi { static final videoChange:Array<VideoChangeFunc> = []; + static final videoRemove:Array<VideoChangeFunc> = []; @:expose - public static function addPlugin(id:String, ?onLoaded:()->Void):Void { + static function addPlugin(id:String, ?onLoaded:()->Void):Void { addScriptToHead('/plugins/$id/index.js', onLoaded); } @:expose - public static function addScriptToHead(url:String, ?onLoaded:()->Void):Void { + static function addScriptToHead(url:String, ?onLoaded:()->Void):Void { var script = document.createScriptElement(); script.type = "text/javascript"; script.onload = onLoaded; @@ -25,7 +25,7 @@ class JsApi { } @:expose - public static function hasScriptInHead(url:String):Bool { + static function hasScriptInHead(url:String):Bool { for (child in document.getElementsByTagName("head")[0].children) { if ((child : Dynamic).src == url) return true; } @@ -33,12 +33,12 @@ class JsApi { } @:expose - public static function notifyOnVideoChange(func:VideoChangeFunc):Void { + static function notifyOnVideoChange(func:VideoChangeFunc):Void { videoChange.push(func); } @:expose - public static function removeFromVideoChange(func:VideoChangeFunc):Void { + static function removeFromVideoChange(func:VideoChangeFunc):Void { videoChange.remove(func); } @@ -46,4 +46,18 @@ class JsApi { for (func in videoChange) func(item); } + @:expose + static function notifyOnVideoRemove(func:VideoChangeFunc):Void { + videoRemove.push(func); + } + + @:expose + static function removeFromVideoRemove(func:VideoChangeFunc):Void { + videoRemove.remove(func); + } + + public static function fireVideoRemoveEvents(item:VideoItem):Void { + for (func in videoRemove) func(item); + } + } |
