function buildListChartType(){if(typeof Keen.BaseVisualization=="undefined")return!1;clearInterval(buildInterval);Keen.List=Keen.BaseVisualization.extend({constructor:function(e,t){this.query=e;this.options={width:"300px","font-family":"'Helvetica Neue', Helvetica, Arial, sans-serif",fontSize:"1em",color:"white","border-radius":"0px","list-background-color":"#7dcc77","title-background-color":"#9CD898",prefix:"",suffix:"",elementPadding:".5em",sortField:"result",sortDirection:"desc"};this.options=_.extend(this.options,t)}});Keen.List.prototype.draw=function(e,t){var n=function(e){return e.replace(/[^\d.-]+/gi,"")},r=function(e){return e.replace(/[^A-Za-z%]+/gi,"")};e.innerHTML="";var i=document.createElement("div");e.appendChild(i);i.style.width=this.options.width;i.style.display="block";i.style.textAlign="center";i.style.backgroundColor=this.options["list-background-color"];i.style.borderRadius=this.options["border-radius"];var s=document.createElement("h2");this.options.label=this.options.title;s.appendChild(document.createTextNode(this.getLabel()));i.appendChild(s);s.style.lineHeight=s.style.height;s.style["font-size"]=n(this.options.fontSize)*2+r(this.options.fontSize);s.style.color=this.options.color;s.style.textTransform="uppercase";s.style.fontWeight="normal";s.style.fontFamily=this.options["font-family"];s.style.margin=0;s.style.padding=0;s.style.borderTop="1px solid";s.style.borderTopColor=this.options.color;s.style.backgroundColor=this.options["title-background-color"];s.style.textShadow="none";s.style.padding=this.options.elementPadding;var o=document.createElement("ul");i.appendChild(o);var u=document.createElement("li");u.innerHTML="Loading...";o.appendChild(u);o.style.lineHeight=s.style.height;o.style["font-size"]=n(this.options.fontSize)+r(this.options.fontSize);o.style.color=s.style.color;o.style.fontWeight="bold";o.style.fontFamily=s.style.fontFamily;o.style.margin=0;o.style.padding=0;o.style.textShadow="none";o.style["list-style-type"]="none";var a=_.bind(function(e){this.data=e.result;this.data==null&&(this.data=0);this.data.length===0?u.innerHTML="No Data":o.removeChild(u);if(typeof this.options.sortField!="undefined"){var t=[];for(s=0,imax=this.data.length;st[j][this.options.sortField]){t.splice(j,0,this.data[s]);r=!0;break}r||t.push(this.data[s])}this.options.sortDirection=="asc"&&(t=t.reverse());this.data=t}var i=typeof this.options.maxElements=="undefined"?this.data.length:this.options.maxElements;for(var s=0;s=u&&typeof t=="function"&&t()};for(var o=0,u=n.elements.length;o":"%DOSPLIT%gt%DOSPLIT%",">=":"%DOSPLIT%gte%DOSPLIT%","\\?":"%DOSPLIT%exists%DOSPLIT%"},n=e.getField("filter");if(n){for(key in t)n=n.replace(new RegExp(key,"g"),t[key]);var r=n.split("|"),i=[];for(var s=0,o=r.length;s-1)u.replace(" "," ");var a=u.split("%DOSPLIT%");if(a.length==3){a[2]==="true"?a[2]=!0:a[2]==="false"&&(a[2]=!1);i.push({property:a[0],operator:a[1],value:a[2]})}}return i}return[]};keentivateChart.prototype.checkRequiredFields=function(){var e=this;if(e.stop)return!1;if(typeof e.requiredAttributes=="undefined"){e.k.log("No required attributes defined");e.stop=!0;return!1}var t=!1;for(var n in e.requiredAttributes)if(!e.element.hasAttribute("data-keen-"+n)&&(n!=="timeframe"||!e.element.hasAttribute("data-keen-start")||!e.element.hasAttribute("data-keen-end"))){e.k.log("Required key not set on keen element: "+n);t=!0;break}t&&(e.stop=!0);return!t};keentivateChart.prototype.getMetricOptions=function(){return this.k.merge(this.options.metric,this.getOptions(this.optionalMetricAttributes))};keentivateChart.prototype.getLabelOptions=function(){return this.getOptions(this.optionalLabelAttributes)};keentivateChart.prototype.getOptions=function(e){var t=this;if(t.stop)return!1;var n={};for(var r in e)t.element.hasAttribute("data-keen-"+r)?n[e[r]]=t.element.getAttribute("data-keen-"+r):r==="timeframe"&&t.element.hasAttribute("data-keen-start")&&t.element.hasAttribute("data-keen-end")&&(n[e[r]]={start:t.element.getAttribute("data-keen-start"),end:t.element.getAttribute("data-keen-end")});return n};keentivateChart.prototype.getField=function(e){var t=this;return t.stop?!1:t.element.hasAttribute("data-keen-"+e)?t.element.getAttribute("data-keen-"+e):!1};keentivateChart.prototype.onRender=function(){var self=this;if(self.element.hasAttribute("data-keen-on-render")){var func=self.element.getAttribute("data-keen-on-render");eval(func)}};var keentivatePie=function(){this.init(arguments)};keentivatePie.prototype=Object.create(keentivateChart.prototype);keentivatePie.prototype.requiredAttributes={event:"eventCollection",group:"groupBy"};keentivatePie.prototype.init=function(){var e=this;e.chartType="pie";e.super.apply(e,arguments[0])};keentivatePie.prototype.draw=function(){var e=this;if(e.stop)return!1;var t=new Keen.PieChart(e.metric,e.getLabelOptions());t.draw(e.element)};var keentivateBar=function(){this.init(arguments)};keentivateBar.prototype=Object.create(keentivateChart.prototype);keentivateBar.prototype.requiredAttributes={event:"eventCollection",group:"groupBy"};keentivateBar.prototype.init=function(){var e=this;e.chartType="bar";e.super.apply(e,arguments[0])};keentivateBar.prototype.draw=function(){var e=this;if(e.stop)return!1;var t=new Keen.BarChart(e.metric,e.getLabelOptions());t.draw(e.element)};var keentivateNumber=function(){this.init(arguments)};keentivateNumber.prototype=Object.create(keentivateChart.prototype);keentivateNumber.prototype.init=function(){var e=this;e.chartType="number";e.super.apply(e,arguments[0])};keentivateNumber.prototype.draw=function(){var e=this;if(e.stop)return!1;var t=new Keen.Number(e.metric,e.getLabelOptions());t.draw(e.element)};var keentivateFunnel=function(){this.init(arguments)};keentivateFunnel.prototype=Object.create(keentivateChart.prototype);keentivateFunnel.prototype.requiredAttributes={watch:"actorProperty"};keentivateFunnel.prototype.optionalMetricAttributes={watch:"actorProperty",timeframe:"timeframe"};keentivateFunnel.prototype.init=function(){var e=this;e.chartType="pie";e.super.apply(e,arguments[0])};keentivateFunnel.prototype.draw=function(){var e=this;if(e.stop)return!1;var t=new Keen.Funnel(e.steps,e.getMetricOptions());t.draw(e.element,e.getLabelOptions())};keentivateFunnel.prototype.getSteps=function(){var e=this,t=e.element.getElementsByTagName("li");if(!t.length){e.stop=!0;e.k.log("You must provide steps for funnels");return!1}e.steps=[];for(var n=0,r=t.length;n":"%DOSPLIT%gt%DOSPLIT%",">=":"%DOSPLIT%gte%DOSPLIT%","\\?":"%DOSPLIT%exists%DOSPLIT%"};if(!e.hasAttribute("data-keen-filter"))return[];var r=e.getAttribute("data-keen-filter");if(r){for(key in n)r=r.replace(new RegExp(key,"g"),n[key]);var i=r.split("|"),s=[];for(var o=0,u=i.length;o-1)a.replace(" "," ");var f=a.split("%DOSPLIT%");if(f.length==3){f[2]==="true"?f[2]=!0:f[2]==="false"&&(f[2]=!1);s.push({property:f[0],operator:f[1],value:f[2]})}}return s}return[]};keentivateFunnel.prototype.startRender=function(){var e=this;e.checkRequiredFields();e.getSteps();e.draw()};var keentivateLine=function(){this.init(arguments)};keentivateLine.prototype=Object.create(keentivateChart.prototype);keentivateLine.prototype.requiredAttributes={timeframe:"timeframe",interval:"interval",event:"eventCollection"};keentivateLine.prototype.init=function(){var e=this;e.chartType="line";e.super.apply(e,arguments[0])};keentivateLine.prototype.getMetric=function(){var e=this;if(e.stop)return!1;e.metric=new Keen.Series(e.getField("event"),e.getMetricOptions());var t=e.getFilters();for(var n=0,r=t.length;n