(function() {
window.CmmAppMatrixVideoApi = {
_videos:{},
_nextPlayerId:0,
_players:{},
_debug:false,
_launchEvent:function(event, clipId){
var playerId = this._getCurrentPlayer(clipId);
// console.log('_launchEvent: ' + ' event: ' + event + ' clipId: ' + clipId + ' playerId: ' + playerId);
yq('.playerContainer' + playerId).trigger(event, playerId);
},
/*Get player object from players array*/
_getPlayer:function(id){
return this._players[id];
},
/*On click again button at post screen*/
_onClickPlayAgain:function(playerId){
var player=this._getPlayer(playerId);
player.params.autoStart = true;
this._loadMatrixPlayer(player);
},
_onClickSendToFriend:function(playerId){
var player=this._getPlayer(playerId);
if (yq.inArray(player.type, ['article', 'article1024', 'headline', 'headlineVideos', 'TopStory', 'TopStoryWide', 'TopStoryArticle']) >= 0) {
if (yq.inArray(player.type, ['article1024', 'TopStory', 'TopStoryWide', 'TopStoryArticle']) >= 0) {
var linkSrc = window.CmmAppVideoApi.CONST.SendToFriendArticle1024Link;
var width = 525;
var height = 480;
} else {
var linkSrc = window.CmmAppVideoApi.CONST.SendToFriendArticleLink;
var width = 400;
var height = 510;
};
openInnewWindow(linkSrc.replace('TOREPLACE',player.video.articleId),width,height,0);
} else if (player.type=="VideoChannel" || player.type=="galleries") {
openInnewWindow(window.CmmAppVideoApi.CONST.SendToFriendVideoChannelLink.replace('TOREPLACE',player.video.id),400,510,0);
} else {
openInnewWindow(window.CmmAppVideoApi.CONST.SendToFriendLink.replace('TOREPLACE',player.video.id),400,510,0);
};
},
/*Get specific player for event*/
_getCurrentPlayer:function(clipId){
var currClipId = null;
var playerId = null;
yq.each(CmmAppMatrixVideoApi._players, function( index, value ) {
currClipId = CmmAppMatrixVideoApi._players[index].clipId;
//Remove ;x from currClipId
var matrixSemicolon = currClipId.indexOf(';');
if (matrixSemicolon > -1) {
currClipId = currClipId.substr(0, matrixSemicolon);
}
if(currClipId == clipId) {
playerId = CmmAppMatrixVideoApi._players[index].id;
}
});
return playerId;
},
/*Get video id by video clip id*/
_getVideoObject:function(clipId){
var currClipId = null;
var videoID = null;
yq.each(CmmAppMatrixVideoApi._players, function( index, value ) {
currClipId = CmmAppMatrixVideoApi._players[index].clipId;
//Remove ;XX from currClipId
var matrixSemicolon = currClipId.indexOf(';');
if (matrixSemicolon > -1) {
currClipId = currClipId.substr(0, matrixSemicolon);
}
if(currClipId == clipId) {
// videoID = CmmAppMatrixVideoApi._players[index].videoId;
videoID = CmmAppMatrixVideoApi._players[index];
}
});
return videoID;
},
/*Initilizing events handlers*/
_initEventsHandlers:function(player){
/*Complete video clip event*/
yq('.playerContainer' + player.id).bind('complete', function(event, playerId) {
var postScreenHtml = CmmAppMatrixVideoApi._getPostScreenHtml(player);
if(postScreenHtml != ""){
document.getElementById('fpPostScreen'+playerId).innerHTML=postScreenHtml;
document.getElementById('fpPostScreen'+playerId).style.display='block';
var decoration = document.getElementById('fpDecoration'+playerId);
if(decoration){
decoration.style.display='none';
}
}
});
/*On mouse hover event*/
yq('.playerContainer' + player.id).bind('hover', function(event, playerId) {
document.getElementById('fpDecoration' + playerId).style.display = 'block';
if(player.type == 'VideoChannel'){
document.getElementById('fpContent_FacebookButton' + playerId).style.display = 'block';
}
yq('#fpDecorationContent'+ playerId ).stop().animate({
top:0
}, 500);
});
/*On mouse out event*/
yq('.playerContainer' + player.id).bind('out', function(event, playerId) {
if(player.type == 'VideoChannel'){
document.getElementById('fpContent_FacebookButton' + playerId).style.display = 'none';
}
yq('#fpDecorationContent' + playerId).stop().animate({
top:player.decorationHeight
}, 500,function(){
document.getElementById('fpDecoration' + playerId).style.display = 'none';
});
});
},
_checkReportedPopularity:function(player, clipDuration) {
if (player.video.reporetedPopularity == null) {
this._reportPopularity(player, clipDuration);
player.video.reporetedPopularity = true;
}
},
_reportPopularity:function(player, clipDuration) {
var url=this.CONST.PopularityReportStatisticsServer;
url+='?content='+player.video.id;
url+='&type=1';
url+='&time='+Math.round(clipDuration);
url+='&random='+((new Date()).getTime());
(document.createElement('img')).src=url;
},
_matrixPlayerEvents : function (eventName, clipId, time){
// console.log('eventName: ' + eventName + ' clipId: ' + clipId);
switch(eventName) {
case "onLoad": {
this.getSiteType();
break;
}
case "onMouseOver": {
this._launchEvent('hover', clipId);
break;
}
case "onMouseOut": {
this._launchEvent('out', clipId);
break;
}
case "onStart": {
// activate popularity update
var currentPlayerObject = null;
currentPlayerObject = this._getVideoObject(clipId);
this._checkReportedPopularity(currentPlayerObject, time);
break;
}
case "onPause": {
break;
}
case "onPlayerSeek": {
break;
}
case "onComplete": {
this._launchEvent('complete', clipId);
//this._onFinish(clipId, clipId);
break;
}
default: {
break;
}
}
},
_matrixPlayerGetParamValue : function (var_name, video_id, videoCategoryId, page_id){
var param_value = '';
switch(var_name) {
case "showadvertisement": {
isShowAds = this.isVideoShowAds(video_id, videoCategoryId);
if ((isShowAds == 1)) {
isShowAds = true;
} else if (isShowAds == 0) {
isShowAds = false;
} else {
isShowAds = false;
}
param_value = isShowAds;
break;
}
case "custparams": {
param_value = 'dcPath%3D'+window.dcPath;
if (window.dcContentID != undefined) {
param_value += '%26dcContentID%3D'+dcContentID;
}
break;
}
case "gacat": {
param_value = window.dcPath;
break;
}
case "cmsid": {
if (window.dcContentID == undefined) {
param_value = page_id + ' - ' + document.title;
} else {
param_value = window.dcContentID + ' - ' + document.title;
}
break;
}
case "geteventarr": {
param_value = '15;45;90'; //constant value
break;
}
default: {
break;
}
}
return param_value;
},
getSiteType: function(){
if (dcSite == 'yntlo') {
return 'myNet';
} else if (dcSite == 'ynt') {
var isPnaiPlus = dcPath.toLowerCase().search('pnaiplus');
if (isPnaiPlus > -1) {
return 'pnaiplus';
} else {
return 'ynet';
}
}
},
isVideoShowAds: function (video_id, videoCategoryId) {
var res = 0;
yq.ajax({
type: 'GET',
dataType: 'html',
async: false,
url: '/novgnpre/Common/App/Video/matrixPlayer/CmmMatrixAjax?videoId='+video_id+'&channelId='+videoCategoryId,
cache: false,
success: function(data){
res = data;
},
error: function(data,st) {
return -1;
}
});
return res;
},
_getPostScreenButtons:function(player) {
var res = [];
res.push('
');
res.push('
');
res.push('
');
res.push('
');
res.push('
');
return res.join('');
},
_getTopStoryPostScreenHtml:function(player){
var res=[];
res.push('');
res.push('
');
res.push('
');
res.push('
');
res.push('
');
res.push('
');
res.push('
');
return res.join('');
},
_getGalleryScreenHtml:function(player) {
var res = [];
var FacebookShareUrl = CmmAppMatrixVideoApi._getFacebookShareUrl(player);
res.push('');
res.push('
');
res.push('
');
res.push('
');
res.push('
');
res.push('
');
res.push('
');
res.push('
');
if (player.video.relatedVideos && player.video.relatedVideos.length>0) {
for(var i = 0; i < Math.min(player.video.relatedVideos.length, 2); i++) {
var relvid=player.video.relatedVideos[i];
res.push('
');
res.push('
');
res.push('
');
res.push('' + this._htmlescape(relvid.title) + '');
res.push('
');
res.push('
');
res.push('
');
};
};
res.push('
');
res.push('
');
return res.join('');
},
_getVideoChannelPostScreenHtml:function(player){
return this._getArticlePostScreenHtml(player, 80, 40);
},
_getHeadlinePostScreenHtml:function(player){
var res=[];
res.push('');
res.push('
');
res.push(this._getPostScreenButtons(player));
res.push('
');
res.push('
');
return res.join('');
},
_getArticlePostScreenHtml:function(player, relativeWidth, contentMargin){
var res = [];
var textAlign=this.CONST.siteDir=='ltr'? 'left':'right';
res.push('');
res.push('
');
res.push(this._getPostScreenButtons(player));
res.push('
');
res.push('
');
if (player.video.relatedVideos && player.video.relatedVideos.length>0) {
for(var i = 0; i < Math.min(player.video.relatedVideos.length, 2); i++) {
var relvid=player.video.relatedVideos[i];
res.push('
');
res.push('
');
res.push('
');
res.push('' + this._htmlescape(relvid.title) + '');
res.push('
');
res.push('
');
res.push('' + this._htmlescape(relvid.subTitle) + '');
res.push('
');
res.push('
');
res.push('
');
};
};
res.push('
');
res.push('
');
return res.join('');
},
_getPostScreenHtml:function(player){
if(player.type == "article" || player.type == "article1024"){
return this._getArticlePostScreenHtml(player, 90, 0);
} else if(player.type == "headline" || player.type == "headlineVideos"){
return this._getHeadlinePostScreenHtml(player);
} else if(player.type == "hot"){
return "";
//return this._getHotPostScreenHtml(player);
} else if(player.type == "VideoChannel"){
return this._getVideoChannelPostScreenHtml(player);
} else if (player.type == "galleries"){
return this._getGalleryScreenHtml(player);
} else if(player.type == "TopStory" || player.type == "TopStoryWide" || player.type == "TopStoryArticle" || player.type == "articlePnaiPlus"){
return this._getTopStoryPostScreenHtml(player);
} else {
return "";
};
},
_updateSharingFooter:function(player){
var params = player.params;
var yqFooter = yq("div.sharingFooter", yq("div#" + params.destId).parent());
if (!yqFooter.length)
{
return;
}
yq("a.sf_fb", yqFooter).attr("href", this._getFacebookShareUrl(player));
yq("input[name=articleId]", yqFooter).attr("value", params.artId);
// var videoEmbedCode=this.getVideoEmbedCode(player.video);
// if (videoEmbedCode.length>0) {
// yq("textarea.sf_embed_code", yqFooter).attr("value", videoEmbedCode);
// };
},
_stringmap:function(map,str){
for (var i=0;i','>',
String.fromCharCode(39),''',
String.fromCharCode(34),'"'
],str);
},
_getFacebookShareUrl:function(player){
var playerType = player.type;
var video = player.video;
var targetPath = null;
if ((playerType === "article" || playerType === "headline" || player.type == "article1024" || player.type === "VideoChannel") && video.articlePath) {
targetPath = video.articlePath;
} else if ((playerType === "hot" || player.type === "stage") && video.pagePath) {
targetPath = video.pagePath;
} else if ((player.type === "galleries") && video.id) {
targetPath = window.CmmAppVideoApi.CONST.VideoIdChannelSrc.replace('TOREPLACE',video.id);
}
if (targetPath && targetPath.length) {
var loc = window.location;
var fbSharer = new Array("https://www.facebook.com/sharer.php?u=", loc.protocol, "//", loc.hostname, escape(targetPath));
return fbSharer.join('');
} else {
return '';
}
},
_getPnaiPlusDecoration:function(player){
var html = [];
var height = player.decorationHeight;
html.push('');
html.push('
');
html.push('
');
html.push('
'+player.params.matrix_credits+'
');
html.push('
');
html.push('
');
return html.join('');
},
_getVideoChannelDecoration:function(player,height){
var html = [];
var height = player.decorationHeight;
html.push('');
html.push('
');
html.push('
');
html.push('
'+this._htmlescape(player.video.title)+'
');
html.push('
'+this._htmlescape(player.video.subTitle)+'
');
html.push('
');
if(player.video.articlePath) {
if(player.video.articleAuthor) {
html.push(''+this._htmlescape(player.video.articleAuthor)+', ');
};
html.push('פורסם: ');
html.push(''+this._htmlescape(player.video.articleLaunchDate)+' ');
html.push('לכתבה המלאה ');
html.push('('+this._htmlescape(player.video.articleComments)+' תגובות) ');
};
html.push('
');
html.push('
');
html.push('
');
return html.join('');
},
_getHotDecoration:function(player){
var html = new Array();
var height = player.decorationHeight;
html.push("");
html.push("
");
html.push("
");
return html.join('');
},
_getHeadlineDecoration:function(player,height){
var html = [];
var height = player.decorationHeight;
html.push('');
html.push('
');
html.push('
');
html.push('
'+this._htmlescape(player.video.articleTitle)+'
');
html.push('
');
html.push('
לכתבה המלאה...
');
html.push('
'+this._htmlescape(player.video.credits)+'
');
html.push('
');
html.push('
');
html.push('
');
return html.join('');
},
_getArticleDecoration:function(player){
var html = [];
var height = player.decorationHeight;
if (player.params.matrix_credits == undefined) {
player.params.matrix_credits = '';
}
if((player.params.matrix_credits != undefined) && (player.params.matrix_credits != '')){
html.push('');
html.push('
');
html.push('
');
html.push('
'+player.params.matrix_credits+'
');
html.push('
');
html.push('
');
}
return html.join('');
},
_getDecorationHtml:function(player){
if(player.type == 'article' || player.type == 'article1024' || player.type == 'sixColVidXnet'){
return this._getArticleDecoration(player);
} else if(player.type == 'headline'){
return this._getHeadlineDecoration(player);
} else if (player.type === 'hot' || player.type === "stage") {
return this._getHotDecoration(player);
} else if (player.type === 'VideoChannel') {
return this._getVideoChannelDecoration(player);
} else if (player.type === 'articlePnaiPlus') {
return this._getPnaiPlusDecoration(player);
} else {
return '';
};
},
_initDecoration:function(player){
var html = [];
if(player.type == 'article' || player.type == 'article1024' || player.type == 'sixColVidXnet'){
player.decorationHeight = 18;
}else if(player.type == 'headline'){
player.decorationHeight = 42;
} else if (player.type === 'hot' || player.type === 'stage') {
player.decorationHeight = 21;
} else if (player.type === 'VideoChannel') {
player.decorationHeight = 79;
} else if (player.type === 'articlePnaiPlus') {
player.decorationHeight = 48;
};
player.decorationTop = player.decorationHeight + this.CONST.FlowplayerControlBarHeight + 3;
html.push('');
html.push('
');
html.push(this._getDecorationHtml(player));
html.push('
');
html.push('
');
if(player.type === 'VideoChannel'){
var facebookShearingUrl = CmmAppMatrixVideoApi._getFacebookShareUrl(player);
html.push("');
}
return html.join('');
},
_initMatrixContainer:function(player){
var isAudio = this._isAudio(player);
var html = [];
// flash audio player size definition
if (isAudio) {
var width = this.CONST.AudioPlayerDimensions[player.type].width;
var height = this.CONST.AudioPlayerDimensions[player.type].height;
} else {
var width = player.width;
var height = player.height;
}
clipAndPlayer = player.videoId+'_'+player.params.player_type;
url = '/ext/Common/App/Video/matrixPlayer/CmaGetMatrixIframe/0,20035,toReplaceMatrixDetails,00.html';
url = url.replace('toReplaceMatrixDetails',clipAndPlayer);
html.push('');
var containerHtml = '
';
containerHtml += '';
containerHtml += '
';
if (isAudio){
//TODO
} else {
html.push('
');
html.push(containerHtml);
html.push(this._initDecoration(player));
html.push('');
html.push('
');
}
document.getElementById(player.params.destId).innerHTML=html.join('');
player.containerInitialized=true;
if (!isAudio){
this._updateSharingFooter(player);
};
},
_addDecorationConf:function(player,conf){
player.hasDecoration = false;
var decorationTypes = [
'article'
,'article1024'
,'headline'
,'hot'
,'VideoChannel'
,'HomepagePlayer'
,'LightBoxArticlePlayer'
,'stage'
,'TopStory'
,'TopStoryWide'
,'TopStoryArticle'
,'articlePnaiPlus'
];
if(yq.inArray(player.type, decorationTypes) >= 0){
var _this = this;
if(player.type == "article" || player.type == "article1024" || player.type == "articlePnaiPlus"){
if(player.video.credits == ""){
return conf;
};
} else if(player.type == "headline"){
if(player.video.credits == "" && player.video.articleTitle == ""){
return conf;
};
} else if ((player.type === "hot" || player.type === "stage") && !player.video.pagePath) {
return conf;
}
}
player.hasDecoration = true;
player.decorationEnabled = true;
return conf;
},
_getConf:function(player){
var _this=this;
var conf ;
//conf=this._addAdsConf(player,conf);
//conf=this._addClipConf(player,conf);
//conf=this._addControlsConf(player,conf);
if (!player.video.isInvalid) {
if(!player.params.dontShowDecoration){
conf=this._addDecorationConf(player,conf);
}
};
return conf;
},
_isAudio:function(player){
return (player.type.search(/audio/i) != -1);
},
_ajax:{
go:function(A,C){var B=this._gX();if(!B){return}B.open("GET",A,true);B.setRequestHeader("User-Agent","XMLHTTP/1.0");B.setRequestHeader("If-Modified-Since","Fri, 31 Dec 1999 00:00:00 GMT");B.onreadystatechange=function(){if((B.readyState==4)&&((B.status==200)||(B.status==304))){C(B)
}};if(B.readyState==4){return}B.send(null)},_XF:[function(){return new XMLHttpRequest()},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")
}],_gX:function(){var B=false;for(var A=0;A