mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-04 02:09:22 +02:00
Listner event
This commit is contained in:
parent
1607cd6af3
commit
dfadfce44b
1 changed files with 19 additions and 7 deletions
|
@ -24,6 +24,18 @@ try {
|
||||||
let deferredPrompt;
|
let deferredPrompt;
|
||||||
var playerCurrentTime;
|
var playerCurrentTime;
|
||||||
var mediaId;
|
var mediaId;
|
||||||
|
// Create browser compatible event handler.
|
||||||
|
var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent";
|
||||||
|
var eventer = window[eventMethod];
|
||||||
|
var messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message";
|
||||||
|
// Listen for a message from the iframe.
|
||||||
|
eventer(messageEvent, function (e) {
|
||||||
|
if(e.getHeight){
|
||||||
|
var height= $('body').height();
|
||||||
|
parent.postMessage(height, '*');
|
||||||
|
}
|
||||||
|
},false);
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Variable declaration ERROR', e);
|
console.log('Variable declaration ERROR', e);
|
||||||
}
|
}
|
||||||
|
@ -1987,11 +1999,11 @@ function isPlayerUserActive() {
|
||||||
return $('#mainVideo').hasClass("vjs-user-active");
|
return $('#mainVideo').hasClass("vjs-user-active");
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('beforeunload', function (e) {
|
eventer('beforeunload', function (e) {
|
||||||
//console.log('window.addEventListener(beforeunload');
|
//console.log('window.addEventListener(beforeunload');
|
||||||
_addViewAsync();
|
_addViewAsync();
|
||||||
}, false);
|
}, false);
|
||||||
document.addEventListener('visibilitychange', function () {
|
eventer('visibilitychange', function () {
|
||||||
if (document.visibilityState === 'hidden') {
|
if (document.visibilityState === 'hidden') {
|
||||||
_addViewAsync();
|
_addViewAsync();
|
||||||
}
|
}
|
||||||
|
@ -2544,7 +2556,7 @@ $(document).ready(function () {
|
||||||
});
|
});
|
||||||
checkAutoPlay();
|
checkAutoPlay();
|
||||||
// Code to handle install prompt on desktop
|
// Code to handle install prompt on desktop
|
||||||
window.addEventListener('beforeinstallprompt', (e) => {
|
eventer('beforeinstallprompt', (e) => {
|
||||||
// Prevent Chrome 67 and earlier from automatically showing the prompt
|
// Prevent Chrome 67 and earlier from automatically showing the prompt
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$('.A2HSInstall').show();
|
$('.A2HSInstall').show();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue