Skip to content

Instantly share code, notes, and snippets.

@gka
Created June 14, 2012 06:05
Show Gist options
  • Save gka/2928236 to your computer and use it in GitHub Desktop.
Save gka/2928236 to your computer and use it in GitHub Desktop.
Miso.Dataset auto column names
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
1995 2000 2005 2010
Germany 29 25 28 29
France 29 28 28 30
Greece 35 33 33 33
<html>
<head>
<script src="miso.ds.deps.min.0.1.3-latest.js"></script>
</head>
<body>
<script>
var ds = new Miso.Dataset({
url : 'data.csv',
delimiter : "\t",
}).fetch({
success: function() {
console.log("Available Columns:" + this.columnNames());
console.log("There are " + this.length + " rows");
console.log(this);
}
});
</script>
</body>
</html>
/**
* Miso.Dataset - v0.1.3 - 6/14/2012
* http://github.com/misoproject/dataset
* Copyright (c) 2012 Alex Graul, Irene Ros;
* Dual Licensed: MIT, GPL
* https://github.com/misoproject/dataset/blob/master/LICENSE-MIT
* https://github.com/misoproject/dataset/blob/master/LICENSE-GPL
*/
(function(a,b){function z(a,b){this._d=a,this._isUTC=!!b}function A(a){return a<0?Math.ceil(a):Math.floor(a)}function B(a){var b=this._data={},c=a.years||a.y||0,d=a.months||a.M||0,e=a.weeks||a.w||0,f=a.days||a.d||0,g=a.hours||a.h||0,h=a.minutes||a.m||0,i=a.seconds||a.s||0,j=a.milliseconds||a.ms||0;this._milliseconds=j+i*1e3+h*6e4+g*36e5,this._days=f+e*7,this._months=d+c*12,b.milliseconds=j%1e3,i+=A(j/1e3),b.seconds=i%60,h+=A(i/60),b.minutes=h%60,g+=A(h/60),b.hours=g%24,f+=A(g/24),f+=e*7,b.days=f%30,d+=A(f/30),b.months=d%12,c+=A(d/12),b.years=c}function C(a,b){var c=a+"";while(c.length<b)c="0"+c;return c}function D(a,b,c){var d=b._milliseconds,e=b._days,f=b._months,g;d&&a._d.setTime(+a+d*c),e&&a.date(a.date()+e*c),f&&(g=a.date(),a.date(1).month(a.month()+f*c).date(Math.min(g,a.daysInMonth())))}function E(a){return Object.prototype.toString.call(a)==="[object Array]"}function F(b){return new a(b[0],b[1]||0,b[2]||1,b[3]||0,b[4]||0,b[5]||0,b[6]||0)}function G(b,c){function p(c){var k,q;switch(c){case"M":return d+1;case"Mo":return d+1+n(d+1);case"MM":return C(d+1,2);case"MMM":return moment.monthsShort[d];case"MMMM":return moment.months[d];case"D":return e;case"Do":return e+n(e);case"DD":return C(e,2);case"DDD":return k=new a(f,d,e),q=new a(f,0,1),~~((k-q)/864e5+1.5);case"DDDo":return k=p("DDD"),k+n(k);case"DDDD":return C(p("DDD"),3);case"d":return g;case"do":return g+n(g);case"ddd":return moment.weekdaysShort[g];case"dddd":return moment.weekdays[g];case"w":return k=new a(f,d,e-g+5),q=new a(k.getFullYear(),0,4),~~((k-q)/864e5/7+1.5);case"wo":return k=p("w"),k+n(k);case"ww":return C(p("w"),2);case"YY":return C(f%100,2);case"YYYY":return f;case"a":return o?o(h,i,!1):h>11?"pm":"am";case"A":return o?o(h,i,!0):h>11?"PM":"AM";case"H":return h;case"HH":return C(h,2);case"h":return h%12||12;case"hh":return C(h%12||12,2);case"m":return i;case"mm":return C(i,2);case"s":return j;case"ss":return C(j,2);case"S":return~~(l/100);case"SS":return C(~~(l/10),2);case"SSS":return C(l,3);case"Z":return(m<0?"-":"+")+C(~~(Math.abs(m)/60),2)+":"+C(~~(Math.abs(m)%60),2);case"ZZ":return(m<0?"-":"+")+C(~~(10*Math.abs(m)/6),4);case"L":case"LL":case"LLL":case"LLLL":case"LT":return G(b,moment.longDateFormat[c]);default:return c.replace(/(^\[)|(\\)|\]$/g,"")}}var d=b.month(),e=b.date(),f=b.year(),g=b.day(),h=b.hours(),i=b.minutes(),j=b.seconds(),l=b.milliseconds(),m=-b.zone(),n=moment.ordinal,o=moment.meridiem;return c.replace(k,p)}function H(a){switch(a){case"DDDD":return o;case"YYYY":return p;case"S":case"SS":case"SSS":case"DDD":return n;case"MMM":case"MMMM":case"ddd":case"dddd":case"a":case"A":return q;case"Z":case"ZZ":return r;case"T":return s;case"MM":case"DD":case"dd":case"YY":case"HH":case"hh":case"mm":case"ss":case"M":case"D":case"d":case"H":case"h":case"m":case"s":return m;default:return new RegExp(a.replace("\\",""))}}function I(a,b,c,d){var e;switch(a){case"M":case"MM":c[1]=b==null?0:~~b-1;break;case"MMM":case"MMMM":for(e=0;e<12;e++)if(moment.monthsParse[e].test(b)){c[1]=e;break}break;case"D":case"DD":case"DDD":case"DDDD":c[2]=~~b;break;case"YY":b=~~b,c[0]=b+(b>70?1900:2e3);break;case"YYYY":c[0]=~~Math.abs(b);break;case"a":case"A":d.isPm=(b+"").toLowerCase()==="pm";break;case"H":case"HH":case"h":case"hh":c[3]=~~b;break;case"m":case"mm":c[4]=~~b;break;case"s":case"ss":c[5]=~~b;break;case"S":case"SS":case"SSS":c[6]=~~(("0."+b)*1e3);break;case"Z":case"ZZ":d.isUTC=!0,e=(b+"").match(w),e&&e[1]&&(d.tzh=~~e[1]),e&&e[2]&&(d.tzm=~~e[2]),e&&e[0]==="+"&&(d.tzh=-d.tzh,d.tzm=-d.tzm)}}function J(b,c){var d=[0,0,1,0,0,0,0],e={tzh:0,tzm:0},f=c.match(k),g,h;for(g=0;g<f.length;g++)h=(H(f[g]).exec(b)||[])[0],b=b.replace(H(f[g]),""),I(f[g],h,d,e);return e.isPm&&d[3]<12&&(d[3]+=12),e.isPm===!1&&d[3]===12&&(d[3]=0),d[3]+=e.tzh,d[4]+=e.tzm,e.isUTC?new a(a.UTC.apply({},d)):F(d)}function K(a,b){var c=Math.min(a.length,b.length),d=Math.abs(a.length-b.length),e=0,f;for(f=0;f<c;f++)~~a[f]!==~~b[f]&&e++;return e+d}function L(a,b){var c,d=a.match(l)||[],e,f=99,g,h,i;for(g=0;g<b.length;g++)h=J(a,b[g]),e=G(new z(h),b[g]).match(l)||[],i=K(d,e),i<f&&(f=i,c=h);return c}function M(b){var c="YYYY-MM-DDT",d;if(t.exec(b)){for(d=0;d<4;d++)if(v[d][1].exec(b)){c+=v[d][0];break}return r.exec(b)?J(b,c+" Z"):J(b,c)}return new a(b)}function N(a,b,c,d){var e=moment.relativeTime[a];return typeof e=="function"?e(b||1,!!c,a,d):e.replace(/%d/i,b||1)}function O(a,b){var c=d(Math.abs(a)/1e3),e=d(c/60),f=d(e/60),g=d(f/24),h=d(g/365),i=c<45&&["s",c]||e===1&&["m"]||e<45&&["mm",e]||f===1&&["h"]||f<22&&["hh",f]||g===1&&["d"]||g<=25&&["dd",g]||g<=45&&["M"]||g<345&&["MM",d(g/30)]||h===1&&["y"]||["yy",h];return i[2]=b,i[3]=a>0,N.apply({},i)}function P(a,b){moment.fn[a]=function(a){var c=this._isUTC?"UTC":"";return a!=null?(this._d["set"+c+b](a),this):this._d["get"+c+b]()}}function Q(a){moment.duration.fn[a]=function(){return this._data[a]}}function R(a,b){moment.duration.fn["as"+a]=function(){return+this/b}}var moment,c="1.6.2",d=Math.round,e,f={},g="en",h=typeof module!="undefined",i="months|monthsShort|monthsParse|weekdays|weekdaysShort|longDateFormat|calendar|relativeTime|ordinal|meridiem".split("|"),j=/^\/?Date\((\-?\d+)/i,k=/(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|dddd?|do?|w[o|w]?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|SS?S?|zz?|ZZ?|LT|LL?L?L?)/g,l=/([0-9a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)/gi,m=/\d\d?/,n=/\d{1,3}/,o=/\d{3}/,p=/\d{4}/,q=/[0-9a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+/i,r=/Z|[\+\-]\d\d:?\d\d/i,s=/T/i,t=/^\s*\d{4}-\d\d-\d\d(T(\d\d(:\d\d(:\d\d(\.\d\d?\d?)?)?)?)?([\+\-]\d\d:?\d\d)?)?/,u="YYYY-MM-DDTHH:mm:ssZ",v=[["HH:mm:ss.S",/T\d\d:\d\d:\d\d\.\d{1,3}/],["HH:mm:ss",/T\d\d:\d\d:\d\d/],["HH:mm",/T\d\d:\d\d/],["HH",/T\d\d/]],w=/([\+\-]|\d\d)/gi,x="Month|Date|Hours|Minutes|Seconds|Milliseconds".split("|"),y={Milliseconds:1,Seconds:1e3,Minutes:6e4,Hours:36e5,Days:864e5,Months:2592e6,Years:31536e6};moment=function(c,d){if(c===null||c==="")return null;var e,f,g;return moment.isMoment(c)?(e=new a(+c._d),g=c._isUTC):d?E(d)?e=L(c,d):e=J(c,d):(f=j.exec(c),e=c===b?new a:f?new a(+f[1]):c instanceof a?c:E(c)?F(c):typeof c=="string"?M(c):new a(c)),new z(e,g)},moment.utc=function(b,c){return E(b)?new z(new a(a.UTC.apply({},b)),!0):c&&b?moment(b+" +0000",c+" Z").utc():moment(b&&!r.exec(b)?b+"+0000":b).utc()},moment.unix=function(a){return moment(a*1e3)},moment.duration=function(a,b){var c=moment.isDuration(a),d=typeof a=="number",e=c?a._data:d?{}:a;return d&&(b?e[b]=a:e.milliseconds=a),new B(e)},moment.humanizeDuration=function(a,b,c){return moment.duration(a,b===!0?null:b).humanize(b===!0?!0:c)},moment.version=c,moment.defaultFormat=u,moment.lang=function(a,b){var c,d,e=[];if(!a)return g;if(b){for(c=0;c<12;c++)e[c]=new RegExp("^"+b.months[c]+"|^"+b.monthsShort[c].replace(".",""),"i");b.monthsParse=b.monthsParse||e,f[a]=b}if(f[a]){for(c=0;c<i.length;c++)moment[i[c]]=f[a][i[c]]||f.en[i[c]];g=a}else h&&(d=require("./lang/"+a),moment.lang(a,d))},moment.lang("en",{months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),longDateFormat:{LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D YYYY",LLL:"MMMM D YYYY LT",LLLL:"dddd, MMMM D YYYY LT"},meridiem:!1,calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[last] dddd [at] LT",sameElse:"L"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},ordinal:function(a){var b=a%10;return~~(a%100/10)===1?"th":b===1?"st":b===2?"nd":b===3?"rd":"th"}}),moment.isMoment=function(a){return a instanceof z},moment.isDuration=function(a){return a instanceof B},moment.fn=z.prototype={clone:function(){return moment(this)},valueOf:function(){return+this._d},unix:function(){return Math.floor(+this._d/1e3)},toString:function(){return this._d.toString()},toDate:function(){return this._d},utc:function(){return this._isUTC=!0,this},local:function(){return this._isUTC=!1,this},format:function(a){return G(this,a?a:moment.defaultFormat)},add:function(a,b){var c=b?moment.duration(+b,a):moment.duration(a);return D(this,c,1),this},subtract:function(a,b){var c=b?moment.duration(+b,a):moment.duration(a);return D(this,c,-1),this},diff:function(a,b,c){var e=this._isUTC?moment(a).utc():moment(a).local(),f=(this.zone()-e.zone())*6e4,g=this._d-e._d-f,h=this.year()-e.year(),i=this.month()-e.month(),j=this.date()-e.date(),k;return b==="months"?k=h*12+i+j/30:b==="years"?k=h+(i+j/30)/12:k=b==="seconds"?g/1e3:b==="minutes"?g/6e4:b==="hours"?g/36e5:b==="days"?g/864e5:b==="weeks"?g/6048e5:g,c?k:d(k)},from:function(a,b){return moment.duration(this.diff(a)).humanize(!b)},fromNow:function(a){return this.from(moment(),a)},calendar:function(){var a=this.diff(moment().sod(),"days",!0),b=moment.calendar,c=b.sameElse,d=a<-6?c:a<-1?b.lastWeek:a<0?b.lastDay:a<1?b.sameDay:a<2?b.nextDay:a<7?b.nextWeek:c;return this.format(typeof d=="function"?d.apply(this):d)},isLeapYear:function(){var a=this.year();return a%4===0&&a%100!==0||a%400===0},isDST:function(){return this.zone()<moment([this.year()]).zone()||this.zone()<moment([this.year(),5]).zone()},day:function(a){var b=this._isUTC?this._d.getUTCDay():this._d.getDay();return a==null?b:this.add({d:a-b})},sod:function(){return moment(this).hours(0).minutes(0).seconds(0).milliseconds(0)},eod:function(){return this.sod().add({d:1,ms:-1})},zone:function(){return this._isUTC?0:this._d.getTimezoneOffset()},daysInMonth:function(){return moment(this).month(this.month()+1).date(0).date()}};for(e=0;e<x.length;e++)P(x[e].toLowerCase(),x[e]);P("year","FullYear"),moment.duration.fn=B.prototype={weeks:function(){return A(this.days()/7)},valueOf:function(){return this._milliseconds+this._days*864e5+this._months*2592e6},humanize:function(a){var b=+this,c=moment.relativeTime,d=O(b,!a);return a&&(d=(b<=0?c.past:c.future).replace(/%s/i,d)),d}};for(e in y)y.hasOwnProperty(e)&&(R(e,y[e]),Q(e.toLowerCase()));R("Weeks",6048e5),h&&(module.exports=moment),typeof window!="undefined"&&typeof ender=="undefined"&&(window.moment=moment),typeof define=="function"&&define.amd&&define("moment",[],function(){return moment})})(Date),function(a,b){function L(a){return new M(a)}function M(a){if(a&&a._wrapped)return a;this._wrapped=a}function U(){var a,b,c,e=-1,f=arguments.length,g={bottom:"",exit:"",init:"",top:"",arrayBranch:{beforeLoop:"",loopExp:"++index < length"},objectBranch:{beforeLoop:""}};while(++e<f){a=arguments[e];for(b in a)c=(c=a[b])==null?"":c,/beforeLoop|loopExp|inLoop/.test(b)?(typeof c=="string"&&(c={array:c,object:c}),g.arrayBranch[b]=c.array,g.objectBranch[b]=c.object):g[b]=c}var h=g.args,i=g.arrayBranch,j=g.objectBranch,l=/^[^,]+/.exec(h)[0],m=j.loopExp,n=/\S+$/.exec(m||l)[0];g.firstArg=l,g.hasDontEnumBug=d,g.hasExp="hasOwnProperty.call("+n+", index)",g.iteratedObject=n,g.shadowed=k,g.useHas=g.useHas!==!1,g.exit||(g.exit="if (!"+l+") return result");if(l=="object"||!i.inLoop)g.arrayBranch=null;m||(j.loopExp="index in "+n);var o=Function("arrayClass, funcClass, hasOwnProperty, identity, iteratorBind, objectTypes, stringClass, toString, undefined",'"use strict"; return function('+h+") {\n"+N(g)+"\n}");return o(r,u,B,cx,Y,p,x,E)}function V(a,b){return n[b]}function W(a){return"\\"+q[a]}function X(a){return o[a]}function Y(a,b){return function(c,d,e){return a.call(b,c,d,e)}}function Z(){}function _(a,b){var c=n.length;return n[c]="'+\n((__t = ("+b+")) == null ? '' : _.escape(__t)) +\n'",m+c}function ba(a,b){var c=n.length;return n[c]="'+\n((__t = ("+b+")) == null ? '' : __t) +\n'",m+c}function bb(a,b){var c=n.length;return n[c]="';\n"+b+";\n__p += '",m+c}function bj(a,b,c,d){if(!a)return c;var e=a.length,f=arguments.length<3;d&&(b=Y(b,d));if(e===e>>>0){e&&f&&(c=a[--e]);while(e--)c=b(c,a[e],e,a);return c}var g,h=cr(a);e=h.length,e&&f&&(c=a[h[--e]]);while(e--)g=h[e],c=b(c,a[g],g,a);return c}function bm(a){if(!a)return[];if(E.call(a.toArray)==u)return a.toArray();var b=a.length;return b===b>>>0?D.call(a):cv(a)}function bn(a){var b=[];if(!a)return b;var c=-1,d=a.length;while(++c<d)a[c]&&b.push(a[c]);return b}function bo(a){var b=[];if(!a)return b;var c=-1,d=a.length,e=A.apply(b,D.call(arguments,1));while(++c<d)bs(e,a[c])<0&&b.push(a[c]);return b}function bp(a,c,d){if(a)return c==b||d?a[0]:D.call(a,0,c)}function bq(a,b){var c=[];if(!a)return c;var d,e=-1,f=a.length;while(++e<f)d=a[e],cc(d)?C.apply(c,b?d:bq(d)):c.push(d);return c}function br(a,b,c){var d={};if(!a)return d;var e,f,g=-1,h=typeof b=="function",i=a.length;h&&c&&(b=Y(b,c));while(++g<i)f=a[g],e=h?b(f,g,a):f[b],(B.call(d,e)?d[e]:d[e]=[]).push(f);return d}function bs(a,b,c){if(!a)return-1;var d=-1,e=a.length;if(c)if(typeof c=="number")d=(c<0?Math.max(0,e+c):c)-1;else return d=bF(a,b),a[d]===b?d:-1;while(++d<e)if(a[d]===b)return d;return-1}function bt(a,c,d){return a?D.call(a,0,-(c==b||d?1:c)):[]}function bu(a){var b=[];if(!a)return b;var c,d=-1,e=a.length,f=D.call(arguments,1);while(++d<e)c=a[d],bs(b,c)<0&&bd(f,function(a){return bs(a,c)>-1})&&b.push(c);return b}function bv(a,b){var c=[];if(!a)return c;var d=D.call(arguments,2),e=-1,f=a.length,g=typeof b=="function";while(++e<f)c[e]=(g?b:a[e][b]).apply(a[e],d);return c}function bw(a,c,d){if(a){var e=a.length;return c==b||d?a[e-1]:D.call(a,-c||e)}}function bx(a,b,c){if(!a)return-1;var d=a.length;c&&typeof c=="number"&&(d=(c<0?Math.max(0,d+c):Math.min(c,d-1))+1);while(d--)if(a[d]===b)return d;return-1}function by(a,b,c){var d=-Infinity,e=d;if(!a)return e;var f,g=-1,h=a.length;if(!b){while(++g<h)a[g]>e&&(e=a[g]);return e}c&&(b=Y(b,c));while(++g<h)f=b(a[g],g,a),f>d&&(d=f,e=a[g]);return e}function bz(a,b,c){var d=Infinity,e=d;if(!a)return e;var f,g=-1,h=a.length;if(!b){while(++g<h)a[g]<e&&(e=a[g]);return e}c&&(b=Y(b,c));while(++g<h)f=b(a[g],g,a),f<d&&(d=f,e=a[g]);return e}function bA(a,b){if(!a)return[];var c=-1,d=a.length,e=Array(d);while(++c<d)e[c]=a[c][b];return e}function bB(a,b,c){c||(c=1),arguments.length<2&&(b=a||0,a=0);var d=-1,e=Math.max(Math.ceil((b-a)/c),0),f=Array(e);while(++d<e)f[d]=a,a+=c;return f}function bC(a,c,d){return a?D.call(a,c==b||d?1:c):[]}function bD(a){if(!a)return[];var b,c=-1,d=a.length,e=Array(d);while(++c<d)b=Math.floor(Math.random()*(c+1)),e[c]=e[b],e[b]=a[c];return e}function bE(a,c,d){if(!a)return[];if(typeof c=="string"){var e=c;c=function(a){return a[e]}}else d&&(c=Y(c,d));var f=-1,g=a.length,h=Array(g);while(++f<g)h[f]={criteria:c(a[f],f,a),value:a[f]};h.sort(function(a,c){var d=a.criteria,e=c.criteria;return d===b?1:e===b?-1:d<e?-1:d>e?1:0});while(g--)h[g]=h[g].value;return h}function bF(a,b,c,d){if(!a)return 0;var e,f=0,g=a.length;if(c){b=c.call(d,b);while(f<g)e=f+g>>>1,c.call(d,a[e])<b?f=e+1:g=e}else while(f<g)e=f+g>>>1,a[e]<b?f=e+1:g=e;return f}function bG(){var a=-1,b=[],c=A.apply(b,arguments),d=c.length;while(++a<d)bs(b,c[a])<0&&b.push(c[a]);return b}function bH(a,b,c,d){var e=[];if(!a)return e;var f,g=-1,h=a.length,i=[];typeof b=="function"&&(d=c,c=b,b=!1),c?d&&(c=Y(c,d)):c=cx;while(++g<h){f=c(a[g],g,a);if(b?!g||i[i.length-1]!==f:bs(i,f)<0)i.push(f),e.push(a[g])}return e}function bI(a){var b=[];if(!a)return b;var c=D.call(arguments,1),d=-1,e=a.length;while(++d<e)bs(c,a[d])<0&&b.push(a[d]);return b}function bJ(a){if(!a)return[];var b=-1,c=by(bA(arguments,"length")),d=Array(c);while(++b<c)d[b]=bA(arguments,b);return d}function bK(a,b){return a<1?b():function(){if(--a<1)return b.apply(this,arguments)}}function bL(a,b){function f(){var g=arguments,h=b;d||(a=b[c]),e.length&&(g=g.length?A.apply(e,g):e);if(this instanceof f){Z.prototype=a.prototype,h=new Z;var i=a.apply(h,g);return p[typeof i]&&i!==null?i:h}return a.apply(h,g)}var c,d=E.call(a)==u;if(!d)c=b,b=a;else if(F)return F.call.apply(F,arguments);var e=D.call(arguments,2);return f}function bM(a){var b=arguments,c=1;b.length==1&&(c=0,b=b_(a));for(var d=b.length;c<d;c++)a[b[c]]=bL(a[b[c]],a);return a}function bN(){var a=arguments;return function(){var b=arguments,c=a.length;while(c--)b=[a[c].apply(this,b)];return b[0]}}function bO(a,c,d){function i(){h=b,d||a.apply(g,e)}var e,f,g,h;return function(){var b=d&&!h;return e=arguments,g=this,J(h),h=K(i,c),b&&(f=a.apply(g,e)),f}}function bP(a,c){var d=D.call(arguments,2);return K(function(){return a.apply(b,d)},c)}function bQ(a){var c=D.call(arguments,1);return K(function(){return a.apply(b,c)},1)}function bR(a,b){var c={};return function(){var d=b?b.apply(this,arguments):arguments[0];return B.call(c,d)?c[d]:c[d]=a.apply(this,arguments)}}function bS(a){var b,c=!1;return function(){return c?b:(c=!0,b=a.apply(this,arguments),b)}}function bT(a){var b=D.call(arguments,1),c=b.length;return function(){var d,e=arguments;return e.length&&(b.length=c,C.apply(b,e)),d=b.length==1?a.call(this,b[0]):a.apply(this,b),b.length=c,d}}function bU(a,c){function i(){h=new Date,g=b,a.apply(f,d)}var d,e,f,g,h=0;return function(){var b=new Date,j=c-(b-h);return d=arguments,f=this,j<=0?(h=b,e=a.apply(f,d)):g||(g=K(i,j)),e}}function bV(a,b){return function(){var c=[a];return arguments.length&&C.apply(c,arguments),b.apply(this,c)}}function bW(a){return p[typeof a]&&a!==null?cc(a)?a.slice():bY({},a):a}function ca(a,b){return B.call(a,b)}function cd(a){return a===!0||a===!1||E.call(a)==s}function ce(a){return E.call(a)==t}function cf(a){return!!a&&a.nodeType==1}function ch(a,c,e){e||(e=[]);if(a===c)return a!==0||1/a==1/c;if(a==b||c==b)return a===c;a._chain&&(a=a._wrapped),c._chain&&(c=c._wrapped);if(a.isEqual&&E.call(a.isEqual)==u)return a.isEqual(c);if(c.isEqual&&E.call(c.isEqual)==u)return c.isEqual(a);var f=E.call(a);if(f!=E.call(c))return!1;switch(f){case x:return a==String(c);case v:return a!=+a?c!=+c:a==0?1/a==1/c:a==+c;case s:case t:return+a==+c;case w:return a.source==c.source&&a.global==c.global&&a.multiline==c.multiline&&a.ignoreCase==c.ignoreCase}if(typeof a!="object"||typeof c!="object")return!1;var g=e.length;while(g--)if(e[g]==a)return!0;var h=-1,i=!0,j=0;e.push(a);if(f==r){j=a.length,i=j==c.length;if(i)while(j--)if(!(i=ch(a[j],c[j],e)))break}else{if("constructor"in a!="constructor"in c||a.constructor!=c.constructor)return!1;for(var l in a)if(B.call(a,l)){j++;if(!(i=B.call(c,l)&&ch(a[l],c[l],e)))break}if(i){for(l in c)if(B.call(c,l)&&!(j--))break;i=!j}if(i&&d)while(++h<7){l=k[h];if(B.call(a,l)&&!(i=B.call(c,l)&&ch(a[l],c[l],e)))break}}return e.pop(),i}function ci(a){return H(a)&&E.call(a)==v}function cj(a){return E.call(a)==u}function ck(a){return p[typeof a]&&a!==null}function cl(a){return E.call(a)==v&&a!=+a}function cm(a){return a===null}function cn(a){return E.call(a)==v}function co(a){return E.call(a)==w}function cp(a){return E.call(a)==x}function cq(a){return a===b}function cs(a){var b,c=0,d=A.apply(y,arguments),e=d.length,f={};while(++c<e)b=d[c],b in a&&(f[b]=a[b]);return f}function ct(a){var b=E.call(a);return b==r||b==x?a.length:cr(a).length}function cu(a,b){return b(a),a}function cw(a){return(a+"").replace(i,X)}function cx(a){return a}function cy(a){bg(b_(a),function(b){var c=L[b]=a[b];M.prototype[b]=function(){var a=[this._wrapped];arguments.length&&C.apply(a,arguments);var b=c.apply(L,a);return this._chain&&(b=new M(b),b._chain=!0),b}})}function cz(){return a._=f,this}function cA(a,b){if(!a)return null;var c=a[b];return E.call(c)==u?a[b]():c}function cB(a,b,c){c||(c={});var d,e=L.templateSettings,f=c.escape,g=c.evaluate,i=c.interpolate,k=c.variable;return f==null&&(f=e.escape),g==null&&(g=e.evaluate),i==null&&(i=e.interpolate),f&&(a=a.replace(f,_)),i&&(a=a.replace(i,ba)),g&&(a=a.replace(g,bb)),a="__p='"+a.replace(j,W).replace(h,V)+"';\n",n.length=0,k||(k=e.variable,a="with ("+k+" || {}) {\n"+a+"\n}\n"),a="function("+k+") {\n"+"var __p, __t, __j = Array.prototype.join;\n"+"function print() { __p += __j.call(arguments, '') }\n"+a+"return __p\n}\n"+"//@ sourceURL=/lodash/template/source["+l++ +"]\n",d=Function("_","return "+a)(L),b?d(b):(d.source=a,d)}function cC(a,b,c){var d=-1;if(c)while(++d<a)b.call(c,d);else while(++d<a)b(d)}function cD(a){var b=e++;return a?a+b:b}function cE(a){return a=new M(a),a._chain=!0,a}function cF(){return this._chain=!0,this}function cG(){return this._wrapped}"use strict";var c=typeof exports=="object"&&exports&&(typeof global=="object"&&global&&global==global.global&&(a=global),exports),d=!{valueOf:0}.propertyIsEnumerable("valueOf"),e=0,f=a._,g=RegExp("^"+({}.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),h=/__token__(\d+)/g,i=/[&<"']/g,j=/['\n\r\t\u2028\u2029\\]/g,k=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],l=0,m="__token__",n=[],o={"&":"&amp;","<":"&lt;",'"':"&quot;","'":"&#x27;"},p={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,"undefined":!1},q={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},r="[object Array]",s="[object Boolean]",t="[object Date]",u="[object Function]",v="[object Number]",w="[object RegExp]",x="[object String]",y=Array.prototype,z=Object.prototype,A=y.concat,B=z.hasOwnProperty,C=y.push,D=y.slice,E=z.toString,F=g.test(F=D.bind)&&/\n|Opera/.test(F+E.call(a.opera))&&F,G=g.test(G=Array.isArray)&&G,H=a.isFinite,I=g.test(I=Object.keys)&&I,J=a.clearTimeout,K=a.setTimeout;L.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:"obj"};var N=cB("var index, result<% if (init) { %> = <%= init %><% } %>;\n<%= exit %>;\n<%= top %>;\n<% if (arrayBranch) { %>var length = <%= firstArg %>.length; index = -1; <% if (objectBranch) { %>\nif (length === length >>> 0) {<% } %>\n <%= arrayBranch.beforeLoop %>;\n while (<%= arrayBranch.loopExp %>) {\n <%= arrayBranch.inLoop %>;\n } <% if (objectBranch) { %>\n}\n<% }}if (objectBranch) { if (arrayBranch) { %>else {\n<% } if (!hasDontEnumBug) { %> var skipProto = typeof <%= iteratedObject %> == 'function';\n<% } %> <%= objectBranch.beforeLoop %>;\n for (<%= objectBranch.loopExp %>) { \n<% if (hasDontEnumBug) { if (useHas) { %> if (<%= hasExp %>) {\n <% } %> <%= objectBranch.inLoop %>;<% if (useHas) { %>\n }<% } } else { %> if (!(skipProto && index == 'prototype')<% if (useHas) { %> && <%= hasExp %><% } %>) {\n <%= objectBranch.inLoop %>;\n } <% } %>\n } <% if (hasDontEnumBug) { %>\n var ctor = <%= iteratedObject %>.constructor;\n <% for (var k = 0; k < 7; k++) { %>\n index = '<%= shadowed[k] %>';\n if (<% if (shadowed[k] == 'constructor') { %>!(ctor && ctor.prototype === <%= iteratedObject %>) && <% } %><%= hasExp %>) {\n <%= objectBranch.inLoop %>;\n }<% } } if (arrayBranch) { %>\n}<% }} %>\n<%= bottom %>;\nreturn result"),O={args:"collection, callback, thisArg",init:"collection",top:"if (!callback) {\n callback = identity\n}\nelse if (thisArg) {\n callback = iteratorBind(callback, thisArg)\n}",inLoop:"callback(collection[index], index, collection)"},P={init:"true",inLoop:"if (!callback(collection[index], index, collection)) return !result"},Q={args:"object",init:"object",top:"for (var source, sourceIndex = 1, length = arguments.length; sourceIndex < length; sourceIndex++) {\n source = arguments[sourceIndex];\n"+(d?" if (source) {":""),loopExp:"index in source",useHas:!1,inLoop:"object[index] = source[index]",bottom:(d?" }\n":"")+"}"},R={init:"[]",inLoop:"callback(collection[index], index, collection) && result.push(collection[index])"},S={top:"if (thisArg) callback = iteratorBind(callback, thisArg)"},T={inLoop:{object:O.inLoop}},$=U({args:"object",exit:"if (!objectTypes[typeof object] || object === null) throw TypeError()",init:"[]",inLoop:"result.push(index)"}),bc=U({args:"collection, target",init:"false",inLoop:"if (collection[index] === target) return true"}),bd=U(O,P),be=U(O,R),bf=U(O,S,{init:"",inLoop:"if (callback(collection[index], index, collection)) return collection[index]"}),bg=U(O,S),bh=U(O,{init:"",exit:"if (!collection) return []",beforeLoop:{array:"result = Array(length)",object:"result = []"},inLoop:{array:"result[index] = callback(collection[index], index, collection)",object:"result.push(callback(collection[index], index, collection))"}}),bi=U({args:"collection, callback, accumulator, thisArg",init:"accumulator",top:"var noaccum = arguments.length < 3;\nif (thisArg) callback = iteratorBind(callback, thisArg)",beforeLoop:{array:"if (noaccum) result = collection[++index]"},inLoop:{array:"result = callback(result, collection[index], index, collection)",object:"result = noaccum\n ? (noaccum = false, collection[index])\n : callback(result, collection[index], index, collection)"}}),bk=U(O,R,{inLoop:"!"+R.inLoop}),bl=U(O,P,{init:"false",inLoop:P.inLoop.replace("!","")}),bX=U(Q,{inLoop:"if (object[index] == undefined)"+Q.inLoop}),bY=U(Q),bZ=U(O,S,T,{useHas:!1}),b$=U(O,S,T),b_=U({args:"object",init:"[]",useHas:!1,inLoop:"if (toString.call(object[index]) == funcClass) result.push(index)",bottom:"result.sort()"}),cb=function(a){return E.call(a)=="[object Arguments]"};cb(arguments)||(cb=function(a){return!!a&&!!B.call(a,"callee")});var cc=G||function(a){return E.call(a)==r},cg=U({args:"value",init:"true",top:"var className = toString.call(value);\nif (className == arrayClass || className == stringClass) return !value.length",inLoop:{object:"return false"}}),cr=I?function(a){return typeof a=="function"?$(a):I(a)}:$,cv=U({args:"object",init:"[]",inLoop:"result.push(object[index])"});L.VERSION="0.3.1",L.after=bK,L.bind=bL,L.bindAll=bM,L.chain=cE,L.clone=bW,L.compact=bn,L.compose=bN,L.contains=bc,L.debounce=bO,L.defaults=bX,L.defer=bQ,L.delay=bP,L.difference=bo,L.escape=cw,L.every=bd,L.extend=bY,L.filter=be,L.find=bf,L.first=bp,L.flatten=bq,L.forEach=bg,L.forIn=bZ,L.forOwn=b$,L.functions=b_,L.groupBy=br,L.has=ca,L.identity=cx,L.indexOf=bs,L.initial=bt,L.intersection=bu,L.invoke=bv,L.isArguments=cb,L.isArray=cc,L.isBoolean=cd,L.isDate=ce,L.isElement=cf,L.isEmpty=cg,L.isEqual=ch,L.isFinite=ci,L.isFunction=cj,L.isNaN=cl,L.isNull=cm,L.isNumber=cn,L.isObject=ck,L.isRegExp=co,L.isString=cp,L.isUndefined=cq,L.keys=cr,L.last=bw,L.lastIndexOf=bx,L.map=bh,L.max=by,L.memoize=bR,L.min=bz,L.mixin=cy,L.noConflict=cz,L.once=bS,L.partial=bT,L.pick=cs,L.pluck=bA,L.range=bB,L.reduce=bi,L.reduceRight=bj,L.reject=bk,L.rest=bC,L.result=cA,L.shuffle=bD,L.size=ct,L.some=bl,L.sortBy=bE,L.sortedIndex=bF,L.tap=cu,L.template=cB,L.throttle=bU,L.times=cC,L.toArray=bm,L.union=bG,L.uniq=bH,L.uniqueId=cD,L.values=cv,L.without=bI,L.wrap=bV,L.zip=bJ,L.all=bd,L.any=bl,L.collect=bh,L.detect=bf,L.each=bg,L.foldl=bi,L.foldr=bj,L.head=bp,L.include=bc,L.inject=bi,L.methods=b_,L.select=be,L.tail=bC,L.take=bp,L.unique=bH,L._iteratorTemplate=N,L._shimKeys=$,M.prototype=L.prototype,cy(L),M.prototype.chain=cF,M.prototype.value=cG,bg(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var b=y[a];M.prototype[a]=function(){var a=this._wrapped;return b.apply(a,arguments),a.length===0&&delete a[0],this._chain&&(a=new M(a),a._chain=!0),a}}),bg(["concat","join","slice"],function(a){var b=y[a];M.prototype[a]=function(){var a=this._wrapped,c=b.apply(a,arguments);return this._chain&&(c=new M(c),c._chain=!0),c}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(a._=L,define(function(){return L})):c?typeof module=="object"&&module&&module.exports==c?(module.exports=L)._=L:c._=L:a._=L}(this),function(){var a=this.math={};a.mean=a.ave=a.average=function(b,c){return a.sum(b,c)/_(b).size()},a.median=function(b){var c=(b.length+1)/2,d=a.sort(b);return d.length%2?d[c-1]:(d[c-1.5]+d[c-.5])/2},a.pow=function(a,b){if(_.isNumber(a))return Math.pow(a,b);if(_.isArray(a))return _.map(a,function(a){return _.pow(a,b)})},a.scale=function(a,b){var b=b||1,c=_.max(a);return _.map(a,function(a){return a*(b/c)})},a.slope=function(a,b){return(b[1]-a[1])/(b[0]-a[0])},a.sort=function(a){return a.sort(function(a,b){return a-b})},a.stdDeviation=a.sigma=function(a){return Math.sqrt(_(a).variance())},a.sum=function(a,b){if(_.isArray(a)&&typeof a[0]=="number")var c=a;else var b=b||"value",c=_(a).pluck(b);var d=0;for(var e=0,f=c.length;e<f;e++)d+=c[e];return d},a.transpose=function(a){var b=[];return _(a).each(function(a,c){_(a).each(function(a,d){b[d]||(b[d]=[]),b[d][c]=a})}),b},a.variance=function(a){var b=_(a).mean();return _(a).chain().map(function(a){return _(a-b).pow(2)}).mean().value()},_.mixin(a)}(),function(a){function p(a){var b=o[a]={},c,d;a=a.split(/\s+/);for(c=0,d=a.length;c<d;c++)b[a[c]]=!0;return b}var b={},c=Array.prototype,d=Object.prototype,e=d.hasOwnProperty,f=d.toString,g=c.forEach,h=c.slice,i=function(a,c,d){var f,h,i;if(!a)return;if(g&&a.forEach===g)a.forEach(c,d);else if(a.length===+a.length){for(h=0,i=a.length;h<i;h++)if(h in a&&c.call(d,a[h],h,a)===b)return}else for(f in a)if(e.call(a,f)&&c.call(d,a[f],f,a)===b)return},j=function(a){return!!(a&&a.constructor&&a.call&&a.apply)},k=function(a){return i(h.call(arguments,1),function(b){var c;for(c in b)b[c]!==void 0&&(a[c]=b[c])}),a},l={"[object Array]":"array","[object Function]":"function"},m=function(a){return a?l[f.call(a)]||"object":String(a)},n={},o={};n.Callbacks=function(a){a=a?o[a]||p(a):{};var b=[],c=[],d,e,f,g,h,i,j=function(c){var d,e,f,g,h;for(d=0,e=c.length;d<e;d++)f=c[d],g=m(f),g==="array"?j(f):g==="function"&&(!a.unique||!l.has(f))&&b.push(f)},k=function(j,k){k=k||[],d=!a.memory||[j,k],e=!0,f=!0,i=g||0,g=0,h=b.length;for(;b&&i<h;i++)if(b[i].apply(j,k)===!1&&a.stopOnFalse){d=!0;break}f=!1,b&&(a.once?d===!0?l.disable():b=[]:c&&c.length&&(d=c.shift(),l.fireWith(d[0],d[1])))},l={add:function(){if(b){var a=b.length;j(arguments),f?h=b.length:d&&d!==!0&&(g=a,k(d[0],d[1]))}return this},remove:function(){if(b){var c=arguments,d=0,e=c.length;for(;d<e;d++)for(var g=0;g<b.length;g++)if(c[d]===b[g]){f&&g<=h&&(h--,g<=i&&i--),b.splice(g--,1);if(a.unique)break}}return this},has:function(a){if(b){var c=0,d=b.length;for(;c<d;c++)if(a===b[c])return!0}return!1},empty:function(){return b=[],this},disable:function(){return b=c=d=undefined,this},disabled:function(){return!b},lock:function(){return c=undefined,(!d||d===!0)&&l.disable(),this},locked:function(){return!c},fireWith:function(b,e){return c&&(f?a.once||c.push([b,e]):(!a.once||!d)&&k(b,e)),this},fire:function(){return l.fireWith(this,arguments),this},fired:function(){return!!e}};return l},n.Deferred=function(a){var b=n.Callbacks("once memory"),c=n.Callbacks("once memory"),d=n.Callbacks("memory"),e="pending",f={resolve:b,reject:c,notify:d},g={done:b.add,fail:c.add,progress:d.add,state:function(){return e},isResolved:b.fired,isRejected:c.fired,then:function(a,b,c){return h.done(a).fail(b).progress(c),this},always:function(){return h.done.apply(h,arguments).fail.apply(h,arguments),this},pipe:function(a,b,c){return n.Deferred(function(d){i({done:[a,"resolve"],fail:[b,"reject"],progress:[c,"notify"]},function(a,b){var c=a[0],e=a[1],f;j(c)?h[b](function(){f=c.apply(this,arguments),f&&j(f.promise)?f.promise().then(d.resolve,d.reject,d.notify):d[e+"With"](this===h?d:this,[f])}):h[b](d[e])})}).promise()},promise:function(a){if(!a)a=g;else for(var b in g)a[b]=g[b];return a}},h=g.promise({}),k;for(k in f)h[k]=f[k].fire,h[k+"With"]=f[k].fireWith;return h.done(function(){e="resolved"},c.disable,d.lock).fail(function(){e="rejected"},b.disable,d.lock),a&&a.call(h,h),h},n.when=function(a){function l(a){return function(c){b[a]=arguments.length>1?h.call(arguments,0):c,--f||i.resolveWith(i,b)}}function m(a){return function(b){e[a]=arguments.length>1?h.call(arguments,0):b,i.notifyWith(k,e)}}var b=h.call(arguments,0),c=0,d=b.length,e=new Array(d),f=d,g=d,i=d<=1&&a&&j(a.promise)?a:n.Deferred(),k=i.promise();if(d>1){for(;c<d;c++)b[c]&&b[c].promise&&j(b[c].promise)?b[c].promise().then(l(c),i.reject,m(c)):--f;f||i.resolveWith(i,b)}else i!==a&&i.resolveWith(i,d?[a]:[]);return k},typeof module!="undefined"&&module.exports?module.exports=n:typeof a._!="undefined"?a._.mixin(n):a._=n}(this),function(a,_){var b=a.Miso={};b.typeOf=function(a,c){var d=_.keys(b.types),e;return d.push(d.splice(_.indexOf(d,"string"),1)[0]),d.push(d.splice(_.indexOf(d,"mixed"),1)[0]),e=_.find(d,function(d){return b.types[d].test(a,c)}),e=_.isUndefined(e)?"string":e,e},b.types={mixed:{name:"mixed",coerce:function(a){return a},test:function(a){return!0},compare:function(a,b){return a<b?-1:a>b?1:0},numeric:function(a){return _.isNaN(Number(a))?0:Number(a)}},string:{name:"string",coerce:function(a){return a==null?null:a.toString()},test:function(a){return a===null||typeof a=="undefined"||typeof a=="string"},compare:function(a,b){return a==null&&b!=null?-1:a!=null&&b==null?1:a<b?-1:a>b?1:0},numeric:function(a){return _.isNaN(+a)?0:+a}},"boolean":{name:"boolean",regexp:/^(true|false)$/,coerce:function(a){return a==="false"?!1:Boolean(a)},test:function(a){return a===null||typeof a=="undefined"||typeof a=="boolean"||this.regexp.test(a)?!0:!1},compare:function(a,b){return a==null&&b!=null?-1:a!=null&&b==null?1:a==null&&b==null?0:a===b?0:a<b?-1:1},numeric:function(a){return a?1:0}},number:{name:"number",regexp:/^[\-\.]?[0-9]+([\.][0-9]+)?$/,coerce:function(a){return _.isNull(a)?null:_.isNaN(a)?null:+a},test:function(a){return a===null||typeof a=="undefined"||typeof a=="number"||this.regexp.test(a)?!0:!1},compare:function(a,b){return a==null&&b!=null?-1:a!=null&&b==null?1:a==null&&b==null?0:a===b?0:a<b?-1:1},numeric:function(a){return a}},time:{name:"time",format:"DD/MM/YYYY",_formatLookup:[["DD","\\d{2}"],["D","\\d{1}|\\d{2}"],["MM","\\d{2}"],["M","\\d{1}|\\d{2}"],["YYYY","\\d{4}"],["YY","\\d{2}"],["A","[AM|PM]"],["hh","\\d{2}"],["h","\\d{1}|\\d{2}"],["mm","\\d{2}"],["m","\\d{1}|\\d{2}"],["ss","\\d{2}"],["s","\\d{1}|\\d{2}"],["ZZ","[-|+]\\d{4}"],["Z","[-|+]\\d{2}:\\d{2}"]],_regexpTable:{},_regexp:function(a){if(this._regexpTable[a])return new RegExp(this._regexpTable[a],"g");var b=a;return _.each(this._formatLookup,function(a){b=b.replace(a[0],a[1])},this),b=b.split("/").join("\\/"),this._regexpTable[a]=b,new RegExp(this._regexpTable[a],"g")},coerce:function(a,b){b=b||{};if(_.isString(a)){var c=b.format||this.format;return moment(a,b.format)}return _.isNumber(a)?moment(a):a},test:function(a,b){b=b||{};if(a===null||typeof a=="undefined")return!0;if(_.isString(a)){var c=b.format||this.format,d=this._regexp(c);return d.test(a)}return!0},compare:function(a,b){return a<b?-1:a>b?1:0},numeric:function(a){return a.valueOf()}}}}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Event=function(a){_.isArray(a)||(a=[a]),this.deltas=a},_.extend(b.Event.prototype,{affectedColumns:function(){var a=[];return _.each(this.deltas,function(b){b.old=b.old||[],b.changed=b.changed||[],a=_.chain(a).union(_.keys(b.old),_.keys(b.changed)).reject(function(a){return a==="_id"}).value()}),a}}),_.extend(b.Event,{isRemove:function(a){return _.isUndefined(a.changed)||_.keys(a.changed).length===0?!0:!1},isAdd:function(a){return _.isUndefined(a.old)||_.keys(a.old).length===0?!0:!1},isUpdate:function(a){return!this.isRemove(a)&&!this.isAdd(a)?!0:!1}}),b.Events={},b.Events.bind=function(a,b,c){var d=this._callbacks||(this._callbacks={}),e=d[a]||(d[a]={}),f=e.tail||(e.tail=e.next={});return f.callback=b,f.context=c,e.tail=f.next={},this},b.Events.unbind=function(a,b){var c,d,e;if(!a)this._callbacks=null;else if(c=this._callbacks)if(!b)c[a]={};else if(d=c[a])while((e=d)&&(d=d.next)){if(d.callback!==b)continue;e.next=d.next,d.context=d.callback=null;break}return this},b.Events.trigger=function(a){var b,c,d,e,f,g=["all",a];if(!(c=this._callbacks))return this;while(f=g.pop()){if(!(b=c[f]))continue;e=f==="all"?arguments:Array.prototype.slice.call(arguments,1);while(b=b.next)(d=b.callback)&&d.apply(b.context||this,e)}return this},b.Events._buildEvent=function(a){return new b.Event(a)}}(this,_),function(a,_){var b=a.Miso||{};b.Builder={detectColumnType:function(a,c){var d=_.inject(c.slice(0,5),function(a,c){var d=b.typeOf(c);return c!==""&&a.indexOf(d)===-1&&!_.isNull(c)&&a.push(d),a},[]);return d.length===1?a.type=d[0]:a.type="mixed",a},detectColumnTypes:function(a,c){_.each(c,function(c,d){var e=a.column(d);if(e.type){e.force=!0;return}b.Builder.detectColumnType(e,c)},this)},cacheRows:function(a){b.Builder.clearRowCache(a),_.each(a._columns[a._columnPositionByName._id].data,function(b,c){a._rowPositionById[b]=c,a._rowIdByPosition.push(b)},a);var c=_.uniq(_.map(a._columns,function(a){return a.data.length}));if(c.length>1)throw new Error("Row lengths need to be the same. Empty values should be set to null."+_.map(a._columns,function(a){return a.data+"|||"}));a.length=c[0]},clearRowCache:function(a){a._rowPositionById={},a._rowIdByPosition=[]},cacheColumns:function(a){a._columnPositionByName={},_.each(a._columns,function(b,c){a._columnPositionByName[b.name]=c})}},Array.prototype.indexOf||(Array.prototype.indexOf=function(a,b){for(var c=b||0,d=this.length;c<d;c++)if(this[c]===a)return c;return-1})}(this,_),function(a,_){var b=a.Miso;b.Column=function(a){return _.extend(this,a),this._id=a.id||_.uniqueId(),this.data=a.data||[],this},_.extend(b.Column.prototype,{toNumeric:function(a){return b.types[this.type].numeric(a)},numericAt:function(a){return this.toNumeric(this.data[a])},coerce:function(){this.data=_.map(this.data,function(a){return b.types[this.type].coerce(a,this)},this)},_sum:function(){return _.sum(this.data)},_mean:function(){var a=0;for(var c=0;c<this.data.length;c++)a+=this.numericAt(c);return a/=this.data.length,b.types[this.type].coerce(a,this)},_median:function(){return b.types[this.type].coerce(_.median(this.data),this)},_max:function(){var a=-Infinity;for(var c=0;c<this.data.length;c++)b.types[this.type].compare(this.data[c],a)>0&&(a=this.numericAt(c));return b.types[this.type].coerce(a,this)},_min:function(){var a=Infinity;for(var c=0;c<this.data.length;c++)b.types[this.type].compare(this.data[c],a)<0&&(a=this.numericAt(c));return b.types[this.type].coerce(a,this)}}),b.DataView=function(a){if(typeof a!="undefined"){a=a||(a={});if(_.isUndefined(a.parent))throw new Error("A view must have a parent specified.");this.parent=a.parent,this._initialize(a)}},_.extend(b.DataView.prototype,{_initialize:function(a){this.parent.syncable===!0&&(_.extend(this,b.Events),this.syncable=!0),this.filter={columns:this._columnFilter(a.filter.columns||undefined),rows:this._rowFilter(a.filter.rows||undefined)},this._columns=this._selectData(),b.Builder.cacheColumns(this),b.Builder.cacheRows(this),this.syncable&&this.parent.bind("change",this._sync,this)},_sync:function(a){var c=a.deltas,d=null;_.each(c,function(c,e){var f=this._rowPositionById[c._id];if(typeof f=="undefined"&&b.Event.isAdd(c))this.filter.rows&&this.filter.rows(c.changed)&&(this._add(c.changed),d="add");else{if(f==="undefined")return;_.each(c.changed,function(a,b){var c=this._columnPositionByName[b];if(_.isUndefined(c))return;this._columns[c].data[f]=a,d="update"},this)}var g=this.rowByPosition(f);if(b.Event.isRemove(c)||this.filter.row&&!this.filter.row(g)){var h={_id:c._id,old:this.rowByPosition(f),changed:{}};a.deltas.splice(e,1,h),this._remove(f),d="delete"}},this),this.syncable&&(this.trigger(d,a),this.trigger("change",a))},where:function(a,c){return c=c||{},c.parent=this,c.filter=a||{},new b.DataView(c)},_selectData:function(){var a=[];return _.each(this.parent._columns,function(c){this.filter.columns(c)&&a.push(new b.Column({name:c.name,data:[],type:c.type,_id:c._id}))},this),this.parent.each(function(b){if(!this.filter.rows(b))return;for(var c=0;c<a.length;c++)a[c].data.push(b[a[c].name])},this),a},_columnFilter:function(a){var b;return _.isUndefined(a)?b=function(){return!0}:(_.isString(a)&&(a=[a]),a.push("_id"),b=function(b){return _.indexOf(a,b.name)===-1?!1:!0}),b},_rowFilter:function(a){var b;return _.isNumber(a)&&(a=[a]),_.isUndefined(a)?b=function(){return!0}:_.isFunction(a)?b=a:b=function(b){return _.indexOf(a,b._id)===-1?!1:!0},b},column:function(a){return this._column(a)},_column:function(a){if(_.isUndefined(this._columnPositionByName))return undefined;var b=this._columnPositionByName[a];return this._columns[b]},columns:function(a){return new b.DataView({filter:{columns:a},parent:this})},columnNames:function(){var a=_.pluck(this._columns,"name");return _.reject(a,function(a){return a==="_id"||a==="_oids"})},hasColumn:function(a){return!_.isUndefined(this._columnPositionByName[a])},each:function(a,b){for(var c=0;c<this.length;c++)a.apply(b||this,[this.rowByPosition(c),c])},reverseEach:function(a,b){for(var c=this.length-1;c>=0;c--)a.apply(b||this,[this.rowByPosition(c),c])},eachColumn:function(a,b){var c=this.columnNames();for(var d=0;d<c.length;d++)a.apply(b||this,[c[d],this.column(c[d]),d])},rowByPosition:function(a){return this._row(a)},rowById:function(a){return this._row(this._rowPositionById[a])},_row:function(a){var b={};return _.each(this._columns,function(c){b[c.name]=c.data[a]}),b},_remove:function(a){var b=this._rowPositionById[a];return _.each(this._columns,function(a){a.data.splice(b,1)}),delete this._rowPositionById[a],this._rowIdByPosition.splice(b,1),this.length--,this},_add:function(a,c){_.each(a,function(c,d){var e=this.column(d);if(typeof e!="undefined"){var f=b.types[e.type];if(e.force||f.test(a[e.name],e))_.isUndefined(e.before)||(a[e.name]=e.before(a[e.name])),a[e.name]=f.coerce(a[e.name],e);else throw"incorrect value '"+a[e.name]+"' of type "+b.typeOf(a[e.name],e)+" passed to column with type "+e.type}},this);if(_.isUndefined(this.comparator))_.each(this._columns,function(b){b.data.push(!_.isUndefined(a[b.name])&&!_.isNull(a[b.name])?a[b.name]:null)}),this.length++,this._rowIdByPosition=this._rowIdByPosition||(this._rowIdByPosition=[]),this._rowPositionById=this._rowPositionById||(this._rowPositionById={}),this._rowIdByPosition.push(a._id),this._rowPositionById[a._id]=this._rowIdByPosition.length;else{var d=function(a,b,c){Array.prototype.splice.apply(c,[a,0].concat(b))},e;this.length++;for(e=0;e<this.length;e++){var f=this.rowByPosition(e);if(_.isUndefined(f._id)||this.comparator(a,f)<0){_.each(this._columns,function(b){d(e,a[b.name]?a[b.name]:null,b.data)});break}}this._rowIdByPosition=[],this._rowPositionById={},this.each(function(a,b){this._rowIdByPosition.push(a._id),this._rowPositionById[a._id]=b})}return this},rows:function(a){return new b.DataView({filter:{rows:a},parent:this})},sort:function(a){var b={};_.isFunction(a)?b.comparator=a:b=a||b,b.comparator&&(this.comparator=b.comparator);if(_.isUndefined(this.comparator))throw new Error("Cannot sort without this.comparator.");var c=this.length,d;if(c===1)return;var e=_.bind(function(a,b){var c=this.rowByPosition(b);_.each(c,function(c,d){var e=this._columnPositionByName[d],f=this._columns[e].data[a];this._columns[e].data.splice(a,1,c),this._columns[e].data.splice(b,1,f)},this)},this),f=_.bind(function(a,b){var c=a,d;while(c*2<=b){d=c*2;var f=this.rowByPosition(c);d+1<b&&this.comparator(this.rowByPosition(d),this.rowByPosition(d+1))<0&&d++;if(this.comparator(f,this.rowByPosition(d))<0)e(c,d),c=d;else return}},this),g=function(a){var b=Math.round((a-2)/2);while(b>=0)f(b,a-1),b--};if(c>2){g(c),d=c-1;while(d>1)e(d,0),d--,f(0,d)}else this.comparator(this.rowByPosition(0),this.rowByPosition(1))>0&&e(0,1);return this.comparator(this.rowByPosition(this.length-2),this.rowByPosition(this.length-1))>0&&e(this.length-1,this.length-2),this.syncable&&b.silent&&this.trigger("sort"),this},toJSON:function(){var a=[];for(var b=0;b<this.length;b++)a.push(this.rowByPosition(b));return a}})}(this,_),function(a,_){var b=a.Miso;b.Product=b.Product||function(a){a=a||{},this.func=a.func;if(a.columns){var b=a.columns;_.isArray(a.columns)&&(b=a.columns[0]),this.valuetype=b.type,this.numeric=function(){return b.toNumeric(this.value)}}return this.func({silent:!0}),this},_.extend(b.Product.prototype,b.Events,{val:function(){return this.value},type:function(){return this.valuetype},_sync:function(a){this.func()},_buildDelta:function(a,b){return{old:a,changed:b}}}),_.extend(b.DataView.prototype,{_findColumns:function(a){var b=[];return _.isUndefined(a)&&(a=this.columnNames()),a=_.isArray(a)?a:[a],_.each(a,function(a){a=this._columns[this._columnPositionByName[a]],b.push(a)},this),b},sum:function(a,c){c=c||{};var d=this._findColumns(a),e=function(a){return function(){return _.each(a,function(a){if(a.type===b.types.time.name)throw new Error("Can't sum up time")}),_.sum(_.map(a,function(a){return a._sum()}))}}(d);return this._calculated(d,e)},max:function(a,c){c=c||{};var d=this._findColumns(a),e=function(a){return function(){var c=_.max(_.map(a,function(a){return a._max()})),d=a[0].type,e=a[0].typeOptions;return b.types[d].coerce(c,e)}}(d);return this._calculated(d,e)},min:function(a,c){c=c||{};var d=this._findColumns(a),e=function(a){return function(){var c=_.min(_.map(a,function(a){return a._min()})),d=a[0].type,e=a[0].typeOptions;return b.types[d].coerce(c,e)}}(d);return this._calculated(d,e)},mean:function(a,c){c=c||{};var d=this._findColumns(a),e=function(a){return function(){var c=[];_.each(a,function(a){c.push(a.data)}),c=_.flatten(c);var d=a[0].type,e=a[0].typeOptions;return c=_.map(c,function(a){return b.types[d].numeric(a)}),b.types[d].coerce(_.mean(c),e)}}(d);return this._calculated(d,e)},_calculated:function(a,c){var d=this,e=new b.Product({columns:a,func:function(a){a=a||{};var b=this._buildDelta(this.value,c.apply(d));this.value=b.changed;if(d.syncable){var e=this._buildEvent(b);!_.isUndefined(b.old)&&!a.silent&&b.old!==b.changed&&this.trigger("change",e)}}});return this.syncable?(this.bind("change",e._sync,e),e):c()}})}(this,_),function(a,_,moment){var b=a.Miso;b.Dataset=function(a){this.length=0,this._columns=[],this._columnPositionByName={},typeof a!="undefined"&&(a=a||{},this._initialize(a))},b.Dataset.prototype=new b.DataView,_.extend(b.Dataset.prototype,{_initialize:function(a){a.sync===!0&&(_.extend(this,b.Events),this.syncable=!0),this.importer=a.importer||null,this.parser=a.parser||b.Parsers.Obj,_.isUndefined(a.parser)&&(a.strict?this.parser=b.Parsers.Strict:a.delimiter&&(this.parser=b.Parsers.Delimited)),this.importer===null&&(a.url?a.interval?(this.importer=b.Importers.Polling,this.interval=a.interval):this.importer=b.Importers.Remote:this.importer=b.Importers.Local),this.parser=new this.parser(a),this.parser instanceof b.Parsers.Delimited&&(a.dataType="text"),this.importer=new this.importer(a),a.comparator&&(this.comparator=a.comparator),a.ready&&(this.ready=a.ready),a.resetOnFetch&&(this.resetOnFetch=a.resetOnFetch),a.uniqueAgainst&&(this.uniqueAgainst=a.uniqueAgainst),_.isUndefined(a.data)&&_.isUndefined(a.url)&&this._addIdColumn(),a.deferred?this.deferred=a.deferred:this.deferred=new _.Deferred,a.columns&&this.addColumns(a.columns)},fetch:function(a){a=a||{};var b=this.deferred;if(_.isNull(this.importer))throw"No importer defined";return this.importer.fetch({success:_.bind(function(c){try{this._apply(c)}catch(d){if(a.error)a.error.call(this,d);else throw d}this.comparator&&this.sort(),this.ready&&this.ready.call(this),a.success&&a.success.call(this),b.resolveWith(this,[this])},this),error:_.bind(function(c){a.error&&a.error.call(this,c),b.reject(c)},this)}),b.promise()},_applications:{againstColumn:function(a){var b=[],c=_.keys(a),d,e=this.column(this.uniqueAgainst),f=a[this._columns[1].name].length,g=_.max(_.map(c,function(b){return a[b].length},this)),h=[],i;for(i=0;i<f;i++){var j=a[this.uniqueAgainst][i];e.data.indexOf(j)!==-1&&h.push(i)}h.sort().reverse();for(i=0;i<g;i++)if(h.indexOf(i)===-1){d={};for(var k=0;k<c.length;k++)d[c[k]]=a[c[k]][i];b.push(d)}this.add(b)},blind:function(a){var b,c,d=[],e,f=_.keys(a),g=_.max(_.map(f,function(b){return a[b].length},this));for(var h=0;h<g;h++){e={};for(var i=0;i<f.length;i++)e[f[i]]=a[f[i]][h];d.push(e)}this.add(d)}},_apply:function(a){var c=this.parser.parse(a);if(!this.fetched)this._addIdColumn(),this.addColumns(_.map(c.columns,function(a){return{name:a}})),b.Builder.detectColumnTypes(this,c.data),this._applications.blind.call(this,c.data),this.fetched=!0;else if(this.resetOnFetch)this.reset(),this._applications.blind.call(this,c.data);else if(this.uniqueAgainst){if(!this.hasColumn(this.uniqueAgainst))throw new Error("You requested a unique add against a column that doesn't exist.");this._applications.againstColumn.call(this,c.data)}else this._applications.blind.call(this,c.data);b.Builder.cacheRows(this)},addColumns:function(a){_.each(a,function(a){this.addColumn(a)},this)},addColumn:function(a){return _.isUndefined(this.column(a.name))?(a=new b.Column(a),this._columns.push(a),this._columnPositionByName[a.name]=this._columns.length-1,a):!1},_addIdColumn:function(a){if(!_.isUndefined(this.column("_id")))return;var b=[];a&&a>0&&_.times(a,function(){b.push(_.uniqueId())}),this.addColumn({name:"_id",type:"number",data:b});if(this._columnPositionByName._id!==0){var c=this._columns[this._columnPositionByName._id],d=this._columnPositionByName._id;this._columns.splice(d,1),this._columns.unshift(c),this._columnPositionByName._id=0,_.each(this._columnPositionByName,function(a,b){b!=="_id"&&this._columnPositionByName[b]<d&&this._columnPositionByName[b]++},this)}},add:function(a,b){b=b||{},_.isArray(a)||(a=[a]);var c=[];_.each(a,function(a){a._id||(a._id=_.uniqueId()),this._add(a,b),this.syncable&&!b.silent&&c.push({changed:a})},this);if(this.syncable&&!b.silent){var d=this._buildEvent(c);this.trigger("add",d),this.trigger("change",d)}return this},remove:function(a,b){a=this._rowFilter(a);var c=[],d=[];this.each(function(b,e){a(b)&&(d.push(b._id),c.push({old:b}))}),_.each(d,function(a){this._remove(a)},this);if(this.syncable&&(!b||!b.silent)){var e=this._buildEvent(c);this.trigger("remove",e),this.trigger("change",e)}},update:function(a,c,d){var e,f=[],g=_.bind(function(a,d){var g,h;_.isFunction(c)?h=c.apply(this,[a]):h=c,e=_.keys(h),_.each(e,function(a){g=this.column(a);var c=b.types[g.type];if(c)if(c.test(h[g.name],g))_.isUndefined(g.before)||(h[g.name]=g.before(h[g.name])),h[g.name]=c.coerce(h[g.name],g);else throw"incorrect value '"+h[g.name]+"' of type "+b.typeOf(h[g.name],g)+" passed to column with type "+g.type;g.data[d]=h[g.name]},this),f.push({_id:a._id,old:a,changed:h})},this);_.isString(a)&&(a=[a]);if(_.isArray(a)){var h,i;_.each(a,function(a){h=this.rowById(a),i=this._rowPositionById[a],g(h,i)})}else a=this._rowFilter(a),this.each(function(b,c){a(b)&&g(b,c)},this);if(this.syncable&&(!d||!d.silent)){var j=this._buildEvent(f);this.trigger("update",j),this.trigger("change",j)}return this},reset:function(a){_.each(this._columns,function(a){a.data=[]}),this.length=0,this.syncable&&(!a||!a.silent)&&this.trigger("reset")}})}(this,_,moment),function(a,_){var b=a.Miso||(a.Miso={});b.Derived=function(a){a=a||{},b.Dataset.call(this),this.parent=a.parent,this.method=a.method,this._addIdColumn(),this.addColumn({name:"_oids",type:"mixed"}),this.parent.syncable&&(_.extend(this,b.Events),this.syncable=!0,this.parent.bind("change",this._sync,this))},b.Derived.prototype=new b.Dataset,_.extend(b.Derived.prototype,{_sync:function(a){this.func.call(this.args),this.trigger("change")}}),_.extend(b.DataView.prototype,{movingAverage:function(a,c,d){d=d||{};var e=new b.Derived({parent:this,method:d.method||_.mean,size:c,args:arguments});this.eachColumn(function(a){e.addColumn({name:a,type:this.column(a).type,data:[]})},this),b.Builder.cacheColumns(e);var f=function(){var d=[];typeof a=="string"&&(a=[a]),this.column("_id").data=this.parent.column("_id").data.slice(c-1,this.parent.length),this.eachColumn(function(b,d,e){a.indexOf(b)===-1&&b!=="_oids"?d.data=this.parent.column(b).data.slice(c-1,this.parent.length):d.data=_.movingAvg(this.parent.column(b).data,c,this.method)},this),this.length=this.parent.length-c+1;var e=this.column("_oids");e.data=[];for(var f=0;f<this.length;f++)e.data.push(this.parent.column("_id").data.slice(f,f+c));return b.Builder.cacheRows(this),this};return e.func=_.bind(f,e),e.func.call(e.args)},countBy:function(a,c){function j(a,c,d){var e;for(e=0;e<a.length;e++)if(b.types[d].compare(a[e],c)===0)return e;return-1}c=c||{};var d=new b.Derived({parent:this,method:_.sum,args:arguments}),e=this.column(a);d.addColumn({name:a,type:e.type}),d.addColumn({name:"count",type:"number"}),d.addColumn({name:"_oids",type:"mixed"}),b.Builder.cacheColumns(d);var f=d._column(a).data,g=d._column("count").data,h=d._column("_oids").data,i=d._column("_id").data;return this.each(function(b){var c=j(f,b[a],e.type);c===-1?(f.push(b[a]),i.push(_.uniqueId()),g.push(1),h.push([b._id])):(g[c]+=1,h[c].push(b._id))}),b.Builder.cacheRows(d),d},groupBy:function(a,c,d){d=d||{};var e=new b.Derived({parent:this,method:d.method||_.sum,args:arguments});d&&d.preprocess&&(e.preprocess=d.preprocess);var f=_.union([a],c);_.each(f,function(a){this.addColumn({name:a,type:this.parent.column(a).type})},e),b.Builder.cacheColumns(e);var g=function(){b.Builder.clearRowCache(this);var d={},e=0,f=this._columnPositionByName[a],g=this.parent.column(a);for(var h=0;h<this.parent.length;h++){var i=null;this.preprocess?i=this.preprocess(g.data[h]):i=g.data[h],_.isUndefined(d[i])&&(d[i]=e,_.each(c,function(a){var b=this.column(a),c=this.column("_id");b.data[e]=[],c.data[e]=_.uniqueId()},this),this.column(a).data[e]=i,e++),_.each(c,function(a){var b=this.column(a),c=this.parent.column(a).data[h],e=d[i];b.data[e].push(this.parent.rowByPosition(h))},this)}var j=this._columns[this._columnPositionByName._oids];return j.data=[],_.each(c,function(a){var b=this.column(a);_.each(b.data,function(c,d){_.isArray(c)&&(j.data[d]=j.data[d]||[],j.data[d].push(_.map(c,function(a){return a._id})),j.data[d]=_.flatten(j.data[d]),b.data[d]=this.method(_.map(c,function(b){return b[a]})),this.length++)},this)},this),b.Builder.cacheRows(this),this};return e.func=_.bind(g,e),e.func.call(e.args)}})}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Importers=function(a,b){},b.Importers.prototype.extract=function(a){return a=_.clone(a),a}}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Importers.Local=function(a){a=a||{},this.data=a.data||null,this.extract=a.extract||this.extract},_.extend(b.Importers.Local.prototype,b.Importers.prototype,{fetch:function(a){var b=a.data?a.data:this.data;a.success(this.extract(b))}})}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Importers.Remote=function(a){a=a||{},this._url=a.url,this.extract=a.extract||this.extract,this.params={type:"GET",url:_.isFunction(this._url)?_.bind(this._url,this):this._url,dataType:a.dataType?a.dataType:a.jsonp?"jsonp":"json",callback:a.callback}},_.extend(b.Importers.Remote.prototype,b.Importers.prototype,{fetch:function(a){var c=_.bind(function(b){a.success(this.extract(b))},this);this.callback&&(window[this.callback]=c),b.Xhr(_.extend(this.params,{success:this.callback?this.callback:c,error:a.error}))}});var c={url:"",data:"",dataType:"",success:function(){},type:"GET",async:!0,xhr:function(){return new a.XMLHttpRequest}},d=/\?/;b.Xhr=function(a){a.dataType=a.dataType&&a.dataType.toLowerCase()||null;var e=_.isFunction(a.url)?a.url():a.url;if(!(!a.dataType||a.dataType!=="jsonp"&&a.dataType!=="script")){b.Xhr.getJSONP(e,a.success,a.dataType==="script",a.error,a.callback);return}var f=_.extend({},c,a,{url:e});f.ajax=f.xhr();if(f.ajax)return f.type==="GET"&&f.data&&(f.url+=(d.test(f.url)?"&":"?")+f.data,f.data=null),f.ajax.open(f.type,f.url,f.async),f.ajax.send(f.data||null),b.Xhr.httpData(f)},b.Xhr.getJSONP=function(a,b,c,d,e){if(c){var f=document.querySelectorAll('script[src="'+a+'"]');if(f.length){b&&b(!0);return}}var g=document.head||document.getElementsByTagName("head")[0]||document.documentElement,h=document.createElement("script"),i=a.split("?")[1],j=!1,k=[],l;i&&!c&&(k=i.split("&")),k.length&&(l=k[k.length-1].split("="));if(!e){var m=_.uniqueId("callback");e=k.length?l[1]?l[1]:m:m}!i&&!c&&(a+="?");if(!i||!/callback/.test(i))i&&(a+="&"),a+="callback="+e;e&&!c&&(!window[e]||(e=e+ +(new Date)+_.uniqueId()),window[e]=function(a){b&&b(a),j=!0},l&&(a=a.replace(l.join("="),l[0]+"="+e))),h.onload=h.onreadystatechange=function(){if(!h.readyState||/loaded|complete/.test(h.readyState)){c&&b&&b();if(j){try{delete window[e]}catch(a){window[e]=void 0}g.removeChild(h)}}},h.onerror=function(a){d&&d.call(null,a)},h.src=a,g.insertBefore(h,g.firstChild);return},b.Xhr.httpData=function(a){var b,c=null;return a.ajax.onreadystatechange=function(){if(a.ajax.readyState===4){try{c=JSON.parse(a.ajax.responseText)}catch(d){}b={xml:a.ajax.responseXML,text:a.ajax.responseText,json:c},a.dataType&&(b=b[a.dataType]),/(2..)/.test(a.ajax.status)?a.success.call(a.ajax,b):a.error&&a.error.call(null,a.ajax.statusText)}},b}}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Importers.Polling=function(a){a=a||{},this.interval=a.interval||1e3,this._def=null,b.Importers.Remote.apply(this,[a])},_.extend(b.Importers.Polling.prototype,b.Importers.Remote.prototype,{fetch:function(c){this._def===null&&(this._def=_.Deferred(),this.success_callback=_.bind(function(a){c.success(this.extract(a)),this._def.resolve(this)},this),this.error_callback=_.bind(function(a){c.error(a),this._def.reject(a)},this)),_.when(this._def.promise()).then(function(a){var b=_.bind(function(){this.fetch({success:this.success_callback,error:this.error_callback})},a);a._timeout=setTimeout(b,a.interval),a._def=_.Deferred()}),b.Xhr(_.extend(this.params,{success:this.success_callback,error:this.error_callback})),a.imp=this},stop:function(){this._def!==null&&this._def.reject(),typeof this._timeout!="undefined"&&clearTimeout(this._timeout)},start:function(){this._def!==null&&(this._def=_.Deferred(),this.fetch())}})}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Importers.GoogleSpreadsheet=function(a){a=a||{};if(a.url)a.url=a.url;else{if(_.isUndefined(a.key))throw new Error("Set options 'key' properties to point to your google document.");a.fast?(a.url="https://spreadsheets.google.com/tq?key="+a.key,typeof a.sheetName=="undefined"&&(a.sheetName="Sheet1"),a.url+="&sheet="+a.sheetName,this.callback="misodsgs"+(new Date).getTime(),a.url+="&tqx=version:0.6;responseHandler:"+this.callback,a.url+=";reqId:0;out:json&tq&_=1335871249558#",delete a.sheetName):a.url="https://spreadsheets.google.com/feeds/cells/"+a.key+"/"+a.worksheet+"/public/basic?alt=json-in-script&callback=",delete a.key}return this.params={type:"GET",url:a.url,dataType:"jsonp"},this},_.extend(b.Importers.GoogleSpreadsheet.prototype,b.Importers.Remote.prototype)}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Parsers=function(a){this.options=a||{}},_.extend(b.Parsers.prototype,{parse:function(){}})}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Parsers.Strict=function(a){this.options=a||{}},_.extend(b.Parsers.Strict.prototype,b.Parsers.prototype,{parse:function(a){var b={},c=[];return _.each(a.columns,function(a){if(c.indexOf(a.name)!==-1)throw new Error('You have more than one column named "'+a.name+'"');c.push(a.name),b[a.name]=a.data}),{columns:c,data:b}}})}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Parsers.Obj=b.Parsers,_.extend(b.Parsers.Obj.prototype,b.Parsers.prototype,{parse:function(a){var b=_.keys(a[0]),c={};return _.each(b,function(a){c[a]=[]}),_.each(b,function(b){_.times(a.length,function(d){c[b].push(a[d][b])})}),{columns:b,data:c}}})}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Parsers.GoogleSpreadsheet=function(a){this.fast=a.fast||!1},_.extend(b.Parsers.GoogleSpreadsheet.prototype,b.Parsers.prototype,{parse:function(a){var b=[],c=[],d={},e;if(typeof a.status!="undefined"&&a.status==="error")throw new Error("You can't use the fast importer for this url. Disable the fast flag");if(this.fast){b=_.pluck(a.table.cols,"label");if(_.unique(b).length<b.length){var f="";throw _.inject(b,function(a,b){return a[b]=a[b]+1||1,a[b]>1&&(f=b),a},{}),new Error('You have more than one column named "'+f+'"')}_.each(a.table.rows,function(a){a=a.c;for(e=0;e<a.length;e++)c[e]=c[e]||[],a[e].v===""?c[e].push(null):c[e].push(a[e].v)}),_.each(b,function(a,b){d[a]=c[b]})}else{var g=/([A-Z]+)(\d+)/,h={};_.each(a.feed.entry,function(a,d){var e=g.exec(a.title.$t),f=e[1],i=parseInt(e[2],10);if(i===1){if(b.indexOf(a.content.$t)!==-1)throw new Error('You have more than one column named "'+a.content.$t+'"');h[f]=c.length,b[h[f]]=a.content.$t,c[h[f]]=[]}else{var j=h[f];c[j][i-1]=a.content.$t}},this),_.each(c,function(a,e){a.length=_.max(_.pluck(c,"length")),a.splice(0,1);for(var f=0;f<a.length;f++)if(_.isUndefined(a[f])||a[f]==="")a[f]=null;d[b[e]]=a})}return{columns:b,data:d}}})}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Parsers.Delimited=function(a){a=a||{},this.delimiter=a.delimiter||",",this.skipRows=a.skipRows||0,this.emptyValue=a.emptyValue||null,this.__delimiterPatterns=new RegExp("(\\"+this.delimiter+"|\\r?\\n|\\r|^)"+'(?:"([^"]*(?:""[^"]*)*)"|'+'([^"\\'+this.delimiter+"\\r\\n]*))","gi")},typeof String.prototype.trim!="function"&&(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}),_.extend(b.Parsers.Delimited.prototype,b.Parsers.prototype,{parse:function(a){var b=[],c={},d={},e=function(a){d[a]||(d[a]=0);var b=a+d[a];return d[a]+=1,b},f=function(a,d,f,g,h){f=f||",";var i=null,j=0,k=!1,l=-1,m=0;try{d=d.trim();if(g>0){var n=0,o=0,p=d.length;while(n<g&&o<p)/\n|\r|\r\n/.test(d[o])&&n++,o++;d=d.slice(o,p)}while(i=a.exec(d)){var q=i[1];if(q.length&&q!==f){m++;if(l<j-1)throw m--,new Error("Not enough items in row");k=!0,l=0}else k||j++,l++;var r=null;i[2]?r=i[2].replace(new RegExp('""',"g"),'"'):r=i[3];if(k){r===""&&(r=h);if(typeof c[b[l]]=="undefined")throw new Error("Too many items in row");c[b[l]].push(r)}else{var s=function(a){var c=e(a);while(b.indexOf(c)!==-1)c=e(a);return c};if(_.isUndefined(r)||r==="")r="X";b.indexOf(r)!==-1&&(r=s(r)),b.push(r),c[r]=[]}}}catch(t){throw new Error("Error while parsing delimited data on row "+m+". Message: "+t.message)}return{columns:b,data:c}};return f(this.__delimiterPatterns,a,this.delimiter,this.skipRows,this.emptyValue)}})}(this,_);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment