Files
roi24/European, Middle Eastern & African Stocks - Bloomberg - Bloomberg Markets_files/that_05Q6.js
T
neo 932ec3ac8f KPI cards: Bloomberg stock ticker style
- Redesign KPI cards to look like stock tickers
- Add ticker ID (e.g. ВЫРУЧК:KPI, AOV:KPI)
- Arrow up/down SVG indicators for change direction
- Mini trend-line (50px) inside each card
- Change color: green (#16a34a) for up, red (#e21d1d) for down
- Remove sparkline background area, keep only line
- Fix duplicate arrowUp variable naming (bArrowUp/bArrowDown/bArrowNeutral)
2026-06-21 18:14:08 +05:00

1 line
12 KiB
JavaScript

(()=>{var Spotlight={selectors:{that:"bb-that",spotlight:".bb-that-spotlight",spotlightActive:"bb-that-spotlight--active",dataEndpoint:"data-spotlight-service"},logs:{invalidTHAT:"THAT was not rendered correctly. ",noEndpoint:"Spotlight retrieval endpoint not set. ",noSpotlight:"There are no spotlights to display at the moment ",parsingError:"There was an error when parsing the spotlight response ",invalidResponse:"There was an error when retrieving the spotlight ",spotlightSeen:"The spotlight has already been seen and closed."},cookieName:"bloomberg.that.spotlight",cookieDuration:1,spotlightEvent:"bloomberg.that.spotlight",endpoint:"",tophat:null,init:function(){this.validateTHAT()&&this.retrieveSpotlight()},validateTHAT:function(){var $valid=!1;return this.tophat=document.querySelector("div#"+this.selectors.that),this.tophat?(this.endpoint=this.tophat.getAttribute(this.selectors.dataEndpoint),this.endpoint?$valid=!0:this.log(!0,this.logs.noEndpoint)):this.log(!0,this.logs.invalidTHAT),$valid},retrieveSpotlight:function(){var xmlhttp=new XMLHttpRequest;xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState===XMLHttpRequest.DONE)if(200===xmlhttp.status)try{var $response=JSON.parse(xmlhttp.responseText);$response.hasOwnProperty("spotlights")&&Array.isArray($response.spotlights)&&0<$response.spotlights.length&&Spotlight.renderSpotlight($response.spotlights[0])}catch(e){Spotlight.log(!0,Spotlight.logs.parsingError,e)}else Spotlight.log(!0,Spotlight.logs.invalidResponse,xmlhttp.status)},xmlhttp.open("GET",this.endpoint,!0),xmlhttp.send()},renderSpotlight:function(spotlight){this.getCookie(this.cookieName)?this.log(!1,this.logs.spotlightSeen):(this.tophat.insertAdjacentHTML("beforeend",spotlight),document.querySelector(this.selectors.spotlight))},bindClose:function(){document.querySelector(this.selectors.spotlightClose).addEventListener("click",function(){Spotlight.tophat.removeChild(document.querySelector(Spotlight.selectors.spotlight)),Spotlight.setCookie(Spotlight.cookieName,!0,Spotlight.cookieDuration),Spotlight.log(!1,Spotlight.logs.spotlightClose)})},setCookie:function(name,value,xdays){var d=new Date;d.setTime(d.getTime()+864e5*xdays),document.cookie=name+"="+value+";path=/;expires="+d.toUTCString()},getCookie:function(name){name=document.cookie.match("(^|;) ?"+name+"=([^;]*)(;|$)");return name?name[2]:null},deleteCookie:function(name){this.setCookie(name,"",-1)},log:function(error,message,extra){error?window.console.error(this.spotlightEvent,{message:message,extra:extra}):window.console.log(this.spotlightEvent,{message:message,extra:extra})}};document.addEventListener(Spotlight.spotlightEvent,function(){Spotlight.init()})})(),(()=>{var That={selectors:{container:"#bb-that--container",header:".bb-that-header",jumpContentLink:".skiplink__hide-until-focus",jumpContentLinkFallback:".bb-that__skip-to-content",jumpContentTarget:"#that-jump-content",jumpContentTargetFallback:"#that-jump-content--default",mobileCategories:".bb-that--visible-xs .bb-that-category:not(.bb-that-category--sub) .bb-that-category__title",sitemapClose:".bb-that__close",sitemapLink:".bb-that-header--sitemap-trigger",tabbableHeaderLinks:".bb-that-header__link",tabbableSitemapLinks:'[tabindex="0"]',wrapper:"#bb-that .bb-that:not(.bb-that--static)",spotlight:"bb-that-spotlight",mobileMenu:".bb-that .bb-that__sitemap-mobile-header span",mobileMenuSection:".bb-that__sitemap-sections.bb-that--visible-xs"},spotlightEvent:"bloomberg.that.spotlight",containerEl:null,headerEl:null,jumpContentLinkFallback:null,jumpContentTarget:null,openClass:"bb-that--open",mobileOpenClass:"bb-that--mobile-open",sitemapCloseEl:null,sitemapLinkEl:null,sitemapLinkSibEl:null,mobileMenuEl:null,mobileMenuSectionEl:null,sitemapOpen:!1,tabbableHeaderLinks:null,tabbableSitemapLinks:null,wrapperEl:null,prepare:function(){var self,observer;document.querySelector(this.selectors.wrapper+" "+this.selectors.sitemapLink)?this.init():window.MutationObserver&&(self=this,(observer=new MutationObserver(function(mutations){for(var i=0;i<mutations.length;i++)for(var j=0;j<mutations[i].addedNodes.length;j++){var el=mutations[i].addedNodes[j];el&&el.querySelector&&el.querySelector(self.selectors.sitemapLink)&&(self.init(),observer.disconnect())}})).observe(document.documentElement,{childList:!0,subtree:!0}))},init:function(){this.wrapperEl=document.querySelector(this.selectors.wrapper),null!==this.wrapperEl&&(this.containerEl=this.wrapperEl.querySelector(this.selectors.container),this.sitemapLinkEl=this.wrapperEl.querySelector(this.selectors.sitemapLink),this.sitemapCloseEl=this.wrapperEl.querySelector(this.selectors.sitemapClose),this.headerEl=this.wrapperEl.querySelector(this.selectors.header),this.sitemapLinkSibEl=this.getNextSibling(this.sitemapLinkEl),this.mobileMenuSectionEl=this.wrapperEl.querySelector(this.selectors.mobileMenuSection),this.mobileMenuEl=this.wrapperEl.querySelector(this.selectors.mobileMenu),this.tabbableHeaderLinks=Array.prototype.slice.call(document.querySelectorAll(this.selectors.tabbableHeaderLinks)),this.tabbableSitemapLinks=Array.prototype.slice.call(this.containerEl.querySelectorAll(this.selectors.tabbableSitemapLinks)),this.jumpContentLink=document.querySelector(this.selectors.jumpContentLink),this.jumpContentLinkFallback=this.wrapperEl.querySelector(this.selectors.jumpContentLinkFallback),this.jumpContentTarget=document.querySelector(this.selectors.jumpContentTarget),null!==this.jumpContentLink&&this.jumpContentLinkFallback.setAttribute("tabindex","-1"),null===this.jumpContentTarget?this.jumpContentTarget=document.querySelector(this.selectors.jumpContentTargetFallback):this.jumpContentLinkFallback.href=this.selectors.jumpContentTarget,this.bindEvents(),this.triggerSpotlight())},getCookie:function(cname){for(var name=cname+"=",ca=decodeURIComponent(document.cookie).split(";"),i=0;i<ca.length;i++){for(var c=ca[i];" "===c.charAt(0);)c=c.substring(1);if(0===c.indexOf(name))return c.substring(name.length,c.length)}return null},bindEvents:function(){var all_utm_values,excluded_tracking_urls,excluded_tracking_urls_array,sitemapCallback=this.btnCallback(this.toggleSitemap),sitemapCallback=(this.sitemapLinkEl.addEventListener("click",sitemapCallback,!1),this.sitemapLinkEl.addEventListener("keypress",sitemapCallback,!1),this.mobileMenuEl&&this.mobileMenuSectionEl&&(sitemapCallback=this.makeCallback(this.toggleMobileMenu),this.mobileMenuEl.addEventListener("click",sitemapCallback,!1)),this.btnCallback(this.closeSitemap)),sitemapCallback=(this.sitemapCloseEl.addEventListener("click",sitemapCallback,!1),this.sitemapCloseEl.addEventListener("keypress",sitemapCallback,!1),this.makeCallback(this.onFocused)),sitemapCallback=(this.sitemapCloseEl.addEventListener("focusin",sitemapCallback,!1),this.makeCallback(this.jumpToContent)),sitemapCallback=(this.jumpContentLinkFallback.addEventListener("click",sitemapCallback,!1),this.tabCallback(this.tabThroughSitemap)),sitemapCallback=(this.containerEl.addEventListener("keydown",sitemapCallback,!1),this.tabCallback(this.tabThroughHeader)),mobileCategoryCallback=(this.headerEl.addEventListener("keydown",sitemapCallback,!1),this.makeCallback(this.toggleMobileCategory));[].forEach.call(this.wrapperEl.querySelectorAll(this.selectors.mobileCategories),function(element){element.addEventListener("click",mobileCategoryCallback,!1)}),document.querySelector("body").classList.contains("has-utm-that")&&(sitemapCallback=this.wrapperEl.querySelectorAll('#bb-that a[data-element="tophat-link"]'),all_utm_values={campaign_name:this.getCookie("campaign_name"),utm_campaign:this.getCookie("utm_campaign"),utm_content:this.getCookie("utm_content"),utm_medium:this.getCookie("utm_medium"),utm_source:this.getCookie("utm_source"),utm_term:this.getCookie("utm_term"),tactic:this.getCookie("tactic")},excluded_tracking_urls=window.bbg_that_exc_urls||{},excluded_tracking_urls_array=Object.entries(excluded_tracking_urls).length?Object.values(excluded_tracking_urls):{},[].forEach.call(sitemapCallback,function(link){var link_href=link.getAttribute("href"),link_href_array=link_href.split("?");if(1!==link_href_array.length){var x,exclude_this_link=!1,excluded_links_list=[];for(x in excluded_tracking_urls_array){var excluded_url=excluded_tracking_urls_array[x];if(link_href.includes(excluded_url))return exclude_this_link=!0,void excluded_links_list.push(excluded_url)}if(!exclude_this_link){var utm_index,orig_search_params=link_href_array.length?"?"+link_href_array[1]:null,link_href_array=link_href_array[0],link_search_params=orig_search_params?new URLSearchParams(orig_search_params):new URLSearchParams({});for(utm_index in all_utm_values){var utm_value=all_utm_values[utm_index];utm_value&&(link_search_params.delete(utm_index),link_search_params.set(utm_index,utm_value),"utm_medium"===utm_index)&&link.setAttribute("data-label",utm_value)}link_href_array=link_href_array+"?"+link_search_params.toString(),link.setAttribute("href",link_href_array)}}}))},onFocused:function(event){-1===this.tabbableHeaderLinks.indexOf(event.relatedTarget)&&-1===this.tabbableSitemapLinks.indexOf(event.relatedTarget)&&this.tabbableHeaderLinks[this.tabbableHeaderLinks.length-1].focus()},jumpToContent:function(){this.jumpContentTarget.focus()},btnCallback:function(callback){var that=this;return function(event){"click"!==event.type&&("keypress"!==event.type||13!==event.keyCode&&32!==event.keyCode)||callback.call(that,event)}},tabCallback:function(callback){var that=this;return function(event){9!==event.keyCode&&27!==event.keyCode||callback.call(that,event)}},makeCallback:function(callback){var that=this;return function(event){callback.call(that,event)}},toggleClass:function(element){var reg=new RegExp("(\\s|^)"+this.openClass+"(\\s|$)");element.className.match(reg)?element.className=element.className.replace(reg," "):element.className+=" "+this.openClass,document.querySelector("."+this.selectors.spotlight)&&document.querySelector("."+this.selectors.spotlight).classList.toggle(this.selectors.spotlight+"--active")},toggleSitemap:function(event){event.preventDefault(),event.stopImmediatePropagation(),this.sitemapOpen=!this.sitemapOpen,this.sitemapLinkEl.setAttribute("aria-expanded",this.sitemapOpen),this.toggleClass(this.wrapperEl),(this.sitemapOpen?this.containerEl:this.sitemapLinkEl).focus()},tabThroughHeader:function(event){var index;9===event.keyCode&&(index=this.tabbableHeaderLinks.indexOf(event.target),event.shiftKey?this.sitemapOpen&&event.target===this.sitemapLinkSibEl&&(event.preventDefault(),event.stopImmediatePropagation(),this.sitemapCloseEl.focus()):this.sitemapOpen&&event.target===this.sitemapLinkEl?this.containerEl.focus():index===this.tabbableHeaderLinks.length-1&&this.sitemapCloseEl.focus())},tabThroughSitemap:function(event){var index;9===event.keyCode?((index=this.tabbableSitemapLinks.indexOf(event.target))===this.tabbableSitemapLinks.length-1&&!event.shiftKey||0===index&&event.shiftKey)&&(event.preventDefault(),event.stopImmediatePropagation(),(0===index&&event.shiftKey?this.sitemapLinkEl:this.sitemapLinkSibEl).focus()):27===event.keyCode&&this.closeSitemap(event)},closeSitemap:function(event,target){event.preventDefault(),event.stopImmediatePropagation();event=target||this.sitemapLinkEl;this.sitemapOpen&&(this.sitemapOpen=!this.sitemapOpen,this.sitemapLinkEl.setAttribute("aria-expanded",this.sitemapOpen),this.toggleClass(this.wrapperEl),event.focus())},getNextSibling:function(nodeEl){for(var nextNodeEl;nextNodeEl=nodeEl.nextSibling;)if(1===nextNodeEl.nodeType)return nextNodeEl;return null},toggleMobileCategory:function(event){event.preventDefault(),this.toggleClass(event.target.parentNode)},triggerSpotlight:function(){var evt=document.createEvent("Events");evt.initEvent(this.spotlightEvent,!0,!0),document.dispatchEvent(evt)},toggleMobileMenu:function(){this.mobileMenuSectionEl.classList.toggle("bb-that--mobile-menu-open")}};"loading"!==document.readyState?That.prepare():document.addEventListener("DOMContentLoaded",function(){That.prepare()})})();