@@ -422,21 +422,39 @@ function isMobile() {
422
422
423
423
var last_videos_id = 0 ;
424
424
var last_currentTime = - 1 ;
425
+ var videoViewAdded = false ;
425
426
function addView ( videos_id , currentTime ) {
426
427
if ( last_videos_id == videos_id && last_currentTime == currentTime ) {
427
428
return false ;
428
429
}
429
430
if ( currentTime > 5 && currentTime % 30 !== 0 ) { // only update each 30 seconds
430
431
return false ;
431
432
}
433
+
434
+ if ( videoViewAdded ) {
435
+ return false ;
436
+ }
437
+
438
+ videoViewAdded = true ;
439
+
432
440
last_videos_id = videos_id ;
433
441
last_currentTime = currentTime ;
434
442
_addView ( videos_id , currentTime ) ;
435
443
}
436
444
445
+ function addViewBeacon ( ) {
446
+ if ( typeof player === 'object' && typeof mediaId !== 'undefined' ) {
447
+ var url = webSiteRootURL + 'objects/videoAddViewCount.json.php?PHPSESSID=' + PHPSESSID ;
448
+ url = addGetParam ( url , 'id' , mediaId ) ;
449
+ url = addGetParam ( url , 'currentTime' , player . currentTime ( ) ) ;
450
+ var beacon = new Image ( ) ;
451
+ beacon . src = url ;
452
+ }
453
+ }
454
+
437
455
function _addView ( videos_id , currentTime ) {
438
456
$ . ajax ( {
439
- url : webSiteRootURL + 'objects/videoAddViewCount.json.php?PHPSESSID=' + PHPSESSID ,
457
+ url : webSiteRootURL + 'objects/videoAddViewCount.json.php?PHPSESSID=' + PHPSESSID ,
440
458
method : 'POST' ,
441
459
data : {
442
460
'id' : videos_id ,
@@ -1212,7 +1230,7 @@ function tabsCategoryDocumentHeightChanged() {
1212
1230
return false ;
1213
1231
}
1214
1232
1215
- function checkDescriptionArea ( ) {
1233
+ function checkDescriptionArea ( ) {
1216
1234
$ ( ".descriptionArea" ) . each ( function ( index ) {
1217
1235
if ( $ ( this ) . height ( ) < $ ( this ) . find ( '.descriptionAreaContent' ) . height ( ) ) {
1218
1236
$ ( this ) . find ( '.descriptionAreaShowMoreBtn' ) . show ( ) ;
@@ -1221,10 +1239,15 @@ function checkDescriptionArea(){
1221
1239
}
1222
1240
1223
1241
$ ( document ) . ready ( function ( ) {
1242
+
1243
+ $ ( window ) . bind ( 'beforeunload' , function ( ) {
1244
+ addViewBeacon ( ) ;
1245
+ } ) ;
1246
+
1224
1247
checkDescriptionArea ( ) ;
1225
- setInterval ( function ( ) { // check for the carousel
1226
- checkDescriptionArea ( ) ;
1227
- } , 3000 ) ;
1248
+ setInterval ( function ( ) { // check for the carousel
1249
+ checkDescriptionArea ( ) ;
1250
+ } , 3000 ) ;
1228
1251
1229
1252
1230
1253
Cookies . set ( 'timezone' , Intl . DateTimeFormat ( ) . resolvedOptions ( ) . timeZone , {
0 commit comments