aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2020-04-25 02:03:49 +0300
committerRblSb <msrblsb@gmail.com>2020-04-25 02:03:49 +0300
commit40589f8e8ee75485ba241777f3b26cd35d8a05ea (patch)
tree198ab3ab16272bbc0269b887c1f5089d2f5da3ab
parentec15079f99724cc0ad40f550687fcca2735c9afc (diff)
VideoRemove api event
-rw-r--r--res/client.js14
-rw-r--r--src/client/JsApi.hx26
-rw-r--r--src/client/Player.hx2
3 files changed, 36 insertions, 6 deletions
diff --git a/res/client.js b/res/client.js
index 186f01e..2f9b418 100644
--- a/res/client.js
+++ b/res/client.js
@@ -877,6 +877,17 @@ client_JsApi.fireVideoChangeEvents = function(item) {
var _g1 = client_JsApi.videoChange;
while(_g < _g1.length) _g1[_g++](item);
};
+client_JsApi.notifyOnVideoRemove = $hx_exports["client"]["JsApi"]["notifyOnVideoRemove"] = function(func) {
+ client_JsApi.videoRemove.push(func);
+};
+client_JsApi.removeFromVideoRemove = $hx_exports["client"]["JsApi"]["removeFromVideoRemove"] = function(func) {
+ HxOverrides.remove(client_JsApi.videoRemove,func);
+};
+client_JsApi.fireVideoRemoveEvents = function(item) {
+ var _g = 0;
+ var _g1 = client_JsApi.videoRemove;
+ while(_g < _g1.length) _g1[_g++](item);
+};
var client_Main = function(host,port) {
this.matchNumbers = new EReg("^-?[0-9]+$","");
this.mask = new EReg("\\${([0-9]+)-([0-9]+)}","g");
@@ -1681,6 +1692,7 @@ client_Player.prototype = {
}
,setPlayer: function(newPlayer) {
if(this.player != null && this.player != newPlayer) {
+ client_JsApi.fireVideoRemoveEvents(this.items[this.itemPos]);
this.player.removeVideo();
}
this.player = newPlayer;
@@ -1722,6 +1734,7 @@ client_Player.prototype = {
window.document.querySelector("#currenttitle").textContent = item.title;
}
,removeVideo: function() {
+ client_JsApi.fireVideoRemoveEvents(this.items[this.itemPos]);
this.currentSrc = "";
this.player.removeVideo();
window.document.querySelector("#currenttitle").textContent = Lang.get("nothingPlaying");
@@ -3170,6 +3183,7 @@ Lang.langs = new haxe_ds_StringMap();
Lang.ids = ["en","ru"];
Lang.lang = HxOverrides.substr(window.navigator.language,0,2).toLowerCase();
client_JsApi.videoChange = [];
+client_JsApi.videoRemove = [];
client_Settings.isSupported = false;
js_youtube_Youtube.isLoadedAPI = false;
client_Main.main();
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);
+ }
+
}
diff --git a/src/client/Player.hx b/src/client/Player.hx
index 780f8cc..d4ed854 100644
--- a/src/client/Player.hx
+++ b/src/client/Player.hx
@@ -90,6 +90,7 @@ class Player {
function setPlayer(newPlayer:IPlayer):Void {
if (player != null && player != newPlayer) {
+ JsApi.fireVideoRemoveEvents(items[itemPos]);
player.removeVideo();
// playerEl.textContent = "";
}
@@ -125,6 +126,7 @@ class Player {
}
public function removeVideo():Void {
+ JsApi.fireVideoRemoveEvents(items[itemPos]);
currentSrc = "";
player.removeVideo();
ge("#currenttitle").textContent = Lang.get("nothingPlaying");
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage