Japan

Japan -1) DEBUG = true;else if (window.location.href.indexOf(‘debug’) > -1) DEBUG = true;if (!DEBUG) {if (!window.console) window.console = {};var methods = [“log”, “debug”, “info”];for (var i = 0; i 0) previousActive = activeTabs[0] else previousActive.classList.add(‘active’); } } }; //// check if the url has a #something, and if there is a tab with the same #something, and simulate a click on the tab //var hash = window.location.hash; //if (hash) { // var all_togglers = document.querySelectorAll(“.pagetabs a[data-toggle]”); // for (var toogle in all_togglers) { // var link = toogle.getAttribute(‘href’); // } //} }); // hack while there is still tabs on top of the chart var all_togglers = document.querySelectorAll(“.pagetabs a[data-toggle]”); for (var i = 0; i < all_togglers.length; i++) { all_togglers[i].addEventListener("click", function (event) { var link = event.target.getAttribute("href"); // remove active from all chart-nav tabs var chartTabs = document.querySelectorAll(".chart-nav li"); for (var i = 0; i < chartTabs.length; i++) { chartTabs[i].classList.remove("active"); } var intradayTab = document.querySelector(".chart-nav li a[href='#intraday']"); var historicalTab = document.querySelector(".chart-nav li a[href='#historical']"); var forecastTab = document.querySelector(".chart-nav li a[href='#forecast']"); if (link == "#historical") { if (intradayTab) { intradayTab.closest('li').style.display = 'block'; intradayTab.closest('li').classList.add("active") } if (historicalTab) { historicalTab.closest('li').style.display = 'block'; if (intradayTab) historicalTab.closest('li').classList.remove("active"); else historicalTab.closest('li').classList.add("active"); } if (forecastTab) { forecastTab.closest('li').style.display = 'none'; forecastTab.closest('li').classList.remove("active"); } swapDataAndApiLinks("historical"); } else if (link == "#forecast") { if (intradayTab) { intradayTab.closest('li').style.display = 'none'; intradayTab.closest('li').classList.remove("active") } if (historicalTab) { historicalTab.closest('li').style.display = 'none'; historicalTab.closest('li').classList.remove("active"); } if (forecastTab) { forecastTab.closest('li').style.display = 'block'; forecastTab.closest('li').classList.add("active"); } swapDataAndApiLinks("forecast"); } else if (link == "#stats") { if (intradayTab) { intradayTab.closest('li').style.display = 'none'; intradayTab.closest('li').classList.remove("active") } if (historicalTab) { historicalTab.closest('li').style.display = 'none'; historicalTab.closest('li').classList.remove("active"); } if (forecastTab) { forecastTab.closest('li').style.display = 'block'; forecastTab.closest('li').classList.add("active"); } swapDataAndApiLinks("stats"); } }); } // swap Data and API links in the page between historical and forecast function swapDataAndApiLinks(type) { var apiUrl = $("#api-url-text").val(); if (typeof apiUrl == 'undefined') apiUrl = ''; var currentUrl = window.location.href; // replace the download btn if ($("#menu-download-dropdown [data-download=csv]")) { downloadBtnAnchor = $("#menu-download-dropdown [data-download=csv]").attr('href'); if (type == "historical" || type == "stats") { downloadBtnAnchor = downloadBtnAnchor.replace(new RegExp("/forecast/", 'g'), "/historical/"); downloadBtnAnchor = downloadBtnAnchor.replace(new RegExp("/forecasts/symbol/", 'g'), "/historical/"); if (currentUrl.indexOf("/commodity/") !== -1) { if (downloadBtnAnchor.indexOf("1900-01-01") === -1) { downloadBtnAnchor = downloadBtnAnchor.replace("?", "/1900-01-01?"); } } } else if (type == "forecast") if (apiUrl.includes("/markets")) { downloadBtnAnchor = downloadBtnAnchor.replace(new RegExp("/historical/", 'g'), "/forecasts/symbol/"); } else { if (currentUrl.indexOf("/commodity/") !== -1) { downloadBtnAnchor = downloadBtnAnchor.replace(new RegExp("/1900-01-01?", 'g'), ""); } downloadBtnAnchor = downloadBtnAnchor.replace(new RegExp("/historical/", 'g'), "/forecast/"); } $("#menu-download-dropdown [data-download=csv]").attr('href', downloadBtnAnchor); } // replace the API inner text var apiContent = $("#api-msg-panel").html(); if (apiContent) { if (type == "historical" || type == "stats") { apiContent = apiContent.replace(new RegExp("/forecasts/symbol/", 'g'), "/historical/"); apiContent = apiContent.replace(new RegExp("/forecast/", 'g'), "/historical/"); apiContent = apiContent.replace(new RegExp("getForecastData", 'g'), "getHistoricalData"); $("#api-msg-panel").html(apiContent); if (currentUrl.includes("/commodity/") !== -1) { if (apiContent.indexOf("1900-01-01") === -1) { apiContent = apiContent.replace("?", "/1900-01-01?"); } } } else if (type = "forecast") { if (apiUrl.includes("/markets")) { apiContent = apiContent.replace(new RegExp("/historical/", 'g'), "/forecasts/symbol/"); } else { apiContent = apiContent.replace(new RegExp("/historical/", 'g'), "/forecast/"); apiContent = apiContent.replace(new RegExp("getHistoricalData", 'g'), "getForecastData"); if (currentUrl.indexOf("/commodity/") !== -1) { apiContent = apiContent.replace(new RegExp("/1900-01-01?", 'g'), ""); } } $("#api-msg-panel").html(apiContent); } } // replace the Data inner text var dataContent = $("#data.tab-pane").html(); if (dataContent) { if (type == "historical") { dataContent = dataContent.replace(new RegExp("/forecast/", 'g'), "/historical/"); $("#data.tab-pane").html(dataContent); if (currentUrl.indexOf("/commodity/") !== -1) { if (dataContent.indexOf("1900-01-01") === -1) { dataContent = dataContent.replace("?", "/1900-01-01?"); } } } else if (type = "forecast") { dataContent = dataContent.replace(new RegExp("/historical/", 'g'), "/forecast/"); $("#data.tab-pane").html(dataContent); if (currentUrl.indexOf("/commodity/") !== -1) { dataContent = dataContent.replace(new RegExp("/1900-01-01?", 'g'), ""); } } } // replace export var exportContent = $("#export-mssg-panel").html(); if (exportContent) { if (type == "historical" || type == "stats") { exportContent = exportContent.replace(new RegExp("/forecast/", 'g'), "/historical/"); exportContent = exportContent.replace(new RegExp("/forecasts/symbol/", 'g'), "/historical/"); exportContent = exportContent.replace(new RegExp("Forecast", 'g'), "Historical"); if (currentUrl.indexOf("/commodity/") !== -1) { if (exportContent.indexOf("1900-01-01") === -1) { var urlHist = "/ticker/" + TESymbol + "/1900-01-01"; var urlFor = "/ticker/" + TESymbol exportContent = exportContent.replace(new RegExp(urlFor, 'g'), urlHist); } } } else if (type = "forecast") { if (apiUrl.includes("/markets")) { exportContent = exportContent.replace(new RegExp("/historical/", 'g'), "/forecasts/symbol/"); } else { exportContent = exportContent.replace(new RegExp("/historical/", 'g'), "/forecast/"); if (currentUrl.indexOf("/commodity/") !== -1) { exportContent = exportContent.replace(new RegExp("/1900-01-01?", 'g'), ""); } } exportContent = exportContent.replace(new RegExp("Historical", 'g'), "Forecast"); } $("#export-mssg-panel").html(exportContent); } } var expandable_panel = document.getElementById("expand-panel"); var expand_links = document.getElementsByClassName("show-expand-panel"); var scroll_top_links = document.getElementsByClassName("scroll-top-on-click"); // scroll top for (var i = 0; i < scroll_top_links.length; i++) { scroll_top_links[i].addEventListener("click", function (event) { scrollTop(event) }); } function scrollTop() { window.scroll(0, 0); console.log("scroll top!"); } // show on click for (var i = 0; i < expand_links.length; i++) { expand_links[i].addEventListener("click", function (event) { expandPanelOnClick(event) }); } function expandPanelOnClick(event) { // get the element var element = event.target.closest("a.show-expand-panel"); // check if the element is expanding the panel if (element.classList.contains("expanding-panel")) return; // clear all the panel opened hidePanel(); // find the current element anchor and build the borders element.classList.add("expanding-panel"); // find the active li and remove the bottom border var active_anchor = document.querySelector(".pagetabs .nav li.active a"); active_anchor.classList.add("expand-panel-open"); // loader var loader = $(""); // clear the panel content var panel_content = document.getElementById("expand-panel-content"); // show the right panel, by convention, it looks for the panel with the element id name, removing the word 'link' var elementId = element.id.replace("Link", ""); var panelToOpen = expandable_panel.querySelector("#" + elementId); if (panelToOpen) panelToOpen.hidden = false; // display the panel expandable_panel.style.display = "block"; console.log("panel openned"); } // hide on outside click function hidePanelOnClickOutside(element) { const isVisible = elem => !!elem && !!(elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length); const outsideClickListener = event => { // find the anchor expanding the panel var anchor_expanding = document.querySelector(“.pagetabs .nav li a.expanding-panel”); if (!anchor_expanding) return; // if the element is not the panel or its children, or the anchor that expanded it, hide the panel if (!element.contains(event.target) && event.target.closest(“a.show-expand-panel”) != anchor_expanding) { if (isVisible(element)) { hidePanel(); } } }; document.addEventListener(‘click’, outsideClickListener); } hidePanelOnClickOutside(expandable_panel); function hidePanel() { // hide the panel expandable_panel.style.display = “none”; // all panels hidden var panelsToHide = expandable_panel.querySelectorAll(“#expand-panel-content > div”); if (panelsToHide) { for (var i = 0; i -1 || URL.indexOf(“/stocks”) > -1 || URL.indexOf(“/bonds”) > -1 || URL.indexOf(“/commodities”) > -1 || URL.indexOf(“/crypto”) > -1 || URL.indexOf(“:”) > -1) { if (!hasTabs) { var download_link = “https://api.tradingeconomics.com/markets/”; if (URL.indexOf(“/currencies”) > -1) { download_link += “currency”; } else if (URL.indexOf(“/stocks”) > -1) { download_link += “index”; } else if (URL.indexOf(“/bonds”) > -1) { download_link += “bond”; } else if (URL.indexOf(“/commodities”) > -1) { download_link += “commodities”; } else if (URL.indexOf(“/crypto”) > -1) { download_link += “currency”; } else if (URL.indexOf(“:”) > -1) { var currCsvDownload = $(“#data a.export-btn-csv”).attr(“href”); download_link = currCsvDownload; } var tab = “

  •  Download”; $(‘#pagemenutabs’).append(tab); hasTabs = true; snapshotPage = true; } } else if ($(“#menu-download-btn”) && $(“#menu-download-btn”).length > 0) { indicatorPage = true; buildDownloadList($(“#menu-download-btn”)); // Event to GA on clicks on the download menu btn in the IndicatorUC pages $(“#menu-download-btn”).click(function () { ga(‘send’, ‘event’, ‘Data Request’, ‘Dropdown’); }); } else if ($(“.calendar-download”) && $(“.calendar-download”).length > 0) { calendarPage = true; buildCalendarDownload($(“.calendar-download”)); } function downloadBtnClickEvent(event) { console.log(“download click ..”); var downloadBtn = $(event.target).closest(“a”); var dataDownload = $(downloadBtn).attr(“data-download”); if (!dataDownload) return; console.log(“data-download = ” + dataDownload); var modalTitle = “”; var modalContent = “”; var modalFooter = “”; var loginReturn = “https://sso.tradingeconomics.com/?returnurl=https://tradingeconomics.com” + URL; var loginAction = “Member? Login”; switch (dataDownload) { case “csv”: if (isLoggedIn) { downloadItem(event.target, dataDownload); return; } else { modalTitle = “Join Trading Economics”; modalContent = “Trading Economics provides more than 20 million economic indicators for nearly 200 countries, plus exchange rates, government bond yields, stock indexes, and commodity prices. “; modalContent += “Subscription users can use a web interface to export data or get it directly through an Excel add-in. “; modalContent += “Clients can also use an API to have direct access to our data, to query our real-time economic calendar and to subscribe to updates from any programming language.”; modalFooter += “Learn More”; modalFooter += “Pricing”; modalFooter += “Questions? Contact us”; modalFooter += loginAction; modalFooter += “” // ga event for logged out CSV download if (indicatorPage) ga(‘send’, ‘event’, ‘Data Request’, ‘Dropdown’, ‘csv’); else if (calendarPage) ga(‘send’, ‘event’, ‘Data Request’, ‘Calendar’, ‘csv’); else if (snapshotPage) ga(‘send’, ‘event’, ‘Data Request’, ‘Snapshot’, ‘csv’); } break; case “excel”: modalTitle = “Trading Economics Excel Add-in”; modalContent += “The Trading Economics Excel Addin allows users with an active subscription to access our data directly from excel. ” modalContent += “Trading Economic provides more than 20 million economic indicators for nearly 200 countries, plus exchange rates, government bond yields, stock indexes, and commodity prices. “; modalFooter = “Learn More”; modalFooter += “Download Addin”; modalFooter += “Questions? Contact us”; if (!isLoggedIn) modalFooter += loginAction; modalFooter += “”; // ga event for Excel click if (indicatorPage) ga(‘send’, ‘event’, ‘Data Request’, ‘Dropdown’, ‘excel’); break; case “api”: modalTitle = “Trading Economics API”; modalContent = “”; modalContent += “API Users have direct access to our economic data from any programming language, can query our real-time calendar, retrieve financial market quotes and subscribe to live updates. “; modalContent += “Trading Economics provides more than 20 million economic indicators for nearly 200 countries, plus exchange rates, government bond yields, stock indexes, and commodity prices.” modalContent += “”; modalFooter = “Learn More”; modalFooter += “API Docs”; modalFooter += “Questions? Contact us”; if (!isLoggedIn) modalFooter += loginAction; modalFooter += “”; // ga event for API click on indicator if (indicatorPage) ga(‘send’, ‘event’, ‘Data Request’, ‘Dropdown’, ‘api’); break; case “api-calendar”: modalTitle = “Trading Economics API” modalContent = “The Trading Economics API provides you with direct access to our calendar, instant updates after economic events get released, historical data on thousands of indicators and live market quotes. “; modalFooter = “Learn More”; modalFooter += “Any question? Contact us”; if (!isLoggedIn) modalFooter += loginAction; modalFooter += “”; // ga event for API click on calendar if (indicatorPage) ga(‘send’, ‘event’, ‘Data Request’, ‘Calendar’, ‘api’); break; case “excel-addin”: console.log(“Excel Addin Download”) ga(‘send’, ‘event’, ‘Data Request’, ‘Excel-Download’); window.location = ‘https://github.com/tradingeconomics/tradingeconomics/raw/master/Excel/All_Releases/ExcelAddInDeploy_latest.msi’; return; break; } showDownloadModal(modalTitle, modalContent, modalFooter); } function showDownloadModal(modalTitle, modalContent, modalFooter) { var modal = “”; modal += “”; modal += “”; modal += “

  • source: tradingeconomics.com” $(‘#TextBoxEmbed’).val(embedText); $(‘#embedPreviewLink’).attr(“href”, src); } $(‘#DropDownListCategory’).change(function () { console.log(“Changing Categories…”); }); $(‘#embedButton’).click(function () { console.log(“Expanding Embed…”); }); $(‘#TextBoxWidth’).keyup(function () { console.log(“Setting Embed Width…”); SetEmbed(); }); $(‘#TextBoxHeight’).keyup(function () { console.log(“Setting Embed Height…”); SetEmbed(); }); $(‘#ImageChart’).on(‘load’, function () { console.log(“Completed load of chart…”); $(‘#spinner’).css(“visibility”, “hidden”); }); $(‘a[data-toggle=”tab”]’).on(‘shown.bs.tab’, function (e) { var target = $(e.target).attr(“href”); console.log(“Chart Tab Click => ” + target); if (target == “#historical”) { HasForecastChart = false; HasStatsChart = false; if ($(e.target).data(‘symbol’)) { var TESymbolChanged = $(this).data(“symbol”) console.log(“data-symbol: ” + TESymbolChanged); TEChartUrl = TEChartUrl.replace(TESymbol.toLowerCase(), TESymbolChanged.toLowerCase()) TESymbol = TESymbolChanged; } SetChart(); } else if (target == “#forecast”) { HasForecastChart = true; HasStatsChart = false; SetChart(); } else if (target == “#stats”) { HasStatsChart = true; HasForecastChart = false; SetChart(); } else if (target == “#alerts”) { //$(‘#AlertMePanel’).collapse(‘show’); if (!isAlertsLoaded) { isAlertsLoaded = true; $.getScript(‘https://d107vmm87795sh.cloudfront.net/historical/te-alerts.js?v=20200117’); } } }); var hasCountriesSelect = false; var hasIndicatorsSelect = false; var categorySelect = ”; $(‘#compareButton’).click(function () { console.log(“Chart => Compare => Click”); if (!hasCountriesSelect) { var countries = [“Afghanistan”, “Albania”, “Algeria”, “Andorra”, “Angola”, “Antigua And Barbuda”, “Argentina”, “Armenia”, “Aruba”, “Australia”, “Austria”, “Azerbaijan”, “Bahamas”, “Bahrain”, “Bangladesh”, “Barbados”, “Belarus”, “Belgium”, “Belize”, “Benin”, “Bhutan”, “Bolivia”, “Bosnia and Herzegovina”, “Botswana”, “Brazil”, “Brunei”, “Bulgaria”, “Burkina Faso”, “Burundi”, “Cambodia”, “Cameroon”, “Canada”, “Cape Verde”, “Central African Republic”, “Chad”, “Chile”, “China”, “Colombia”, “Comoros”, “Congo”, “Costa Rica”, “Croatia”, “Cuba”, “Cyprus”, “Czech Republic”, “Denmark”, “Djibouti”, “Dominica”, “Dominican Republic”, “East Timor”, “Ecuador”, “Egypt”, “El Salvador”, “Equatorial Guinea”, “Eritrea”, “Estonia”, “Ethiopia”, “Euro Area”, “European Union”, “Fiji”, “Finland”, “France”, “Gabon”, “Gambia”, “Georgia”, “Germany”, “Ghana”, “Greece”, “Greenland”, “Grenada”, “Guatemala”, “Guinea”, “Guinea Bissau”, “Guyana”, “Haiti”, “Honduras”, “Hong Kong”, “Hungary”, “Iceland”, “India”, “Indonesia”, “Iran”, “Iraq”, “Ireland”, “Isle Of Man”, “Israel”, “Italy”, “Ivory Coast”, “Jamaica”, “Japan”, “Jordan”, “Kazakhstan”, “Kenya”, “Kiribati”, “Kosovo”, “Kuwait”, “Kyrgyzstan”, “Laos”, “Latvia”, “Lebanon”, “Lesotho”, “Liberia”, “Libya”, “Liechtenstein”, “Lithuania”, “Luxembourg”, “Macau”, “Macedonia”, “Madagascar”, “Malawi”, “Malaysia”, “Maldives”, “Mali”, “Malta”, “Mauritania”, “Mauritius”, “Mexico”, “Micronesia”, “Moldova”, “Monaco”, “Mongolia”, “Montenegro”, “Morocco”, “Mozambique”, “Myanmar”, “Namibia”, “Nepal”, “Netherlands”, “New Caledonia”, “New Zealand”, “Nicaragua”, “Niger”, “Nigeria”, “Norway”, “Oman”, “Pakistan”, “Palau”, “Palestine”, “Panama”, “Papua New Guinea”, “Paraguay”, “Peru”, “Philippines”, “Poland”, “Portugal”, “Puerto Rico”, “Qatar”, “Republic of the Congo”, “Romania”, “Russia”, “Rwanda”, “Samoa”, “Sao Tome and Principe”, “Saudi Arabia”, “Senegal”, “Serbia”, “Seychelles”, “Sierra Leone”, “Singapore”, “Slovakia”, “Slovenia”, “Solomon Islands”, “Somalia”, “South Africa”, “South Korea”, “South Sudan”, “Spain”, “Sri Lanka”, “St Kitts and Nevis”, “St Lucia”, “St Vincent And The Grenadines”, “Sudan”, “Suriname”, “Swaziland”, “Sweden”, “Switzerland”, “Syria”, “Taiwan”, “Tajikistan”, “Tanzania”, “Thailand”, “Togo”, “Tonga”, “Trinidad and Tobago”, “Tunisia”, “Turkey”, “Turkmenistan”, “Uganda”, “Ukraine”, “United Arab Emirates”, “United Kingdom”, “United States”, “Uruguay”, “Uzbekistan”, “Vanuatu”, “Venezuela”, “Vietnam”, “Yemen”, “Zambia”, “Zimbabwe”, “Commodity”]; var countriesSelect = ‘Pick Country’; for (i = 0; i < countries.length; i++) { countriesSelect += '' + countries[i] + ''; } $('#compare-countries').append(countriesSelect); hasCountriesSelect = true; } $("#compare-countries").change(function () { if (hasIndicatorsSelect) { $('#compare-indicators').find('option').remove().end(); $("#compare-indicators").hide(); } var countrySelected = $("#compare-countries option:selected").text(); console.log("Chart => Compare => Country = ” + countrySelected); $.getJSON(“/ws/query.ashx?c=” + countrySelected, function (data) { //console.log(data); var indicatorsSelect = ‘Pick Indicator’; for (i = 0; i < data.length; i++) { indicatorsSelect += '' + data[i].category + ''; } $("#compare-indicators").show(); $('#compare-indicators').append(indicatorsSelect); hasIndicatorsSelect = true; if (categorySelect != '') { $categoryOption = $('#compare-indicators option').filter(function () { return $(this).html() == categorySelect; }) if ($categoryOption.length > 0) { $categoryOption.prop(‘selected’, true); var urlSelect = $categoryOption.val(); SetComparison(urlSelect); } else { console.log(“Chart => Compare => This Country Does not Have Such Category”); } } } ); }); $(“#compare-indicators”).change(function () { categorySelect = $(“#compare-indicators option:selected”).text(); var urlSelect = $(“#compare-indicators option:selected”).val(); console.log(“Chart => Compare => Indicator => ” + categorySelect + ” ” + urlSelect); SetComparison(urlSelect); }); }); if (document.location.href.indexOf(“#alerts”) > -1) { console.log(“Expand AlertMePanel”); //$(‘#AlertMePanel’).prepend(“
    ALERTS

    “) $(‘.nav-tabs a[href=”#alerts”]’).tab(‘show’); //$(‘#AlertMePanel’).collapse(‘show’); } var $myGroup = $(‘#historical’); $myGroup.on(‘show.bs.collapse’, ‘.collapse’, function () { $myGroup.find(‘.collapse.in’).collapse(‘hide’); }); /* if (TEFrequency == “Yearly”) { $(“li”).find(“[data-lookback=’365′]”).hide(); $(“li”).find(“[data-lookback=’1095′]”).hide(); }*/ }); ]]>

    showChar) { var c = content.substr(0, showChar); var h = content.substr(showChar, content.length – showChar); var html = c + ” + ellipsestext + ” + h + ‘ ‘ + moretext + ”; $(this).html(html); } }); $(“.morelink”).click(function () { if ($(this).hasClass(“less”)) { $(this).removeClass(“less”); $(this).html(moretext); } else { $(this).addClass(“less”); $(this).html(lesstext); } $(this).parent().prev().toggle(); $(this).prev().toggle(); return false; }); }); ]]>“; if (IsTicker) { item += “” + j.title + “”; } else { if (j.country) { var countryColor = “#858585”; if (j.country.toLowerCase() == “united states”) countryColor = ‘#0075b5’; else if (j.country.toLowerCase() == “united kingdom”) countryColor = ‘darkred’; item += ” + j.country + ”; } if (j.category && j.category != j.country) { var categoryColor = “#ddd”; item += ‘ ‘ + j.category + ”; } item += “
    “; item += “” + j.title + “”; } if (j.html) item += “
    ” + j.html; else if (j.description) item += “
    ” + j.description; if (j.image) item += ‘
    ‘; if (j.diff) item += ‘
    ‘ + j.diff + ”; item += ”; streamPreviousTitle = j.title; if (isPrepend) { $(“#stream”).prepend(item); setTimeout(function () { $(“#” + j.ID).css(“backgroundColor”, ‘#fff’); }, 2000) streamHeight = $(“#stream”).height(); } return item; } else { console.log(“Skipping Repeated Title: ” + j.title); return null; } } else { console.log(“Missing Title”); return null; } } function getresult(start, size) { console.log(“Stream getresult”); var streamURL = streamBaseURL + “?start=” + start + “&size=” + size; if (IsTicker) { console.log(“Stream for Ticker”); start = start + 4; site = 10; streamURL = streamBaseURL + “?start=” + start + “&size=” + size; if (TECountry) streamURL += “&c=” + TECountry; if (TECategory) streamURL += “&i=” + TECategory; } else if (location.pathname.indexOf(‘/news’) !== -1 && location.pathname.split(‘/’).length == 3) { console.log(“Stream for News”); var sCountry = location.pathname.split(‘/’)[1]; if (sCountry) { sCountry = sCountry.replace(‘-‘, ‘ ‘); streamURL += “&c=” + sCountry; }; } else if (location.pathname.indexOf(‘/stream’) !== -1) { var sCategory = getParameterByName(‘i’); if (sCategory) streamURL += “&i=” + sCategory; var sCountry = getParameterByName(‘c’); if (sCountry) streamURL += “&c=” + sCountry; } else { return; } console.log(streamURL); $.ajax({ url: streamURL, type: “GET”, dataType: “json”, beforeSend: function () { $(‘#spinner’).show(); streamIsLoading = true; }, complete: function () { $(‘#spinner’).hide(); streamIsLoading = false; }, success: function (data) { appendResult(data); if (start == 0) { $(‘#stream-btn’).css(“visibility”, “visible”); if (sCategory || sCountry) { var sFilter = sCategory || sCountry; if (sFilter == “economy”) $(‘#streamTabEconomy’).tab(‘show’); else if (sFilter == “markets”) $(‘#streamTabMarkets’).tab(‘show’); else { //var sFilterDiv = ‘‘ + sFilter + ‘ 

    ‘;$(“#stream”).prepend(sFilterDiv); $(‘#streamTabs’).append(‘

  • ‘ + sFilter + ‘ ‘); } } } }, error: function () { console.error(“Stream Error”) } }); } function appendResult(data) { console.log(“Stream Appending Results”); //console.log(data); var now = (new Date).getTime(); var item = ”; var items = []; $.each(data, function (i, j) { //console.log(j); var diff = ”; var diffMs = now – new Date(j.date).getTime(); // Miliseconds var offset = new Date().getTimezoneOffset() * 60 * 1000; diffMs = diffMs + offset; if (diffMs < 0) { diff = 'few seconds ago'; } else if (diffMs < 120000) { var diffS = Math.round(diffMs / 1000); // Seconds diff = diffS + ' seconds ago'; } else if (diffMs < 7200000) { var diffMins = Math.round(diffMs / 60000); // minutes diff = diffMins + ' minutes ago'; } else if (diffMs < 172800000) { var diffHrs = Math.round(diffMs / 3600000); // hours diff = diffHrs + ' hours ago'; } else { var diffDays = Math.round(diffMs / 86400000); // days if (diffDays < 30) diff = diffDays + ' days ago'; else diff = j.date; } //console.log(j.date, j.title, j.url, j.importance); j.diff = diff; j.bgcolor = '#fff'; if (streamStart == 0) { j.bgcolor = '#cdebf9'; //if (j.url) j.image = 'https://d3fy651gv2fhd3.cloudfront.net/charts/stream.png?h=200&w=300&lbl=0&url=' + j.url; var itemLatest = getItem(j, true); } else { j.append = true; item = getItem(j, false) if (item) items.push(item); } streamStart += 1; }); $("
      “, { “class”: “list-group”, html: items.join(“”) }).appendTo(“#stream”); streamHeight = $(“#stream”).height(); } if (!IsTicker) { $(window).scroll(function () { if (streamHeight = streamHeight * 0.80) { if (!streamIsLoading) { getresult(streamStart, streamSize); } else { console.log(“Stream Loading is Busy. Hold on …”) } } } }); getresult(streamStart, streamSize); } $(‘#stream-btn’).click(function () { console.log(“Load more Streams After Click”); getresult(streamStart, streamSize); }); ]]>
    • 0) { $(“#export-msg-panel”).remove(); $(“#export-data-msg”).append(loading); } else { experience = 2; } // find the anchor element if (!$(element).is(‘a’)) { element = $(element).find(‘a’)[0]; } if (!element || element.length == 0 || !$(element).is(‘a’)) { console.log(‘download link not found’); return; } var url = $(element).attr(‘href’); console.log(‘url to download = ‘ + url); var d_type = format; if (format == ‘csv’) { url = url.replace(‘format=csv’, ‘format=json’); d_type = ‘json’; } $.ajax({ url: url, type: “GET”, dataType: d_type, xhrFields: { withCredentials: true }, }).done(function (data, status, xhr) { console.log(‘SUCCESS’); console.log(‘status = ‘ + xhr.status); console.log(‘data = ‘ + data.length); ga(‘send’, ‘event’, ‘Data Request’, ‘tab export’, format, 1); var filename = buildFilename(url, format); downloadData(data, filename, format); }).fail(function (xhr, status, error) { console.log(‘ERROR’); console.log(‘status = ‘ + xhr.status); console.log(‘error message = ‘ + xhr.responseText) ga(‘send’, ‘event’, ‘Data Request’, ‘tab export’, format, 0); if (xhr.status) { switch (xhr.status) { case 401: // unauthorized launchInvalidKeyModal(experience); break; case 403: // forbidden launchTrialOverModal(experience); break; case 400: // bad request launchBadRequestModal(experience); break; case 409: // conflict (more requests per second than allowed) launchThrottleModal(experience); break; default: console.log(‘Unhandled status = ‘ + xhr.status) var redirect_url = ”; if (TESymbol) { redirect_url = ‘https://data.tradingeconomics.com/Data/Export?term=’ + TESymbol; } else { redirect_url = ‘https://data.tradingeconomics.com/Data/Export’; } console.log(‘redirecting to: ‘ + redirect_url); window.open(redirect_url, ‘_blank’); break; } } }).always(function (xhr, status, error) { loading.remove(); console.log(‘done downloading!’); lock_download = false; }); } function buildFilename(url, format) { var filename = decodeURI(url); filename = filename.replace(“https://api.tradingeconomics.com/”, “”); var questionMark = filename.indexOf(‘?’); if (questionMark != -1) filename = filename.substring(0, questionMark); filename = filename.replace(///g, ‘_’); filename = filename.replace(/s/g, ‘_’); filename = filename.replace(/:/g, ‘_’); filename = filename.replace(/-/g, ‘_’); return filename + ‘.’ + format; } function downloadData(data, filename, type) { var dataFile = null; switch (type) { case “csv”: var csv = convertArrayOfObjectsToCSV({ data: data }); if (csv == null) return; // create the csv file var dataFile = new Blob([csv], { type: “text/csv;charset=utf-8” }); break; case “json”: var dataFile = new Blob([JSON.stringify(data)], { type: “text/json;charset=utf-8” }); break; case “xml”: var dataFile = new Blob([new XMLSerializer().serializeToString(data.documentElement)], { type: “text/plain;charset=utf-8” }); break; } if (dataFile != null) { var anchor = document.createElement(‘a’); anchor.href = window.URL.createObjectURL(dataFile); anchor.setAttribute(“hidden”, true); anchor.setAttribute(“target”, “_self”); anchor.setAttribute(“download”, filename); document.body.appendChild(anchor); anchor.click(); anchor.remove(); } } /* Download CSV from: https://halistechnology.com/2015/05/28/use-javascript-to-export-your-data-as-csv/ */ function convertArrayOfObjectsToCSV(args) { var result, ctr, keys, columnDelimiter, lineDelimiter, data; data = args.data || null; if (data == null || !data.length) { return null; } columnDelimiter = args.columnDelimiter || ‘,’; lineDelimiter = args.lineDelimiter || ‘rn’; keys = Object.keys(data[0]); result = ”; result += keys.join(columnDelimiter); result += lineDelimiter; data.forEach(function (item) { ctr = 0; keys.forEach(function (key) { if (ctr > 0) result += columnDelimiter; result += item[key]; ctr++; }); result += lineDelimiter; }); return result; } function launchTrialOverModal(experience) { if (!experience) { experience = getParameterByName(“ex”, window.location.href); } if (!experience || experience == 1) { var panel = createPanel( ‘ACTIVATE’, ‘https://billing.tradingeconomics.com/plans.aspx?activate=true’, ‘Activate your plan to get more data from Trading Economics’, ‘account+limit’); $(“#export-data-msg”).append(panel); } else if (experience == 2) { createModal( ‘ACTIVATE’, ‘https://billing.tradingeconomics.com/plans.aspx?activate=true’, ‘Activate your plan to get more data from Trading Economics’, ‘account+limit’); } } function launchInvalidKeyModal() { var experience = getParameterByName(“ex”, window.location.href); if (!experience || experience == 1) { var panel = createPanel( ‘Get Started’, ‘https://billing.tradingeconomics.com/plans.aspx?lead=true’, ‘Trading Economics provides its premium members with access to more than 20 million indicators for 196 countries plus historical/delayed/live quotes for exchange rates, stocks,’ + ‘ indexes, bonds and commodity prices. Subscribe to a plan to download data in a easy to use web interface, using our excel addin or our API.’, ‘Subscription+Plans’); $(“#export-data-msg”).append(panel); } else if (experience == 2) { createModal( ‘Get Started’, ‘https://billing.tradingeconomics.com/plans.aspx?lead=true’, ‘Trading Economics provides its premium members with access to more than 20 million indicators for 196 countries plus historical/delayed/live quotes for exchange rates, stocks,’ + ‘ indexes, bonds and commodity prices. Subscribe to a plan to download data in a easy to use web interface, using our excel addin or our API.’, ‘Subscription+Plans’); } } function launchThrottleModal() { var experience = getParameterByName(“ex”, window.location.href); if (!experience || experience == 1) { var panel = createPanel( null, null, ‘Limit of request per second reached’, ‘API+Access’); $(“#export-data-msg”).append(panel); } else if (experience == 2) { createModal( null, null, ‘Limit of request per second reached’, ‘API+Access’); } } function launchBadRequestModal() { var experience = getParameterByName(“ex”, window.location.href); if (!experience || experience == 1) { var panel = createPanel( ‘CONTACT SUPPORT’, ‘https://tradingeconomics.com/contact.aspx?subject=API+Bad+Request’, ‘Something went wrong with the request, please contact support@tradingeconomics.com, or click the button bellow’, ‘API+Access’); $(“#export-data-msg”).append(panel); } else if (experience == 2) { createModal( ‘CONTACT SUPPORT’, ‘https://tradingeconomics.com/contact.aspx?subject=API+Bad+Request’, ‘Something went wrong with the request, please contact support@tradingeconomics.com, or click the button bellow’, ‘API+Access’); } } function createModal(actionCallBtnText, actionCallBtnLink, text, contactSubject, title) { var htmlModal = ` `+ (title ? ‘

      ‘ + title + ” : ”) + ` `+ (text ? ‘

      ‘ + text + ” : ”) + ` `+ (actionCallBtnText ? ” + actionCallBtnText + ” : ”) + `

      Any question? Contact us ` // create the modal var modal = $(htmlModal); $(modal).modal(‘show’); } function createPanel(actionCallBtnText, actionCallBtnLink, text, contactSubject, title) { var htmlPanel = ` `+ (title ? ‘

      ‘ + title + ” : ”) + ` `+ (text ? ‘

      ‘ + text + ” : ”) + ` `+ (actionCallBtnText ? ‘‘ + actionCallBtnText + ” : ”) + `

      Any question? Contact us ` return htmlPanel; } function getParameterByName(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, ” “)); } function getApiSamples(country, category) { var _country = ”; var _category = ”; var exportURL = ”; if (country) _country = country.trim().toLowerCase(); else if (TECountry) _country = TECountry.trim().toLowerCase(); if (category) _category = category.trim().toLowerCase(); else if (TECategory) _category = TECategory.trim().toLowerCase(); var link = $(‘.export-btn-csv’).attr(‘href’); if (link) { if (link.indexOf(‘?format=csv’) != -1) exportURL = link.replace(‘?format=csv’, ”); else exportURL = link.replace(‘&format=csv’, ”); var userKeyURL = exportURL.indexOf(‘?’) != -1 ? ‘&c=Your_Key: Your_Secret’ : ‘?c=Your_Key: Your_Secret’; exportURL = exportURL + userKeyURL; } var apiCodeSamples = `

      API URL: ` + exportURL + `

      Code examples:

      Python:

      import tradingeconomics as te
      te.login(‘Your_Key:Your_Secret’)
      te.getIndicatorData(country=’`+ _country + `’, indicators=’` + _category + `’)

      jQuery:

      var url = ‘`+ exportURL + `’;
      $.ajax({
      url: url,
      type: “GET”,
      dataType: ‘json’
      }).done(function (data) {
      console.log(data);
      });
      `; return apiCodeSamples; } ]]>

      = remaining ? (clearTimeout(timeout), timeout = null, previous = now, result = func.apply(context, args)) : timeout || (timeout = setTimeout(later, remaining)), result } }, noop: function () { } } }(), VERSION = “0.10.5”, tokenizers = function () { “use strict”; function whitespace(str) { return str = _.toStr(str), str ? str.split(/s+/) : [] } function nonword(str) { return str = _.toStr(str), str ? str.split(/W+/) : [] } function getObjTokenizer(tokenizer) { return function () { var args = [].slice.call(arguments, 0); return function (o) { var tokens = []; return _.each(args, function (k) { tokens = tokens.concat(tokenizer(_.toStr(o[k]))) }), tokens } } } return { nonword: nonword, whitespace: whitespace, obj: { nonword: getObjTokenizer(nonword), whitespace: getObjTokenizer(whitespace) } } }(), LruCache = function () { “use strict”; function LruCache(maxSize) { this.maxSize = _.isNumber(maxSize) ? maxSize : 100, this.reset(), this.maxSize = this.maxSize && (this.list.remove(tailItem), delete this.hash[tailItem.key]), (node = this.hash[key]) ? (node.val = val, this.list.moveToFront(node)) : (node = new Node(key, val), this.list.add(node), this.hash[key] = node, this.size++) }, get: function (key) { var node = this.hash[key]; return node ? (this.list.moveToFront(node), node.val) : void 0 }, reset: function () { this.size = 0, this.hash = {}, this.list = new List } }), _.mixin(List.prototype, { add: function (node) { this.head && (node.next = this.head, this.head.prev = node), this.head = node, this.tail = this.tail || node }, remove: function (node) { node.prev ? node.prev.next = node.next : this.head = node.next, node.next ? node.next.prev = node.prev : this.tail = node.prev }, moveToFront: function (node) { this.remove(node), this.add(node) } }), LruCache }(), PersistentStorage = function () { “use strict”; function PersistentStorage(namespace) { this.prefix = [“__”, namespace, “__”].join(“”), this.ttlKey = “__ttl__”, this.keyMatcher = new RegExp(“^” + _.escapeRegExChars(this.prefix)) } function now() { return (new Date).getTime() } function encode(val) { return JSON.stringify(_.isUndefined(val) ? null : val) } function decode(val) { return JSON.parse(val) } var ls, methods; try { ls = window.localStorage, ls.setItem(“~~~”, “!”), ls.removeItem(“~~~”) } catch (err) { ls = null } return methods = ls && window.JSON ? { _prefix: function (key) { return this.prefix + key }, _ttlKey: function (key) { return this._prefix(key) + this.ttlKey }, get: function (key) { return this.isExpired(key) && this.remove(key), decode(ls.getItem(this._prefix(key))) }, set: function (key, val, ttl) { return _.isNumber(ttl) ? ls.setItem(this._ttlKey(key), encode(now() + ttl)) : ls.removeItem(this._ttlKey(key)), ls.setItem(this._prefix(key), encode(val)) }, remove: function (key) { return ls.removeItem(this._ttlKey(key)), ls.removeItem(this._prefix(key)), this }, clear: function () { var i, key, keys = [], len = ls.length; for (i = 0; len > i; i++) (key = ls.key(i)).match(this.keyMatcher) && keys.push(key.replace(this.keyMatcher, “”)); for (i = keys.length; i–;) this.remove(keys[i]); return this }, isExpired: function (key) { var ttl = decode(ls.getItem(this._ttlKey(key))); return _.isNumber(ttl) && now() > ttl ? !0 : !1 } } : { get: _.noop, set: _.noop, remove: _.noop, clear: _.noop, isExpired: _.noop }, _.mixin(PersistentStorage.prototype, methods), PersistentStorage }(), Transport = function () { “use strict”; function Transport(o) { o = o || {}, this.cancelled = !1, this.lastUrl = null, this._send = o.transport ? callbackToDeferred(o.transport) : $.ajax, this._get = o.rateLimiter ? o.rateLimiter(this._get) : this._get, this._cache = o.cache === !1 ? new LruCache(0) : sharedCache } function callbackToDeferred(fn) { return function (url, o) { function onSuccess(resp) { _.defer(function () { deferred.resolve(resp) }) } function onError(err) { _.defer(function () { deferred.reject(err) }) } var deferred = $.Deferred(); return fn(url, o, onSuccess, onError), deferred } } var pendingRequestsCount = 0, pendingRequests = {}, maxPendingRequests = 6, sharedCache = new LruCache(10); return Transport.setMaxPendingRequests = function (num) { maxPendingRequests = num }, Transport.resetCache = function () { sharedCache.reset() }, _.mixin(Transport.prototype, { _get: function (url, o, cb) { function done(resp) { cb && cb(null, resp), that._cache.set(url, resp) } function fail() { cb && cb(!0) } function always() { pendingRequestsCount– , delete pendingRequests[url], that.onDeckRequestArgs && (that._get.apply(that, that.onDeckRequestArgs), that.onDeckRequestArgs = null) } var jqXhr, that = this; this.cancelled || url !== this.lastUrl || ((jqXhr = pendingRequests[url]) ? jqXhr.done(done).fail(fail) : maxPendingRequests > pendingRequestsCount ? (pendingRequestsCount++ , pendingRequests[url] = this._send(url, o).done(done).fail(fail).always(always)) : this.onDeckRequestArgs = [].slice.call(arguments, 0)) }, get: function (url, o, cb) { var resp; return _.isFunction(o) && (cb = o, o = {}), this.cancelled = !1, this.lastUrl = url, (resp = this._cache.get(url)) ? _.defer(function () { cb && cb(null, resp) }) : this._get(url, o, cb), !!resp }, cancel: function () { this.cancelled = !0 } }), Transport }(), SearchIndex = function () { “use strict”; function SearchIndex(o) { o = o || {}, o.datumTokenizer && o.queryTokenizer || $.error(“datumTokenizer and queryTokenizer are both required”), this.datumTokenizer = o.datumTokenizer, this.queryTokenizer = o.queryTokenizer, this.reset() } function normalizeTokens(tokens) { return tokens = _.filter(tokens, function (token) { return !!token }), tokens = _.map(tokens, function (token) { return token.toLowerCase() }) } function newNode() { return { ids: [], children: {} } } function unique(array) { for (var seen = {}, uniques = [], i = 0, len = array.length; len > i; i++) seen[array[i]] || (seen[array[i]] = !0, uniques.push(array[i])); return uniques } function getIntersection(arrayA, arrayB) { function compare(a, b) { return a – b } var ai = 0, bi = 0, intersection = []; arrayA = arrayA.sort(compare), arrayB = arrayB.sort(compare); for (var lenArrayA = arrayA.length, lenArrayB = arrayB.length; lenArrayA > ai && lenArrayB > bi;) arrayA[ai] arrayB[bi] ? bi++ : (intersection.push(arrayA[ai]), ai++ , bi++); return intersection } return _.mixin(SearchIndex.prototype, { bootstrap: function (o) { this.datums = o.datums, this.trie = o.trie }, add: function (data) { var that = this; data = _.isArray(data) ? data : [data], _.each(data, function (datum) { var id, tokens; id = that.datums.push(datum) – 1, tokens = normalizeTokens(that.datumTokenizer(datum)), _.each(tokens, function (token) { var node, chars, ch; for (node = that.trie, chars = token.split(“”); ch = chars.shift();) node = node.children[ch] || (node.children[ch] = newNode()), node.ids.push(id) }) }) }, get: function (query) { var tokens, matches, that = this; return tokens = normalizeTokens(this.queryTokenizer(query)), _.each(tokens, function (token) { var node, chars, ch, ids; if (matches && 0 === matches.length) return !1; for (node = that.trie, chars = token.split(“”); node && (ch = chars.shift());) node = node.children[ch]; return node && 0 === chars.length ? (ids = node.ids.slice(0), void (matches = matches ? getIntersection(matches, ids) : ids)) : (matches = [], !1) }), matches ? _.map(unique(matches), function (id) { return that.datums[id] }) : [] }, reset: function () { this.datums = [], this.trie = newNode() }, serialize: function () { return { datums: this.datums, trie: this.trie } } }), SearchIndex }(), oParser = function () { “use strict”; function getLocal(o) { return o.local || null } function getPrefetch(o) { var prefetch, defaults; return defaults = { url: null, thumbprint: “”, ttl: 864e5, filter: null, ajax: {} }, (prefetch = o.prefetch || null) && (prefetch = _.isString(prefetch) ? { url: prefetch } : prefetch, prefetch = _.mixin(defaults, prefetch), prefetch.thumbprint = VERSION + prefetch.thumbprint, prefetch.ajax.type = prefetch.ajax.type || “GET”, prefetch.ajax.dataType = prefetch.ajax.dataType || “json”, !prefetch.url && $.error(“prefetch requires url to be set”)), prefetch } function getRemote(o) { function byDebounce(wait) { return function (fn) { return _.debounce(fn, wait) } } function byThrottle(wait) { return function (fn) { return _.throttle(fn, wait) } } var remote, defaults; return defaults = { url: null, cache: !0, wildcard: “%QUERY”, replace: null, rateLimitBy: “debounce”, rateLimitWait: 300, send: null, filter: null, ajax: {} }, (remote = o.remote || null) && (remote = _.isString(remote) ? { url: remote } : remote, remote = _.mixin(defaults, remote), remote.rateLimiter = /^throttle$/i.test(remote.rateLimitBy) ? byThrottle(remote.rateLimitWait) : byDebounce(remote.rateLimitWait), remote.ajax.type = remote.ajax.type || “GET”, remote.ajax.dataType = remote.ajax.dataType || “json”, delete remote.rateLimitBy, delete remote.rateLimitWait, !remote.url && $.error(“remote requires url to be set”)), remote } return { local: getLocal, prefetch: getPrefetch, remote: getRemote } }(); !function (root) { “use strict”; function Bloodhound(o) { o && (o.local || o.prefetch || o.remote) || $.error(“one of local, prefetch, or remote is required”), this.limit = o.limit || 5, this.sorter = getSorter(o.sorter), this.dupDetector = o.dupDetector || ignoreDuplicates, this.local = oParser.local(o), this.prefetch = oParser.prefetch(o), this.remote = oParser.remote(o), this.cacheKey = this.prefetch ? this.prefetch.cacheKey || this.prefetch.url : null, this.index = new SearchIndex({ datumTokenizer: o.datumTokenizer, queryTokenizer: o.queryTokenizer }), this.storage = this.cacheKey ? new PersistentStorage(this.cacheKey) : null } function getSorter(sortFn) { function sort(array) { return array.sort(sortFn) } function noSort(array) { return array } return _.isFunction(sortFn) ? sort : noSort } function ignoreDuplicates() { return !1 } var old, keys; return old = root.Bloodhound, keys = { data: “data”, protocol: “protocol”, thumbprint: “thumbprint” }, root.Bloodhound = Bloodhound, Bloodhound.noConflict = function () { return root.Bloodhound = old, Bloodhound }, Bloodhound.tokenizers = tokenizers, _.mixin(Bloodhound.prototype, { _loadPrefetch: function (o) { function handlePrefetchResponse(resp) { that.clear(), that.add(o.filter ? o.filter(resp) : resp), that._saveToStorage(that.index.serialize(), o.thumbprint, o.ttl) } var serialized, deferred, that = this; return (serialized = this._readFromStorage(o.thumbprint)) ? (this.index.bootstrap(serialized), deferred = $.Deferred().resolve()) : deferred = $.ajax(o.url, o.ajax).done(handlePrefetchResponse), deferred }, _getFromRemote: function (query, cb) { function handleRemoteResponse(err, resp) { cb(err ? [] : that.remote.filter ? that.remote.filter(resp) : resp) } var url, uriEncodedQuery, that = this; if (this.transport) return query = query || “”, uriEncodedQuery = encodeURIComponent(query), url = this.remote.replace ? this.remote.replace(this.remote.url, query) : this.remote.url.replace(this.remote.wildcard, uriEncodedQuery), this.transport.get(url, this.remote.ajax, handleRemoteResponse) }, _cancelLastRemoteRequest: function () { this.transport && this.transport.cancel() }, _saveToStorage: function (data, thumbprint, ttl) { this.storage && (this.storage.set(keys.data, data, ttl), this.storage.set(keys.protocol, location.protocol, ttl), this.storage.set(keys.thumbprint, thumbprint, ttl)) }, _readFromStorage: function (thumbprint) { var isExpired, stored = {}; return this.storage && (stored.data = this.storage.get(keys.data), stored.protocol = this.storage.get(keys.protocol), stored.thumbprint = this.storage.get(keys.thumbprint)), isExpired = stored.thumbprint !== thumbprint || stored.protocol !== location.protocol, stored.data && !isExpired ? stored.data : null }, _initialize: function () { function addLocalToIndex() { that.add(_.isFunction(local) ? local() : local) } var deferred, that = this, local = this.local; return deferred = this.prefetch ? this._loadPrefetch(this.prefetch) : $.Deferred().resolve(), local && deferred.done(addLocalToIndex), this.transport = this.remote ? new Transport(this.remote) : null, this.initPromise = deferred.promise() }, initialize: function (force) { return !this.initPromise || force ? this._initialize() : this.initPromise }, add: function (data) { this.index.add(data) }, get: function (query, cb) { function returnRemoteMatches(remoteMatches) { var matchesWithBackfill = matches.slice(0); _.each(remoteMatches, function (remoteMatch) { var isDuplicate; return isDuplicate = _.some(matchesWithBackfill, function (match) { return that.dupDetector(remoteMatch, match) }), !isDuplicate && matchesWithBackfill.push(remoteMatch), matchesWithBackfill.length < that.limit }), cb && cb(that.sorter(matchesWithBackfill)) } var that = this, matches = [], cacheHit = !1; matches = this.index.get(query), matches = this.sorter(matches).slice(0, this.limit), matches.length 0 || !this.transport) && cb && cb(matches) }, clear: function () { this.index.reset() }, clearPrefetchCache: function () { this.storage && this.storage.clear() }, clearRemoteCache: function () { this.transport && Transport.resetCache() }, ttAdapter: function () { return _.bind(this.get, this) } }), Bloodhound }(this) }(window.jQuery);]]>‘, “”, “”]; var i = function (i, s) { if (this.$element = t(i), this.options = t.extend({}, t.fn.iec_typeahead.defaults, s), this.matcher = this.options.matcher || this.matcher, this.wrapper = this.options.wrapper || [], this.table_chart_button = this.options.table_chart_button || !1, this.goDirectly = this.options.goDirectly || !1, this.lang = “string” == typeof window.iec_language ? window.iec_language : “en”, this.sorter = this.options.sorter || this.sorter, this.allow_more = this.options.allow_more || !1, this.go_for_context = this.options.go_for_context || this.options.goForContext || !1, this.in_context_length = this.options.in_context_length || this.options.inContextLength || 0, this.in_context_stack = [], this.rendered = 0, this.select = this.options.select || this.select, this.allow_facilitator_more = this.options.allow_facilitator_more || this.options.allowNavigator || !1, this.on_facilitator_more_click = this.options.on_facilitator_more_click || this.options.onNavigatorMoreClick || !1, this.autoSelect = “boolean” != typeof this.options.autoSelect || this.options.autoSelect, this.expandable = “boolean” == typeof this.options.expandable && this.options.expandable, this.highlighter = this.options.highlighter || this.highlighter, this.render = this.options.render || this.render, this.updater = this.options.updater || this.updater, this.source = this.options.source, this.delay = “number” == typeof this.options.delay ? this.options.delay : 100, this.forceRenderToTextBox = void 0 === this.options.forceRenderToTextBox || this.options.forceRenderToTextBox, this.selectionHandler = void 0 !== this.options.selectionHandler && this.options.selectionHandler, this.$menu = t(this.options.menu), this.options.setClasses && this.options.setClasses.ul) { var o = this.options.setClasses.ul.split(” “); for (var n in o) this.$menu.addClass(o[n]) } if (this.options.setStyles && this.options.setStyles.ul) for (var a in this.options.setStyles.ul) this.options.setStyles.ul[a].p && (console.log(“setting style”, this.options.setStyles.ul[a]), this.$menu.style(this.options.setStyles.ul[a].p, this.options.setStyles.ul[a].v, this.options.setStyles.ul[a].i)); this.shown = !1, this.tabs = [], this.stance = 0, this.req_num = 0, this.listen(), this.showHintOnFocus = “boolean” == typeof this.options.showHintOnFocus && this.options.showHintOnFocus, this.afterSelect = this.options.afterSelect || this.afterSelect, this.appendMenuTo = this.options.appendMenuTo || !1, this.originalQuery = !1, this.searching_for_something = !1, this.renderAnimation = this.options.renderAnimation || !1; var r = {}; void 0 !== e ? r = e : void 0 !== s.typeahead_little_helper && (r = this.options.typeahead_little_helper), this.typeahead_little_helper = r, void 0 === this.options.typeahead_little_helper && (this.options.typeahead_little_helper = r), r[this.wrapper] ? this.classname = t(r[this.wrapper][0])[0].className || “none” : this.classname = “none”, this.own_special_class = “ieconomics-” + Math.round(1e6 * Math.random()) + “-logic”, this.$element.data(“ieconomics”, this.own_special_class), this.$element.addClass(this.own_special_class) }; i.prototype = { constructor: i, afterSelect: function (e, i) { if (e && “go” == e) { console.log(“trigger:”, e), this.renderAnimation && this.renderAnimation(); var s = (t(“#searchu”).val() || t(“#searchd”).val()).trim().toLowerCase(); window.searchQueryEncode && (s = searchQueryEncode(s)), window.location.href = “http://” + window.location.host + “/” + s } }, select: function (e) { var i = this.$menu.find(“.active”).data(“value”), s = !0; i || (i = this.$element.val(), s = !1); var o = { raw: this.$menu.find(“.active”).data(“raw”) || i, value: i, isListed: s, type: this.$menu.find(“.active”).data(“type”) }; if (this.selectionHandler) return this.selectionHandler(“https://tradingeconomics.com” + i, o, t(“#” + this.options.searchBoxId).val()); if (“go_more_results” != i) { if (this.autoSelect || i) { if (“go_facilitator_modal” == i) return this.hide(), event.preventDefault(), event.stopPropagation(), this.mouse_ignore = !0, this.focusout(), void (this.on_facilitator_more_click && this.on_facilitator_more_click()); this.goDirectly ? (this.renderAnimation && this.renderAnimation(), this.hide(), t(“#searchButton”).attr(“style”, “background-image: url(‘/cdn/ie/img/roundload.gif’)!important;background-color: #fff;”), window.location.href = “http://” + window.location.host + “/” + (“en” == this.lang ? “” : this.lang + “/”) + searchQueryEncode(i)) : (this.$element.val(this.updater(i)).change(), this.table_chart_button && e ? this.afterSelect(e, o) : this.afterSelect(null, o)) } else this.table_chart_button && e ? this.afterSelect(e, o) : this.afterSelect(“go”, o); return this.hide(), this.mouse_ignore = !0, “” } window.location.href = “https://tradingeconomics.com” + (“en” == this.lang ? “” : this.lang + “/”) + “more/” + (t(“#searchu”).val() || t(“#searchd”).val()).trim().toLowerCase().replace(/s/, “-“) }, updater: function (t) { this.query; return t }, setSource: function (t) { this.source = t }, show: function () { var e, i = t.extend({}, this.$element.position(), { height: this.$element[0].offsetHeight }); e = “function” == typeof this.options.scrollHeight ? this.options.scrollHeight.call() : this.options.scrollHeight; var s = i.top + i.height + e, o = i.left; return this.options.align && “left” == this.options.align && (console.log(“fix left”, this.$menu.width()), o = i.left + this.$element.width() – (0 != this.$menu.width() ? this.$menu.width() : 556)), this.appendMenuTo ? this.appendMenuTo.append(this.$menu.css({ top: s, left: o, display: “table” })) : this.forceRenderToTextBox ? this.$menu.insertAfter(this.$element).css({ top: s, left: o, display: “table” }) : this.$menu.show(), this.shown = !0, this }, hide: function () { return this.shown && (this.$menu.hide(), this.shown = !1), this }, lookup: function (e) { var i; if (this.originalQuery = !1, this.have_news = !0, this.query = null != e ? e : this.$element.val() || “”, this.query.length > this.options.minLength) { this.searching_for_something = setTimeout(function () { }, 1e3) } if (this.query.length < this.options.minLength && !this.showHintOnFocus) return this.shown ? this.hide() : this; var s = t.proxy(function () { var e = "?"; this.options && "thisIstheSearchBoxIdTag" == this.options.searchBoxId && (e = "&"), this.options && "thisIstheTinySearchBoxIdTag" == this.options.searchBoxId && (e = "&"), this.options && "ac" == this.options.wrapper && (e = "&"), (i = t.isFunction(this.source) ? this.source(encodeURIComponent(this.query) + e + "stance=" + ++this.req_num, t.proxy(this.process, this)) : this.source) && this.process(i) }, this); clearTimeout(this.lookupWorker), this.lookupWorker = setTimeout(s, this.delay) }, process: function (e) { this.have_news = !1, clearTimeout(this.searching_for_something); var i = this; if (e[0]) { if (e[0].stance) if (!(e[0].stance == i.req_num || "searching" == e[0].stance)) return; (e[0].total || 0 === e[0].total) && (i.setBadges(e[0]), e = e.slice(1, e.length + 1)) } return e = t.grep(e, function (t) { return i.matcher(t.name) }), (e = this.sorter(e)).length ? "all" == this.options.items ? this.render(e).show() : this.focused ? this.render(e).show() : void 0 : this.shown ? this.hide() : this }, setBadges: function (i) { if (this.tabs = [], 0 == this.tabs.length) { var s = e[this.wrapper]; for (var o in s) { var n = (t(s[o]).find("span").attr("class") || "").replace("iec-menu-tabs-nresults numresults-", ""); if (!(n.length t || e.tabs[0] && jQuery.getJSON("http://" + iec_api + "/src/iecac/" + e.query + "?tab=" + e.tabs[0].tab + " &onlystats=true", function () { }).done(function (i) { e.populate(e.tabs[0].l, e.tabs[0].tab, i[0].total), e.stance > t || (e.tabs = e.tabs.slice(1, e.tabs.length), e.fetchAndPopulate(t)) }) }, populate: function (i, s, o) { (o || 0 === o) && (e[this.wrapper][i] = t(e[this.wrapper][i]).find(“span”).text(“(” + o + “)”).parent().prop(“outerHTML”), t(“.numresults-” + s).text(“(” + o + “)”)) }, matcher: function (t) { return t ? “no results” == t ? -1 : “searching” == t ? -1 : ~t.toLowerCase().indexOf(this.query.toLowerCase()) > -1 ? -1 : ~t.toLowerCase().indexOf(this.query.toLowerCase()) : -1 }, sorter: function (t) { return t }, highlighter: function (t) { var e = extractor_multi(this.query), i = 0; return t ? (t.match(new RegExp(“(” + (e[0] || “”).trim() + “)”, “ig”)) || (t.match(new RegExp(“(” + e[1] + “)”, “ig”)) ? i = 1 : t.match(new RegExp(“(” + e[2] + “)”, “ig”)) ? i = 2 : t.match(new RegExp(“(” + e[3] + “)”, “ig”)) ? i = 3 : t.match(new RegExp(“(” + e[4] + “)”, “ig”)) && (i = 4)), t.replace(new RegExp(“(” + e[i] + “)”, “ig”), function (t, e) { return “” + e + “” })) : “” }, render: function (e) { var i = e; e[0] && void 0 !== e[0].page && (i = e[1]); var s = this; e.length; if (e = t(i).map(function (e, i) { e || (s.in_context_stack = [], s.rendered = 0); var o = s.options.items; if (s.allow_facilitator_more && o > 1 && (o -= 1), !(s.rendered > o)) { i.full_name = i.pretty_name || i.full_name || i.name, i.name = i.pretty_name || i.name, i.the_url = i.url || i.the_url || i.value, i.value = i.the_url, (e = t(s.options.item)).addClass(“list-group-item”), e.data(“value”, (i.value || “”).toLowerCase()), e.data(“type”, (i.type || “”).toLowerCase()), e.data(“raw”, i.value), e.find(“a”).prop(“title”, i.full_name || i.name), e.find(“a”).prop(“href”, “https://tradingeconomics.com” + i.the_url), e.find(“a > .iec-dd-val”).html(s.highlighter(i.name)), e.find(“a > .iec-dd-symbol”).html(i.symbol); var n = !1; return i.url && i.url.indexOf(“:”) > 0 && (“GOV” != (n = i.url.split(“:”)[1].toUpperCase()) && “IND” != n && “CUR” != n && “COM” != n || (n = !1)), i.origin = n || i.origin, i.origin ? e.find(“a > .iec-dd-origin”).html(i.origin.toUpperCase()) : e.find(“a > .iec-dd-origin”).addClass(“iec-dd-origin-empty”), s.rendered++ , e[0] } }), this.autoSelect && e.first().addClass(“active”), this.options.renderDiv ? this.$menu = t(“#” + this.options.renderDiv) : this.$menu.html(this.options.typeahead_little_helper[this.wrapper].join(“n”)), this.$menu.empty(), this.$menu.append(e), s.allow_more && e.length > 1) { var o = t(‘

    • ‘), n = t(“#” + this.options.searchBoxId).val().trim().toLowerCase(); this.options.moreUrlFormat && (n = this.options.moreUrlFormat + t(“#” + this.options.searchBoxId).val().trim().toLowerCase()), o.append(‘More’), this.$menu.append(o) } s.allow_facilitator_more && ((o = t(‘
    • ‘)).append(‘More’), this.$menu.append(o)); return this }, next: function (e) { var i = this.$menu.find(“.active”).removeClass(“active”).next(); i.length || (i = t(this.$menu.find(“li”)[0])), i.addClass(“active”) }, prev: function (e) { var i = this.$menu.find(“.active”).removeClass(“active”).prev(); i.length || (i = this.$menu.find(“li”).last()), “DIV” != t(i[0]).get(0).tagName && i.addClass(“active”) }, listen: function () { this.$element.on(“focus”, t.proxy(this.focus, this)).on(“blur”, t.proxy(this.blur, this)).on(“focusout”, t.proxy(this.focusout, this)).on(“keypress”, t.proxy(this.keypress, this)).on(“keyup”, t.proxy(this.keyup, this)), this.eventSupported(“keydown”) && this.$element.on(“keydown”, t.proxy(this.keydown, this)), this.$menu.on(“click”, t.proxy(this.click, this)).on(“mouseenter”, “li”, t.proxy(this.mouseenter, this)).on(“mouseleave”, “li”, t.proxy(this.mouseleave, this)) }, destroy: function () { this.$element.data(“typeahead”, null), this.$element.off(“focus”).off(“focusout”).off(“blur”).off(“keypress”).off(“keyup”), this.eventSupported(“keydown”) && this.$element.off(“keydown”), this.$menu.remove() }, eventSupported: function (t) { var e = t in this.$element; return e || (this.$element.setAttribute(t, “return;”), e = “function” == typeof this.$element[t]), e }, move: function (e) { if (this.shown) { switch (e.keyCode) { case 9: case 13: case 27: case 39: e.preventDefault(); break; case 38: if (e.shiftKey) return; if (e.preventDefault(), this.prev(), this.originalQuery || (this.originalQuery = this.$element.val()), “more results” == (i = t(t(“.” + this.classname).parent().find(“> li.active”)[0]).find(“span.iec-dd-val”).text()).toLowerCase() || “more” == i.toLowerCase()) return; “” == i.toLowerCase() && (i = this.originalQuery), this.$element.val(i.replace(/ss/g, ” “).trim().toLowerCase()); break; case 40: if (e.shiftKey) return; e.preventDefault(); var i; if (this.classname.indexOf(” “) > 1 && (this.classname = this.classname.substr(0, this.classname.indexOf(” “))), this.next(), this.originalQuery || (this.originalQuery = this.$element.val()), “more results” == (i = t(t(“.” + this.classname).parent().find(“> li.active”)[0]).find(“span.iec-dd-val”).text()).toLowerCase() || “more” == i.toLowerCase()) return; “” == i.toLowerCase() && (i = this.originalQuery), this.$element.val(i.replace(/ss/g, ” “).trim().toLowerCase()) }e.stopPropagation() } }, keydown: function (e) { this.suppressKeyPressRepeat = ~t.inArray(e.keyCode, [40, 38, 9, 13, 27, 39]), this.shown || 40 != e.keyCode ? this.move(e) : this.lookup(“”) }, keypress: function (t) { this.suppressKeyPressRepeat || this.move(t) }, keyup: function (e) { switch (e.keyCode) { case 40: case 38: case 16: case 17: case 18: break; case 9: case 39: if (!this.shown) return; this.select(); break; case 13: if (console.log(“event this?”, this.shown, this.autoSelect), !this.shown) { if (!this.autoSelect) { if (this.selectionHandler) { var i = { raw: “https://tradingeconomics.com” + this.$element.val(), value: this.$element.val(), isListed: !1, type: !1 }; return this.selectionHandler(“https://tradingeconomics.com” + this.$element.val(), i, t(“#” + this.options.searchBoxId).val()) } this.goDirectly || this.afterSelect(“go”) } return } this.select(), this.goDirectly || this.afterSelect(“go”); break; case 27: if (!this.shown) return; this.hide(); break; default: this.lookup() }e.stopPropagation(), e.preventDefault() }, focus: function (t) { if (!this.focused) { if (this.focused = !0, this.went_away) return this.$element.blur(), void (this.went_away = !1); this.show(), (0 === this.options.minLength && !this.$element.val() || this.options.showHintOnFocus) && this.lookup() } }, focusout: function (e) { this.focused = !1, this.mousedover || !this.shown || t(“#” + this.options.renderDiv).is(“:hover”) || this.hide() }, click: function (t) { console.log(“CLICKED -> e.target”, t.target), t.preventDefault(), t.target.className.toString().indexOf(“menu-tabs”) > -1 || this.select() }, mouseenter: function (e) { this.mousedover = !0, this.$menu.find(“.active”).removeClass(“active”), t(e.currentTarget).addClass(“active”) }, mouseleave: function (t) { this.mousedover = !1, this.mouse_ignore ? this.mouse_ignore = !1 : this.focused || (this.$element.focus(), this.focused = !0) } }; var s = t.fn.typeahead; t.fn.iec_typeahead = function (e) { var s = arguments; return this.each(function () { var o = t(this), n = o.data(“typeahead”), a = “object” == typeof e && e; n || o.data(“typeahead”, n = new i(this, a)), “string” == typeof e && (s.length > 1 ? n[e].apply(n, Array.prototype.slice.call(s, 1)) : n[e]()) }) }, t.fn.iec_typeahead.defaults = { source: [], items: 8, menu: ‘

    • 0?d(n||$(“#”+o).val()):window.location.href=e:d(n||$(“#”+o).val())}a.initialize();$(“#”+o).iec_typeahead({items:7,autoSelect:!1,wrapper:”default”,expandable:!0,source:a.ttAdapter(),goDirectly:!0,allow_more:!0,searchBoxId:o,renderDiv:”dpSearch-resultCnt”,forceRenderToTextBox:!1,selectionHandler:r,moreUrlFormat:e}),$(“#thisIstheTinySearchBoxIdTag”).iec_typeahead({items:7,autoSelect:!1,wrapper:”default”,expandable:!0,source:a.ttAdapter(),goDirectly:!0,allow_more:!0,searchBoxId:”thisIstheTinySearchBoxIdTag”,renderDiv:”dpSearch-resultCnt-tiny”,forceRenderToTextBox:!1,selectionHandler:r,moreUrlFormat:e});$(“#”+o).on(“focus”,function(e){s()}),$(“#”+o).on(“focusout”,function(e){$(e.target).attr(“id”)!=o&&(i=!1,c())});var s=function(){if(myResultsDisplayer=”#dpSearch-resultCnt”,!n){n=!0;var e=$(“.navbar-collapse”).width(),t=$(“.navbar-header”).width(),a=Math.min(Math.max(400,e-t-200),800);console.log(“expand”),$(“#thisIsTheSearchBoxWrapperId”).toggleClass(“is-wide-open”),$(“#”+o).animate({width:a},301),$(“#”+o).toggleClass(“hidden-sm”),$(“#”+o).animate({width:a},10),$(“.nav>.dropdown”).hide(300,function(){i||(i=!0)}),$(“#”+o).focus(),$(“#”+o).val()&&$(“#”+o).val().length&&(console.log(“expand immediatly”),l())}},c=function(){n&&(n=!1,$(“#thisIsTheSearchBoxWrapperId”).toggleClass(“is-wide-open”),$(“#”+o).toggleClass(“hidden-sm”),h(),$(“#”+o).css(“width”,””),$(“.nav>.dropdown”).show(100,function(){}))},l=function(){t||(t=!0)},h=function(){t=!1};function d(o){if(o&&””!=o){var t=e+encodeURIComponent(o);window.location=t}}$(“#thisIsTheBigGlyphiconId”).click(function(e){n?d($(“#”+o).val()):s()}),$(“#thisIsTheSmallGlyphiconId”).click(function(e){n?d($(“#”+o).val()):s()}),$(“#thisIsTheTinyGlyphiconId”).click(function(e){console.log(“tiny click”),n||function(){myResultsDisplayer=”#dpSearch-resultCnt-tiny”;$(“#mainHeader”).hide(300,function(){}),$(“#searchMobileHeader”).show(300,function(){}),$(“#thisIstheTinySearchBoxIdTag”).focus(),$(“#thisIstheTinySearchBoxIdTag”).val()&&$(“#thisIstheTinySearchBoxIdTag”).val().length&&(console.log(“expand immediatly”),l())}()}),$(“#thisIsTheTinyRemoveId”).click(function(e){$(“#searchMobileHeader”).hide(300,function(){}),$(“#mainHeader”).show(300,function(){})}),$(document).on(“click”,function(e){!n||$(“#dpSearch-resultCnt”).is(“:hover”)||$(“#”+o).is(“:hover”)||$(“#”+o).is(“:focus”)||$(“#thisIsTheSearchPlaceholderId”).is(“:hover”)||c()})}();]]> -1) { console.log(“AdSense Not Loaded”); return; } console.log(“AdSense Document Ready”); // Wait for one second to ensure the user started browsing setTimeout(function () { console.log(“AdSense Timeout”); (adsbygoogle = window.adsbygoogle || []); $(“ins.adsbygoogle”).each(function () { console.log(‘AdSense Found Ad’); var s = document.createElement(“script”); s.type = “text/javascript”; s.text = “(adsbygoogle = window.adsbygoogle || []).push({})”; $(s).insertAfter($(this)); }); addScript(“https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js”, true); }, 100); }); ]]>

      Source