1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-04 02:09:22 +02:00

Make sure unload works

This commit is contained in:
Daniel 2021-08-02 15:06:40 -03:00
parent 786e48d71a
commit c8c5201a80

View file

@ -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();
});