-
Notifications
You must be signed in to change notification settings - Fork 2
/
custom.min.js
1 lines (1 loc) · 28.2 KB
/
custom.min.js
1
"use strict";var CD=CD||{};CD.Api=function(a,b){var c="//api.coindesk.com",d=function(a,c){var d=c.times,e=a.timeout;return function(f){function g(){b.ajax(h).retry({times:d-1,timeout:c.timeout}).pipe(i.resolve,i.reject)}var h=this,i=new b.Deferred,j=a.getResponseHeader("Retry-After");return d>1&&(!a.statusCodes||b.inArray(f.status,a.statusCodes)>-1)?(j&&(e=isNaN(j)?new Date(j).getTime()-b.now():1e3*parseInt(j,10),(isNaN(e)||0>e)&&(e=a.timeout)),void 0!==e?setTimeout(g,e):g()):i.rejectWith(this,arguments),i}};return b.ajaxPrefilter(function(a,b,c){c.retry=function(a){return a.timeout&&(this.timeout=a.timeout),a.statusCodes&&(this.statusCodes=a.statusCodes),this.pipe(null,d(this,a))}}),a.getBPICurrentPrice=function(){return b.ajax({url:c+"/site/headerdata.json",dataType:"json"})},a.getBPICurrentPriceCalc=function(){return b.ajax({url:c+"/v1/bpi/currentprice/allcurrencies.json?showex=1&calc=1",dataType:"json"})},a.getBPICurrentPrice24Hours=function(){return b.ajax({url:c+"/headerchart/history",dataType:"json"})},a.getBTXChartData=function(a){return b.ajax({url:c+"/btxcharts/data?data="+a,dataType:"json"})},a.getSentimentIndexData=function(a){return a=a.toUpperCase(),b.ajax({type:"GET",url:"//widgets.qriously.com/coindesk/idxI_"+a+"_s_v2.json"})},a.redditSearch=function(a){return b.ajax({type:"GET",contentType:"text/plain",xhrFields:{withCredentials:!1},url:"//www.reddit.com/search.json?q=url:"+a})},a}(CD.Api||{},jQuery);var CD=CD||{};CD.Calculator=function(a,b){var c=b("#btcinput"),d=b("#fiatinput"),e=b("#fiatcurrency"),f=b("#fiatcurrencymobile"),g=null,h=[],i="btc",j=" - Bitcoin Calculator - Convert Bitcoin Prices into USD",k="Conversion rate as per Bitcoin Price Index, last updated at ",l="USD",m=!1,n=6e4,o=function(){CD.Api.getBPICurrentPriceCalc().then(function(b){a.storeCurrencyRates(b)})},p=function(){var a,f=e.val();if("btc"===i){var h=c.val();h=parseFloat(h.replace(/[^0-9-.]/g,"")),a=h*g.bpi[f].rate_float,d.val(CD.Helpers.formatMoney(a,2,"")),m||(document.title=CD.Helpers.formatMoney(a,2,"")+" "+f+j)}else{var l=d.val();l=parseFloat(l.replace(/[^0-9-.]/g,"")),a=l/g.bpi[f].rate_float,c.val(CD.Helpers.formatMoney(a,6,"")),m||(document.title=CD.Helpers.formatMoney(a,6,"")+j)}b(".updatetime").html(k+g.time.updateduk)},q=function(a){var c="";return b.each(a,function(a,b){return"BTC"===a?!0:(c+='<option value="'+a+'">'+a+"</option>",void h.push({iso:a,label:a+" - "+b.description}))}),c},r=function(){f.append(q(g.bpi)),e.autocomplete({minLength:0,source:h,position:{offset:"-150 4"},focus:function(a,b){return e.val(b.item.iso),!1},select:function(a,b){return e.val(b.item.iso).blur(),p(),!1},_resizeMenu:function(){this.menu.element.outerWidth(325)},open:function(){b(this).autocomplete("widget").css("width",300)}})},s=function(){c.keyup(function(a){9!==a.which&&(i="btc",p())}),d.keyup(function(a){9!==a.which&&(i="fiat",p())}),b(".exchangeratecontainer .numericonly").bind("keyup paste",function(){setTimeout(b.proxy(function(){this.val(this.val().replace(/[^0-9.]/g,"")),p()},b(this)),0)}),e.on({change:function(){p()},focus:function(){return""!==b(this).val()&&(l=b(this).val()),b(this).val("").autocomplete("search",""),!1},blur:function(){""===b(this).val()&&b(this).val(l)},keydown:function(a){13===a.keyCode&&e.autocomplete("close")}}),d.add(c).on({focus:function(){var a=b(this).val();b(this).val(parseFloat(a.replace(/[^0-9-.]/g,"")))},blur:function(){var a="fiatinput"===b(this).attr("id")?2:6,c=parseFloat(b(this).val());b(this).val(CD.Helpers.formatMoney(c,a,""))},keydown:function(a){38===a.which&&setTimeout(b.proxy(function(){this.val(parseFloat(this.val())+1)},b(this)),0),40===a.which&&setTimeout(b.proxy(function(){parseFloat(this.val())>0&&this.val(parseFloat(this.val())-1)},b(this)),0)}}),f.on("change",function(){e.val(f.find(":selected").text()).trigger("keyup"),p()})};return a.storeCurrencyRates=function(a){g=a,0===f.has("option").length&&r(),p()},a.init=function(){m=CD.Helpers.detectPages("price"),setInterval(function(){o()},n),o(),s()},a}(CD.Calculator||{},jQuery);var CD=CD||{};CD.ChartConfigs=function(a,b){var c=function(a){var b={};switch(a){case"xbttotal":b.LHSLegend="Total Bitcoins (XBT)",b.toolTipText="Total XBT",b.friendlyUnit="millions";break;case"ltctotal":b.LHSLegend="Total Litecoins (LTC)",b.toolTipText="Total LTC",b.friendlyUnit="millions";break;case"xbtdailytransactions":case"ltcdailytransactions":b.LHSLegend="Daily Transactions",b.toolTipText="Transactions",b.friendlyUnit="thousands";break;case"xbtavgtransactionsperblock":case"ltcavgtransactionsperblock":b.LHSLegend="Daily # Average Transactions",b.toolTipText="Avg. Transactions";break;case"xbtmarketcap":case"ltcmarketcap":b.LHSLegend="Market Cap (USD)",b.toolTipText="Market Cap (USD)",b.friendlyUnit="billions",b.currencySymbol="$",b.initialZoom=3;break;case"xbtminingdifficulty":case"ltcminingdifficulty":b.LHSLegend="Difficulty",b.toolTipText="Difficulty",b.friendlyUnit="thousands",b.initialZoom=3}return b};return a.setGlobalChartOptions=function(){return Highcharts?void Highcharts.setOptions({chart:{style:{fontFamily:"ProximaNova, 'Helvetica Neue', Helvetica, Arial, sans-serif"}},lang:{rangeSelectorZoom:"",rangeSelectorFrom:"",rangeSelectorTo:"to"}}):!1}(),a.getBaseConfig=function(){return{colors:["#333"],chart:{events:{load:CD.ChartConfigs.addLogoToChart},alignTicks:!1,zoomType:"x",pinchType:"x",panning:!0,selectionMarkerFill:"rgba(251,192,1,0.25)",backgroundColor:"#fff",borderWidth:0,borderRadius:0,plotBackgroundColor:null,plotShadow:!1,plotBorderWidth:0},lang:{contextButtonTitle:"Export options for this chart"},navigation:{menuItemStyle:{background:"none",padding:"10px",color:"#555",fontSize:"12px"},menuItemHoverStyle:{background:"#d8d8d8",color:"#555"},buttonOptions:{theme:{r:0,states:{hover:{fill:"#fff",stroke:"#fff"},select:{stroke:"#fff",fill:"#fff"}}}}},navigator:{adaptToUpdatedData:!1,handles:{backgroundColor:"#FBC001",borderColor:"#555"},outlineColor:"#555",maskFill:"rgba(255,255,255,.75)",series:{color:"#fcf0d7",lineColor:"#FBC001",fillOpacity:1,lineWidth:2}},rangeSelector:{inputPosition:{x:-80},buttonSpacing:3,inputBoxBorderColor:"#d8d8d8",inputStyle:{color:"#8a8a8a",fontSize:"12px",fontFamily:"Arial"},labelStyle:{color:"#8a8a8a",fontSize:"13px",fontFamily:"Arial",marginTop:"-10px"},buttonTheme:{fill:"#e6e6e6",stroke:"#e6e6e6",r:0,width:30,style:{color:"#555",fontSize:"12px"},states:{hover:{fill:"#d8d8d8",stroke:"#d8d8d8",style:{color:"#555"}},select:{fill:"#FBC001",stroke:"#FBC001",style:{color:"#555"}}}}},title:{text:"",style:{fontSize:"20px",fontWeight:"bold",color:"#545454"}},scrollbar:{liveRedraw:!1},yAxis:{showFirstLabel:!1,gridLineColor:"#e8e8e8",lineWidth:0,tickWidth:0,labels:{style:{color:"#8a8a8a"}}},xAxis:{gridLineWidth:0,lineColor:"#fff",tickColor:"#fff",labels:{style:{color:"#8a8a8a"}},endOnTick:!1},legend:{itemStyle:{color:"#CCC"},itemHoverStyle:{color:"#ccc"},itemHiddenStyle:{color:"#333"}},labels:{style:{color:"#CCC"}},credits:{enabled:!1},exporting:{chartOptions:{scrollbar:{enabled:!1}},enabled:!0,scale:1,sourceWidth:900,sourceHeight:500,buttons:{downArrow:{symbol:"url(/wp-content/themes/coindesk2/images/cd-export.png)",symbolX:15,symbolY:10,text:"Export",y:-1,x:0,_titleKey:"contextButtonTitle",theme:{fill:"#fbc001",stroke:"#fff",r:0,height:17,width:40,padding:2,states:{hover:{fill:"#f0b91c",stroke:"#fff"},select:{fill:"#f0b91c",stroke:"#fff"}}},menuItems:[{textKey:"printChart",onclick:function(){this.print()}},{separator:!0},{textKey:"downloadPNG",onclick:function(){this.exportChart(null,{chart:{events:{load:CD.ChartConfigs.addLogoToChart}}})}},{textKey:"downloadJPEG",onclick:function(){this.exportChart({type:"image/jpeg",events:{load:CD.ChartConfigs.addLogoToChart}})}},{textKey:"downloadPDF",onclick:function(){this.exportChart({type:"application/pdf",events:{load:CD.ChartConfigs.addLogoToChart}})}},{textKey:"downloadSVG",onclick:function(){this.exportChart({type:"image/svg+xml",events:{load:CD.ChartConfigs.addLogoToChart}})}}]}}}}},a.getBPIChartConfig=function(c,d,e,f,g,h){var i,j;return i=a.getBaseConfig(),j={chart:{renderTo:"xbtindex-chart"},navigator:{series:{data:c.navigator}},rangeSelector:{buttonSpacing:2,selected:d,inputEnabled:e,buttons:f},plotOptions:{candlestick:{borderWidth:0,lineWidth:1,color:"#b95516",lineColor:"#b95516",upColor:"#009b2c",upLineColor:"#009b2c",tooltip:{useHTML:!0,headerFormat:'<span style="font-size: 10px">{point.key}</span><br/><table>',pointFormat:'<tr><td style="color: {series.color}; font-weight: bold;">{series.name}</td></tr><tr><td style="font-weight: bold;">Open:<td><td style="text-align: right; padding-left: 20px"><b>{point.open}</b></td></tr><tr><td style="font-weight: bold;">High:<td><td style="text-align: right; padding-left: 20px"><b>{point.high}</b></td></tr><tr><td style="font-weight: bold;">Low:<td><td style="text-align: right; padding-left: 20px"><b>{point.low}</b></td></tr><tr><td style="font-weight: bold;">Close:<td><td style="text-align: right; padding-left: 20px"><b>{point.close}</b></td></tr>',footerFormat:"</table><br/>"}},ohlc:{borderWidth:0,lineWidth:1,marker:{enabled:!1,radius:100}}},tooltip:{shadow:!1,backgroundColor:"#e6e6e6",borderWidth:0,valueDecimals:2,valuePrefix:g,color:"#333",shared:!0,useHTML:!0,headerFormat:"<small>{point.key} UTC</small><table>",pointFormat:'<tr><td style="color: {series.color}; font-weight: bold;">{series.name}:</td><td style="text-align: right; padding-left: 20px"><b>{point.y}</b></td></tr>',footerFormat:"</table>"},series:h.seriesOptions,yAxis:{labels:{format:g+"{value}"}},xAxis:{tickPixelInterval:200,type:"datetime",ordinal:!1},exporting:{filename:"coindesk-bpi-chart"}},b.extend(!0,i,j)},a.getDataChartConfig=function(d,e,f){var g,h,i,j;return g=a.getBaseConfig(),j=c(e),h={chart:{renderTo:"networkchart"},rangeSelector:{selected:j.initialZoom,inputEnabled:!0,buttons:[{type:"month",count:1,text:"1m"},{type:"month",count:3,text:"3m"},{type:"ytd",text:"YTD"},{type:"year",count:1,text:"1y"},{type:"all",text:"All"}]},plotOptions:{series:{dataGrouping:{dateTimeLabelFormats:{minute:["%A, %b %e, %Y","%A, %b %e, %Y",""],hour:["%A, %b %e, %Y","%A, %b %e, %Y",""],day:["%A, %b %e, %Y","%A, %b %e, %Y",""],week:["Week from %A, %b %e, %Y","%A, %b %e","-%A, %b %e, %Y"],month:["%B %Y","%B",""],year:["%Y","%Y",""]}}}},tooltip:{xDateFormat:"%Y-%m-%d",shadow:!1,backgroundColor:"#FBC001",borderWidth:0,borderRadius:0,valueDecimals:2,style:{color:"#555",padding:"10px"}},series:[{name:j.toolTipText,data:d}],yAxis:{title:{text:j.LHSLegend,style:{color:"#8a8a8a"}},min:0,labels:{formatter:function(){var a;if(j.friendlyUnit)switch(j.friendlyUnit){case"thousands":a=CD.Helpers.addCommas(this.value);break;case"millions":a=this.value/1e6+"M";break;case"billions":a=this.value/1e9+"B";break;default:a=this.value}return j.currencySymbol&&(a=j.currencySymbol+a),j.friendlyUnit||j.currencySymbol?a:this.value},format:j.yLabel}},xAxis:{minRange:2592e5,max:f.getTime()},exporting:{filename:j.LHSLegend}},i={text:"Download CSV Chart Data",onclick:function(){var a="http://api.coindesk.com/btxcharts/data?data="+e+"&outputType=csv";window.location.href=a}},g.exporting.buttons.downArrow.menuItems.push(i),b.extend(!0,g,h)},a.getSentimentChartConfig=function(c){var d,e;return d=a.getBaseConfig(),e={chart:{renderTo:"sentimentindex-chart"},rangeSelector:{selected:4,inputEnabled:!0,buttons:[{type:"week",count:1,text:"1w"},{type:"month",count:1,text:"1m"},{type:"month",count:3,text:"3m"},{type:"year",count:1,text:"1y"},{type:"all",text:"All"}]},plotOptions:{series:{dataGrouping:{dateTimeLabelFormats:{minute:["%A, %b %e, %Y","%A, %b %e, %Y",""],hour:["%A, %b %e, %Y","%A, %b %e, %Y",""],day:["%A, %b %e, %Y","%A, %b %e, %Y",""],week:["Week from %A, %b %e, %Y","%A, %b %e","-%A, %b %e, %Y"],month:["%B %Y","%B",""],year:["%Y","%Y",""]}}}},tooltip:{xDateFormat:"%Y-%m-%d",shadow:!1,backgroundColor:"#FBC001",borderWidth:0,borderRadius:0,valueDecimals:2,style:{color:"#555",padding:"10px"}},series:[{name:"Score",data:c}],xAxis:{type:"datetime"},exporting:{filename:"sentiment-index",sourceWidth:1260,sourceHeight:800}},b.extend(!0,d,e)},a.getHeaderChartConfig=function(a){var c=b(window).width()<=640,d={},e={chart:{renderTo:"header-chart",backgroundColor:null,borderWidth:0,type:"area",margin:[8,0,3,30],style:{overflow:"visible"},skipClone:!0},colors:["#f1c40f"],title:{text:""},credits:{enabled:!1},xAxis:{labels:{enabled:!1},title:{text:null},lineWidth:0,tickPositions:[]},yAxis:{tickPositioner:function(){return[Math.floor(this.series[0].dataMin),(this.series[0].dataMin+this.series[0].dataMax)/2,Math.ceil(this.series[0].dataMax)]},lineWidth:0,gridLineColor:"#4F4F4F",gridLineWidth:1,labels:{enabled:!0,formatter:function(){return"$"+Math.round(this.value)},style:{color:"#fff",fontSize:10},x:-4,y:1},title:{text:null}},navigation:{buttonOptions:{enabled:!1}},legend:{enabled:!1},tooltip:{enabled:!1},plotOptions:{series:{animation:!1,lineWidth:2,shadow:!1,states:{hover:{enabled:!1}},marker:{radius:0},fillOpacity:.2,events:{click:function(){window.location="/price/"}}}},series:[{data:a}]};return c&&(d={chart:{margin:[0,0,0,0]},yAxis:{gridLineWidth:0,labels:{enabled:!1}}},b.extend(!0,e,d)),e},a.addLogoToChart=function(){var a=b(this.container),c=a.width(),d=a.height(),e=document.location.protocol+"//"+document.location.hostname,f="/wp-content/themes/coindesk2/images/bpi-chart-branding.png",g={x:c-199,y:d-126};this.renderer.image(e+f,g.x,g.y,189,26).add()},a}(CD.ChartConfigs||{},jQuery);var CD=CD||{};CD.Device=function(a,b){var c=function(){return/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.userAgent.toLowerCase())};return a.init=function(){CD.isMobile=c(),CD.isMobile?(b("div.wpsr-floatbar-float_left").remove(),b(".showDisqus").css("display","block")):b("#disqus_thread").length&&CD.Helpers.setupComments()},a}(CD.Device||{},jQuery);var CD=CD||{};CD.Events=function(a,b){var c=function(){var a,c=b(".previous-next"),d=b(".popup"),e="-300px";!CD.isMobile&&c.length&&(a=function(){CD.Helpers.scrolledPast(c)&&d.css("right")===e?d.animate({right:"0"},500):CD.Helpers.scrolledPast(c)||"0px"!==d.css("right")||d.animate({right:e},500)},b(window).scroll(CD.Helpers.debounce(a,100,!1)))},d=function(){b(".showDisqus").on("click",function(){b(this).fadeOut(),CD.Helpers.setupComments()}),b(".overlay, .flickr_badge_image a img").hover(function(){b(this).stop().animate({opacity:"0.3"},300)},function(){b(this).stop().animate({opacity:"1"},300)}),b(".tip").on("click",function(){b(this).find(".tip-content").slideToggle(200)}),b(".widget .tabs li").click(function(a){var c=b(this).closest(".tabs-wrapper");if(!b(this).parent().attr("data-link")){var d=b(this).attr("rel");c.find(".tabs li").removeClass("active"),b(this).addClass("active"),c.find(".tab_content").hide(),c.find("#"+d).fadeIn(),a.preventDefault()}}),c()};return a.init=function(){d()},a}(CD.Events||{},jQuery);var CD=CD||{};CD.HeaderBPI=function(a,b){var c=6e4,d=b(".bpi-info-button"),e=b("#exinfo"),f=b("#extable"),g=e.find(".bpiUpdated"),h=function(a){function c(a,b){return'<tr><td class="bpi'+a+'">'+a+'</td><td class="value">'+b+"</td></tr>"}var d;return d='<tr><th colspan="2">USD:</th></tr>',b.each(a.exchangesUSD,function(a,b){d+=c(a,b)}),d+='<tr><th colspan="2">CNY:</th></tr>',b.each(a.exchangesCNY,function(a,b){d+=c(a,b)}),d},i=function(a){var c,d;for(d in a.bpi)c=CD.Helpers.formatMoney(a.bpi[d].rate_float,2,a.bpi[d].symbol),b("#bpiDisplay .bpi"+d).html(c)},j=function(a){var c,d;for(c in a.changepc)d=a.changepc[c],b("#bpiDisplay .change"+c).removeClass("data-up data-down").html(d+"%").addClass(d>=0?"data-up":"data-down")},k=function(){d.hover(function(){e.stop(!0,!0).fadeIn(200)},function(){e.stop(!0,!0).fadeOut(100)}),b(".price-usd, .price-eur, .price-gbp").click(function(){window.location="/price/"}),b(".price-cny").click(function(){window.location="/price-cny/"})};return a.init=function(){setInterval(function(){CD.Api.getBPICurrentPrice().done(function(a){i(a),j(a),g.html(a.time.updateduk),f.html(h(a))})},c),k()},a}(CD.HeaderBPI||{},jQuery);var CD=CD||{};CD.HeaderChart=function(a,b,c){var d=b("#header-chart"),e={},f={},g={lines:12,length:8,width:3,radius:7,color:"#757575",speed:1.3},h=function(a){f=CD.ChartConfigs.getHeaderChartConfig(a.d),e=new Highcharts.Chart(f)},i=function(){e&&a.data&&(e.destroy(),h(a.data))},j=function(){b(".header-price-index").click(function(){window.location="/price/"})};return a.data={},a.init=function(){var e=new c(g).spin(d.get(0));CD.Api.getBPICurrentPrice24Hours().retry({times:3,timeout:3e3}).done(function(b){a.data=b,e.stop(),h(b)}).fail(function(){e.stop(),_gaq.push(["_trackEvent","Access Error","Call to http://api.coindesk.com/headerchart/history failed"])}),j(),b(window).resize(CD.Helpers.debounce(i,150,!1))},a}(CD.HeaderChart||{},jQuery,Spinner);var CD=CD||{};CD.Helpers=function(a,b){return a.formatMoney=function(a,b,c,d,e){var f,g,h;return b=isNaN(b=Math.abs(b))?2:b,c=void 0!==c?c:"$",c="$"===c?"$":c,d=void 0!==d?d:",",e=e||".",f=0>a?"-":"",g=parseInt(a=Math.abs(+a||0).toFixed(b),10)+"",h=(h=g.length)>3?h%3:0,c+f+(h?g.substr(0,h)+d:"")+g.substr(h).replace(/(\d{3})(?=\d)/g,"$1"+d)+(b?e+Math.abs(a-g).toFixed(b).slice(2):"")},a.addCommas=function(a){a+="";for(var b=a.split("."),c=b[0],d=b.length>1?"."+b[1]:"",e=/(\d+)(\d{3})/;e.test(c);)c=c.replace(e,"$1,$2");return c+d},a.displayRounded=function(a,b){var c=b||0,d=Math.pow(10,c);return Math.round(a*d)/d},a.abbreviateNumber=function(a){var b,c,d,e,f,g=["","K","M","B","T"];if(a>=1e3){for(c=Math.floor((""+a).length/3),d="",f=4;f>=1&&(d=parseFloat((0!==c?a/Math.pow(1e3,c):a).toPrecision(f)),e=(d+"").replace(/[^a-zA-Z 0-9]+/g,""),!(e.length<=4));f--);b=d+g[c]}return b},a.getPercentageChange=function(a,b){return(b-a)/a*100},a.stripDomainFromUrl=function(a){return a.replace(/^.*\/\/[^\/]+/,"")},a.getReferrerDomain=function(){var a=document.referrer.match(/:\/\/(www\.|)([^\/]*)/);return a&&a.length>=3&&(a=a[2]),a},a.getFBWidth=function(){return b(window).width()<400?270:300},a.setupComments=function(){return b.ajax({type:"GET",url:"http://coindesk.disqus.com/embed.js",dataType:"script",cache:!0})},a.debounce=function(a,b,c){var d;return function(){function e(){c||a.apply(f,g),d=null}var f=this,g=arguments;d?clearTimeout(d):c&&a.apply(f,g),d=setTimeout(e,b||100)}},a.scrolledVisible=function(a){var c=b(window).scrollTop(),d=c+b(window).height(),e=a.offset().top,f=e+a.height();return d>=f&&e>=c},a.scrolledPast=function(a){var c=b(window).scrollTop(),d=c+b(window).height(),e=a.offset().top;return d>=e},a.detectPages=function(a){var b,c;if(a instanceof Array&&a.length)b=a.join("|");else{if("string"!=typeof a)return!1;b=a}return c=new RegExp("/("+b+")/?$","i"),null!==window.location.pathname.match(c)},a.dateToYMD=function(a){var b=a.getDate(),c=a.getMonth()+1,d=a.getFullYear();return""+d+"-"+(9>=c?"0"+c:c)+"-"+(9>=b?"0"+b:b)},a.dateFromYMD=function(a){var b=a.split("-");return 3!==b.length?!1:new Date(b[0],b[1]-1,b[2])},a.isWithinDateRange=function(a,b,c){return a=a.setHours(0,0,0,0),b=b.setHours(0,0,0,0),c=c.setHours(23,59,59,999),a>=b&&c>=a},a.encompassesRange=function(a,b){return a[0]=a[0].setHours(0,0,0,0),b[0]=b[0].setHours(0,0,0,0),a[1]=a[1].setHours(23,59,59,999),b[1]=b[1].setHours(23,59,59,999),a[0]>=b[0]&&a[0]<=b[1]&&a[1]>=b[0]&&a[1]<=b[1]},a}(CD.Helpers||{},jQuery);var CD=CD||{};CD.Newsletter=function(a,b,c){var d=b("#nlsignup"),e=b("#rhs-signupbox"),f=e.find(".error"),g=e.find('input[name="your-email"]'),h=e.find('input[type="submit"]'),i={lines:10,length:8,width:3,radius:7,color:"#EEEEEE",speed:1.3},j=function(a){f.html(a).fadeIn(450)},k=function(){return g.val()?l(g.val())?!0:(j("Sorry, but your email address looks incorrect.<br />Please check and try again."),!1):(j("Please enter your email address."),!1)},l=function(a){var b=new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);return b.test(a)},m=function(){_gaq.push(["_trackEvent","Email Signup","RHS"]),b.cookie("nl",1,{expires:3650,path:"/"}),d.find(".signup-sidebar").addClass("success").html("<h4>Thanks! Please check your inbox to confirm your subscription.</h4>")},n=function(){h.removeAttr("disabled"),f.html("Sorry, we've encounted a problem.<br />Is your email address correct?")},o=function(a){var f,g;a.preventDefault(),k()&&(d.children().animate({opacity:.2},500),g=new c(i).spin(d.get(0)),h.attr("disabled","disabled"),f=e.serialize(),b.ajax({type:e.attr("method"),url:e.attr("action"),data:f}).then(function(a){a?n():m()},function(){n()}).always(function(){g.stop(),d.children().animate({opacity:1},300)}))};return a.init=function(){e.submit(function(a){o(a)})},a}(CD.Newsletter||{},jQuery,Spinner);var CD=CD||{};CD.Reddit=function(a,b){var c=["BTCNews","MuchBitcoin"],d=function(a){return-1!==b.inArray(a,c)},e=function(){var a="https://redditstatic.s3.amazonaws.com",b="http://www.reddit.com/static",c="https:"===document.location.protocol?a:b;return c+"/button/button1.html"},f=function(){return document.referrer.match(/reddit.com(\/|\/\/)r(\/|\/\/)([^/]*)/)[3]},g=function(a,c){var d=e(),f="?title="+c+"&"+b.param(a),g='<iframe src="'+d+f+'" height="22" width="120" scrolling="no" frameborder="0"></iframe>';return g};return a.init=function(){var a,c,e,h,i,j;a=b(".reddit-share-button"),a.length&&(c=CD.Helpers.getReferrerDomain(),h=a.attr("data-title")||document.title,i={width:120,url:b("[rel=canonical]").attr("href")||window.location.href,sr:"Bitcoin"},"reddit.com"===c?(i.sr=f(),a.html(g(i,h))):(e=CD.Helpers.stripDomainFromUrl(i.url),j=-999,CD.Api.redditSearch(e).done(function(a){var b,c;if(a.data&&a.data.children)for(b=0;b<a.data.children.length;b++)c=a.data.children[b].data,c.score>j&&c.url.indexOf("http://www.coindesk.com")>-1&&!d(c.subreddit)&&(j=c.score,i.sr=c.subreddit)}).always(function(){a.html(g(i,h))})))},a}(CD.Reddit||{},jQuery);var CD=CD||{};CD.SentimentIndex=function(a,b,c){var d,e=b(".buttonHeaders .button"),f=b("#index-today"),g=b("#index-change"),h=b(".progressBar span"),i=b(".indexScore"),j=b(".indexError"),k=!0,l={},m=[],n="US",o={lines:12,length:8,width:3,radius:12,color:"#999",speed:1.3},p=function(a){var c=CD.ChartConfigs.getSentimentChartConfig(a);CD.isMobile&&(b.extend(c.chart,{resetZoomButton:{theme:{display:"none"}}}),b.extend(c.rangeSelector,{inputPosition:{y:30,x:5}}),b.extend(c.exporting,{enabled:!1})),b.isEmptyObject(l)?l=new Highcharts.StockChart(c,function(a){setTimeout(function(){b("input.highcharts-range-selector",b(a.container).parent()).datepicker()},0)}):(b("#chart-rawdata").css("display","none"),l.series[0].setData(a,!0))},q=function(a){return a[a.length-1][1]},r=function(a){var b=q(a),c=a[a.length-2][1];return CD.Helpers.getPercentageChange(c,b)},s=function(){j.hide(),i.find("span").css("opacity",0),d.spin(i.get(0)),CD.Api.getSentimentIndexData(n).done(function(a){function b(){d.stop(),h.css("width",c/2+"%"),i.find("span").fadeTo(600,1),k=!1}m=a;var c=q(m),e=r(m);f.text(CD.Helpers.displayRounded(c,2)),g.removeClass("change-up change-down").addClass(function(){return e>=0?"change-up":"change-down"}).text(CD.Helpers.displayRounded(e,2)+"%"),k?setTimeout(b,1e3):b(),p(m)}).fail(function(){d.stop(),h.css("width",0),j.fadeIn(600)})},t=function(){b.datepicker.setDefaults({dateFormat:"yy-mm-dd",minDate:new Date(2014,3,2),maxDate:new Date,onSelect:function(){this.onchange(),this.onblur()}}),b(window).on("orientationchange",function(){p(m)}),b(window).resize(CD.Helpers.debounce(function(){p(m)},300,!1)),e.click(function(){n="indexUS"===b(this).attr("id")?"US":"UK",b(this).hasClass("active")||(e.removeClass("active"),b(this).addClass("active"),s())})};return a.init=function(){d=new c(o),b(document).ready(function(){t(),s()})},a}(CD.SentimentIndex||{},jQuery,Spinner);var CD=CD||{};CD.TestSuite=function(pub,$){var _tests=[],TestSetup=function(){var getTestDetails=function(a){var b=$.cookie("_cdtest_"+a);if(b){var c=b.split("|");return{testVariation:+c[0],views:c[1],firstSeen:c[2],lastSeen:c[3]}}return null},setTestDetails=function(a,b,c){var d=b.testVariation+"|"+b.views+"|"+b.firstSeen+"|"+b.lastSeen;$.cookie("_cdtest_"+a,d,{expires:c})};this.run=function(_gaq,tests){for(var timestamp=Math.floor((new Date).getTime()/1e3),userTest=null,i=0;i<tests.length;i++)userTest=getTestDetails(tests[i].cookieName),userTest||(userTest={testVariation:null,views:0,firstSeen:timestamp,lastSeen:timestamp},userTest.testVariation=Math.random()<tests[i].sample?1:2),userTest.views=parseInt(userTest.views,10)+1,userTest.lastSeen=timestamp,setTestDetails(tests[i].cookieName,userTest,tests[i].cookieLength),2===userTest.testVariation&&eval(tests[i].variationEval),_gaq.push(["_setCustomVar",tests[i].gaCustomVar,tests[i].testName,tests[i].variationNames[userTest.testVariation],2])}};return pub.init=function(){var a=new TestSetup;a.run(_gaq,_tests)},pub}(CD.TestSuite||{},jQuery);var CD=CD||{};CD.Tooltips=function(a,b){var c=function(a){var c=a.data("title"),d=a.data("position"),e=b("<div />",{"class":"tooltip "+d}).text(c);a.append(e)},d=function(){var a={},c=b(this).data("position");a.opacity=1,"vertical"===c?a.top="-=10":a.left="+=10",b(this).find("div.tooltip").stop(!0,!0).animate(a,200)},e=function(){var a={},c=b(this).data("position");a.opacity=0,"vertical"===c?a.top="+=10":a.left="-=10",b(this).find("div.tooltip").stop(!0,!0).animate(a,200)},f=function(){b("a.tooltip").on({mouseenter:d,mouseleave:e})};return a.init=function(){b("a.tooltip").each(function(){c(b(this))}),f()},a}(CD.Tooltips||{},jQuery);var CD=CD||{};CD.Tracking=function(a,b){var c=function(){var c=a.trackAnchorClick,d=b('body.single .single-post .single-author a[rel="author"]').html();b("#coindesk_quotes_widget-2 a").on("click",function(a){c.call(this,a,!0,"Quotes","Click")}),b("div.grid_4.sidebar .guide ul li a").on("click",function(a){c.call(this,a,!0,"RHS Guides","Click")}),b("article.popup a").on("click",function(a){c.call(this,a,!0,"Article","Slide-In Click")}),b("body.single .single-post div.previous-next a").on("click",function(a){c.call(this,a,!0,"Article","Previous/Next")}),b("body.single .single-post div.related-posts a").on("click",function(a){c.call(this,a,!0,"Article","Related Posts")}),b(".navigation ul.social-links a").on("click",function(a){c.call(this,a,!0,"Social Clickout",b(this).parent().attr("class"))}),b("body.single .single-post .single-author .authortwitter").on("click",function(a){c.call(this,a,!1,"Article","Author Twitter Click",d)}),b("ul#popular li a").on("click",function(a){c.call(this,a,!0,"RHS Must Read/Most Popular","Popular Click")}),b("ul#must-read li a").on("click",function(a){c.call(this,a,!0,"RHS Must Read/Most Popular","Must Read Click")}),b(".header-trending a").on("click",function(a){c.call(this,a,!0,"Trending Post","Click")}),b("#featured-posts li a").on("click",function(a){c.call(this,a,!0,"RHS Features","Click")}),b(".header-logo a").on("click",function(a){c.call(this,a,!0,"Header Logo","Click")}),b("#megaMenu").on("click","#menu-item-14880 > a",function(a){c.call(this,a,!0,"Home Menu Item","Click")}),b(".wpsr-floatbar-float_left").on("click",function(a){c.call(this,a,!0,"Floating Social Bar","Click")}),b(".article-share").eq(0).on("click",function(a){c.call(this,a,!0,"Share Bar Click","Top Bar")}),b(".article-share").eq(1).on("click",function(a){c.call(this,a,!0,"Share Bar Click","Bottom Bar")}),b("#search").submit(function(){_gaq.push(["_trackEvent","Searches","RHS",b("#s").val()])})};return a.trackAnchorClick=function(a,c,d,e,f){var g,h;return c&&(g=b(this).attr("href"),h="_blank"===b(this).attr("target")),_gaq.push(["_set","hitCallback",function(){g&&(h?window.open(g,"_blank"):window.location=g)}]),_gaq.push(["_trackEvent",d,e,g,f]),!window._gat},a.init=function(){c()},a}(CD.Tracking||{},jQuery),jQuery(document).ready(function(){var a=CD.Helpers.detectPages;CD.Device.init(),CD.HeaderChart.init(),CD.HeaderBPI.init(),CD.Newsletter.init(),CD.Tooltips.init(),CD.Tracking.init(),CD.TestSuite.init(),CD.Events.init(),CD.Reddit.init(),a(["price","calculator"])&&CD.Calculator.init(),a("sentiment-index")&&CD.SentimentIndex.init()});