HiddenEye-Legacy/WebPages/playstation/sony_playstation_files/unifiedfooter.en-gb.js.download

613 lines
40 KiB
Plaintext
Raw Normal View History

2019-10-30 03:14:29 +08:00
(function () {
'use strict';
// Add indexOf to Array
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function (elt) {
var len = this.length >>> 0;
var from = Number(arguments[1]) || 0;
from = (from < 0)
? Math.ceil(from)
: Math.floor(from);
if (from < 0) {
from += len;
}
for (; from < len; from++) {
if (from in this && this[from] === elt) {
return from;
}
}
return -1;
};
}
var BrowserDetect = {
init: function () {
this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "an unknown version";
this.OS = this.searchString(this.dataOS) || "an unknown OS";
},
searchString: function (data) {
for (var i = 0; i < data.length; i++) {
var dataString = data[i].string;
var dataProp = data[i].prop;
this.versionSearchString = data[i].versionSearch || data[i].identity;
if (dataString) {
if (dataString.indexOf(data[i].subString) !== -1)
return data[i].identity;
}
else if (dataProp)
return data[i].identity;
}
},
searchVersion: function (dataString) {
var index = dataString.indexOf(this.versionSearchString);
if (index >= 0)
return parseFloat(dataString.substring(index + this.versionSearchString.length + 1));
},
dataBrowser: [
{
string: navigator.userAgent,
subString: "Chrome",
identity: "Chrome"
},
{ string: navigator.userAgent,
subString: "OmniWeb",
versionSearch: "OmniWeb/",
identity: "OmniWeb"
},
{
string: navigator.vendor,
subString: "Apple",
identity: "Safari",
versionSearch: "Version"
},
{
prop: window.opera,
identity: "Opera",
versionSearch: "Version"
},
{
string: navigator.vendor,
subString: "iCab",
identity: "iCab"
},
{
string: navigator.vendor,
subString: "KDE",
identity: "Konqueror"
},
{
string: navigator.userAgent,
subString: "Firefox",
identity: "Firefox"
},
{
string: navigator.vendor,
subString: "Camino",
identity: "Camino"
},
{ // for newer Netscapes (6+)
string: navigator.userAgent,
subString: "Netscape",
identity: "Netscape"
},
{
string: navigator.userAgent,
subString: "MSIE",
identity: "Explorer",
versionSearch: "MSIE"
},
{
string: navigator.userAgent,
subString: "Gecko",
identity: "Mozilla",
versionSearch: "rv"
},
{ // for older Netscapes (4-)
string: navigator.userAgent,
subString: "Mozilla",
identity: "Netscape",
versionSearch: "Mozilla"
}
],
dataOS: [
{
string: navigator.platform,
subString: "Win",
identity: "Windows"
},
{
string: navigator.platform,
subString: "Mac",
identity: "Mac"
},
{
string: navigator.userAgent,
subString: "iPhone",
identity: "iPhone/iPod"
},
{
string: navigator.platform,
subString: "Linux",
identity: "Linux"
}
]
};
BrowserDetect.init();
/**
* Global SNEI Unified Footer Object
* Only variable that bleeds to the global namespace to be accessible
*
* @type {}
*/
window.SNEIUnifiedFooter = {
// Variables that can be set indirectly using the corresponding data- attribute
isResponsive: "1",
openLinksInNewWindow: "0",
displayCookieWarning: "1",
displayBrowserWarning: "0",
containerId: "footerContainer",
useDefaultCss: "1",
callbackFuncName: null,
onRenderFuncName: null,
includeSonyFont: "0",
// Internal
footerJSON: {},
baseCSS: "@font-face{font-family:\"Sony-Icons-Footer\";src:url(\"data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAAj8AA4AAAAADOgAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAABRAAAABoAAAAcb9jBWkdERUYAAAFgAAAAHQAAACAANgAET1MvMgAAAYAAAABKAAAAYEBt3XVjbWFwAAABzAAAAEIAAAFCAA/0AGN2dCAAAAIQAAAABAAAAAQAEQFEZ2FzcAAAAhQAAAAIAAAACP//AANnbHlmAAACHAAABJMAAAX02VgoL2hlYWQAAAawAAAALgAAADYHf5LBaGhlYQAABuAAAAAdAAAAJAPtAeNobXR4AAAHAAAAACAAAAAkC+cAEWxvY2EAAAcgAAAAFAAAABQDsAWubWF4cAAABzQAAAAgAAAAIABXAO9uYW1lAAAHVAAAAWkAAAMDaRdkAnBvc3QAAAjAAAAAOgAAAGTUudjPeJxjYGBgZACCk535hiD6svpKERgNAD0pBWIAAHicY2BkYGDgA2IJBhBgYmAEQg4gZgHz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AAcAAQAIAAAAAQABAABAADwVf//AADwUP//D7MAAQAAAAAAAAEGAAABAAAAAAAAAAECAAAAAgAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
responsiveCSS: "@media (max-width: 47.9375em){.snei-label{padding:10px 20px;background:#494949;margin-bottom:0;font-size:1em}.snei-list li{margin:0;border-top:1px solid #454545}.snei-list li:first-child{border-top:none}.snei-list a{display:block;padding:10px 20px}.snei-container,.snei-grid{padding:0;width:auto}.snei-column-services,.snei-column-store,.snei-column-account,.snei-column-legal,.snei-column-sen{margin:0;padding:0;float:none;width:auto}.snei-column-sen{padding-bottom:20px}.snei-column-sen .snei-label{margin:0}.snei-column-sen .snei-label br{display:none}.snei-column-sen .snei-list{margin:0;font-size:1em}.snei-column-sen .snei-list li{float:none;margin:0}.snei-social,.snei-country-selector{margin:10px 20px 0}}#cookieWarningMessage{left:0;bottom:-125px;position:fixed;text-align:center;width:100%;background:#000;background:rgba(0,0,0,0.9);border-top:1px solid #000000;z-index:999999;padding:25px 50px 25px 15px;font-size:14px;-webkit-box-shadow:0 -1px 3px rgba(0,0,0,0.75);-moz-box-shadow:0 -1px 3px rgba(0,0,0,0.75);box-shadow:0 -1px 3px rgba(0,0,0,0.75);color:white}#cookieWarningMessage #cookiesTellMeMoreLink{padding:0;color:#00A2FF;white-space:nowrap}#cookieWarningMessage #cookiesTellMeMoreLink:hover{text-decoration:underline}#cookieWarningMessage .cw_close{position:fixed;top:auto;bottom:25px;right:10px;margin:0;border:none;padding:0;text-align:center;background:#494949;color:white;font-size:1em;width:25px;height:25px;border-radius:3px;cursor:pointer} ",
defaultTemplate: "<section id=\"snei-footer\" class=\"snei-footer\"> <div class=\"snei-container\"> <div class=\"snei-grid\"> {% if(o.service && o.service.title!='' && o.service.list.length > 0) { %} <div class=\"snei-column-services\"> <h5 class=\"snei-label\">{%=o.service.title %}</h5> {% if(o.service.list.length > 0) { %} <ul class=\"snei-list\"> {% for (var y = 0; y < o.service.list.length; y ++) { %} {% var currentTarget = o.openNewWindowHTML ? o.openNewWindowHTML : o.service.list[y].target; %} <li> <a href=\"{%=o.service.list[y].link %}\" target=\"{%=currentTarget %}\">{%=o.service.list[y].title %}</a> </li> {% } %} </ul> {% } %} </div> {% } %} {% if(o.shop) { %} <div class=\"snei-column-store\"> <h5 class=\"snei-label\">{%=o.shop.title %}</h5> {% if(o.shop.list.length > 0) { %} <ul class=\"snei-list\"> {% for (var y = 0; y < o.shop.list.length; y ++) { %} {% var currentTarget = o.openNewWindowHTML ? o.openNewWindowHTML : o.shop.list[y].target; %} <li> <a href=\"{%=o.shop.list[y].link %}\" target=\"{%=currentTarget %}\">{%=o.shop.list[y].title %}</a> </li> {% } %} </ul> {% } %} </div> {% } %} {% if(o.account) { %} <div class=\"snei-column-account\"> <h5 class=\"snei-label\">{%=o.account.title %}</h5> {% if(o.account.list.length > 0) { %} <ul class=\"snei-list\"> {% for (var y = 0; y < o.account.list.length; y ++) { %} {% var currentTarget = o.openNewWindowHTML ? o.openNewWindowHTML : o.account.list[y].target; %} <li> <a href=\"{%=o.account.list[y].link %}\" target=\"{%=currentTarget %}\">{%=o.account.list[y].title %}</a> </li> {% } %} </ul> {% } %} </div> {% } %} {% if(o.legal) { %} <div class=\"snei-column-legal\"> <h5 class=\"snei-label\">{%=o.legal.title %}</h5> {% if(o.legal.list.length > 0) { %} <ul class=\"snei-list\"> {% for (var y = 0; y < o.legal.list.length; y ++) { %} {% var currentTarget = o.openNewWindowHTML ? o.openNewWindowHTML : o.legal.list[y].target; %} <li> <a href=\"{%=o.legal.list[y].link %}\" target=\"{%=currentTarget %}\">{%=o.legal.list[y].title %}</a> </li> {% } %} </ul> {% } %} </div> {% } %} <div class=\"snei-column-sen\"> {% if(o.sen) { %} <h5 class=\"snei-label\"> {%#o.sen.title.replace(/([^>\\r\\n]?)(\\r\\n|\\n\\r|\\r|\\n)/g, \'$1<br />$2\') %} </h5> {% } %} {% if(o.about && o.about.list.length > 0) { %} <ul class=\"snei-list\"> {% for (var y = 0; y < o.about.list.length; y ++) { %} {% var currentTarget = o.openNewWindowHTML ? o.openNewWindowHTML : o.about.list[y].target; %} <li> <a href=\"{%=o.about.list[y].link %}\" target=\"{%=currentTarget %}\">{%=o.about.list[y].title %}</a> </li> {% } %} </ul> {% } %} {% if(o.social && o.social.list.length > 0) { %} <div class=\"snei-social\"> {% for (var y = 0; y < o.social.list.length; y ++) { %} {% var socialClassName = \"\"; var socialIconClassName = \"\"; switch (o.social.list[y].id) { case \"footerLink_Twitter\": socialClassName = \"snei-social-twitter\"; socialIconClassName = \"fonticon-15-twitter\"; break; case \"footerLink_Facebook\": socialClassName = \"snei-social-facebook\"; socialIconClassName = \"fonticon-15-facebook-sm\"; break; case \"footerLink_GooglePlus\": socialClassName = \"snei-social-gplus\"; socialIconClassName = \"fonticon-15-gplus\"; break; case \"footerLink_Youtube\": socialClassName = \"snei-social-youtube\"; socialIconClassName = \"fonticon-15-youtube\"; break; case \"footerLink_Instagram\": socialClassName = \"snei-social-instagram\"; socialIconClassName = \"fonticon-15-instagram\"; break; case \"footerLink_Weibo\": socialClassName = \"snei-social-weibo\"; socialIconClassName = \"fonticon-15-weibo\"; break; } var currentTarget = o.openNewWindowHTML ? o.openNewWindowHTML : o.social.list[y].target; %} <a href=\"{%=o.social.list[y].link %}\" title=\"{%=o.social.list[y].title %}\" class=\"{%=socialClassName %}\" target=\"{%=currentTarget %}\"> <i class=\"{%=socialIconClassName %}\"></i> <span>{%=o.social.list[y].title %}</span> </a> {% } %} </div> {% } %} </div> </div> </div> </section>",
html: null,
cookieWarningScript: "",
head: document.getElementsByTagName('head')[0],
tmpl: null,
/**
* Returns a cookie by name
*
* @param {String} c_name
* @returns {*}
*/
getCookie: function (c_name) {
var i, x, y, ARRcookies = document.cookie.split(";");
for (i = 0; i < ARRcookies.length; i++) {
x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
x = x.replace(/^\s+|\s+$/g, "");
if (x == c_name) {
return decodeURI(y);
}
}
},
/**
* Sets a cookie with lifetime in minutes
*
* @param {String} c_name Cookie Name
* @param {*} value
* @param {Integer} exmins
*/
setCookie: function (c_name, value, exmins) {
var domainSplit = document.domain.split(".");
var cookieDomain = domainSplit[domainSplit.length - 2] + "." + domainSplit[domainSplit.length - 1];
var exdate = new Date();
exdate.setMinutes(exdate.getMinutes() + exmins);
var c_value = encodeURI(value) + ((exmins == null) ? "" : ";expires=" + exdate.toUTCString() + "domain=." + cookieDomain + ";path=/");
document.cookie = c_name + "=" + c_value;
},
/**
* Renders a given template with data
* @param {String} str Template String
* @param {JSON} data JSON Data
* @returns {String}
*/
template: function (str, data) {
if (!this.tmpl) {
/*
* JavaScript Templates 2.4.1
* https://github.com/blueimp/JavaScript-Templates
*
* Inspired by John Resig's JavaScript Micro-Templating:
* http://ejohn.org/blog/javascript-micro-templating/
*/
var tmpl = function (str, data) {
var f = !/[^\w\-\.:]/.test(str) ? tmpl.cache[str] = tmpl.cache[str] ||
tmpl(tmpl.load(str)) :
new Function(
tmpl.arg + ',tmpl',
"var _e=tmpl.encode" + tmpl.helper + ",_s='" +
str.replace(tmpl.regexp, tmpl.func) +
"';return _s;"
);
return data ? f(data, tmpl) : function (data) {
return f(data, tmpl);
};
};
tmpl.cache = {};
tmpl.load = function (id) {
return document.getElementById(id).innerHTML;
};
tmpl.regexp = /([\s'\\])(?!(?:[^{]|\{(?!%))*%\})|(?:\{%(=|#)([\s\S]+?)%\})|(\{%)|(%\})/g;
tmpl.func = function (s, p1, p2, p3, p4, p5) {
if (p1) { // whitespace, quote and backspace in HTML context
return {
"\n": "\\n",
"\r": "\\r",
"\t": "\\t",
" ": " "
}[p1] || "\\" + p1;
}
if (p2) { // interpolation: {%=prop%}, or unescaped: {%#prop%}
if (p2 === "=") {
return "'+_e(" + p3 + ")+'";
}
return "'+(" + p3 + "==null?'':" + p3 + ")+'";
}
if (p4) { // evaluation start tag: {%
return "';";
}
if (p5) { // evaluation end tag: %}
return "_s+='";
}
};
tmpl.encReg = /[<>&"'\x00]/g;
tmpl.encMap = {
"<": "&lt;",
">": "&gt;",
"&": "&amp;",
"\"": "&quot;",
"'": "\'"
};
tmpl.encode = function (s) {
/*jshint eqnull:true */
return (s == null ? "" : "" + s).replace(
tmpl.encReg,
function (c) {
return tmpl.encMap[c] || "";
}
);
};
tmpl.arg = "o";
tmpl.helper = ",print=function(s,e){_s+=e?(s==null?'':s):_e(s);}" + ",include=function(s,d){_s+=tmpl(s,d);}";
this.tmpl = tmpl;
}
return this.tmpl(str, data);
},
/**
* Checks the parameters on the script tag for any optional overrides
*
* @return {void}
*/
initializeWithDataAttributes: function () {
var scripts = document.getElementsByTagName('script'),
dataAttributeMatrix = {
'data-id': 'containerId',
'data-useDefaultCss': 'useDefaultCss',
'data-isResponsive': 'isResponsive',
'data-callback': 'callbackFuncName',
'data-openLinksInNewWindow': 'openLinksInNewWindow',
'data-displayCookieWarning': 'displayCookieWarning',
'data-onRender': 'onRenderFuncName',
'data-includeSonyFont': 'includeSonyFont'
},
dataAttributeValue,
correspondingProperty,
thisScriptTag = null;
for (var i = 0; i < scripts.length; i++) {
if (scripts[i].src.indexOf("unifiedfooter.") >= 0) {
thisScriptTag = scripts[i];
break;
}
if (scripts[i].src.search("type=1384785453") >= 0) {
thisScriptTag = scripts[i];
break;
}
}
if (null == thisScriptTag) {
throw new Exception('Could not find unified footer script tag');
}
for (var dataAttributeName in dataAttributeMatrix) {
if (dataAttributeMatrix.hasOwnProperty(dataAttributeName)) {
correspondingProperty = dataAttributeMatrix[dataAttributeName];
dataAttributeValue = thisScriptTag.getAttribute(dataAttributeName);
this[correspondingProperty] = dataAttributeValue || this[correspondingProperty];
}
}
},
/**
* Loads the footer
*
* @return {void}
*/
load: function () {
this.initializeWithDataAttributes();
this.loadFooterCssAndJs();
this.insert();
},
/**
* Inserts a CSS stylesheet into the document
*
* @param {String} css
* @return {void}
*/
insertCss: function (css) {
var cssSheet = document.createElement('style');
cssSheet.type = 'text/css';
if (cssSheet.styleSheet) {
cssSheet.styleSheet.cssText = css;
} else {
cssSheet.appendChild(document.createTextNode(css));
}
this.head.appendChild(cssSheet);
},
/**
* Inserts the font family
*
* @return {void}
*/
insertFont: function () {
var linkSheet = document.createElement('link');
linkSheet.rel = 'stylesheet';
if (BrowserDetect.browser === 'MSIE') {
linkSheet.href = '//www.playstationnetwork.com/typo3conf/ext/sonyswt_template/Resources/Public/build/deploy/fonts/fonts-eot.css';
} else {
var fontType = navigator.userAgent.match(/android|vita|playstation/gi) !== null ? 'ttf' : 'woff';
linkSheet.href = '//fonts.sony.net/shf/v6/b64-fonts-' + fontType + '.css';
}
this.head.appendChild(linkSheet);
},
/**
* Inserts a JS script into the document
*
* @param {String} js
* @return {void}
*/
insertJs: function (js) {
var jsNode = document.createElement('script');
jsNode.type = 'text/javascript';
jsNode.text = js;
this.head.appendChild(jsNode);
},
/**
* Injects the footer's CSS into the document head
*
* @return {void}
*/
loadFooterCssAndJs: function () {
// Add default styles, if not disabled
if ("1" !== this.useDefaultCss) {
return;
}
this.insertCss(this.baseCSS);
// Add responsive, if not disabled
if ("1" === this.isResponsive) {
this.insertCss(this.responsiveCSS);
}
// Add font
if ("1" === this.includeSonyFont) {
this.insertFont();
}
},
/**
* Creates the HTML
*
* @return {void}
*/
buildCookieWarning: function () {
var openNewWindowHTML = "";
if (this.openLinksInNewWindow == "1") {
openNewWindowHTML = "_blank";
}
// Adding variable values to the footerJSON to be used in the template
this.footerJSON.openNewWindowHTML = openNewWindowHTML;
if (this.callbackFuncName) {
var callbackFunc = window[this.callbackFuncName],
returnValue = callbackFunc.call(this, this.defaultTemplate);
if (typeof returnValue === 'string') {
this.defaultTemplate = returnValue;
} else {
// Abort.
console.log('The parsed template is not valid. Aborted footer parsing.');
return;
}
}
// Parse template
var result;
try {
result = this.template(this.defaultTemplate, this.footerJSON);
} catch (e) {
// If the template string don't have space character which is unlikely, then the template will fail.
result = this.template('tmpl-error', e);
}
this.appendToHTMLString(result);
this.insertCookieWarningHTMLandEventHandler();
},
/**
* Computes a nodes height including box-shadow
* @param {Node} element
* @return {int}
*/
getElementHeight: function (element) {
// Trouble is, that the cookie uses box-shadow which isn't included in getBoundingClientRect()
// Determining the elements true height need to take box-shadow into account.
// 1st value of matched values can be ignored since it positions the box-shadow horizontally
// The remaining values position the bs vertically and therefore need to be added
// but we need to transform them to positive numbers (neg. values mean position up/pos. values = pos down)
// Since the regEx ignores the minus in front of numbers we do not need to check for neg. values inside the loop.
// This is our box-shadow:
// rgba(0, 0, 0, 0.74902) 0px -1px 3px 0px
// .match(/(\dpx)/gim)
// ["0px", "1px", "3px", "0px"]
if (!(element instanceof Node)) {
return;
}
var elemHeight = element.getBoundingClientRect().height,
elemBoxShadow = getComputedStyle(element).getPropertyValue('box-shadow'),
elemBoxShadowMatch = elemBoxShadow.match(/(\dpx)/gim),
value,
sum = 0,
k;
for (k = 1; k < elemBoxShadowMatch.length; k++) {
value = parseFloat(elemBoxShadowMatch[k]);
sum += value;
}
return parseInt(elemHeight + sum);
},
/**
* Logic for the CookieWarning: inserts html and adds event handler
*
* @return {void}
*/
insertCookieWarningHTMLandEventHandler: function () {
var that = this;
var cookieWarningMessage;
var cWMheight;
// Display cookie warning on first hit
if (this.footerJSON.labels.cookieWarningContent != undefined
&& this.footerJSON.labels.cookieWarningContent != ""
&& this.displayCookieWarning == "1"
&& this.getCookie("cookieWarningMessageHasDisplayed") != "true") {
this.appendToHTMLString("<div id=\"cookieWarningMessage\">" + this.footerJSON.labels.cookieWarningContent + "<button type='button' class='cw_close'><span aria-hidden='true'>X</span></button></div>");
this.insertHTMLStringIntoDOM();
cookieWarningMessage = document.getElementById('cookieWarningMessage');
cWMheight = this.getElementHeight(cookieWarningMessage);
setTimeout(function () {
that.showCookieWarning(cookieWarningMessage, cWMheight);
}, 0);
} else {
this.insertHTMLStringIntoDOM();
}
},
/**
* Moves the Cookie Warning into the display
*
* @param {Node} cookieWarningMessage
* @param {int} cWMheight
* @returns {void}
*/
showCookieWarning: function (cookieWarningMessage, cWMheight) {
var bottom = -cWMheight;
cookieWarningMessage.style.bottom = bottom + 'px';
cookieWarningMessage.style.left = '0px';
this.cWMclickHandler(cookieWarningMessage, cWMheight);
function moveWarningUp() {
bottom++;
cookieWarningMessage.style.bottom = bottom + 'px';
if (bottom === 0) {
clearInterval(id2);
}
}
var id2 = setInterval(moveWarningUp, 1000 / 60);
},
/**
* Removes the Cookie Warning by moving it out of the display
*
* @param {Node} cookieWarningMessage
* @returns {void}
*/
removeCookieWarning: function (cookieWarningMessage) {
var bottom = 0,
cWMheight = this.getElementHeight(cookieWarningMessage);
function moveWarningDown() {
bottom--;
cookieWarningMessage.style.bottom = bottom + 'px';
if (bottom === -cWMheight) {
clearInterval(id);
cookieWarningMessage.style.display = 'none';
}
}
var id = setInterval(moveWarningDown, 10);
this.setCookie("cookieWarningMessageHasDisplayed", "true", (365 * 60 * 60));
},
/**
* Registers the event handler that removes the Cookie Warning
*
* @param {Node} cookieWarningMessage
* @param {int} cWMheight
* @returns {void}
*/
cWMclickHandler: function (cookieWarningMessage, cWMheight) {
var that = this;
var cWMessage = cookieWarningMessage.getElementsByClassName('cw_close')[0];
cWMessage.onclick = function (e) {
that.removeCookieWarning(cookieWarningMessage);
};
},
htmlStr: '',
/**
* Build a html string that appends every html string that gets processed
*
* @param {Node} htmlStr
* @returns {void}
*/
appendToHTMLString: function (htmlStr) {
this.htmlStr += htmlStr;
},
/**
* Inserts the htmlString into the DOM
*
* @returns {void}
*/
insertHTMLStringIntoDOM: function () {
document.getElementById(this.containerId).innerHTML = this.htmlStr;
},
/**
* Inserts the footer
*
* @return {void}
*/
insert: function () {
// data is injected by TYPO3; placed here because we otherwise get warnings all over the place because of syntax
this.footerJSON = {"service":{"title":"Services","id":"header_Services","list":[{"title":"PlayStation Store","link":"https:\/\/www.playstationnetwork.com\/en-gb\/store\/","target":"_blank","id":"footerLink_PSN"},{"title":"PlayStation Video","link":"https:\/\/www.playstationnetwork.com\/en-gb\/video\/","target":"_blank","id":"footerLink_VideoOnDemand"},{"title":"PlayStation Music","link":"https:\/\/www.playstationnetwork.com\/en-gb\/music\/","target":"_blank","id":"footerLink_MusicUnlimited"},{"title":"PlayStation Now","link":"https:\/\/www.playstation.com\/en-gb\/explore\/playstation-now\/","target":"_blank","id":"footerLink_PSNow"},{"title":"PlayStation Plus","link":"https:\/\/www.playstation.com\/en-gb\/explore\/playstation-plus\/","target":"_blank","id":"footerLink_PSPlus"}]},"account":{"title":"Account","id":"header_Account","list":[{"title":"Manage Account","link":"https:\/\/id.sonyentertainmentnetwork.com\/id\/management\/","target":"_blank","id":"footerLink_AccountManagement"},{"title":"My Media","link":"https:\/\/account.sonyentertainmentnetwork.com\/liquid\/login.action","target":"_blank","id":"footerLink_MyMedia"}]},"legal":{"title":"Legal","id":"header_Legal","list":[{"title":"Terms of Service","link":"https:\/\/www.playstationnetwork.com\/en-gb\/terms-of-service\/","target":"_blank","id":"footerLink_TermsOfService"},{"title":"Privacy Policy","link":"https:\/\/www.playstationnetwork.com\/en-gb\/privacy-policy\/","target":"_blank","id":"footerLink_PrivacyPolicy"},{"title":"Health Warning","link":"https:\/\/www.playstationnetwork.com\/en-gb\/health-warnings\/","target":"_blank","id":"5889be1d30d7b"},{"title":"Contact Us","link":"https:\/\/www.playstation.com\/footer\/about-us\/","target":"_blank","id":"footerLink_ContactUs"},{"title":"Ratings","link":"https:\/\/www.playstationnetwork.com\/en-gb\/ratings\/","target":"_blank","id":"footerLink_PSN"}]},"about":{"title":"Meta - About","id":"header_LearnMore","list":[{"title":"About Us","link":"https:\/\/www.playstation.com\/footer\/about-us\/","target":"_blank","id":"footerLink_AboutUs"},{"title":"Support","link":"https:\/\/www.playstation.com\/en-gb\/get-help\/help-library","target":"_blank","id":"footerLink_Support"}]},"social":{"title":"Social Media","id":"footerLink_SocialMedia","list":[{"title":"Twitter","link":"http:\/\/twitter.com\/PlayStationUK","target":"_blank","id":"footerLink_Twitter"},{"title":"Facebook","link":"https:\/\/www.facebook.com\/PlayStationAccess","target":"_blank","id":"footerLink_Facebook"},{"title":"Google+","link":"https:\/\/plus.google.com\/106749926655265456368\/posts","target":"_blank","id":"footerLink_GooglePlus"},{"title":"YouTube","link":"https:\/\/www.youtube.com\/user\/PlayStationAccess","target":"_blank","id":"footerLink_Youtube"}]},"sen":{"title":"PlayStation Network","id":"footerLink_SEN"},"labels":{"browserWarningContent":"","cookieWarningContent":""}};
this.buildCookieWarning();
if (this.onRenderFuncName) {
window[this.onRenderFuncName].call(this);
}
}
};
SNEIUnifiedFooter.load();
})();