// Copyright (c) EMBL-EBI 2021 // Do not edit this file directly. // It is made by concating .js files with by npm into script.js. // Source files: js/ebi-css-build/script/*.js /** * Utility function to get params from the URL. * * @param {string} name The string to look for * @param {string} [url=browserURL] Optionally pass a specific URL to parse * * @example * query string: ?foo=lorem&bar=&baz * var foo = getParameterByName('foo'); // "lorem" */ function ebiGetParameterByName(name, url) { if (!url) url = window.location.href; name = name.replace(/[\[\]]/g, "\\$&"); var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), results = regex.exec(url); if (!results) return null; if (!results[2]) return ''; return decodeURIComponent(results[2].replace(/\+/g, " ")); } // utility function to see if element has a class // hasClass(element, 'class-deska'); function ebiHasClass(element, cls) { return (' ' + element.className + ' ').indexOf(' ' + cls + ' ') > -1; } /** * Mark pdf/doc/txt links with link-pdf/link-doc/link-txt classes. */ function ebiFrameworkExternalLinks() { // exclude links with images // include only links to own domains function isOwnDomain(url) { return url.indexOf('//') === -1 || url.indexOf('//www.ebi.ac.uk') !== -1 || url.indexOf('//wwwdev.ebi.ac.uk') !== -1 || url.indexOf('//srs.ebi.ac.uk') !== -1 || url.indexOf('//ftp.ebi.ac.uk') !== -1 || url.indexOf('//intranet.ebi.ac.uk') !== -1 || url.indexOf('//pdbe.org') !== -1 || url.indexOf('//' + document.domain) !== -1; } function isFileType(url, type) { return url.indexOf(type, url.length - type.length) !== -1; } try { var alist = document.getElementsByTagName('a'); var fileTypes = ['pdf', 'doc', 'txt']; var i, icon; for (i = 0; i < alist.length; i++) { for (var type in fileTypes) { if (alist[i].innerHTML.indexOf('') === -1 && alist[i].innerHTML.indexOf(' * Can also be disabled by adding class 'no-global-search' to the body element. */ function ebiFrameworkManageGlobalSearch() { try { var hasLocalSearch = document.getElementById('local-search') !== null; var hasLocalEBISearch = document.getElementById('ebi_search') !== null; if (hasLocalSearch || hasLocalEBISearch) { document.body.className += ' no-global-search'; } else { try { // If the page gets a global search, we specify how the dropdown box should be. #RespectMyAuthoriti // remove any current dropdown if ((elem = document.getElementById('search-bar')) !== null) { document.getElementById('search-bar').remove(); } var dropdownDiv = document.createElement("div"); dropdownDiv.innerHTML = ''; document.getElementById("masthead-black-bar").insertBefore(dropdownDiv, document.getElementById("masthead-black-bar").firstChild); var searchBar = document.querySelectorAll(".search-bar")[0]; var searchBarButton = document.querySelectorAll(".search-toggle")[0]; var blackBar = document.querySelectorAll(".masthead-black-bar")[0]; // add "peeking" animation for embl selector searchBarButton.addEventListener("mouseenter", function (event) { if (ebiHasClass(document.querySelectorAll(".search-bar")[0], 'active') == false) { blackBar.className += ' peek'; } }, false); searchBarButton.addEventListener("mouseleave", function (event) { if (ebiHasClass(document.querySelectorAll(".search-bar")[0], 'active') == false) { blackBar.classList.remove("peek"); } }, false); // toggle the .embl-bar var searchSelector = document.querySelectorAll(".search-toggle")[0].addEventListener("click", function (event) { event.preventDefault(); ebiToggleClass(searchBar, 'active'); ebiToggleClass(searchBarButton, 'active'); window.scrollTo(0, 0); }, false); var searchSelectorClose = document.querySelectorAll(".search-bar .close-button")[0].addEventListener("click", function (event) { event.preventDefault(); ebiToggleClass(searchBar, 'active'); ebiToggleClass(searchBarButton, 'active'); window.scrollTo(0, 0); }, false); } catch (err) { setTimeout(init, 500); } } } catch (err) {} } /** * Add error alerts for 'no input' on search boxes.
* Todo: this, perhaps, should be moved to a value-add script file */ function ebiFrameworkSearchNullError() { try { var disabled = document.body.className.indexOf('no-search-error') !== -1; // Array of search box definition objects, specify inputNode, defaultText (optional, default ''), errorText (optional, default 'Please enter a search term') var searchBoxes = [{ inputNode: document.getElementById('global-searchbox') }, // in global masthead { inputNode: document.getElementById('local-searchbox') }, // in local masthead { inputNode: document.body.className.indexOf('front') !== -1 ? document.getElementById('query') : null }, // on home page { inputNode: document.getElementById('people-groups') ? document.getElementById('people-groups').getElementsByTagName('input')[0] : null // on people and group page }]; if (!disabled) { for (searchBox in searchBoxes) { var searchInput = searchBoxes[searchBox].inputNode; var searchForm = searchInput ? searchInput.form : null; var searchInputDefault = searchBoxes[searchBox].defaultText || ''; var searchError = searchBoxes[searchBox].errorText || 'Please enter a search term'; var searchAction = searchForm ? searchForm.action : ''; var isEbiSearch = searchAction.indexOf('/ebisearch/') !== -1; if (searchForm && searchInput && isEbiSearch) { // add reference to other items for onsubmit anonymous function searchForm.searchInput = searchInput; searchForm.searchInputDefault = searchInputDefault; searchForm.searchError = searchError; searchForm.onsubmit = function () { searchInput = this.searchInput; searchInputDefault = this.searchInputDefault; searchError = this.searchError; // Ensure input is trimmed searchInput.value = searchInput.value.trim(); if (searchInput.value === searchInputDefault || searchInput.value === '') { alert(searchError); return false; } }; } } } } catch (err) {} } /** * Utility method to get if it is IE, and what integer version. * via: https://stackoverflow.com/a/15983064 * @returns {int} the IE version number * @example if (isIE () && isIE () < 9) { } */ function isIE() { var myNav = navigator.userAgent.toLowerCase(); return myNav.indexOf('msie') != -1 ? parseInt(myNav.split('msie')[1]) : false; } /** * Utility function to toggle classes. Chiefly to show the #embl-bar. */ function ebiToggleClass(element, toggleClass) { var currentClass = element.className; var newClass; if (currentClass.split(" ").indexOf(toggleClass) > -1) { // has class newClass = currentClass.replace(new RegExp('\\b' + toggleClass + '\\b', 'g'), ""); } else { newClass = currentClass + " " + toggleClass; } element.className = newClass.trim(); } /** * Utility function to add classes (only once). */ function ebiActivateClass(element, cssClass) { element.classList.remove(cssClass); element.classList.add(cssClass); } /** * Utility function to remove classes. */ function ebiRemoveClass(element, cssClass) { element.classList.remove(cssClass); } /** * Remove global-nav/global-nav-expanded from header/footer if body.no-global-nav is set */ function ebiFrameworkHideGlobalNav() { try { var hasGlobalMasthead = document.getElementById('masthead-black-bar') !== null; var disabled = document.body.className.indexOf('no-global-nav') !== -1; var elem; if (hasGlobalMasthead && disabled) { if ((elem = document.getElementById('global-nav')) !== null) { elem.parentNode.removeChild(elem); } if ((elem = document.getElementById('global-nav-expanded')) !== null) { elem.parentNode.removeChild(elem); } } } catch (err) {} } /** * Assign global nav background images through meta tags */ function ebiFrameworkAssignImageByMetaTags() { var masthead = document.getElementById('masthead'); // check for both ebi: and ebi- formatted meta tags var mastheadColor = document.querySelector("meta[name='ebi:masthead-color']") || document.querySelector("meta[name='ebi-masthead-color']"); var mastheadImage = document.querySelector("meta[name='ebi:masthead-image']") || document.querySelector("meta[name='ebi-masthead-image']"); if (mastheadColor != null) { masthead.style.backgroundColor = mastheadColor.getAttribute("content"); masthead.className += ' meta-background-color'; } if (mastheadImage != null) { masthead.style.backgroundImage = 'url(' + mastheadImage.getAttribute("content") + ')'; masthead.className += ' meta-background-image'; } } /** * Populate `#masthead-black-bar` */ function ebiFrameworkPopulateBlackBar() { try { // Clear any existing black bar contents if ((elem = document.getElementById('masthead-black-bar')) !== null) { document.getElementById('masthead-black-bar').innerHTML = ""; } var barContents = document.createElement("div"); barContents.innerHTML = ''; document.getElementById("masthead-black-bar").insertBefore(barContents, document.getElementById("masthead-black-bar").firstChild); document.body.className += ' ebi-black-bar-loaded'; } catch (err) {}; } /** * Reusable function to get part of the black bar */ function ebiGetFacet(passedAttribute) { var tag = "#masthead-black-bar ." + passedAttribute.toLowerCase(); return document.querySelectorAll(tag)[0]; } /** * Active tabs in `#masthead-black-bar` according to metadata */ function ebiFrameworkActivateBlackBar() { // Look at the embl:facet-* meta tags to set active states // // // // // try { // reset black bar contexts when mousing out var resetBlackBar = function resetBlackBar() { // console.log('purged'); // $('#masthead-black-bar .hover').removeClass('hover float-left'); // $('#masthead-black-bar .what').removeClass('hide'); // $('#masthead-black-bar .where').addClass('hide'); ebiFrameworkActivateBlackBar(); }; // This meta navigation concept has been deprecated in favour of the VF 2.0 // var metas = document.getElementsByTagName('meta'); // for (var i = 0; i < metas.length; i++) { // if (metas[i].getAttribute("name") == "embl:active") { // var targetFacet = ebiGetFacet(metas[i].getAttribute("content").replace(':','.')); // ebiRemoveClass(targetFacet,'hide'); // ebiActivateClass(targetFacet,'active'); // } // if (metas[i].getAttribute("name") == "embl:parent-1") { // var targetFacet = ebiGetFacet(metas[i].getAttribute("content").replace(':','.')); // ebiRemoveClass(targetFacet,'hide'); // ebiActivateClass(targetFacet,'active'); // } // if (metas[i].getAttribute("name") == "embl:parent-2") { // var targetFacet = ebiGetFacet(metas[i].getAttribute("content").replace(':','.')); // ebiRemoveClass(targetFacet,'hide'); // ebiActivateClass(targetFacet,'active'); // } // } // add interactivity to facets, so that hovering on what:research shows what:* // we do this bit with jquery to prototype; need to rewire as vanilla JS. // ebiGetFacet('where.active').addEventListener("mouseenter", function( event ) { // $('#masthead-black-bar .where.hide').addClass('hover float-left').removeClass('hide'); // // $('#masthead-black-bar .where.hide').removeClass('hide').addClass('hover'); // $('#masthead-black-bar .what').addClass('hide'); // }, false); // ebiGetFacet('what.active').addEventListener("mouseenter", function( event ) { // $('#masthead-black-bar .what').removeClass('hide float-left'); // $('#masthead-black-bar .what').addClass('hover float-left'); // $('#masthead-black-bar .where').addClass('hide'); // }, false); // Only reset blackbar after XXXms outside the blackbar var mouseoutTimer; blackBar.addEventListener("mouseenter", function () { window.clearTimeout(mouseoutTimer); }, false); blackBar.addEventListener("mouseleave", function () { mouseoutTimer = window.setTimeout(function () { resetBlackBar(); }, 500); }); } catch (err) {}; } /** * Insert EMBL dropdown menu into `#masthead-black-bar` */ function ebiFrameworkInsertEMBLdropdown() { try { // remove any current dropdown if ((elem = document.getElementById('embl-bar')) !== null) { document.getElementById('embl-bar').remove(); } var dropdownDiv = document.createElement("div"); dropdownDiv.innerHTML = ''; dropdownDiv.innerHTML = ""; document.getElementById("masthead-black-bar").insertBefore(dropdownDiv, document.getElementById("masthead-black-bar").firstChild); var emblBar = document.querySelectorAll(".embl-bar")[0]; var emblBarButton = document.querySelectorAll(".embl-selector")[0]; var blackBar = document.querySelectorAll(".masthead-black-bar")[0]; // add "peeking" animation for embl selector // emblBarButton.addEventListener("mouseenter", function( event ) { // if (ebiHasClass(document.querySelectorAll(".embl-bar")[0], 'active') == false) { // blackBar.className += ' peek'; // } // }, false); // emblBarButton.addEventListener("mouseleave", function( event ) { // if (ebiHasClass(document.querySelectorAll(".embl-bar")[0], 'active') == false) { // blackBar.classList.remove("peek"); // } // }, false); // // // toggle the .embl-bar // var emblSelector = document.querySelectorAll(".embl-selector")[0].addEventListener("click", function( event ) { // ebiToggleClass(emblBar,'active'); // ebiToggleClass(emblBarButton,'active'); // event.preventDefault(); // window.scrollTo(0, 0); // }, false); var emblSelectorClose = document.querySelectorAll(".embl-bar .close-button")[0].addEventListener("click", function (event) { ebiToggleClass(emblBar, 'active'); ebiToggleClass(emblBarButton, 'active'); event.preventDefault(); window.scrollTo(0, 0); }, false); } catch (err) {}; } /** * Insert EBI Footer into `#global-nav-expanded` */ function ebiFrameworkUpdateFoot() { var html = '
' + '

EMBL-EBI

' + ' Intranet for staff' + '
' + '
' + '' + '
' + '
Research
' + ' ' + ' ' + '
' + '
About
' + '
'; function init() { try { var foot = document.getElementById('global-nav-expanded'); foot.innerHTML = html; } catch (err) { setTimeout(init, 500); } } init(); } /** * Insert footer meta info into `#ebi-footer-meta` */ function ebiFrameworkUpdateFooterMeta() { var d = new Date(); var html = '
' + '

EMBL-EBI, Wellcome Genome Campus, Hinxton, Cambridgeshire, CB10 1SD, UK. +44 (0)1223 49 44 44

'; function init() { try { var foot = document.getElementById('ebi-footer-meta'); foot.innerHTML = html; } catch (err) { setTimeout(init, 500); } } init(); } /** * Once an announcement has been matched to the current page, show it (if there is one). * @param {Object} message - The message you wish to show on the page. * @param {string} message.headline - The headline to show (text) * @param {string} message.message - The contents of the message (HTML) * @param {string} [message.priority = 'callout'] - Optional class to add to message box. 'alert', 'warning', 'industry-background white-color' * @example * ebiInjectAnnouncements({ headline: 'Your headline here', message: 'this', priority: 'alert' }); */ function ebiInjectAnnouncements(message) { if (typeof message == 'undefined') { return false; }; if (typeof message.processed != 'undefined') { // don't show a message more than once return true; } else { // mark message as shown message.processed = true; } var container = document.getElementById('main-content-area') || document.getElementById('main-content') || document.getElementById('main') || document.getElementById('content') || document.getElementById('contentsarea'); if (container == null) { // if no suitable container, warn console.warn('A message needs to be shown on this site, but an appropriate container could not be found. \n Message follows:', '\n' + message.headline, '\n' + message.message, '\n' + 'Priority:', message.priority); return false; } var banner = document.createElement('div'); var wrapper = document.createElement('div'); // var inner = document.createElement('div'); // banner.id = ""; banner.className = "notifications-js row margin-top-medium"; wrapper.className = "callout " + (message.priority || ""); wrapper.innerHTML = "

" + message.headline + "

" + message.message + // "" + ""; container.insertBefore(banner, container.firstChild); banner.appendChild(wrapper); } /** * Load the downtime/announcement messages, if any. * We do match not by comparison but by find a url as an array key. * For more info, see: https://gitlab.ebi.ac.uk/ebiwd/ebi.emblstatic.net-root-assets/tree/master/src */ function ebiFrameworkIncludeAnnouncements() { // var downtimeScript = 'https://dev.ebi.emblstatic.net/announcements.js?' + Math.round(new Date().getTime() / 3600000); // are there matching announcements for the current URL function detectAnnouncements(messages) { var currentHost = window.location.hostname, currentPath = window.location.pathname; // don't treat `wwwdev` as distinct from `www` currentHost = currentHost.replace(/wwwdev/g, "www"); // if the page has a path, try to make matches // don't try to much no path or '/' if (currentPath.length > 1) { // Is there an exact match // console.log('matching:', currentHost+currentPath); ebiInjectAnnouncements(messages[currentHost + currentPath]); ebiInjectAnnouncements(messages[currentHost + currentPath + '/']); // Handle wildcard matches like `/about/*` var currentPathArray = currentPath.split('/'); // construct a list of possible paths to match // /style-lab/frag1/frag2 = // - /style-lab/frag1/frag2 // - /style-lab/frag1 // - /style-lab var pathsToMatch = [currentHost + currentPathArray[0]]; for (var i = 1; i < currentPathArray.length; i++) { var tempPath = pathsToMatch[i - 1]; pathsToMatch.push(tempPath + '/' + currentPathArray[i]); } // console.log(pathsToMatch); for (var i = 0; i < pathsToMatch.length; i++) { // console.log('matching:', pathsToMatch[i]+'*'); // we only match partial paths if they end in * ebiInjectAnnouncements(messages[pathsToMatch[i] + '*']); ebiInjectAnnouncements(messages[pathsToMatch[i] + '/*']); } } else { // no current path means we're on the root domain // `https://www.ebi.ac.uk` should match `www.ebi.ac.uk` and `www.ebi.ac.uk/` and `www.ebi.ac.uk/*` // console.log('matching:', currentHost); ebiInjectAnnouncements(messages[currentHost]); ebiInjectAnnouncements(messages[currentHost + '/']); ebiInjectAnnouncements(messages[currentHost + '/*']); } } function loadRemoteAnnouncements(file) { if (window.XMLHttpRequest) { var xmlhttp = new XMLHttpRequest(); } xmlhttp.open("GET", file, true); xmlhttp.onload = function (e) { if (xmlhttp.readyState === 4) { if (xmlhttp.status === 200) { eval(xmlhttp.responseText); var m = m || ''; // make sure the message isn't null detectAnnouncements(m); } else { console.error(xmlhttp.statusText); } } }; xmlhttp.onerror = function (e) { console.error(xmlhttp.statusText); }; xmlhttp.send(null); } if (window.location.hostname.indexOf('wwwdev.') === 0) { // Load test message on wwwdev loadRemoteAnnouncements('https://dev.ebi.emblstatic.net/announcements.js'); } else { loadRemoteAnnouncements('https://ebi.emblstatic.net/announcements.js'); } } /** * Injects the Data Protection notice onto sites * For guidance on using: https://www.ebi.ac.uk/style-lab/websites/patterns/banner-data-protection.html */ function ebiFrameworkCreateDataProtectionBanner() { var banner = document.createElement('div'); var wrapper = document.createElement('div'); var inner = document.createElement('div'); // don't accidently create two banners if (document.getElementById("data-protection-banner") != null) { document.getElementById("data-protection-banner").remove(); } banner.id = "data-protection-banner"; banner.className = "data-protection-banner"; banner.style.cssText = "position: fixed; background: #707372; width: 100%; padding: .75rem 1%; left: 0; bottom: 0; border-top: 1px solid #373a36; color: #eee; z-index: 10;"; wrapper.className = "row"; wrapper.innerHTML = "" + "
" + dataProtectionSettings.message + "
" + "
I agree, dismiss this banner
" + ""; document.body.appendChild(banner); banner.appendChild(wrapper); ebiFrameworkTrackDataProtectionBanner(); openDataProtectionBanner(); } /** * Log acceptance of banner, if GA is set and using EBIFoundationExtend * */ function ebiFrameworkTrackDataProtectionBanner() { var bannerTrackingEventLoaded = 0; // has the tracking coad loaded? if (typeof analyticsTrackInteraction == 'function' && typeof jQuery == 'function') { if (jQuery("body").hasClass("google-analytics-loaded")) { bannerTrackingEventLoaded = 1; jQuery("body.google-analytics-loaded .data-protection-banner a").on('mousedown', function (e) { analyticsTrackInteraction(e.target, 'Data protection banner'); }); } else { bannerTrackingEventLoaded = ebiFrameworkRetryTrackDataProtectionBanner(bannerTrackingEventLoaded); } } else { bannerTrackingEventLoaded = ebiFrameworkRetryTrackDataProtectionBanner(bannerTrackingEventLoaded); } } /** * Give a second for banner checking if GA was slow to load * */ function ebiFrameworkRetryTrackDataProtectionBanner(bannerTrackingEventLoaded) { bannerTrackingEventLoaded--; if (bannerTrackingEventLoaded > -3) { // try up to 3 fails setTimeout(ebiFrameworkTrackDataProtectionBanner, 900); } return bannerTrackingEventLoaded; } /** * Shows the data protection banner on screen. */ function openDataProtectionBanner() { var height = document.getElementById('data-protection-banner').offsetHeight || 0; document.getElementById('data-protection-banner').style.display = 'block'; document.body.style.paddingBottom = height + 'px'; document.getElementById('data-protection-agree').onclick = function () { closeDataProtectionBanner(); return false; }; } /** * Hides the data protection banner from the screen. */ function closeDataProtectionBanner() { var height = document.getElementById('data-protection-banner').offsetHeight; document.getElementById('data-protection-banner').style.display = 'none'; document.body.style.paddingBottom = '0'; ebiFrameworkSetCookie(dataProtectionSettings.cookieName, 'true', 90); } function ebiFrameworkSetCookie(c_name, value, exdays) { var exdate = new Date(); var c_value; exdate.setDate(exdate.getDate() + exdays); // c_value = escape(value) + ((exdays===null) ? "" : ";expires=" + exdate.toUTCString()) + ";domain=.ebi.ac.uk;path=/"; // document.cookie = c_name + "=" + c_value; c_value = escape(value) + (exdays === null ? "" : ";expires=" + exdate.toUTCString()) + ";domain=" + document.domain + ";path=/"; document.cookie = c_name + "=" + c_value; } function ebiFrameworkGetCookie(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 unescape(y); } } } var dataProtectionSettings = new Object(); /** * The main 'brain' of the EBI Data Protection banner. * Further documentation at https://www.ebi.ac.uk/style-lab/websites/patterns/banner-data-protection.html * @param {string} [targetedFrameworkVersion=generic] targeted Framework version; options: 1.1, 1.2, 1.3, 1.4, compliance, other */ function ebiFrameworkRunDataProtectionBanner(targetedFrameworkVersion) { try { if (typeof newDataProtectionNotificationBanner !== "undefined") { targetedFrameworkVersion = newDataProtectionNotificationBanner.src.split('legacyRequest=')[1] || 'generic'; } var compatibilityStyles = document.createElement('style'); compatibilityStyles.innerHTML = "\n #cookie-banner {\n display: none;\n }\n .data-protection-banner {\n box-sizing: border-box;\n }\n .data-protection-banner a,\n .data-protection-banner a:hover {\n cursor: pointer;\n color: #fff;\n border-bottom-width: 1px;\n border-bottom-style: dotted;\n border-bottom-color: inherit;\n text-decoration: none;\n }\n .data-protection-banner .medium-8 {\n width: 75%; margin-left: 1%; float: left;\n }\n .data-protection-banner .medium-4 {\n width: 23%; margin-right: 1%; float: right; text-align: right;\n }\n "; // remove any old style cookie banner switch (targetedFrameworkVersion) { case '1.1': case '1.2': if (document.getElementById("cookie-banner") != null) { document.getElementById("cookie-banner").remove(); } document.body.style.paddingBottom = 0; break; case '1.3': case '1.4': // cookie banner really shouldn't be here, but just in case if (document.getElementById("cookie-banner") != null) { document.getElementById("cookie-banner").remove(); } break; case 'compliance': if (document.getElementById("cookie-banner") != null) { document.getElementById("cookie-banner").remove(); } document.body.style.paddingTop = 0; document.body.appendChild(compatibilityStyles); break; case 'other': // If you're not using any formally supported framework, we'll do our best to help out document.body.appendChild(compatibilityStyles); break; default: console.warn('You should specify the targeted FrameworkVersion (allowed values: 1.1, 1.2, 1.3, 1.4, compliance, other). You sent: ' + targetedFrameworkVersion); } // Default global values dataProtectionSettings.message = 'This website requires cookies, and the limited processing of your personal data in order to function. By using the site you are agreeing to this as outlined in our Privacy Notice and Terms of Use.'; dataProtectionSettings.serviceId = 'embl-ebi-public-website'; // use the URL stub from your DP record at http://content.ebi.ac.uk/list-data-protection-records dataProtectionSettings.dataProtectionVersion = '1.0'; // A method to disable the DP banner. // Particularly suited for using 1.4 along side 2.0 and you don't want two cookie banners // Example: var disableDataProtectionBanner = false; var divDataProtectionBannerDisable = document.querySelectorAll('[data-protection-message-disable]'); if (divDataProtectionBannerDisable.length > 0) { divDataProtectionBannerDisable = divDataProtectionBannerDisable[0]; if (divDataProtectionBannerDisable.dataset.protectionMessageDisable == "true") { disableDataProtectionBanner = true; } } // If there's a div#data-protection-message-configuration, override defaults var divDataProtectionBanner = document.getElementById('data-protection-message-configuration'); if (divDataProtectionBanner !== null) { if (typeof divDataProtectionBanner.dataset.message !== "undefined") { dataProtectionSettings.message = divDataProtectionBanner.dataset.message; } if (typeof divDataProtectionBanner.dataset.serviceId !== "undefined") { dataProtectionSettings.serviceId = divDataProtectionBanner.dataset.serviceId; } if (typeof divDataProtectionBanner.dataset.dataProtectionVersion !== "undefined") { dataProtectionSettings.dataProtectionVersion = divDataProtectionBanner.dataset.dataProtectionVersion; } } dataProtectionSettings.cookieName = dataProtectionSettings.serviceId + "-v" + dataProtectionSettings.dataProtectionVersion + "-data-protection-accepted"; // If this version of banner not accepted, show it: if (ebiFrameworkGetCookie(dataProtectionSettings.cookieName) != "true" && disableDataProtectionBanner === false) { ebiFrameworkCreateDataProtectionBanner(); } } catch (err) { setTimeout(function () { ebiFrameworkRunDataProtectionBanner(targetedFrameworkVersion); }, 100); } } /** * Clear the cooke. This is mostly a development tool. */ function resetDataProtectionBanner() { document.cookie = dataProtectionSettings.cookieName + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT;domain=" + document.domain + ";path=/"; ebiFrameworkRunDataProtectionBanner('1.4'); } /** * Fallback for any code that was directly calling the old cookie banner: * https://github.com/ebiwd/EBI-Framework/blob/6707eff40e15036f735637413deed0dcb7392818/js/ebi-global-includes/script/5_ebiFrameworkCookieBanner.js */ function ebiFrameworkCookieBanner() { console.warn('You are calling an old function name, update it to ebiFrameworkRunDataProtectionBanner();'); ebiFrameworkRunDataProtectionBanner('1.4'); } // execute // ebiFrameworkRunDataProtectionBanner('1.4'); /** * All scripts are automatically loaded, unless the page asked us not to. * @example * Configurable with a data attribute: * */ function ebiFrameworkInvokeScripts() { ebiFrameworkPopulateBlackBar(); ebiFrameworkActivateBlackBar(); ebiFrameworkExternalLinks(); ebiFrameworkManageGlobalSearch(); ebiFrameworkSearchNullError(); ebiFrameworkHideGlobalNav(); ebiFrameworkAssignImageByMetaTags(); ebiFrameworkInsertEMBLdropdown(); ebiFrameworkUpdateFoot(); ebiFrameworkUpdateFooterMeta(); ebiFrameworkIncludeAnnouncements(); ebiFrameworkRunDataProtectionBanner('1.4'); } document.addEventListener("DOMContentLoaded", function (event) { var bodyData = document.body.dataset; // document.body.dataset not supported in < ie10 if (isIE() && isIE() <= 10) { bodyData = []; } if (bodyData["ebiframeworkinvokescripts"] != "false") { ebiFrameworkInvokeScripts(); } });