//Global Omniture namespace+++++++++++++++++++++++++++++++++++++++++++++++++++++++ var $O = {}; //Omniture //handler for flash objects, returns page level omniture data $O.flashOmniParams = function() { try { //check for account value and omniture object existence, //these two must be valid for return object, otherwise //return null if($O.Gerry) { //create return object, copy required values var r = {}; r.account = s_account; r.pageName = s_msn.pageName; r.pageURL = s_msn.pageURL; r.dc = s_msn.dc; r.visitorNamespace = s_msn.visitorNamespace; //copy valid prop and evar values for(var i = 1;i <= 50;i++) { var prop = 'prop' + i; var evar = 'eVar' + i; if (s_msn[prop]) { r[prop] = s_msn[prop]; } if (s_msn[evar]) { r[evar] = s_msn[evar]; } } return r; } return null; } catch(err) { return null; } }; //General error handler for Omniture namespace $O.ErrorHandler = function(e) { //Debug if ($A && $A.Debug) { alert('Error:::' + e); } }; //Global Omniture namespace+++++++++++++++++++++++++++++++++++++++++++++++++++++++ //Omniture.Page namespace+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ $O.P = {}; //page $O.P.GetName = function () { var pn = this.GetType() + '|' + this.GetSection() + '|' + this.GetSubSection() + '|' + this.GetDocID() + '|' + this.GetHeadline(); return pn; }; $O.P.GetType = function() { if (s_msn.prop16) { if (s_msn.prop16.toLowerCase() === 'story') { return 'StoryV2'; } return s_msn.prop16.limit(15); } return ''; }; $O.P.GetSection = function() { if (s_msn.prop4) { return s_msn.prop4.limit(15); } return ''; }; $O.P.GetSubSection = function() { if (s_msn.prop5) { return s_msn.prop5.limit(15); } return ''; }; $O.P.GetDocID = function () { if(s_msn.prop15) { return s_msn.prop15.limit(15); } return ''; }; $O.P.GetHeadline = function() { if(pd_me.h) { return pd_me.h.pd_nou(); } return ''; }; $O.P.GetSlices = function() { //Get module slice list from the page data //quirky nature of initial page load omniture code, the tracking call is called //before quilt is set up, so I don't have the complete module slice information, because the //default text data is processed after the tracking call. Since tracking call is in xsl, //it has sitewide implications, and not worth the effort. //Thereby, this captures the slice data from the initial page load moduledata, and determines //whether default text is in the slice list, if not then assumes the first slice is default text. var sl = []; var defTextInList = false; if(msnbc && msnbc.document && msnbc.document.moduleData) { var md = msnbc.document.moduleData; $.each(md, function(i,value) { $.each(value,function(n,val) { if (val && val.type) { var sType = val.type.toString(); sl.push(sType); if(sType.toLowerCase().indexOf('defaulttext') >= 0) { defTextInList = true; } } }); }); } var slt = ''; if(!defTextInList) { slt = 'DefaultText'; } $.each(sl, function(i, value) { if(!defTextInList || i > 0) { slt += '|'; } slt += value.toString().limit(15); }); return slt.limit(100); }; //Omniture.Page namespace+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //Omniture.Track namespace+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ $O.T = {}; $O.T.GetModuleData = function (md) { var rd = ''; if (md) { rd = $O.P.GetType().limit(10) + '|' + $O.P.GetSection().limit(10) + '|' + $O.P.GetDocID().limit(10) + '|' + $O.P.GetHeadline().limit(20); $.each(md, function (name,value) { if(name === 'last') { rd += ('|' + value.trim()); } else { rd += ('|' + value.limit(15)); } }); } return rd.limit(100); }; $O.T.GetPageViewData = function (pv) { var rd = ''; if (pv) { var first = true; $.each(pv, function (name,value) { if(name === 'last' && first) { rd += value.trim(); first = false; } else if(name === 'last') { rd += ('|' + value.trim()); } else if (first) { rd += (value.limit(15)); first = false; } else { rd += ('|' + value.limit(15)); } }); } return rd.limit(100); }; $O.T.GetNonPageViewData = function (npv) { var rd = ''; if (npv) { var first = true; $.each(npv, function (name,value) { if(name === 'last' && first) { rd += value.trim(); first = false; } else if(name === 'last') { rd += ('|' + value.trim()); } else if (first) { rd += (value.limit(20)); first = false; } else { rd += ('|' + value.limit(20)); } }); } return rd.limit(100); }; //validate the property name //whitelist the omniture properties that can be changed // $O.T.ValidName = function(name) { //prop1 to prop50, eVar1 to eVar50 can be changed. //May only be certain prop values, like prop35??? //use regular expression to check for prop1 - prop50 range //change to eVar var re1 = new RegExp('^eVar([1-9]|[1-4][0-9]|50)$'); var re2 = new RegExp('^prop([1-9]|[1-4][0-9]|50)$'); if(name.match(re1) || name.match(re2)) { return true; } return false; }; //omniture handler for modules with javascript object driven configuration processing. $O.T.OmniDataHandler = function(e) { var beacon = false; for(var p in e) { //check valid property name, overwrite/append new values if ($O.T.ValidName(p)) { s_msn[p] = e[p]; beacon = true; } } return beacon; }; //Omniture.Track namespace+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //Omniture.Gerry namespace++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //This is the public interface for event handlers $O.G = {}; //Gerry namespace $O.G.PageExit = function(pe) { var str = $O.G.GetProp27(pe); //set cookie, enable multiple suite processing SetCookie('lt', str); //Debug if ($A && $A.Debug) { $A.DebugHandler('Cookie:lt === ' + str); } }; //General event interface for processing omniture page view calls //pass in null for p27, if no module tracking $O.G.PageView = function(p27, p35, ev7) { var beacon = false; var t = {}; if (p27 || p35) { if(p27) { t.prop27 = $O.G.GetProp27(p27); } if(p35) { t.prop35 = $O.G.GetProp35(p35); } beacon = $O.T.OmniDataHandler(t); } //update only if beacon is dirty //t() increments page view count for this page name if(beacon) { try { //call t() function that does increment page view counter s_msn.t(); } catch(e) { $O.ErrorHandler(e); } finally { //remover prop assignments s_msn.prop27 = ''; s_msn.prop35 = ''; } } //Debug if ($A && $A.Debug) { var pp = 'prop27 === ' + t.prop27 +' ::: prop35 === ' + t.prop35; $A.DebugHandler(pp); } }; $O.G.NonPageView = function (ev2,ev7) { //intentionally blank for change request }; //slice useage handler $O.G.SliceUse = function (ev7) { //intentionally blank for change request }; //helper method to get text from html elements $O.G.GetText = function (et) { var str = ''; if(!et) { return str; } if(et.alt) { str = et.alt; } else if(et.text) { str = et.text; } else if(et.textContent) { str = et.textContent; } else if (et.innerText) { str = et.innerText; } return str; }; //prop adn evar helpers $O.G.GetProp27 = function(md) { return $O.T.GetModuleData(md); }; $O.G.GetProp35 = function(pv) { return $O.T.GetPageViewData(pv); }; $O.G.GetEvar1 = function(t) { return s_msn.pageName; }; $O.G.GetEvar2 = function(npv) { //return non page view data return $O.T.GetNonPageViewData(npv); }; $O.G.GetEvar6 = function() { //return slices data return $O.P.GetSlices(); }; $O.G.GetEvar7 = function(ev7) { //return non page view data return $O.T.GetNonPageViewData(ev7); }; //This runs before the s_account assignment, and readCookie for multiple suite processing $O.G.PreInit = function () { if (typeof(SetCookie)==='function') { //set cookie, enable multiple suite processing SetCookie('o.sv2', 'true', 'session'); } }; //This executes after omniture object is created, right after pd_om() function exits. $O.G.Init = function() { $O.Gerry = true; //Default Gerry state is true //check if s_msn exists, preview mode doesn't have s_msn //s_msn must exist for Gerry //also if preview mode, set gerry to false if (typeof(s_msn) === 'undefined' || $O.Preview) { $O.Gerry = false; } if ($O.Gerry) { s_msn.pageName = $O.P.GetName(); s_msn.prop16 = 'StoryV2'; } }; //This executes after omniture call and page is ready. $O.G.PageReady = function() { if($O.Gerry) { //intentionally blank for change request } }; $O.CheckPreview = function() { $O.Preview = false; //Default preview state is false var p = window.location.toString(); if( p.indexOf('workarea=') >= 0 && p.indexOf('previewmode=')>=0) { $O.Preview = true; } }; $O.CheckPreview();