';
$pdk.NBCplayer.GetMainContainer();
var playerContainer = $pdk.NBCplayer.mainPlayerDiv;
if (playerContainer.length < 1) {
console.error('AdContainers:: Main container not found!');
}
playerContainer.after('
' + this.fw300x60adHTML + '
');
playerContainer.after('
' + this.fw300x250adHTML + '
');
this.adContainer300x60 = $('#' + $pdk.NBCplayer.playerDivContainers.ad300x60);
this.adContainer300x250 = $('#' + $pdk.NBCplayer.playerDivContainers.ad300x250);
if ($pdk.NBCplayer.playerMode == "show") {
this.adContainer300x60.addClass('showPlayer');
this.adContainer300x250.addClass('showPlayer');
}
if (this.adContainer300x60.length > 0) {
this.adContainer300x60.hide();
this.adContainer300x250.hide();
}
},
reassign300x60: function (child) {
try {
if (!child) {
child = "TPVideoPlayerPlaylistTitle";
}
var tpva3x6 = document.getElementById("TPVideoPlayerAd300x60");
var tpvppt = document.getElementById(child);
var tpparent = tpvppt.parentNode;
tpparent.appendChild(tpva3x6);
}
catch (e) {
}
},
setAdPosition: function (mode) {
//console.log('setAdPositon:: ',mode);
switch (mode) {
case "mobile":
if (this.adContainer300x250) {
this.adContainer300x250.hide();
}
if (this.adContainer300x60) {
this.adContainer300x60.hide();
}
//$('#TPVideoPlayerAd300x60').prependTo('#TPVideoPlayerMeta');
break;
case "tablet":
this.reassign300x60();
break;
case "tablet-landscape":
this.reassign300x60();
break;
default:
this.reassign300x60("TPVideoMainPlaylist");
//$('#TPVideoPlayerAd300x60').insertAfter('#TPVideoMainPlaylist');
break;
}
},
AdListener: function (e) {
if (e.evt == "AdStart") {
//console.error('AdStart');
this.adIsRunning = true;
//this.FadeIn300x250();
//this.FadeOut300x60();
}
if (e.evt == "AdComplete") {
//console.error('ad complete');
this.adIsRunning = false;
//this.FadeOut300x250();
//this.FadeIn300x60();
}
},
Hide300x250: function () {
if (this.adContainer300x250.length > 0) {
this.adContainer300x250.hide();
}
},
Hide300x60: function () {
if (this.adContainer300x60.length > 0) {
this.adContainer300x60.hide();
}
},
FadeIn300x250: function () {
if (this.adContainer300x250.length > 0) {
//console.error('FadeIn300x250');
this.adContainer300x250.css('opacity', 0);
this.adContainer300x250.show();
this.adContainer300x250.fadeTo(2000, 1);
}
},
FadeOut300x250: function () {
var context = this;
if (this.adContainer300x250.length > 0) {
//console.error('FadeOut300x250');
context.adContainer300x250.fadeTo("slow", 0, function () {
$(this).hide();
context.adContainer300x250.html(context.fw300x250adHTML);
});
}
},
FadeIn300x60: function () {
if ($pdk.NBCplayer.displayMode != "mobile") {
if (this.adContainer300x60.length > 0) {
//console.error('FadeIn300x60');
this.adContainer300x60.css('opacity', 0);
this.adContainer300x250.show();
this.adContainer300x60.fadeTo(2000, 1);
}
}
},
FadeOut300x60: function () {
if (this.adContainer300x60.length > 0) {
//console.error('FadeOut300x60');
this.adContainer300x60.fadeTo("slow", 0, function () { $(this).hide(); });
}
},
FreeWheelEvents: function (e) {
//console.log('FreewheelEvent: ',e);
},
OnAdClickEvent: function (e) {
//console.log('OnAdClickEvent',e);
}
};
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
var AimsSizes = {
"16x9": {
id: "16x9",
wRatio: (9 / 16),
hRatio: (16 / 9),
aimssizes:
[{ id: "video_115x65", width: 115, height: 65 },
{ id: "video_200x113", width: 200, height: 113 },
{ id: "video_320x180", width: 320, height: 180 },
{ id: "video_560x315", width: 560, height: 315}]
},
"3x4": {
id: "3x4",
wRatio: (3 / 4),
hRatio: (4 / 3),
aimssizes:
[{ id: "video-260x195", width: 260, height: 195 },
{ id: "video_640x480", width: 640, height: 480 },
{ id: "video_1280x960", width: 1280, height: 960}]
},
"thumb": {
id: "thumb",
wRatio: (3 / 4),
hRatio: (4 / 3),
aimssizes:
[{ id: "thumb-m", width: 92, height: 69}]
}
};
var VPMSNBCAimsImager = function (owner) {
this.image = "";
this.expectedType = "16x9";
this.responsive = false;
this.fillToOwner = true;
this.resizeOwner = false;
this.create = function (src, w, h) {
this.image = document.createElement("img");
var obj = this.getBestFit(w, h);
obj.src = src;
obj.id = this.aimsByWidth(obj.width);
this.sizeImage(obj);
owner.appendChild(this.image);
if (this.responsive) {
var currentResizeMethods = window.onresize;
var resizeContext = this;
window.onresize = function (e) {
resizeContext.resize();
if (currentResizeMethods) {
currentResizeMethods(e);
}
}
}
};
this.resizeMethod = function (obj) { };
var context = this;
this.resize = function () {
if (!this.inresize) {
this.inresize = true;
var width = owner.clientWidth;
var height = owner.clientHeight;
if (!this.fillToOwner) {
var width = $pdk.NBCplayer.playerWidth(); //(window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth);
var height = $pdk.NBCplayer.playerHeight(); //(window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight); \
}
var obj = this.getBestFit(width, height);
obj.id = this.aimsByWidth(obj.width);
this.preSizeImage();
this.sizeImage(obj);
if (this.resizeOwner) {
owner.style.width = obj.width;
owner.style.height = obj.height;
}
this.resizeMethod(obj);
setTimeout(function () {
context.inresize = false;
}, 100);
}
};
this.sizeImage = function (obj) {
var replaceText;
if (!obj.src) {
replaceText = this.image.src;
}
else {
replaceText = obj.src;
}
// supperfast snapy quick fix -- need to rewrite
var origImage = replaceText;
var preText = replaceText.substr(replaceText.lastIndexOf("/"));
var postText = preText.substr(preText.indexOf("."));
replaceText = replaceText.replace(postText, "." + obj.id + ".jpg");
replaceText = replaceText.replace(/\/i\//, "\/j\/");
testNonAims = $pdk.NBCplayer.DataStoreModule.ConvertToFixedAims(origImage);
if (testNonAims == origImage) {
replaceText = origImage;
}
if (testNonAims.indexOf('/vocativ/') > 0) {
replaceText = testNonAims;
}
this.image.src = replaceText;
this.image.width = obj.width;
this.image.height = obj.height;
if (this.resizeOwner) {
owner.style.width = obj.width;
owner.style.height = obj.height;
}
this.resizeMethod(obj);
};
this.preSizeImage = function () {
this.image.width = 10;
this.image.height = 10;
if (this.resizeOwner) {
owner.style.width = 10;
owner.style.height = 10;
}
};
this.getBestFit = function (width, height) {
var ratio = this.getRatio();
var rObj = { height: height, width: width };
if (ratio.hRatio > ratio.wRatio) {
rObj.height = Math.round(width * ratio.wRatio);
}
else {
rObj.width = Math.round(height * ratio.hRatio);
}
if (rObj.width > width) {
rObj.width = width;
rObj.height = Math.round(width * ratio.wRatio);
}
if (rObj.height > height) {
rObj.height = height;
rObj.width = Math.round(height * ratio.hRatio);
}
return rObj;
};
this.getRatio = function () {
return (AimsSizes[this.expectedType]) ? AimsSizes[this.expectedType] : AimsSizes["16x9"];
};
this.aimsByWidth = function (width) {
var aimz = this.getRatio().aimssizes;
for (var i in aimz) {
if (aimz[i].width > width) {
return aimz[i].id;
break;
}
}
return aimz[aimz.length - 1].id;
};
};
var VPNBCShowPlayerTaxonomyModule = {
version: "5/28/2013 1t",
feedList: [],
renderTaxonomyList: function () {
if ($pdk.NBCplayer.showSource) {
this.RequestList($pdk.NBCplayer.showSource);
} else {
if ($pdk.NBCplayer.debug) {console.error('no source specified using default'); }
this.RequestList('test');
}
//showLists.hide();
},
RequestList: function (sourceName) {
//var urlList = "http://www.nbcnews.com/id/52024383&callback=$pdk.NBCplayer.ShowPlayerTaxonomy.GetList";
var urlList = "http://data.nbcnews.com/VideoRendering/PlaylistTemplate/" + sourceName + "?jsoncallback=$pdk.NBCplayer.ShowPlayerTaxonomy.GetList";
if ($pdk.NBCplayer.debug) {
urlList += "&cb=" + Math.floor(Math.random() * 80003);
}
$pdk.NBCplayer.DebugLog(':::::Requesting Taxonomy from ', urlList);
$.ajax({
type: "GET",
url: urlList,
async: false,
cache: true,
dataType: "script",
crossDomain: true,
error: function (xhr, textStatus, errorThrown) {
$pdk.controller.dispatchEvent('NBCplayerOnFeedError', errorThrown);
//alert(errorThrown);
}
});
},
GetList: function (data) {
//console.log('GetList:: ');
//console.log(data);
var showListDiv = $('#' + $pdk.NBCplayer.playerDivContainers.showPlaylists);
if (showListDiv.length < 1) {
//console.log('Mode is show and no playlistcontainer - creating it');
$('body').prepend('');
showListDiv = $('#' + $pdk.NBCplayer.playerDivContainers.showPlaylists);
}
$('#TPVideoPlaylistTaxonomyContainer').after('');
var mobileShowList = $('#mobileTaxonomy');
var oneItem = '
Name
';
var mobileOneItem = ''
showListDiv.html('');
//var firstline = "";
//showListDiv.append(firstline);
var itemSelected = 0;
var itemindex = 0;
if (data.playlistTaxonomy) {
for (var i = 0; i < data.playlistTaxonomy.length; i++) {
iType = data.playlistTaxonomy[i].type;
switch (iType) {
case "item":
menuName = data.playlistTaxonomy[i].reference.name;
feedId = data.playlistTaxonomy[i].reference.feed;
this.feedList[itemindex] = feedId;
itemClass = data.playlistTaxonomy[i].reference.id;
newItem = oneItem.replace('Name', menuName).replace('FeedId', feedId);
mobileNewItem = mobileOneItem.replace('Name', menuName).replace('FeedId', feedId);
showListDiv.append(newItem);
mobileShowList.append(mobileNewItem);
$('#TPVideoPlaylistTaxonomyContainer .' + feedId).parent().parent().bind('click', function (e) {
// Triggers select box. Keeping div menu for legacy purposes
$('#mobileTaxonomy').val($(this).find('div')[1].className).change();
$('#TPVideoPlaylistTaxonomyContainer .showTaxListItem').removeClass('selected');
$(this).addClass('selected');
});
if (itemSelected == itemindex) {
$('#TPVideoPlaylistTaxonomyContainer .' + feedId).parent().parent().addClass('selected');
}
itemindex++;
break;
}
}
$('#mobileTaxonomy').bind('change', function (e) {
pid = $("select option:selected").attr('value');
$pdk.NBCplayer.LoadNewFeed(pid);
});
} else {
//console.error('unable to load playlistTaxonomy');
}
//console.log('sourceFeed ',this.feedList[0]);
$pdk.NBCplayer.SetVideoHeight();
$pdk.NBCplayer.SetFeedURL(this.feedList[0]);
$pdk.NBCplayer.GetPlayerData();
}
};
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
var VPNBCReportModule = {
report0: true,
reportAd0: true,
report25: true,
report50: true,
report75: true,
report999: true,
reportStart: true,
reportEnd: true,
reportAdStart: true,
reportAdEnd: true,
currentTime: 0,
cc: false,
fullscreen: false,
Init: function () {
},
report: function (evtObj) {
evtObj.fullscreen = this.fullscreen;
evtObj.closedCaption = this.cc;
evtObj.duration=this.duration;
evtObj.canonoical = $pdk.NBCplayer.DataStoreModule.canonical;
$pdk.controller.dispatchEvent("NBCplayerReport", evtObj);
},
reportOnStart: function (adRunning) {
// var eventData = { reportType: (adRunning) ? "videoAdStart" : "videoStart",
// time: 0
// }
// this.report(eventData);
},
reportOnEnd: function (adRunning) {
adIsRunning=$pdk.NBCplayer.isCurrentlyAd;
if (adIsRunning){return;}
var eventData = { reportType: (adRunning) ? "videoAdEnd" : "videoEnd",
time: this.currentTime
}
this.report(eventData);
},
reportPause: function (adRunning) {
adIsRunning=$pdk.NBCplayer.isCurrentlyAd;
var eventData = {
reportType: (adRunning) ? "videoAdPause" : "videoPause",
time: this.currentTime
}
this.report(eventData);
},
playerError: function (eType, eMsg) {
var eventData = {
reportType: "playerError",
errorType: eType,
errorMsg: eMsg,
time: this.currentTime
}
this.report(eventData);
},
reportScrub: function () {
var eventData = {
reportType: "videoScrub",
time: this.currentTime
}
this.report(eventData);
},
reportOnTime: function (e, adIsRunning) {
adIsRunning=$pdk.NBCplayer.isCurrentlyAd;
try {
var context = this;
var percent = e.data.percentComplete;
context.currentTime = e.data.currentTime;
context.duration=e.data.duration;
var eventData = {
time: context.currentTime
};
if ($pdk.NBCplayer.DataStoreModule.videoType == "live" && !adIsRunning) {
percent = 0.1;
}
switch (true) {
case (!adIsRunning) && context.report999 && (percent > 99.8):
context.report999 = false;
eventData.reportType = "video100Complete";
context.report(eventData);
break;
case (adIsRunning) && context.reportAdEnd && (percent > 90):
context.reportAdEnd = false;
eventData.reportType = "videoAdEnd";
setTimeout(function(){$pdk.NBCplayer.isCurrentlyAd=false;},3000);
context.report(eventData);
break;
case (!adIsRunning) && context.report75 && (percent > 74):
context.report75 = false;
eventData.reportType = "video75Complete";
context.report(eventData);
break;
case (!adIsRunning) && context.report50 && (percent > 49):
context.report50 = false;
eventData.reportType = "video50Complete";
context.report(eventData);
break;
case (!adIsRunning) && context.report25 && (percent > 24):
context.report25 = false;
eventData.reportType = "video25Complete";
context.report(eventData);
break;
case (percent > 0):
if (!adIsRunning) {
if (context.report0) {
context.report0 = false;
var eventData = {
reportType: "videoStart",
time: 0
}
context.report(eventData);
}
}
else {
if (context.reportAd0) {
context.reportAd0 = false;
var eventData = {
reportType: "videoAdStart",
time: 0
}
context.report(eventData);
}
}
break;
}
} catch (err) {
// nothing
}
},
setFullscreen: function () {
this.fullscreen = !this.fullscreen;
},
setCC: function () {
this.cc = !this.cc;
},
reset: function () {
this.report0 = true;
this.reportAd0 = true;
this.report25 = true;
this.report50 = true;
this.report75 = true;
this.report999 = true;
this.reportStart = true;
this.reportEnd = true;
this.reportAdStart = true;
this.reportAdEnd = true;
this.currentTime = 0;
}
};
var VPNBChashCheck = {
change: 0,
original: ";",
grabHash: function () {
var z = location.hash;
if (z != this.original && z != "#") {
var asplit=z.split("-");
z=asplit[0];
var wdth=asplit[1];
if (z){
console.log(z);
}
if (z == "#resetvideo") {
location.hash = "#";
setTimeout(function(){
$pdk.NBCplayer.SetVideoHeight(wdth);
$pdk.controller.pause(true);
},100);
}
else{
if (wdth) {
if (!isNaN(parseInt(wdth,10))){
$pdk.NBCplayer.SetVideoHeight(parseInt(wdth,10));
}
}
}
if (z == "#pause") {
$pdk.controller.pause(true);
location.hash = "#";
}
if (z == "#play") {
$pdk.controller.pause(false);
location.hash = "#";
}
if (z == "#embed") {
$pdk.controller.pause(true);
location.hash = "#";
}
}
var context = this;
setTimeout(function () {
context.grabHash();
}, 200);
}
};
var VPNBCmessaging = {
loading: {},
loadItem: {},
loadingOnMessage: { restStateRendered: false, startPlayback: true },
loadImage: "http://media4.s-nbcnews.com/i/MSNBC/Components/Video/_Player/configurations/thePlatform/assets/pinwheel4.gif",
init: function (render) {
this.loadItem = document.createElement("div");
var imgdiv = document.createElement("div");
var img = document.createElement("img");
img.width = 128;
img.height = 40;
imgdiv.style.width = "128px";
imgdiv.style.height = "40px";
imgdiv.style.top = "50%";
img.src = this.loadImage;
imgdiv.style.margin = "auto";
imgdiv.style.position = "relative";
imgdiv.appendChild(img);
this.loadItem.appendChild(imgdiv);
this.loadItem.style.position = "absolute";
this.loadItem.style.top = "0px";
this.loadItem.style.left = "0px";
this.loadItem.style.width = "100%";
this.loadItem.style.height = "100%";
this.loadItem.style.zIndex = "999999";
this.loadItem.style.background = "black";
this.loadItem.setAttribute("id","TPVideoPlayerLoading");
render.appendChild(this.loadItem);
},
reassign: function (owner) {
try{
owner.appendChild(this.loadItem);
}
catch(errrrr){
}
},
loadInactive: function () {
if (this.loadItem && this.loadItem.style){
this.loadItem.style.display = "none";
}
},
loadActive: function () {
if (this.loadItem && this.loadItem.style){
this.loadItem.style.display = "block";
}
},
Message: function (m) {
if (this.loadingOnMessage[m]) {
this.loadActive()
}
else {
this.loadInactive();
}
}
}
var VPNBCccSupport = {
init: function () {
$('#TPVideoPlayerContainer .tpContainer').after(this.ui());
},
onPDKInitiazed: function () {
$pdk.controller.addPlayerCard("forms", "tpSubtitleStylesCard", document.getElementById("tpSubtitleStylesCard").outerHTML, "urn:theplatform:pdk:area:player", {title: 'CC Settings', instructions: "Edit your caption styles below", apply: 'Apply', close: 'Close'}, $pdk.NBCplayer.CCSupport.presenter, 100);
},
onCCPreview: function(release) {
var durationCheck = (isNaN(release.duration)) ? -1 : release.duration;
if (durationCheck < 1) {
return true;
}
if (release.captions.length > 0) {
return true;
}
else {
return false;
}
},
onCCMedia: function(clip) {
var durationCheck = (isNaN(clip.baseClip.duration)) ? -1 : clip.baseClip.duration;
if (durationCheck < 1) {
return true;
}
if (clip.baseClip.availableSubtitles.length > 0) {
return true;
}
else {
return false;
}
},
setReleaseCall: function () {
var val = document.getElementById('url').value;
$pdk.controller.setReleaseURL(val);
},
presenter: {
show: function(initVars)
{
var me = this;
this.card = initVars.card;
this.initVars = initVars;
if (!this.controller)
{
this.controller = initVars.controller;
if (!this.loadedLanguage || !this.loadStyles)
{
this.card.style.display = "none";
}
this.listeners = {};
}
$pdk.jQuery(this.card).find(".tpFormActions .tpButton").click(function() {
me.apply();
})
$pdk.jQuery(this.card).find(".tpFontColor").click(function(e)
{
$pdk.jQuery(me.card).find(".tpFontColor").css('border-color', '');
$pdk.jQuery(e.target).css('border-color', "#FFFFFF");
var color;
try {
color = me.colorToHex($pdk.jQuery(this).css('background-color'));//.attr('style').split(": ")[1];
}
catch (e)
{
color = "";
}
$pdk.jQuery(me.card).find("#fontColor").val(color);
}
);
$pdk.jQuery(this.card).find(".tpFontBackgroundColor").click(function(e)
{
$pdk.jQuery(me.card).find(".tpFontBackgroundColor").css('border-color', '');
$pdk.jQuery(e.target).css('border-color', "#FFFFFF");
var color = $pdk.jQuery(this).css('background-color');
if (color == "rgba(0, 0, 0, 0)")
{
color = null;
}
else
{
color = me.colorToHex(color);
}
$pdk.jQuery(me.card).find("#backgroundColor").val(color);
}
);
$pdk.jQuery(this.card).find(".tpFontEdgeColor").click(function(e)
{
$pdk.jQuery(me.card).find(".tpFontEdgeColor").css('border-color', '');
$pdk.jQuery(e.target).css('border-color', "#FFFFFF");
var color = me.colorToHex($pdk.jQuery(this).css('background-color'));
$pdk.jQuery(me.card).find("#fontEdgeColor").val(color);
}
);
if (!this.listeners.lang)
{
initVars.controller.addEventListener("OnGetSubtitleLanguage", this.listeners.lang = function (e) { me.loadLanguage(e) });
initVars.controller.addEventListener("OnGetSubtitleStyle", this.listeners.style = function (e) { me.loadStyles(e) });
}
// initVars.controller.addEventListener("OnSubtitleCuePoint", this.listeners.cue = function(e) { me.cuePoint(e) });
this.loadedStyles = false;
this.loadedLanguage = false;
$pdk.controller.getSubtitleStyle();
$pdk.controller.getSubtitleLanguage();
},
hide: function()
{
initVars.controller.removeEventListener("OnGetSubtitleLanguage", this.listeners.lang);
initVars.controller.removeEventListener("OnGetSubtitleStyle", this.listeners.style);
// $pdk.controller.removeEventListener("OnSubtitleCuePoint", this.listeners.cue);
},
colorToHex: function(color) {
if (!color) return;
if (color.substr(0, 1) === '#') {
return color;
}
var digits = /(.*?)rgb\((\d+), (\d+), (\d+)\)/.exec(color);
if (!digits)
{
digits = /(.*?)rgba\((\d+), (\d+), (\d+), (\d+)\)/.exec(color);
}
if (!digits || digits.length < 5) return;
var red = parseInt(digits[2]);
var green = parseInt(digits[3]);
var blue = parseInt(digits[4]);
var rgb = blue | (green << 8) | (red << 16);
return "#" + (0x1000000 | rgb).toString(16).substring(1);
// return digits[1] + '#' + rgb.toString(16);
},
loadStyles: function(e)
{
if (e.data)
{
this.loadedStyles = true;
if (e.data.fontSize == 0 || isNaN(e.data.fontSize))
{
$pdk.jQuery(this.card).find("#fontSize")[0].value = "";
}
else
{
$pdk.jQuery(this.card).find("#fontSize")[0].value = (isNaN(e.data.fontSize) || e.data.fontSize == null ? "5" : e.data.fontSize);
}
$pdk.jQuery(this.card).find("#fontColor")[0].value = e.data.fontColor;
$pdk.jQuery(this.card).find("#fontFamily")[0].value = (e.data.fontFamily ? e.data.fontFamily : "");
$pdk.jQuery(this.card).find("#fontEdge")[0].value = (e.data.fontEdge ? e.data.fontEdge : "");
$pdk.jQuery(this.card).find("#fontEdgeColor")[0].value = e.data.fontEdgeColor;
$pdk.jQuery(this.card).find("#backgroundColor")[0].value = e.data.backgroundColor;
$pdk.jQuery(this.card).find("#opacity")[0].value = (isNaN(e.data.opacity) || e.data.opacity == null ? "100" : e.data.opacity);
$pdk.jQuery(this.card).find("#padding")[0].value = (isNaN(e.data.padding) || e.data.padding == null ? "0" : e.data.padding);
$pdk.jQuery(this.card).find("#bold")[0].checked = Boolean(e.data.bold);
$pdk.jQuery(this.card).find("#italic")[0].checked = Boolean(e.data.italic);
$pdk.jQuery(this.card).find("#underline")[0].checked = Boolean(e.data.underline);
$pdk.jQuery(this.card).find("#textAlign")[0].value =(e.data.textAlign ? e.data.textAlign : "");
$pdk.jQuery(this.card).find("#textAlignVertical")[0].value = (e.data.textAlignVertical ? e.data.textAlignVertical : "");
var me = this;
var tiles = $pdk.jQuery(this.card).find('.tpFontColor');
var found = false;
for (var i=0; i';
$m += '