1//WPB-379 -- new file created. 2jQuery(document).ready(function($) { 3 var donotIncludeAWS = false; 4 if (typeof kinesis === "undefined") { 5 //if found from audio stats file. 6 donotIncludeAWS = true; 7 } 8 //-------------------------------------------------- 9 if (donotIncludeAWS) { 10 //same kind of code for audio in file : wpb-jquery-jplayer.js 11 //WPB-402 12 // AWS CONFIGURATION 13 AWS.config.credentials = new AWS.CognitoIdentityCredentials({ 14 IdentityPoolId: "us-east-1:adc43218-48bc-4c15-87ed-037b09ebb86d" 15 }); 16 AWS.config.region = "us-east-1"; 17 // STATE 18 // make a default kinesis var for context 19 var kinesis; 20 // define record holding array 21 var recordData = []; 22 } //End of if (donotIncludeAWS) 23 //-------------------------------------------------- 24 25 //WPB-621 26 //WPB-749 -- same into video_metabox.js file. get_embedcode:function( video_id, type ) 27 jQuery.embedClick_Video = function( 28 embedLinkObj, 29 video_id, 30 flag_call, 31 instance_video_val, 32 embed_param 33 ) { 34 var textArea = document.createElement("textarea"); 35 var id_embed = embedLinkObj.id; //alert(id_embed); 36 /*var tempArr = id_embed.split('embed-video-code-'); 37 var tempArr2 = tempArr[1]; 38 var player_unique_index_val = tempArr2[0];*/ 39 var player_unique_index_val = id_embed.replace("embed-video-code-", ""); 40 textArea.style.position = "fixed"; 41 textArea.style.top = 0; 42 textArea.style.left = 0; 43 // Ensure it has a small width and height. Setting to 1px / 1em 44 // doesn't work as this gives a negative w/h on some browsers. 45 textArea.style.width = "2em"; 46 textArea.style.height = "2em"; 47 textArea.style.padding = 0; // We don't need padding, reducing the size if it does flash render. 48 textArea.style.border = "none"; 49 textArea.style.outline = "none"; 50 textArea.style.boxShadow = "none"; // Clean up any borders. 51 textArea.style.background = "transparent"; // Avoid flash of white box if rendered for any reason. 52 var siteURL = eval("wpb_video_settings_" + player_unique_index_val).siteUrl; 53 var blogID = eval("wpb_video_settings_" + player_unique_index_val).blogid; 54 var playerID = eval("wpb_video_settings_" + player_unique_index_val) 55 .playerid; 56 var playerSlug = eval("wpb_video_settings_" + player_unique_index_val) 57 .playerslug; 58 var autoplay = eval("wpb_video_settings_" + player_unique_index_val) 59 .autoplay; 60 var playerWidth = ""; 61 var playerHeight = ""; 62 if (embed_param) { 63 var tempJSArr = embed_param.split("_"); 64 playerWidth = tempJSArr[0]; 65 //playerHeight = tempJSArr[1]; 66 var n_per = playerWidth.indexOf("%"); 67 if (n_per > 0) { 68 //if % things then donot do anything with width. 69 playerWidth = ""; 70 } 71 } 72 73 var iframeStylesheet = 74 "<link rel='stylesheet' href='" + 75 siteURL + 76 "/wp-content/plugins/wpb-video/wpb-video-embed/iframe-style.css' />"; 77 var iframeURL = 78 siteURL + 79 "/wp-content/plugins/wpb-video/wpb-video-embed/wpb-video-embed.php?blogid=" + 80 blogID; 81 82 var class_Div = ""; 83 var class_iFrame = ""; 84 var iframe_Height = "330"; 85 var iframe_Width = "600"; //default. 86 87 if (flag_call == "singleVideo") { 88 iframeURL = iframeURL + "&id=" + video_id + "&flag_call=singleVideo"; 89 class_Div = "embedded-video-single-player"; 90 class_iFrame = "video-single-player-iframe"; 91 iframe_Height = "330"; 92 } else if (flag_call == "playlistVideo") { 93 iframeURL = 94 iframeURL + 95 "&playlistid=" + 96 video_id + 97 "&flag_call=playlistVideo&autoplay=" + 98 autoplay; 99 class_Div = "embedded-video-playlist-player"; 100 class_iFrame = "video-playlist-player-iframe"; 101 //iframe_Height = '400'; //from left side to now bottom. 102 iframe_Height = "480"; 103 } 104 105 if (playerWidth) { 106 if (flag_call == "singleVideo") { 107 iframe_Width = parseInt(playerWidth) + 5; //5 px more to iframe than width value. 108 iframe_Height = "100%"; 109 110 iframe_Height = parseInt(Math.round((9 * iframe_Width) / 16)) + 20; 111 } else if (flag_call == "playlistVideo") { 112 iframe_Width = "100%"; 113 iframe_Height = "480"; 114 } 115 } 116 117 iframeURL = 118 iframeURL + 119 "&playerid=" + 120 playerID + 121 "&player_slug=" + 122 playerSlug + 123 "&playerWidth=" + 124 playerWidth; 125
126 var iframeHTML = 127 "<!-- Start div video embed --><div class='video-embed-container " + 128 class_Div + 129 "'><iframe class='wpb_videoplayer " + 130 class_iFrame + 131 "' allowfullscreen scrolling='no' width='" + 132 iframe_Width + 133 "' height='" + 134 iframe_Height + 135 "' frameborder='0' src='" + 136 iframeURL + 137 "'></iframe></div><!-- End div video embed -->"; 138 139 textArea.value = iframeStylesheet + iframeHTML; 140 document.body.appendChild(textArea); 141 textArea.select(); 142 try { 143 var successful = document.execCommand("copy"); 144 } catch (err) {} 145 document.body.removeChild(textArea); 146 alert("Video Player Embed Code has been copied to your clipboard."); 147 }; //End of function embedClick_Video 148 149 jQuery.stopAllVideos = function() { 150 jQuery("video").each(function() { 151 try { 152 //var videoID = this.attr('id'); 153 //var videoID = this.id; //work this. 154 this.pause(); 155 } catch (e) {} 156 }); 157 }; 158 159 jQuery.stopOtherVideos = function(current_vid_player_id_val) { 160 jQuery("video").each(function() { 161 try { 162 var videoID = this.id; 163 if (videoID) { 164 if (current_vid_player_id_val) { 165 var n_pos = videoID.search(current_vid_player_id_val); 166 if (n_pos < 0) { 167 //-1 not found. 168 this.pause(); 169 } 170 } 171 } 172 } catch (e) {} 173 }); 174 }; 175 176 jQuery.getHidExtraInfo_Video = function(num_unique) { 177 var ObjHid = document.getElementById("hid-extra-vid-" + num_unique); 178 if (ObjHid && ObjHid != "undefined") { 179 var field_arr = ObjHid.value.split("^#^"); 180 var field1_arr = field_arr[0].split("^@^"); 181 var v_id = field1_arr[1]; 182 var field2_arr = field_arr[1].split("^@^"); 183 var p_id = field2_arr[1]; 184 var field3_arr = field_arr[2].split("^@^"); 185 var flag_play = field3_arr[1]; 186 var field4_arr = field_arr[3].split("^@^"); 187 var pl_id = field4_arr[1]; 188 var field5_arr = field_arr[4].split("^@^"); 189 var ply_f = field5_arr[1]; 190 191 var plr_id = ""; 192 try { 193 var field6_arr = field_arr[5].split("^@^"); 194 var plr_id = field6_arr[1]; 195 } catch (e) {} 196 } else { 197 var v_id = 0; 198 var p_id = 0; 199 var flag_play = ""; 200 var pl_id = 0; 201 var ply_f = ""; 202 var plr_id = ""; 203 } 204 205 var hidExtraInfoArr = []; 206 hidExtraInfoArr["v_id"] = v_id; 207 hidExtraInfoArr["p_id"] = p_id; 208 hidExtraInfoArr["flag_play"] = flag_play; 209 hidExtraInfoArr["pl_id"] = pl_id; 210 hidExtraInfoArr["ply_f"] = ply_f; 211 hidExtraInfoArr["plr_id"] = plr_id; 212 213 return hidExtraInfoArr; 214 }; //End of function getHidExtraInfo_Video 215 //video object class have unique video number for video stats. 216 jQuery.getVideoUniqueNo = function(playerObj) { 217 if (playerObj) { 218 try { 219 var videoTagCssClasses = playerObj.el().className; 220 } catch (e) { 221 var videoTagCssClasses = ""; 222 } 223 224 if (videoTagCssClasses) { 225 //var tempArr = playerObj.el().className.split('wpb-vid-'); 226 var tempArr = videoTagCssClasses.split("wpb-vid-"); 227 //container div should have this class name. 228 var tempArr2 = tempArr[1].split(" "); 229 var num_unique_vid = tempArr2[0]; 230 231 if (num_unique_vid) return num_unique_vid; 232 else return 0; 233 } else { 234 return 0; 235 } 236 } else { 237 return 0; 238 } 239 }; //End of function getVideoUniqueNo 240 241 jQuery.checkPlaylistPlayer_Video = function(num) { 242 //$('#player-'+num); 243 var player_unique_index_val = num; 244 var player_flag = ""; 245 try { 246 var playlists_arr = eval( 247 "playlists_arr_video_" + player_unique_index_val 248 ); 249 if (playlists_arr) { 250 player_flag = "video_playlist"; 251 } 252 } catch (e) {} 253 254 return player_flag; 255 }; //End of function checkPlaylistPlayer_Video 256 257 jQuery.collectStats_Video = function( 258 playerObj, 259 video_id, 260 video_event, 261 durationVal, 262 uuidVal, 263 instance_video_val, 264 total_duration = 0, // WPB-1202 265 flag_chk_video_event = '' 266 ) { 267 var vid_player_id_val = playerObj.id(); 268 //alert(playerObj.el().className); 269 var num_unique_vid = jQuery.getVideoUniqueNo(playerObj); 270 //console.log('collectStats_Video : '+video_id+' : '+video_event+' : '+num_unique_vid+' == '+instance_video_val+' >> '+flag_chk_video_event); 271 if (num_unique_vid) { 272 //console.log('Here 1 >> collectStats_Video : '+num_unique_vid); 273 } else { 274 //get from func param. 275 num_unique_vid = instance_video_val; 276 //console.log('Here 2 >> collectStats_Video : '+instance_video_val); 277 } 278 279 var player_flag = jQuery.checkPlaylistPlayer_Video(num_unique_vid); 280 var hidExtraInfoArr = jQuery.getHidExtraInfo_Video(num_unique_vid); 281 282 //pl_id is playlist and plr_id is player. p_id is preroll 283 var v_id = hidExtraInfoArr["v_id"]; 284 var p_id = hidExtraInfoArr["p_id"]; 285 var flag_play = hidExtraInfoArr["flag_play"]; 286 var pl_id = hidExtraInfoArr["pl_id"]; 287 var ply_f = hidExtraInfoArr["ply_f"]; 288 var plr_id = hidExtraInfoArr["plr_id"]; 289 290 if (pl_id) { 291 //if found from hidden then use that. otherwise from wpb_video_settings variable. 292 } else { 293 pl_id = eval("wpb_video_settings_" + num_unique_vid).playlist_id; 294 } 295 //alert(v_id + ' >> ' + p_id + ' >> ' + pl_id + ' >> ' + plr_id); 296 //return; 297 var p_id_from_tracker_vast_url = 0; 298 /*if (playerObj.vast.prerollURL) { 299 var tempArr = playerObj.vast.prerollURL.split("?prerollId="); 300 p_id_from_tracker_vast_url = tempArr[1]; 301 } 302*/ 303 if (p_id_from_tracker_vast_url) { 304 p_id = p_id_from_tracker_vast_url; 305 } 306 307 //console.log('collectStats_Video : ' + v_id + ' >> ' + p_id); 308 309 var ajax_url_val = eval("wpb_video_settings_" + num_unique_vid) 310 .ajaxurl_path; 311 var ajax_simple = 0; 312 if (ajax_url_val) { 313 ajax_url_val = 314 eval("wpb_video_settings_" + num_unique_vid).siteUrl + ajax_url_val; 315 ajax_simple = 1; 316 } else { 317 ajax_url_val = ajaxurl; //as usual. 318 } 319 //console.log('collectStats_Video >> uuid unique : '+uuidVal); 320 321 var uuid_vid = uuidVal; 322 323 var blogid = eval("wpb_video_settings_" + num_unique_vid).blogid; 324 var gmt_offset_site = eval("wpb_video_settings_" + num_unique_vid) 325 .gmt_offset_site; 326 var sub_id = eval("wpb_video_settings_" + num_unique_vid).sub_id; 327 328 //console.log(video_event + ' >> ' + video_id + ' >> ' + p_id + ' >> ' + p_id_from_tracker_vast_url + ' >> ' + pl_id + ' >> ' + uuid_vid + ' >> ' + blogid + ' >> ' + ajax_simple + ' >> ' + durationVal); 329 //console.log(num_unique_vid + ' >>>>> ' + sub_id + ' : ' + gmt_offset_site) 330 //return; //during local check just print values. not send to aws. 331 332 var data = {}; 333 data.topic = "video_player_stats"; 334 data.video_id = video_id; 335 data.uuid_vid = uuid_vid; 336 data.blogid = blogid; 337 data.action = "video_save_play_duration"; 338 data.type = "video"; 339 340 data.preroll_id = p_id; 341 data.playlist_id = pl_id; 342 data.total_duration = total_duration; // WPB-1202 343 data.sub_id = sub_id; 344 345 if (ajax_simple) { 346 data.gmt_offset_site = gmt_offset_site; 347 data.ajax_simple = ajax_simple; 348 } 349 350 data.duration = durationVal; //must be -1 or 00:00:01 etc... 351 352 if (durationVal == 0 || durationVal == "0") { 353 return; 354 } 355 if (video_event) { 356 data.video_event = video_event; 357 } 358 //console.log(video_id + ' >> ' + total_duration); 359 360 //892 - vanilla. //WPB-740 361 //658 - ozarkssportszone 362 var checkToStaging = false;
363 if (blogid == 892 || blogid == "892" 364 /* || blogid == 658 || blogid == "658" */ 365 ) { 366 data.temp_call = 367 "check to staging by changing video_player_stats_staging_check"; 368 data.log_chk = 1; 369 checkToStaging = true; 370 console.log( 371 "topic : staging_check >> " + 372 video_event + 373 " >> " + 374 video_id + 375 " >> " + 376 p_id + 377 " >> " + 378 p_id_from_tracker_vast_url + 379 " >> " + 380 pl_id + 381 " >> " + 382 uuid_vid + 383 " >> " + 384 blogid + 385 " >> " + 386 ajax_simple + 387 " >> " + 388 durationVal + 389 " >> " + 390 total_duration 391 ); 392 //console.log(num_unique_vid + ' >>>>> ' + sub_id + ' : ' + gmt_offset_site) 393 } 394 else { 395 data.log_chk = 0; 396 } 397 398 //-------------------------------------------------- 399 //WPB-402 400 var record = { 401 topic: "video_player_stats", 402 data: data 403 }; 404 //WPB-740 405 if (checkToStaging) { 406 //if vanilla then check to staging. 407 record.topic = "video_player_stats_staging_check"; 408 } 409 var params = { 410 // for AWS Kinesis 411 Data: JSON.stringify(record) + ",", 412 PartitionKey: "partition-" + AWS.config.credentials.identityId 413 }; 414 //console.log(params) 415 var localCheck = false; //Temp check to local. 416 if (localCheck) { 417 /*jQuery.ajax({ 418 type: 'GET', 419 url: ajax_url_val, 420 data: data 421 });*/ 422 } else { 423 //for live pipeline. 424 recordData.push(params); //temp stop donot fill array during local checking and check with console.log() 425 } 426 //-------------------------------------------------- 427 }; //End of function collectStats_Video 428 429 //-------------------------------------------------------------- 430 if (donotIncludeAWS) { 431 //put outside foreach playlists loop. 432 //WPB-402 433 AWS.config.credentials.get(function(err) { 434 // attach event listener 435 if (err) { 436 //console.error(err); 437 return; 438 } 439 // create kinesis service object 440 kinesis = new AWS.Kinesis({ 441 apiVersion: "2013-12-02" 442 }); 443 444 setInterval(function() { 445 //return; //donot pass during local check. 446 //console.log('video : '+recordData.length); 447 //console.log(recordData); 448 if (!recordData.length) { 449 return; 450 } // dont do anything if there is no records 451 //console.log('Here video : '+recordData.length); 452 453 // upload data to Amazon Kinesis 454 if (kinesis) { 455 kinesis.putRecords( 456 { 457 Records: recordData, 458 StreamName: "iap-stats-pipeline" 459 }, 460 function(err, data) { 461 if (err) { 462 //console.error(err); 463 } 464 recordData = []; 465 //console.log(data); // debug 466 } 467 ); 468 // clear record data 469 } // if there is a kinesis 470 }, 2000); // set interval 471 }); 472 } //End of if (donotIncludeAWS) 473 //-------------------------------------------------------------- 474 $('.list_rec_vid_item').on("click", function (e) { 475 var video_id = $(this).attr('vid'); 476 var widget_id= $(this).attr('widget_id'); 477 var width = $(this).attr('width'); 478 var player_width = $(this).attr('player_width'); 479 var player_height = $(this).attr('player_height'); 480 var playlist_id = $(this).attr('playlist_id'); 481 var playerid = $(this).attr('playerid'); 482 var player_type = $(this).attr('player_type'); 483 var isDefaultPlayer = $(this).attr('isDefaultPlayer'); 484 var playerName = $(this).attr('playerName'); 485 var player_slug = $(this).attr('player_slug'); 486 487 var recent_ajax_url = location.protocol+"//"+document.location.host+"/wp-content/plugins/wpb-video/public/recent-video-ajax.php"; 488 var params = { 489 vid: video_id, 490 playlist_id: playlist_id, 491 width: width, 492 player_width: player_width, 493 player_height: player_height, 494 playerid: playerid, 495 player_type: player_type, 496 isDefaultPlayer: isDefaultPlayer, 497 playerName: playerName, 498 player_slug: player_slug 499 }; 500 501 $.ajax( { 502 type:'GET', 503 url:recent_ajax_url, 504 data:params, 505 success:function( data ){ 506 $('#vidDiv_'+widget_id).html(data); 507 } 508 } ); 509 510 }); 511}); 512 513jQuery.guid_vid = function() { 514 function s4() { 515 return Math.floor((1 + Math.random()) * 0x10000) 516 .toString(16) 517 .substring(1); 518 } 519 return ( 520 s4() + 521 s4() + 522 "-" + 523 s4() + 524 "-" + 525 s4() + 526 "-" + 527 s4() + 528 "-" + 529 s4() + 530 s4() + 531 s4() 532 ); 533 }; //End of function guid_vid - updated
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.