mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-04 10:19:24 +02:00
Make sure unload works
This commit is contained in:
parent
786e48d71a
commit
c8c5201a80
1 changed files with 10 additions and 2 deletions
|
@ -448,7 +448,11 @@ function addView(videos_id, currentTime) {
|
|||
_addView(videos_id, currentTime);
|
||||
}
|
||||
|
||||
var _addViewBeaconAdded = false;
|
||||
function addViewBeacon() {
|
||||
if(_addViewBeaconAdded){
|
||||
return false;
|
||||
}
|
||||
if (typeof player === 'object' && typeof mediaId !== 'undefined') {
|
||||
var url = webSiteRootURL + 'objects/videoAddViewCount.json.php?PHPSESSID=' + PHPSESSID;
|
||||
url = addGetParam(url, 'id', mediaId);
|
||||
|
@ -456,6 +460,7 @@ function addViewBeacon() {
|
|||
url = addGetParam(url, 'seconds_watching_video', seconds_watching_video);
|
||||
var beacon = new Image();
|
||||
beacon.src = url;
|
||||
_addViewBeaconAdded = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1244,8 +1249,11 @@ function checkDescriptionArea() {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
window.onbeforeunload = function() {
|
||||
addViewBeacon();
|
||||
};
|
||||
|
||||
$(window).on("unload", function () {
|
||||
addViewBeacon();
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue