Skip to content
Browse files

0.4.1 - Fixing require.js

  • Loading branch information...
1 parent 9da4124 commit 68c3546d283d128c92c742756cb6196409f00843 @iros iros committed Nov 19, 2012
View
16 README.md
@@ -11,25 +11,25 @@ All downloads are located in the [/dist](https://github.com/misoproject/dataset/
### Including Dependencies
-[miso.ds.dev.0.4.0.zip](https://github.com/downloads/misoproject/dataset/miso.ds.dev.0.4.0.zip) - Download Development With Dependencies - 0.3.0
+[miso.ds.dev.0.4.1.zip](https://github.com/downloads/misoproject/dataset/miso.ds.dev.0.4.1.zip) - Download Development With Dependencies - 0.3.0
-[miso.ds.deps.min.0.3.0.js](https://github.com/downloads/misoproject/dataset/miso.ds.deps.min.0.4.0.js) - Download Production With Dependencies - 0.4.0
+[miso.ds.deps.min.0.3.0.js](https://github.com/downloads/misoproject/dataset/miso.ds.deps.min.0.4.1.js) - Download Production With Dependencies - 0.4.1
-[miso.ds.deps.ie.0.4.0.js](https://github.com/downloads/misoproject/dataset/miso.ds.deps.ie.0.4.0.js) - Download Development With Dependencies for IE - 0.4.0
+[miso.ds.deps.ie.0.4.1.js](https://github.com/downloads/misoproject/dataset/miso.ds.deps.ie.0.4.1.js) - Download Development With Dependencies for IE - 0.4.1
-[miso.ds.deps.ie.min.0.4.0.js](https://github.com/downloads/misoproject/dataset/miso.ds.deps.ie.0.4.0.js) - Download Production With Dependencies for IE - 0.4.0
+[miso.ds.deps.ie.min.0.4.1.js](https://github.com/downloads/misoproject/dataset/miso.ds.deps.ie.0.4.1.js) - Download Production With Dependencies for IE - 0.4.1
### Without Dependencies
The following builds do not have any of the dependencies built in. It is your own responsibility to include them as appropriate script elements in your page.
-[miso.ds.0.4.0.js](https://github.com/downloads/misoproject/dataset/miso.ds.0.4.0.js) - Download Development No Dependencies - 0.4.0
+[miso.ds.0.4.1.js](https://github.com/downloads/misoproject/dataset/miso.ds.0.4.1.js) - Download Development No Dependencies - 0.4.1
-[miso.ds.min.0.4.0.js](https://github.com/misoproject/dataset/tree/master/dist/miso.ds.min.0.4.0.js) - Download Production No Dependencies - 0.4.0
+[miso.ds.min.0.4.1.js](https://github.com/misoproject/dataset/tree/master/dist/miso.ds.min.0.4.1.js) - Download Production No Dependencies - 0.4.1
-[miso.ds.0.4.0.m.js](https://github.com/misoproject/dataset/tree/master/dist/miso.ds.0.4.0.m.js) - Download AMD Compatibile Build No Dependencies- 0.4.0
+[miso.ds.0.4.1.m.js](https://github.com/misoproject/dataset/tree/master/dist/miso.ds.0.4.1.m.js) - Download AMD Compatibile Build No Dependencies- 0.4.1
-[miso.ds.min.0.4.0.m.js](https://github.com/misoproject/dataset/tree/master/dist/miso.ds.min.0.4.0.m.js) - Download AMD Compatibile Build Production No Dependencies- 0.4.0
+[miso.ds.min.0.4.1.m.js](https://github.com/misoproject/dataset/tree/master/dist/miso.ds.min.0.4.1.m.js) - Download AMD Compatibile Build Production No Dependencies- 0.4.1
### Dependencies
View
1 dist/LASTBUILD
@@ -0,0 +1 @@
+2012/11/19 03:27
View
2 dist/miso.ds.0.4.0.js → dist/miso.ds.0.4.1.js
@@ -1,5 +1,5 @@
/**
-* Miso.Dataset - v0.4.0 - 11/16/2012
+* Miso.Dataset - v0.4.1 - 11/19/2012
* http://github.com/misoproject/dataset
* Copyright (c) 2012 Alex Graul, Irene Ros;
* Dual Licensed: MIT, GPL
View
9 dist/miso.ds.0.4.0.m.js → dist/miso.ds.0.4.1.m.js
@@ -1,5 +1,5 @@
/**
-* Miso.Dataset - v0.4.0 - 11/16/2012
+* Miso.Dataset - v0.4.1 - 11/19/2012
* http://github.com/misoproject/dataset
* Copyright (c) 2012 Alex Graul, Irene Ros;
* Dual Licensed: MIT, GPL
@@ -3312,7 +3312,6 @@ Version 0.0.1.2
(function(global) {
var Miso = global.Miso || {};
- delete window.Miso;
// CommonJS module is defined
if (typeof exports !== 'undefined') {
@@ -3321,12 +3320,6 @@ Version 0.0.1.2
module.exports = Miso;
}
exports.miso = Miso;
-
- } else if (typeof define === 'function' && define.amd) {
- // Register as a named module with AMD.
- define('miso', [], function() {
- return Miso;
- });
}
}(this));
View
4 dist/miso.ds.deps.0.4.0.js → dist/miso.ds.deps.0.4.1.js
@@ -1,5 +1,5 @@
/**
-* Miso.Dataset - v0.4.0 - 11/16/2012
+* Miso.Dataset - v0.4.1 - 11/19/2012
* http://github.com/misoproject/dataset
* Copyright (c) 2012 Alex Graul, Irene Ros;
* Dual Licensed: MIT, GPL
@@ -6053,7 +6053,7 @@
}(this, _));
/**
-* Miso.Dataset - v0.4.0 - 11/16/2012
+* Miso.Dataset - v0.4.1 - 11/19/2012
* http://github.com/misoproject/dataset
* Copyright (c) 2012 Alex Graul, Irene Ros;
* Dual Licensed: MIT, GPL
View
4 dist/miso.ds.deps.ie.0.4.0.js → dist/miso.ds.deps.ie.0.4.1.js
@@ -1,5 +1,5 @@
/**
-* Miso.Dataset - v0.4.0 - 11/16/2012
+* Miso.Dataset - v0.4.1 - 11/19/2012
* http://github.com/misoproject/dataset
* Copyright (c) 2012 Alex Graul, Irene Ros;
* Dual Licensed: MIT, GPL
@@ -6541,7 +6541,7 @@ if (!JSON) {
}(this, _));
/**
-* Miso.Dataset - v0.4.0 - 11/16/2012
+* Miso.Dataset - v0.4.1 - 11/19/2012
* http://github.com/misoproject/dataset
* Copyright (c) 2012 Alex Graul, Irene Ros;
* Dual Licensed: MIT, GPL
View
2 dist/miso.ds.deps.ie.min.0.4.0.js → dist/miso.ds.deps.ie.min.0.4.1.js
@@ -1,5 +1,5 @@
/**
-* Miso.Dataset - v0.4.0 - 11/16/2012
+* Miso.Dataset - v0.4.1 - 11/19/2012
* http://github.com/misoproject/dataset
* Copyright (c) 2012 Alex Graul, Irene Ros;
* Dual Licensed: MIT, GPL
View
2 dist/miso.ds.deps.min.0.4.0.js → dist/miso.ds.deps.min.0.4.1.js
@@ -1,5 +1,5 @@
/**
-* Miso.Dataset - v0.4.0 - 11/16/2012
+* Miso.Dataset - v0.4.1 - 11/19/2012
* http://github.com/misoproject/dataset
* Copyright (c) 2012 Alex Graul, Irene Ros;
* Dual Licensed: MIT, GPL
View
BIN dist/miso.ds.dev.0.4.1.zip
Binary file not shown.
View
2 dist/miso.ds.min.0.4.0.js → dist/miso.ds.min.0.4.1.js
@@ -1,5 +1,5 @@
/**
-* Miso.Dataset - v0.4.0 - 11/16/2012
+* Miso.Dataset - v0.4.1 - 11/19/2012
* http://github.com/misoproject/dataset
* Copyright (c) 2012 Alex Graul, Irene Ros;
* Dual Licensed: MIT, GPL
View
4 dist/miso.ds.min.0.4.0.m.js → dist/miso.ds.min.0.4.1.m.js
@@ -1,9 +1,9 @@
/**
-* Miso.Dataset - v0.4.0 - 11/16/2012
+* Miso.Dataset - v0.4.1 - 11/19/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(e){e.Miso=e.Miso||{},e.Miso.Dataset=function(e){e=e||{},this.length=0,this._columns=[],this._columnPositionByName={},this._computedColumns=[],this._initialize(e)}})(this),function(e,_){var t=e.Miso||(e.Miso={}),n=e.Miso.Dataset;n.Column=function(e){return _.extend(this,e),this._id=e.id||_.uniqueId(),this.data=e.data||[],this},_.extend(n.Column.prototype,{toNumeric:function(e){return n.types[this.type].numeric(e)},numericAt:function(e){return this.toNumeric(this.data[e])},coerce:function(){this.data=_.map(this.data,function(e){return n.types[this.type].coerce(e,this)},this)},compute:function(e,t){if(this.func){var n=this.func(e);return typeof t!="undefined"?this.data[t]=n:this.data.push(n),n}},isComputed:function(){return!_.isUndefined(this.func)},_sum:function(){return _.sum(this.data)},_mean:function(){var e=0;for(var t=0;t<this.data.length;t++)e+=this.numericAt(t);return e/=this.data.length,n.types[this.type].coerce(e,this)},_median:function(){return n.types[this.type].coerce(_.median(this.data),this)},_max:function(){var e=-Infinity;for(var t=0;t<this.data.length;t++)this.data[t]!==null&&n.types[this.type].compare(this.data[t],e)>0&&(e=this.numericAt(t));return n.types[this.type].coerce(e,this)},_min:function(){var e=Infinity;for(var t=0;t<this.data.length;t++)this.data[t]!==null&&n.types[this.type].compare(this.data[t],e)<0&&(e=this.numericAt(t));return n.types[this.type].coerce(e,this)}}),n.DataView=function(e){if(typeof e!="undefined"){e=e||(e={});if(_.isUndefined(e.parent))throw new Error("A view must have a parent specified.");this.parent=e.parent,this._initialize(e)}},_.extend(n.DataView.prototype,{_initialize:function(e){this.parent.syncable===!0&&(_.extend(this,t.Events),this.syncable=!0),this.idAttribute=this.parent.idAttribute,this.filter={},this.filter.columns=_.bind(this._columnFilter(e.filter.columns||undefined),this),this.filter.rows=_.bind(this._rowFilter(e.filter.rows||undefined),this),this._columns=this._selectData(),n.Builder.cacheColumns(this),n.Builder.cacheRows(this),this.syncable&&this.parent.subscribe("change",this._sync,{context:this})},_sync:function(e){var t=e.deltas,r=null;_.each(t,function(t,i){var s=this._rowPositionById[t[this.idAttribute]];if(typeof s=="undefined"&&n.Event.isAdd(t))this.filter.rows&&this.filter.rows(t.changed)&&(this._add(t.changed),r="add");else{if(s==="undefined")return;_.each(t.changed,function(e,t){var n=this._columnPositionByName[t];if(_.isUndefined(n))return;this._columns[n].data[s]=e,r="update"},this)}var o=this.rowByPosition(s);if(n.Event.isRemove(t)||this.filter.row&&!this.filter.row(o)){var u={old:this.rowByPosition(s),changed:{}};u[this.idAttribute]=t[this.idAttribute],e.deltas.splice(i,1,u),this._remove(s),r="delete"}},this),this.syncable&&(this.publish(r,e),this.publish("change",e))},where:function(e,t){return t=t||{},t.filter=t.filter||{},_.isFunction(e)?t.filter.rows=e:t.filter=e,t.parent=this,new n.DataView(t)},_selectData:function(){var e=[];return _.each(this.parent._columns,function(t){this.filter.columns(t)&&e.push(new n.Column({name:t.name,data:[],type:t.type,_id:t._id}))},this),this.parent.each(function(t){if(!this.filter.rows(t))return;for(var n=0;n<e.length;n++)e[n].data.push(t[e[n].name])},this),e},_columnFilter:function(e){var t;return _.isUndefined(e)?t=function(){return!0}:(_.isString(e)&&(e=[e]),e.push(this.idAttribute),t=function(t){return _.indexOf(e,t.name)===-1?!1:!0}),t},_rowFilter:function(e){var t;return _.isNumber(e)&&(e=[e]),_.isUndefined(e)?t=function(){return!0}:_.isFunction(e)?t=e:t=_.bind(function(t){return _.indexOf(e,t[this.idAttribute])===-1?!1:!0},this),t},column:function(e){return this._column(e)},_column:function(e){if(_.isUndefined(this._columnPositionByName))return undefined;var t=this._columnPositionByName[e];return this._columns[t]},columns:function(e){return new n.DataView({filter:{columns:e},parent:this})},columnNames:function(){var e=_.pluck(this._columns,"name");return _.reject(e,function(e){return e===this.idAttribute||e==="_oids"},this)},hasColumn:function(e){return!_.isUndefined(this._columnPositionByName[e])},each:function(e,t){for(var n=0;n<this.length;n++)e.apply(t||this,[this.rowByPosition(n),n])},reverseEach:function(e,t){for(var n=this.length-1;n>=0;n--)e.apply(t||this,[this.rowByPosition(n),n])},eachColumn:function(e,t){var n=this.columnNames();for(var r=0;r<n.length;r++)e.apply(t||this,[n[r],this.column(n[r]),r])},rowByPosition:function(e){return this._row(e)},rowById:function(e){return this._row(this._rowPositionById[e])},_row:function(e){var t={};return _.each(this._columns,function(n){t[n.name]=n.data[e]}),t},_remove:function(e){var t=this._rowPositionById[e];return _.each(this._columns,function(e){e.data.splice(t,1)}),delete this._rowPositionById[e],this._rowIdByPosition.splice(t,1),this.length--,this},_add:function(e){_.each(e,function(t,r){var i=this.column(r);if(i.isComputed())throw"You're trying to update a computed column. Those get computed!";if(typeof i!="undefined"){var s=n.types[i.type];if(!i.force&&!s.test(e[i.name],i))throw"incorrect value '"+e[i.name]+"' of type "+n.typeOf(e[i.name],i)+" passed to column '"+i.name+"' with type "+i.type;_.isUndefined(i.before)||(e[i.name]=i.before(e[i.name])),e[i.name]=s.coerce(e[i.name],i)}},this),this._computedColumns&&_.each(this._computedColumns,function(t){var n=t.compute(e);e[t.name]=n});if(_.isUndefined(this.comparator)){_.each(this._columns,function(t){t.isComputed()||t.data.push(!_.isUndefined(e[t.name])&&!_.isNull(e[t.name])?e[t.name]:null)}),this.length++,this._rowIdByPosition=this._rowIdByPosition||(this._rowIdByPosition=[]),this._rowPositionById=this._rowPositionById||(this._rowPositionById={});if(typeof this._rowPositionById[e[this.idAttribute]]!="undefined")throw"The id "+e[this.idAttribute]+" is not unique. The "+this.idAttribute+" column must be unique";this._rowPositionById[e[this.idAttribute]]=this._rowIdByPosition.length,this._rowIdByPosition.push(e[this.idAttribute])}else{var t=function(e,t,n){Array.prototype.splice.apply(n,[e,0].concat(t))},r;this.length++;for(r=0;r<this.length;r++){var i=this.rowByPosition(r);if(_.isUndefined(i[this.idAttribute])||this.comparator(e,i)<0){_.each(this._columns,function(n){t(r,e[n.name]?e[n.name]:null,n.data)});break}}this._rowIdByPosition=[],this._rowPositionById={},this.each(function(e,t){this._rowIdByPosition.push(e[this.idAttribute]),this._rowPositionById[e[this.idAttribute]]=t},this)}return this},rows:function(e){return new n.DataView({filter:{rows:e},parent:this})},sort:function(e){var t={},n=[];_.isFunction(e)?t.comparator=e:t=e||{};if(t.comparator)this.comparator=t.comparator;else if(_.isUndefined(this.comparator))throw new Error("Cannot sort without this.comparator.");var r,i,s;for(r=0;r<this.length;r++)n[r]=this._row(r);n.sort(this.comparator),r=n.length;while(r--){s=n[r],this._rowIdByPosition[r]=s[this.idAttribute],this._rowPositionById[s[this.idAttribute]]=r,i=this._columns.length;while(i--){var o=this._columns[i];o.data[r]=s[o.name]}}return this.syncable&&!t.silent&&this.publish("sort"),this},toJSON:function(){var e=[];for(var t=0;t<this.length;t++)e.push(this.rowByPosition(t));return e}})}(this,_),function(e,_,moment){var t=e.Miso||(e.Miso={}),n=e.Miso.Dataset;n.prototype=new n.DataView,_.extend(n.prototype,{_initialize:function(e){e.sync===!0&&(_.extend(this,t.Events),this.syncable=!0),this.idAttribute=e.idAttribute||"_id",this.importer=e.importer||null,this.parser=e.parser||n.Parsers.Obj,_.isUndefined(e.parser)&&(e.strict?this.parser=n.Parsers.Strict:e.delimiter&&(this.parser=n.Parsers.Delimited)),this.importer===null&&(e.url?e.interval?(this.importer=n.Importers.Polling,this.interval=e.interval):this.importer=n.Importers.Remote:this.importer=n.Importers.Local),this.parser=new this.parser(e),this.parser instanceof n.Parsers.Delimited&&(e.dataType="text"),this.importer=new this.importer(e),e.comparator&&(this.comparator=e.comparator),e.ready&&(this.ready=e.ready),e.resetOnFetch&&(this.resetOnFetch=e.resetOnFetch),e.uniqueAgainst&&(this.uniqueAgainst=e.uniqueAgainst),_.isUndefined(e.data)&&_.isUndefined(e.url)&&this._addIdColumn(),e.deferred?this.deferred=e.deferred:this.deferred=new _.Deferred,e.columns&&this.addColumns(e.columns)},fetch:function(e){e=e||{};var t=this.deferred;if(_.isNull(this.importer))throw"No importer defined";return this.importer.fetch({success:_.bind(function(n){try{this._apply(n)}catch(r){if(!e.error)throw r;e.error.call(this,r)}this.comparator&&this.sort(),this.ready&&this.ready.call(this),e.success&&e.success.call(this),t.resolveWith(this,[this])},this),error:_.bind(function(n){e.error&&e.error.call(this,n),t.reject(n)},this)}),t.promise()},_applications:{againstColumn:function(e){var t=[],r=_.keys(e),i,s=this.uniqueAgainst,o=this.column(s),u=[],a=[],f=[];_.each(e[s],function(t,r){var i=o.data.indexOf(n.types[o.type].coerce(t)),s={};_.each(e,function(e,t){s[t]=e[r]}),i===-1?u.push(s):(a.push(s),s[this.idAttribute]=this.rowById(this.column(this.idAttribute).data[i])[this.idAttribute],this.update(s))},this),u.length>0&&this.add(u)},blind:function(e){var t,n,r=[],i,s=_.keys(e),o=_.max(_.map(s,function(t){return e[t].length},this));for(var u=0;u<o;u++){i={};for(var a=0;a<s.length;a++)i[s[a]]=e[s[a]][u];r.push(i)}this.add(r)}},_apply:function(e){var t=this.parser.parse(e);if(!this.fetched)this._addIdColumn(),this.addColumns(_.map(t.columns,function(e){return{name:e}})),n.Builder.detectColumnTypes(this,t.data),this._applications.blind.call(this,t.data),this.fetched=!0;else if(this.resetOnFetch)this.reset(),this._applications.blind.call(this,t.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,t.data)}else this._applications.blind.call(this,t.data);n.Builder.cacheRows(this)},addColumns:function(e){_.each(e,function(e){this.addColumn(e)},this)},addComputedColumn:function(e,t,r){if(!_.isUndefined(this.column(e)))throw"There is already a column by this name.";if(typeof n.types[t]=="undefined")throw"The type "+t+" doesn't exist";var i=new n.Column({name:e,type:t,func:_.bind(r,this)});return this._columns.push(i),this._computedColumns.push(i),this._columnPositionByName[i.name]=this._columns.length-1,this.length>0&&this.each(function(e,t){i.compute(e,t)},this),i},addColumn:function(e){return _.isUndefined(this.column(e.name))?(e=new n.Column(e),this._columns.push(e),this._columnPositionByName[e.name]=this._columns.length-1,e):!1},_addIdColumn:function(e){if(!_.isUndefined(this.column(this.idAttribute)))return;var t=[];e&&e>0&&_.times(e,function(){t.push(_.uniqueId())});var n=this.addColumn({name:this.idAttribute,data:t});this.idAttribute==="_id"&&(n.type="number");if(this._columnPositionByName[this.idAttribute]!==0){var r=this._columnPositionByName[this.idAttribute];this._columns.splice(r,1),this._columns.unshift(n),this._columnPositionByName[this.idAttribute]=0,_.each(this._columnPositionByName,function(e,t){t!==this.idAttribute&&this._columnPositionByName[t]<r&&this._columnPositionByName[t]++},this)}},add:function(e,t){t=t||{},_.isArray(e)||(e=[e]);var r=[];_.each(e,function(e){e[this.idAttribute]||(e[this.idAttribute]=_.uniqueId()),this._add(e,t),this.syncable&&!t.silent&&r.push({changed:e})},this);if(this.syncable&&!t.silent){var i=n.Events._buildEvent(r,this);this.publish("add",i),this.publish("change",i)}return this},remove:function(e,t){e=this._rowFilter(e);var r=[],i=[];this.each(function(t,n){e(t)&&(i.push(t[this.idAttribute]),r.push({old:t}))}),_.each(i,function(e){this._remove(e)},this);if(this.syncable&&(!t||!t.silent)){var s=n.Events._buildEvent(r,this);this.publish("remove",s),this.publish("change",s)}},_arrayUpdate:function(e){var t=[];return _.each(e,function(e){var r={old:{},changed:{}};r[this.idAttribute]=e[this.idAttribute];var i=this._rowPositionById[e[this.idAttribute]];_.each(e,function(e,t){var s=this._columns[this._columnPositionByName[t]],o=n.types[s.type];if(s.name===this.idAttribute&&s.data[i]!==e)throw"You can't update the id column";if(typeof s=="undefined")throw"column "+t+" not found!";if(!o.test(e,s))throw"Value is incorrect type";if(this._computedColumns[s.name])return;e=o.coerce(e,s),_.isUndefined(s.before)||(e=s.before(e)),s.data[i]!==e&&(r.old[t]=s.data[i],s.data[i]=e,r.changed[t]=e)},this),typeof this._computedColumns!="undefined"&&_.each(this._computedColumns,function(e){var t=_.extend({},this._row(i)),n=t[e.name],s=e.compute(t,i);n!==s&&(r.old[e.name]=n,e.data[i]=s,r.changed[e.name]=s)},this),_.keys(r.changed).length>0&&t.push(r)},this),t},_functionUpdate:function(e){var t=[];for(var n=0;n<this.length;n++){var r=e(this.rowByPosition(n));r!==!1&&t.push(r)}return this._arrayUpdate(t)},update:function(e,t){var r;if(_.isFunction(e))r=this._functionUpdate(e);else{var i=_.isArray(e)?e:[e];r=this._arrayUpdate(i)}if(this.syncable&&(!t||!t.silent)){var s=n.Events._buildEvent(r,this);this.publish("update",s),this.publish("change",s)}return this},reset:function(e){_.each(this._columns,function(e){e.data=[]}),this.length=0,this.syncable&&(!e||!e.silent)&&this.publish("reset")}})}(this,_,moment),function(e,_){var t=e.Miso.Dataset;t.typeOf=function(e,n){var r=_.keys(t.types),i;return r.push(r.splice(_.indexOf(r,"string"),1)[0]),r.push(r.splice(_.indexOf(r,"mixed"),1)[0]),i=_.find(r,function(r){return t.types[r].test(e,n)}),i=_.isUndefined(i)?"string":i,i},t.types={mixed:{name:"mixed",coerce:function(e){return _.isNull(e)||typeof e=="undefined"||_.isNaN(e)?null:e},test:function(){return!0},compare:function(e,t){if(_.isEqual(e,t))return 0;if(e<t)return-1;if(e>t)return 1},numeric:function(e){return e===null||_.isNaN(+e)?null:+e}},string:{name:"string",coerce:function(e){return _.isNaN(e)||e===null||typeof e=="undefined"?null:e.toString()},test:function(e){return e===null||typeof e=="undefined"||typeof e=="string"},compare:function(e,t){return e==null&&t!=null?-1:e!=null&&t==null?1:e<t?-1:e>t?1:0},numeric:function(e){return _.isNaN(+e)||e===null?null:_.isNumber(+e)?+e:null}},"boolean":{name:"boolean",regexp:/^(true|false)$/,coerce:function(e){return _.isNaN(e)||e===null||typeof e=="undefined"?null:e==="false"?!1:Boolean(e)},test:function(e){return e===null||typeof e=="undefined"||typeof e=="boolean"||this.regexp.test(e)?!0:!1},compare:function(e,t){return e==null&&t!=null?-1:e!=null&&t==null?1:e==null&&t==null?0:e===t?0:e<t?-1:1},numeric:function(e){return e===null||_.isNaN(e)?null:e?1:0}},number:{name:"number",regexp:/^\s*[\-\.]?[0-9]+([\.][0-9]+)?\s*$/,coerce:function(e){var t=+e;return _.isNull(e)||typeof e=="undefined"||_.isNaN(t)?null:t},test:function(e){return e===null||typeof e=="undefined"||typeof e=="number"||this.regexp.test(e)?!0:!1},compare:function(e,t){return e==null&&t!=null?-1:e!=null&&t==null?1:e==null&&t==null?0:e===t?0:e<t?-1:1},numeric:function(e){return _.isNaN(e)||e===null?null:e}},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(e){if(this._regexpTable[e])return new RegExp(this._regexpTable[e],"g");var t=e;return _.each(this._formatLookup,function(e){t=t.replace(e[0],e[1])},this),t=t.split("/").join("\\/"),this._regexpTable[e]=t,new RegExp(this._regexpTable[e],"g")},coerce:function(e,t){t=t||{};if(_.isNull(e)||typeof e=="undefined"||_.isNaN(e))return null;if(_.isString(e)){var n=t.format||this.format;return moment(e,n)}return _.isNumber(e)?moment(e):e},test:function(e,t){t=t||{};if(e===null||typeof e=="undefined")return!0;if(_.isString(e)){var n=t.format||this.format,r=this._regexp(n);return r.test(e)}return!0},compare:function(e,t){return e<t?-1:e>t?1:0},numeric:function(e){return _.isNaN(e)||e===null?null:e.valueOf()}}}}(this,_),function(e,_){var t=e.Miso.Dataset;t.Event=function(e,t){_.isArray(e)||(e=[e]),this.deltas=e,this.dataset=t||null},_.extend(t.Event.prototype,{affectedColumns:function(){var e=[];return _.each(this.deltas,function(t){t.old=t.old||[],t.changed=t.changed||[],e=_.chain(e).union(_.keys(t.old),_.keys(t.changed)).reject(function(e){return e===this.dataset.idAttribute},this).value()},this),e}}),_.extend(t.Event,{isRemove:function(e){return _.isUndefined(e.changed)||_.keys(e.changed).length===0?!0:!1},isAdd:function(e){return _.isUndefined(e.old)||_.keys(e.old).length===0?!0:!1},isUpdate:function(e){return!this.isRemove(e)&&!this.isAdd(e)?!0:!1}}),t.Events={},t.Events._buildEvent=function(e,n){return new t.Event(e,n)}}(this,_),function(e,_){var t=e.Miso.Dataset;t.Builder={detectColumnType:function(e,n){var r=_.inject(n.slice(0,5),function(e,n){var r=t.typeOf(n);return n!==""&&e.indexOf(r)===-1&&!_.isNull(n)&&e.push(r),e},[]);return r.length===1?e.type=r[0]:e.type="mixed",e},detectColumnTypes:function(e,n){_.each(n,function(n,r){var i=e.column(r);if(i.type){i.force=!0;return}t.Builder.detectColumnType(i,n)},this)},cacheRows:function(e){t.Builder.clearRowCache(e),_.each(e._columns[e._columnPositionByName[e.idAttribute]].data,function(t,n){e._rowPositionById[t]=n,e._rowIdByPosition.push(t)},e);var n=_.uniq(_.map(e._columns,function(e){return e.data.length}));if(n.length>1)throw new Error("Row lengths need to be the same. Empty values should be set to null."+_.map(e._columns,function(e){return e.data+"|||"}));e.length=n[0]},clearRowCache:function(e){e._rowPositionById={},e._rowIdByPosition=[]},cacheColumns:function(e){e._columnPositionByName={},_.each(e._columns,function(t,n){e._columnPositionByName[t.name]=n})}},Array.prototype.indexOf||(Array.prototype.indexOf=function(e,t){for(var n=t||0,r=this.length;n<r;n++)if(this[n]===e)return n;return-1})}(this,_),function(e,_){var t=e.Miso||(e.Miso={}),n=e.Miso.Dataset;n.Product=function(e){e=e||{},this.func=e.func;if(e.columns){var t=e.columns;_.isArray(e.columns)&&(t=e.columns[0]),this.valuetype=t.type,this.numeric=function(){return t.toNumeric(this.value)}}return this.func({silent:!0}),this},_.extend(n.Product.prototype,t.Events,{val:function(){return this.value},type:function(){return this.valuetype},_sync:function(e){this.func()},_buildDelta:function(e,t){return{old:e,changed:t}}}),n.Product.define=function(e){return function(t,r){r=r||{};var i=this._findColumns(t),s=this;r.type=r.type||i[0].type,r.typeOptions=r.typeOptions||i[0].typeOptions;var o=function(){var t=e.call(s,i,r);return n.types[r.type].coerce(t,r.typeOptions)};if(this.syncable){var u=new n.Product({columns:i,func:function(e){e=e||{};var t=this._buildDelta(this.value,o.call(s));this.value=t.changed;if(s.syncable){var r=n.Events._buildEvent(t,this);!_.isUndefined(t.old)&&!e.silent&&t.old!==t.changed&&this.publish("change",r)}}});return this.subscribe("change",u._sync,{context:u}),u}return o.call(s)}},_.extend(n.DataView.prototype,{_findColumns:function(e){var t=[];return _.isUndefined(e)&&(e=this.columnNames()),e=_.isArray(e)?e:[e],_.each(e,function(e){e=this._columns[this._columnPositionByName[e]],t.push(e)},this),t},sum:n.Product.define(function(e,t){return _.each(e,function(e){if(e.type===n.types.time.name)throw new Error("Can't sum up time")}),_.sum(_.map(e,function(e){return e._sum()}))}),max:n.Product.define(function(e,t){return _.max(_.map(e,function(e){return e._max()}))}),min:n.Product.define(function(e,t){return _.min(_.map(e,function(e){return e._min()}))}),mean:n.Product.define(function(e,t){var r=[];_.each(e,function(e){r.push(e.data)}),r=_.flatten(r);var i=e[0].type;return r=_.map(r,function(e){return n.types[i].numeric(e)}),_.mean(r)})})}(this,_),function(e,_){var t=e.Miso.Dataset;t.Importers=function(e,t){},t.Importers.prototype.extract=function(e){return e=_.clone(e),e}}(this,_),function(e,_){var t=e.Miso.Dataset;t.Importers.Local=function(e){e=e||{},this.data=e.data||null,this.extract=e.extract||this.extract},_.extend(t.Importers.Local.prototype,t.Importers.prototype,{fetch:function(e){var t=e.data?e.data:this.data;e.success(this.extract(t))}})}(this,_),function(e,_){var t=e.Miso.Dataset;t.Importers.Remote=function(e){e=e||{},this._url=e.url,this.extract=e.extract||this.extract,this.params={type:"GET",url:_.isFunction(this._url)?_.bind(this._url,this):this._url,dataType:e.dataType?e.dataType:e.jsonp?"jsonp":"json",callback:e.callback}},_.extend(t.Importers.Remote.prototype,t.Importers.prototype,{fetch:function(e){var n=_.bind(function(t){e.success(this.extract(t))},this);this.callback&&(window[this.callback]=n),t.Xhr(_.extend(this.params,{success:this.callback?this.callback:n,error:e.error}))}});var n={url:"",data:"",dataType:"",success:function(){},type:"GET",async:!0,xhr:function(){return e.ActiveXObject?new e.ActiveXObject("Microsoft.XMLHTTP"):new e.XMLHttpRequest}},r=/\?/;t.Xhr=function(e){e.dataType=e.dataType&&e.dataType.toLowerCase()||null;var i=_.isFunction(e.url)?e.url():e.url;if(!(!e.dataType||e.dataType!=="jsonp"&&e.dataType!=="script")){t.Xhr.getJSONP(i,e.success,e.dataType==="script",e.error,e.callback);return}var s=_.extend({},n,e,{url:i});s.ajax=s.xhr();if(s.ajax)return s.type==="GET"&&s.data&&(s.url+=(r.test(s.url)?"&":"?")+s.data,s.data=null),s.ajax.open(s.type,s.url,s.async),s.ajax.send(s.data||null),t.Xhr.httpData(s)},t.Xhr.getJSONP=function(e,t,n,r,i){if(n){var s=document.querySelectorAll('script[src="'+e+'"]');if(s.length){t&&t(!0);return}}var o=document.head||document.getElementsByTagName("head")[0]||document.documentElement,u=document.createElement("script"),a=e.split("?")[1],f=!1,l=[],c;a&&!n&&(l=a.split("&")),l.length&&(c=l[l.length-1].split("="));if(!i){var h=_.uniqueId("callback");i=l.length?c[1]?c[1]:h:h}!a&&!n&&(e+="?");if(!a||!/callback/.test(a))a&&(e+="&"),e+="callback="+i;i&&!n&&(!window[i]||(i=i+ +(new Date)+_.uniqueId()),window[i]=function(e){t&&t(e),f=!0},c&&(e=e.replace(c.join("="),c[0]+"="+i))),u.onload=u.onreadystatechange=function(){if(!u.readyState||/loaded|complete/.test(u.readyState)){n&&t&&t();if(f){try{delete window[i]}catch(e){window[i]=void 0}o.removeChild(u)}}},u.onerror=function(e){r&&r.call(null,e)},u.src=e,o.insertBefore(u,o.firstChild);return},t.Xhr.httpData=function(e){var t,n=null,r;return r=function(){if(e.ajax.readyState===4){try{n=JSON.parse(e.ajax.responseText)}catch(r){}t={xml:e.ajax.responseXML,text:e.ajax.responseText,json:n},e.dataType&&(t=t[e.dataType]),/(2..)/.test(e.ajax.status)?e.success.call(e.ajax,t):e.error&&e.error.call(null,e.ajax.statusText)}},e.ajax.readyState===4?r():e.ajax.onreadystatechange=r,t}}(this,_),function(e,_){var t=e.Miso.Dataset;t.Importers.Polling=function(e){e=e||{},this.interval=e.interval||1e3,this._def=null,t.Importers.Remote.apply(this,[e])},_.extend(t.Importers.Polling.prototype,t.Importers.Remote.prototype,{fetch:function(n){this._def===null&&(this._def=_.Deferred(),this.success_callback=_.bind(function(e){n.success(this.extract(e)),this._def.resolve(this)},this),this.error_callback=_.bind(function(e){n.error(e),this._def.reject(e)},this)),_.when(this._def.promise()).then(function(e){var t=_.bind(function(){this.fetch({success:this.success_callback,error:this.error_callback})},e);e._timeout=setTimeout(t,e.interval),e._def=_.Deferred()}),t.Xhr(_.extend(this.params,{success:this.success_callback,error:this.error_callback})),e.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(e,_){var t=e.Miso.Dataset;t.Importers.GoogleSpreadsheet=function(e){e=e||{};if(e.url)e.url=e.url;else{if(_.isUndefined(e.key))throw new Error("Set options 'key' properties to point to your google document.");e.fast?(e.url="https://spreadsheets.google.com/tq?key="+e.key,typeof e.sheetName=="undefined"&&(e.sheetName="Sheet1"),e.url+="&sheet="+e.sheetName,this.callback="misodsgs"+(new Date).getTime(),e.url+="&tqx=version:0.6;responseHandler:"+this.callback,e.url+=";reqId:0;out:json&tq&_=1335871249558#",delete e.sheetName):e.url="https://spreadsheets.google.com/feeds/cells/"+e.key+"/"+e.worksheet+"/public/basic?alt=json-in-script&callback=",delete e.key}return this.params={type:"GET",url:e.url,dataType:"jsonp"},this},_.extend(t.Importers.GoogleSpreadsheet.prototype,t.Importers.Remote.prototype)}(this,_),function(e,_){var t=e.Miso.Dataset;t.Parsers=function(e){this.options=e||{}},_.extend(t.Parsers.prototype,{parse:function(){}})}(this,_),function(e,_){var t=e.Miso.Dataset;t.Parsers.Strict=function(e){this.options=e||{}},_.extend(t.Parsers.Strict.prototype,t.Parsers.prototype,{parse:function(e){var t={},n=[];return _.each(e.columns,function(e){if(n.indexOf(e.name)!==-1)throw new Error('You have more than one column named "'+e.name+'"');n.push(e.name),t[e.name]=e.data}),{columns:n,data:t}}})}(this,_),function(e,_){var t=e.Miso.Dataset;t.Parsers.Obj=t.Parsers,_.extend(t.Parsers.Obj.prototype,t.Parsers.prototype,{parse:function(e){var t=_.keys(e[0]),n={};return _.each(t,function(e){n[e]=[]}),_.each(t,function(t){_.times(e.length,function(r){n[t].push(e[r][t])})}),{columns:t,data:n}}})}(this,_),function(e,_){var t=e.Miso.Dataset;t.Parsers.GoogleSpreadsheet=function(e){this.fast=e.fast||!1},_.extend(t.Parsers.GoogleSpreadsheet.prototype,t.Parsers.prototype,{parse:function(e){var t=[],n=[],r={},i;if(typeof e.status!="undefined"&&e.status==="error")throw new Error("You can't use the fast importer for this url. Disable the fast flag");if(this.fast){t=_.pluck(e.table.cols,"label");if(_.unique(t).length<t.length){var s="";throw _.inject(t,function(e,t){return e[t]=e[t]+1||1,e[t]>1&&(s=t),e},{}),new Error('You have more than one column named "'+s+'"')}_.each(e.table.rows,function(e){e=e.c;for(i=0;i<e.length;i++)n[i]=n[i]||[],e[i].v===""?n[i].push(null):n[i].push(e[i].v)}),_.each(t,function(e,t){r[e]=n[t]})}else{var o=/([A-Z]+)(\d+)/,u={};_.each(e.feed.entry,function(e){var r=o.exec(e.title.$t),i=r[1],s=parseInt(r[2],10);if(s===1){if(t.indexOf(e.content.$t)!==-1)throw new Error('You have more than one column named "'+e.content.$t+'"');u[i]=n.length,t[u[i]]=e.content.$t,n[u[i]]=[]}else{var a=u[i];n[a][s-1]=e.content.$t}},this),_.each(n,function(e,i){e.length=_.max(_.pluck(n,"length")),e.splice(0,1);for(var s=0;s<e.length;s++)if(_.isUndefined(e[s])||e[s]==="")e[s]=null;r[t[i]]=e})}return{columns:t,data:r}}})}(this,_),function(e,_){var t=e.Miso.Dataset;t.Parsers.Delimited=function(e){e=e||{},this.delimiter=e.delimiter||",",this.skipRows=e.skipRows||0,this.emptyValue=e.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(t.Parsers.Delimited.prototype,t.Parsers.prototype,{parse:function(e){var t=[],n={},r={},i=function(e){r[e]||(r[e]=0);var t=e+r[e];return r[e]+=1,t},s=function(e,r,s,o,u){s=s||",";var a=null,f=0,l=!1,c=-1,h=0;try{r=r.replace(/\s+$/,"").replace(/^[\r|\n|\s]+[\r|\n]/,"\n");if(o>0){var p=0,d=0,v=r.length;while(p<o&&d<v)/\n|\r|\r\n/.test(r.charAt(d))&&p++,d++;r=r.slice(d,v)}function m(e){var r=e[1];if(r.length&&r!==s){h++;if(c<f-1)throw h--,new Error("Not enough items in row");l=!0,c=0}else l||f++,c++;var o=null;e[2]?o=e[2].replace(new RegExp('""',"g"),'"'):o=e[3];if(l){o===""&&(o=u);if(typeof n[t[c]]=="undefined")throw new Error("Too many items in row");n[t[c]].push(o)}else{var a=function(e){var n=i(e);while(t.indexOf(n)!==-1)n=i(e);return n};if(_.isUndefined(o)||o==="")o="X";t.indexOf(o)!==-1&&(o=a(o)),t.push(o),n[o]=[]}}(new RegExp("^"+s)).test(r)&&m(["","",undefined,""]);while(a=e.exec(r))m(a)}catch(g){throw new Error("Error while parsing delimited data on row "+h+". Message: "+g.message)}return{columns:t,data:n}};return s(this.__delimiterPatterns,e,this.delimiter,this.skipRows,this.emptyValue)}})}(this,_),function(e,_){var t=e.Miso||(e.Miso={}),n=t.Dataset;n.Derived=function(e){e=e||{},n.call(this),this.parent=e.parent,this.idAttribute="_id",this.method=e.method,this._addIdColumn(),this.addColumn({name:"_oids",type:"mixed"}),this.parent.syncable&&(_.extend(this,t.Events),this.syncable=!0,this.parent.subscribe("change",this._sync,{context:this}))},n.Derived.prototype=new n,_.extend(n.Derived.prototype,{_sync:function(){this.func.call(this.args),this.publish("change")}}),_.extend(n.DataView.prototype,{movingAverage:function(e,t,r){r=r||{};var i=new n.Derived({parent:this,method:r.method||_.mean,size:t,args:arguments});this.eachColumn(function(e){if(e===this.idAttribute)throw"You can't compute a moving average on the id column";i.addColumn({name:e,type:this.column(e).type,data:[]})},this),n.Builder.cacheColumns(i);var s=function(){typeof e=="string"&&(e=[e]),this.column(this.idAttribute).data=this.parent.column(this.parent.idAttribute).data.slice(t-1,this.parent.length),this.eachColumn(function(n,r){e.indexOf(n)===-1&&n!=="_oids"?r.data=this.parent.column(n).data.slice(t-1,this.parent.length):r.data=_.movingAvg(this.parent.column(n).data,t,this.method)},this),this.length=this.parent.length-t+1;var r=this.column("_oids");r.data=[];for(var i=0;i<this.length;i++)r.data.push(this.parent.column(this.parent.idAttribute).data.slice(i,i+t));return n.Builder.cacheRows(this),this};return i.func=_.bind(s,i),i.func.call(i.args)},countBy:function(e,t){function f(e,t,r){var i;for(i=0;i<e.length;i++)if(n.types[r].compare(e[i],t)===0)return i;return-1}t=t||{};var r=new n.Derived({parent:this,method:_.sum,args:arguments}),i=this.column(e);r.addColumn({name:e,type:i.type}),r.addColumn({name:"count",type:"number"}),r.addColumn({name:"_oids",type:"mixed"}),n.Builder.cacheColumns(r);var s=r.column(e).data,o=r.column("count").data,u=r.column("_oids").data,a=r.column(r.idAttribute).data;return this.each(function(t){var n=f(s,t[e],i.type);n===-1?(s.push(t[e]),a.push(_.uniqueId()),o.push(1),u.push([t[this.parent.idAttribute]])):(o[n]+=1,u[n].push(t[this.parent.idAttribute]))},r),n.Builder.cacheRows(r),r},groupBy:function(e,t,r){r=r||{};var i=new n.Derived({parent:this,method:r.method||_.sum,args:arguments});r&&r.preprocess&&(i.preprocess=r.preprocess);var s=_.union([e],t);_.each(s,function(e){this.addColumn({name:e,type:this.parent.column(e).type})},i),n.Builder.cacheColumns(i);var o=function(){var r=this;n.Builder.clearRowCache(this);var i={},s=0,o=this.parent.column(e);for(var u=0;u<this.parent.length;u++){var a=null;this.preprocess?a=this.preprocess(o.data[u]):a=o.data[u],_.isUndefined(i[a])&&(i[a]=s,_.each(t,function(e){var t=this.column(e),n=this.column(this.idAttribute);t.data[s]=[],n.data[s]=_.uniqueId()},this),this.column(e).data[s]=a,s++),_.each(t,function(e){var t=this.column(e),n=i[a];t.data[n].push(this.parent.rowByPosition(u))},this)}var f=this._columns[this._columnPositionByName._oids];return f.data=[],_.each(t,function(e){var t=this.column(e);_.each(t.data,function(n,i){_.isArray(n)&&(f.data[i]=f.data[i]||[],f.data[i].push(_.map(n,function(e){return e[r.parent.idAttribute]})),f.data[i]=_.flatten(f.data[i]),t.data[i]=this.method(_.map(n,function(t){return t[e]})),this.length++)},this)},this),n.Builder.cacheRows(this),this};return i.func=_.bind(o,i),i.func.call(i.args)}})}(this,_),function(e){var t=e.Miso||{};delete window.Miso,typeof exports!="undefined"?(typeof module!="undefined"&&module.exports&&(module.exports=t),exports.miso=t):typeof define=="function"&&define.amd&&define("miso",[],function(){return t})}(this);
+(function(e){e.Miso=e.Miso||{},e.Miso.Dataset=function(e){e=e||{},this.length=0,this._columns=[],this._columnPositionByName={},this._computedColumns=[],this._initialize(e)}})(this),function(e,_){var t=e.Miso||(e.Miso={}),n=e.Miso.Dataset;n.Column=function(e){return _.extend(this,e),this._id=e.id||_.uniqueId(),this.data=e.data||[],this},_.extend(n.Column.prototype,{toNumeric:function(e){return n.types[this.type].numeric(e)},numericAt:function(e){return this.toNumeric(this.data[e])},coerce:function(){this.data=_.map(this.data,function(e){return n.types[this.type].coerce(e,this)},this)},compute:function(e,t){if(this.func){var n=this.func(e);return typeof t!="undefined"?this.data[t]=n:this.data.push(n),n}},isComputed:function(){return!_.isUndefined(this.func)},_sum:function(){return _.sum(this.data)},_mean:function(){var e=0;for(var t=0;t<this.data.length;t++)e+=this.numericAt(t);return e/=this.data.length,n.types[this.type].coerce(e,this)},_median:function(){return n.types[this.type].coerce(_.median(this.data),this)},_max:function(){var e=-Infinity;for(var t=0;t<this.data.length;t++)this.data[t]!==null&&n.types[this.type].compare(this.data[t],e)>0&&(e=this.numericAt(t));return n.types[this.type].coerce(e,this)},_min:function(){var e=Infinity;for(var t=0;t<this.data.length;t++)this.data[t]!==null&&n.types[this.type].compare(this.data[t],e)<0&&(e=this.numericAt(t));return n.types[this.type].coerce(e,this)}}),n.DataView=function(e){if(typeof e!="undefined"){e=e||(e={});if(_.isUndefined(e.parent))throw new Error("A view must have a parent specified.");this.parent=e.parent,this._initialize(e)}},_.extend(n.DataView.prototype,{_initialize:function(e){this.parent.syncable===!0&&(_.extend(this,t.Events),this.syncable=!0),this.idAttribute=this.parent.idAttribute,this.filter={},this.filter.columns=_.bind(this._columnFilter(e.filter.columns||undefined),this),this.filter.rows=_.bind(this._rowFilter(e.filter.rows||undefined),this),this._columns=this._selectData(),n.Builder.cacheColumns(this),n.Builder.cacheRows(this),this.syncable&&this.parent.subscribe("change",this._sync,{context:this})},_sync:function(e){var t=e.deltas,r=null;_.each(t,function(t,i){var s=this._rowPositionById[t[this.idAttribute]];if(typeof s=="undefined"&&n.Event.isAdd(t))this.filter.rows&&this.filter.rows(t.changed)&&(this._add(t.changed),r="add");else{if(s==="undefined")return;_.each(t.changed,function(e,t){var n=this._columnPositionByName[t];if(_.isUndefined(n))return;this._columns[n].data[s]=e,r="update"},this)}var o=this.rowByPosition(s);if(n.Event.isRemove(t)||this.filter.row&&!this.filter.row(o)){var u={old:this.rowByPosition(s),changed:{}};u[this.idAttribute]=t[this.idAttribute],e.deltas.splice(i,1,u),this._remove(s),r="delete"}},this),this.syncable&&(this.publish(r,e),this.publish("change",e))},where:function(e,t){return t=t||{},t.filter=t.filter||{},_.isFunction(e)?t.filter.rows=e:t.filter=e,t.parent=this,new n.DataView(t)},_selectData:function(){var e=[];return _.each(this.parent._columns,function(t){this.filter.columns(t)&&e.push(new n.Column({name:t.name,data:[],type:t.type,_id:t._id}))},this),this.parent.each(function(t){if(!this.filter.rows(t))return;for(var n=0;n<e.length;n++)e[n].data.push(t[e[n].name])},this),e},_columnFilter:function(e){var t;return _.isUndefined(e)?t=function(){return!0}:(_.isString(e)&&(e=[e]),e.push(this.idAttribute),t=function(t){return _.indexOf(e,t.name)===-1?!1:!0}),t},_rowFilter:function(e){var t;return _.isNumber(e)&&(e=[e]),_.isUndefined(e)?t=function(){return!0}:_.isFunction(e)?t=e:t=_.bind(function(t){return _.indexOf(e,t[this.idAttribute])===-1?!1:!0},this),t},column:function(e){return this._column(e)},_column:function(e){if(_.isUndefined(this._columnPositionByName))return undefined;var t=this._columnPositionByName[e];return this._columns[t]},columns:function(e){return new n.DataView({filter:{columns:e},parent:this})},columnNames:function(){var e=_.pluck(this._columns,"name");return _.reject(e,function(e){return e===this.idAttribute||e==="_oids"},this)},hasColumn:function(e){return!_.isUndefined(this._columnPositionByName[e])},each:function(e,t){for(var n=0;n<this.length;n++)e.apply(t||this,[this.rowByPosition(n),n])},reverseEach:function(e,t){for(var n=this.length-1;n>=0;n--)e.apply(t||this,[this.rowByPosition(n),n])},eachColumn:function(e,t){var n=this.columnNames();for(var r=0;r<n.length;r++)e.apply(t||this,[n[r],this.column(n[r]),r])},rowByPosition:function(e){return this._row(e)},rowById:function(e){return this._row(this._rowPositionById[e])},_row:function(e){var t={};return _.each(this._columns,function(n){t[n.name]=n.data[e]}),t},_remove:function(e){var t=this._rowPositionById[e];return _.each(this._columns,function(e){e.data.splice(t,1)}),delete this._rowPositionById[e],this._rowIdByPosition.splice(t,1),this.length--,this},_add:function(e){_.each(e,function(t,r){var i=this.column(r);if(i.isComputed())throw"You're trying to update a computed column. Those get computed!";if(typeof i!="undefined"){var s=n.types[i.type];if(!i.force&&!s.test(e[i.name],i))throw"incorrect value '"+e[i.name]+"' of type "+n.typeOf(e[i.name],i)+" passed to column '"+i.name+"' with type "+i.type;_.isUndefined(i.before)||(e[i.name]=i.before(e[i.name])),e[i.name]=s.coerce(e[i.name],i)}},this),this._computedColumns&&_.each(this._computedColumns,function(t){var n=t.compute(e);e[t.name]=n});if(_.isUndefined(this.comparator)){_.each(this._columns,function(t){t.isComputed()||t.data.push(!_.isUndefined(e[t.name])&&!_.isNull(e[t.name])?e[t.name]:null)}),this.length++,this._rowIdByPosition=this._rowIdByPosition||(this._rowIdByPosition=[]),this._rowPositionById=this._rowPositionById||(this._rowPositionById={});if(typeof this._rowPositionById[e[this.idAttribute]]!="undefined")throw"The id "+e[this.idAttribute]+" is not unique. The "+this.idAttribute+" column must be unique";this._rowPositionById[e[this.idAttribute]]=this._rowIdByPosition.length,this._rowIdByPosition.push(e[this.idAttribute])}else{var t=function(e,t,n){Array.prototype.splice.apply(n,[e,0].concat(t))},r;this.length++;for(r=0;r<this.length;r++){var i=this.rowByPosition(r);if(_.isUndefined(i[this.idAttribute])||this.comparator(e,i)<0){_.each(this._columns,function(n){t(r,e[n.name]?e[n.name]:null,n.data)});break}}this._rowIdByPosition=[],this._rowPositionById={},this.each(function(e,t){this._rowIdByPosition.push(e[this.idAttribute]),this._rowPositionById[e[this.idAttribute]]=t},this)}return this},rows:function(e){return new n.DataView({filter:{rows:e},parent:this})},sort:function(e){var t={},n=[];_.isFunction(e)?t.comparator=e:t=e||{};if(t.comparator)this.comparator=t.comparator;else if(_.isUndefined(this.comparator))throw new Error("Cannot sort without this.comparator.");var r,i,s;for(r=0;r<this.length;r++)n[r]=this._row(r);n.sort(this.comparator),r=n.length;while(r--){s=n[r],this._rowIdByPosition[r]=s[this.idAttribute],this._rowPositionById[s[this.idAttribute]]=r,i=this._columns.length;while(i--){var o=this._columns[i];o.data[r]=s[o.name]}}return this.syncable&&!t.silent&&this.publish("sort"),this},toJSON:function(){var e=[];for(var t=0;t<this.length;t++)e.push(this.rowByPosition(t));return e}})}(this,_),function(e,_,moment){var t=e.Miso||(e.Miso={}),n=e.Miso.Dataset;n.prototype=new n.DataView,_.extend(n.prototype,{_initialize:function(e){e.sync===!0&&(_.extend(this,t.Events),this.syncable=!0),this.idAttribute=e.idAttribute||"_id",this.importer=e.importer||null,this.parser=e.parser||n.Parsers.Obj,_.isUndefined(e.parser)&&(e.strict?this.parser=n.Parsers.Strict:e.delimiter&&(this.parser=n.Parsers.Delimited)),this.importer===null&&(e.url?e.interval?(this.importer=n.Importers.Polling,this.interval=e.interval):this.importer=n.Importers.Remote:this.importer=n.Importers.Local),this.parser=new this.parser(e),this.parser instanceof n.Parsers.Delimited&&(e.dataType="text"),this.importer=new this.importer(e),e.comparator&&(this.comparator=e.comparator),e.ready&&(this.ready=e.ready),e.resetOnFetch&&(this.resetOnFetch=e.resetOnFetch),e.uniqueAgainst&&(this.uniqueAgainst=e.uniqueAgainst),_.isUndefined(e.data)&&_.isUndefined(e.url)&&this._addIdColumn(),e.deferred?this.deferred=e.deferred:this.deferred=new _.Deferred,e.columns&&this.addColumns(e.columns)},fetch:function(e){e=e||{};var t=this.deferred;if(_.isNull(this.importer))throw"No importer defined";return this.importer.fetch({success:_.bind(function(n){try{this._apply(n)}catch(r){if(!e.error)throw r;e.error.call(this,r)}this.comparator&&this.sort(),this.ready&&this.ready.call(this),e.success&&e.success.call(this),t.resolveWith(this,[this])},this),error:_.bind(function(n){e.error&&e.error.call(this,n),t.reject(n)},this)}),t.promise()},_applications:{againstColumn:function(e){var t=[],r=_.keys(e),i,s=this.uniqueAgainst,o=this.column(s),u=[],a=[],f=[];_.each(e[s],function(t,r){var i=o.data.indexOf(n.types[o.type].coerce(t)),s={};_.each(e,function(e,t){s[t]=e[r]}),i===-1?u.push(s):(a.push(s),s[this.idAttribute]=this.rowById(this.column(this.idAttribute).data[i])[this.idAttribute],this.update(s))},this),u.length>0&&this.add(u)},blind:function(e){var t,n,r=[],i,s=_.keys(e),o=_.max(_.map(s,function(t){return e[t].length},this));for(var u=0;u<o;u++){i={};for(var a=0;a<s.length;a++)i[s[a]]=e[s[a]][u];r.push(i)}this.add(r)}},_apply:function(e){var t=this.parser.parse(e);if(!this.fetched)this._addIdColumn(),this.addColumns(_.map(t.columns,function(e){return{name:e}})),n.Builder.detectColumnTypes(this,t.data),this._applications.blind.call(this,t.data),this.fetched=!0;else if(this.resetOnFetch)this.reset(),this._applications.blind.call(this,t.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,t.data)}else this._applications.blind.call(this,t.data);n.Builder.cacheRows(this)},addColumns:function(e){_.each(e,function(e){this.addColumn(e)},this)},addComputedColumn:function(e,t,r){if(!_.isUndefined(this.column(e)))throw"There is already a column by this name.";if(typeof n.types[t]=="undefined")throw"The type "+t+" doesn't exist";var i=new n.Column({name:e,type:t,func:_.bind(r,this)});return this._columns.push(i),this._computedColumns.push(i),this._columnPositionByName[i.name]=this._columns.length-1,this.length>0&&this.each(function(e,t){i.compute(e,t)},this),i},addColumn:function(e){return _.isUndefined(this.column(e.name))?(e=new n.Column(e),this._columns.push(e),this._columnPositionByName[e.name]=this._columns.length-1,e):!1},_addIdColumn:function(e){if(!_.isUndefined(this.column(this.idAttribute)))return;var t=[];e&&e>0&&_.times(e,function(){t.push(_.uniqueId())});var n=this.addColumn({name:this.idAttribute,data:t});this.idAttribute==="_id"&&(n.type="number");if(this._columnPositionByName[this.idAttribute]!==0){var r=this._columnPositionByName[this.idAttribute];this._columns.splice(r,1),this._columns.unshift(n),this._columnPositionByName[this.idAttribute]=0,_.each(this._columnPositionByName,function(e,t){t!==this.idAttribute&&this._columnPositionByName[t]<r&&this._columnPositionByName[t]++},this)}},add:function(e,t){t=t||{},_.isArray(e)||(e=[e]);var r=[];_.each(e,function(e){e[this.idAttribute]||(e[this.idAttribute]=_.uniqueId()),this._add(e,t),this.syncable&&!t.silent&&r.push({changed:e})},this);if(this.syncable&&!t.silent){var i=n.Events._buildEvent(r,this);this.publish("add",i),this.publish("change",i)}return this},remove:function(e,t){e=this._rowFilter(e);var r=[],i=[];this.each(function(t,n){e(t)&&(i.push(t[this.idAttribute]),r.push({old:t}))}),_.each(i,function(e){this._remove(e)},this);if(this.syncable&&(!t||!t.silent)){var s=n.Events._buildEvent(r,this);this.publish("remove",s),this.publish("change",s)}},_arrayUpdate:function(e){var t=[];return _.each(e,function(e){var r={old:{},changed:{}};r[this.idAttribute]=e[this.idAttribute];var i=this._rowPositionById[e[this.idAttribute]];_.each(e,function(e,t){var s=this._columns[this._columnPositionByName[t]],o=n.types[s.type];if(s.name===this.idAttribute&&s.data[i]!==e)throw"You can't update the id column";if(typeof s=="undefined")throw"column "+t+" not found!";if(!o.test(e,s))throw"Value is incorrect type";if(this._computedColumns[s.name])return;e=o.coerce(e,s),_.isUndefined(s.before)||(e=s.before(e)),s.data[i]!==e&&(r.old[t]=s.data[i],s.data[i]=e,r.changed[t]=e)},this),typeof this._computedColumns!="undefined"&&_.each(this._computedColumns,function(e){var t=_.extend({},this._row(i)),n=t[e.name],s=e.compute(t,i);n!==s&&(r.old[e.name]=n,e.data[i]=s,r.changed[e.name]=s)},this),_.keys(r.changed).length>0&&t.push(r)},this),t},_functionUpdate:function(e){var t=[];for(var n=0;n<this.length;n++){var r=e(this.rowByPosition(n));r!==!1&&t.push(r)}return this._arrayUpdate(t)},update:function(e,t){var r;if(_.isFunction(e))r=this._functionUpdate(e);else{var i=_.isArray(e)?e:[e];r=this._arrayUpdate(i)}if(this.syncable&&(!t||!t.silent)){var s=n.Events._buildEvent(r,this);this.publish("update",s),this.publish("change",s)}return this},reset:function(e){_.each(this._columns,function(e){e.data=[]}),this.length=0,this.syncable&&(!e||!e.silent)&&this.publish("reset")}})}(this,_,moment),function(e,_){var t=e.Miso.Dataset;t.typeOf=function(e,n){var r=_.keys(t.types),i;return r.push(r.splice(_.indexOf(r,"string"),1)[0]),r.push(r.splice(_.indexOf(r,"mixed"),1)[0]),i=_.find(r,function(r){return t.types[r].test(e,n)}),i=_.isUndefined(i)?"string":i,i},t.types={mixed:{name:"mixed",coerce:function(e){return _.isNull(e)||typeof e=="undefined"||_.isNaN(e)?null:e},test:function(){return!0},compare:function(e,t){if(_.isEqual(e,t))return 0;if(e<t)return-1;if(e>t)return 1},numeric:function(e){return e===null||_.isNaN(+e)?null:+e}},string:{name:"string",coerce:function(e){return _.isNaN(e)||e===null||typeof e=="undefined"?null:e.toString()},test:function(e){return e===null||typeof e=="undefined"||typeof e=="string"},compare:function(e,t){return e==null&&t!=null?-1:e!=null&&t==null?1:e<t?-1:e>t?1:0},numeric:function(e){return _.isNaN(+e)||e===null?null:_.isNumber(+e)?+e:null}},"boolean":{name:"boolean",regexp:/^(true|false)$/,coerce:function(e){return _.isNaN(e)||e===null||typeof e=="undefined"?null:e==="false"?!1:Boolean(e)},test:function(e){return e===null||typeof e=="undefined"||typeof e=="boolean"||this.regexp.test(e)?!0:!1},compare:function(e,t){return e==null&&t!=null?-1:e!=null&&t==null?1:e==null&&t==null?0:e===t?0:e<t?-1:1},numeric:function(e){return e===null||_.isNaN(e)?null:e?1:0}},number:{name:"number",regexp:/^\s*[\-\.]?[0-9]+([\.][0-9]+)?\s*$/,coerce:function(e){var t=+e;return _.isNull(e)||typeof e=="undefined"||_.isNaN(t)?null:t},test:function(e){return e===null||typeof e=="undefined"||typeof e=="number"||this.regexp.test(e)?!0:!1},compare:function(e,t){return e==null&&t!=null?-1:e!=null&&t==null?1:e==null&&t==null?0:e===t?0:e<t?-1:1},numeric:function(e){return _.isNaN(e)||e===null?null:e}},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(e){if(this._regexpTable[e])return new RegExp(this._regexpTable[e],"g");var t=e;return _.each(this._formatLookup,function(e){t=t.replace(e[0],e[1])},this),t=t.split("/").join("\\/"),this._regexpTable[e]=t,new RegExp(this._regexpTable[e],"g")},coerce:function(e,t){t=t||{};if(_.isNull(e)||typeof e=="undefined"||_.isNaN(e))return null;if(_.isString(e)){var n=t.format||this.format;return moment(e,n)}return _.isNumber(e)?moment(e):e},test:function(e,t){t=t||{};if(e===null||typeof e=="undefined")return!0;if(_.isString(e)){var n=t.format||this.format,r=this._regexp(n);return r.test(e)}return!0},compare:function(e,t){return e<t?-1:e>t?1:0},numeric:function(e){return _.isNaN(e)||e===null?null:e.valueOf()}}}}(this,_),function(e,_){var t=e.Miso.Dataset;t.Event=function(e,t){_.isArray(e)||(e=[e]),this.deltas=e,this.dataset=t||null},_.extend(t.Event.prototype,{affectedColumns:function(){var e=[];return _.each(this.deltas,function(t){t.old=t.old||[],t.changed=t.changed||[],e=_.chain(e).union(_.keys(t.old),_.keys(t.changed)).reject(function(e){return e===this.dataset.idAttribute},this).value()},this),e}}),_.extend(t.Event,{isRemove:function(e){return _.isUndefined(e.changed)||_.keys(e.changed).length===0?!0:!1},isAdd:function(e){return _.isUndefined(e.old)||_.keys(e.old).length===0?!0:!1},isUpdate:function(e){return!this.isRemove(e)&&!this.isAdd(e)?!0:!1}}),t.Events={},t.Events._buildEvent=function(e,n){return new t.Event(e,n)}}(this,_),function(e,_){var t=e.Miso.Dataset;t.Builder={detectColumnType:function(e,n){var r=_.inject(n.slice(0,5),function(e,n){var r=t.typeOf(n);return n!==""&&e.indexOf(r)===-1&&!_.isNull(n)&&e.push(r),e},[]);return r.length===1?e.type=r[0]:e.type="mixed",e},detectColumnTypes:function(e,n){_.each(n,function(n,r){var i=e.column(r);if(i.type){i.force=!0;return}t.Builder.detectColumnType(i,n)},this)},cacheRows:function(e){t.Builder.clearRowCache(e),_.each(e._columns[e._columnPositionByName[e.idAttribute]].data,function(t,n){e._rowPositionById[t]=n,e._rowIdByPosition.push(t)},e);var n=_.uniq(_.map(e._columns,function(e){return e.data.length}));if(n.length>1)throw new Error("Row lengths need to be the same. Empty values should be set to null."+_.map(e._columns,function(e){return e.data+"|||"}));e.length=n[0]},clearRowCache:function(e){e._rowPositionById={},e._rowIdByPosition=[]},cacheColumns:function(e){e._columnPositionByName={},_.each(e._columns,function(t,n){e._columnPositionByName[t.name]=n})}},Array.prototype.indexOf||(Array.prototype.indexOf=function(e,t){for(var n=t||0,r=this.length;n<r;n++)if(this[n]===e)return n;return-1})}(this,_),function(e,_){var t=e.Miso||(e.Miso={}),n=e.Miso.Dataset;n.Product=function(e){e=e||{},this.func=e.func;if(e.columns){var t=e.columns;_.isArray(e.columns)&&(t=e.columns[0]),this.valuetype=t.type,this.numeric=function(){return t.toNumeric(this.value)}}return this.func({silent:!0}),this},_.extend(n.Product.prototype,t.Events,{val:function(){return this.value},type:function(){return this.valuetype},_sync:function(e){this.func()},_buildDelta:function(e,t){return{old:e,changed:t}}}),n.Product.define=function(e){return function(t,r){r=r||{};var i=this._findColumns(t),s=this;r.type=r.type||i[0].type,r.typeOptions=r.typeOptions||i[0].typeOptions;var o=function(){var t=e.call(s,i,r);return n.types[r.type].coerce(t,r.typeOptions)};if(this.syncable){var u=new n.Product({columns:i,func:function(e){e=e||{};var t=this._buildDelta(this.value,o.call(s));this.value=t.changed;if(s.syncable){var r=n.Events._buildEvent(t,this);!_.isUndefined(t.old)&&!e.silent&&t.old!==t.changed&&this.publish("change",r)}}});return this.subscribe("change",u._sync,{context:u}),u}return o.call(s)}},_.extend(n.DataView.prototype,{_findColumns:function(e){var t=[];return _.isUndefined(e)&&(e=this.columnNames()),e=_.isArray(e)?e:[e],_.each(e,function(e){e=this._columns[this._columnPositionByName[e]],t.push(e)},this),t},sum:n.Product.define(function(e,t){return _.each(e,function(e){if(e.type===n.types.time.name)throw new Error("Can't sum up time")}),_.sum(_.map(e,function(e){return e._sum()}))}),max:n.Product.define(function(e,t){return _.max(_.map(e,function(e){return e._max()}))}),min:n.Product.define(function(e,t){return _.min(_.map(e,function(e){return e._min()}))}),mean:n.Product.define(function(e,t){var r=[];_.each(e,function(e){r.push(e.data)}),r=_.flatten(r);var i=e[0].type;return r=_.map(r,function(e){return n.types[i].numeric(e)}),_.mean(r)})})}(this,_),function(e,_){var t=e.Miso.Dataset;t.Importers=function(e,t){},t.Importers.prototype.extract=function(e){return e=_.clone(e),e}}(this,_),function(e,_){var t=e.Miso.Dataset;t.Importers.Local=function(e){e=e||{},this.data=e.data||null,this.extract=e.extract||this.extract},_.extend(t.Importers.Local.prototype,t.Importers.prototype,{fetch:function(e){var t=e.data?e.data:this.data;e.success(this.extract(t))}})}(this,_),function(e,_){var t=e.Miso.Dataset;t.Importers.Remote=function(e){e=e||{},this._url=e.url,this.extract=e.extract||this.extract,this.params={type:"GET",url:_.isFunction(this._url)?_.bind(this._url,this):this._url,dataType:e.dataType?e.dataType:e.jsonp?"jsonp":"json",callback:e.callback}},_.extend(t.Importers.Remote.prototype,t.Importers.prototype,{fetch:function(e){var n=_.bind(function(t){e.success(this.extract(t))},this);this.callback&&(window[this.callback]=n),t.Xhr(_.extend(this.params,{success:this.callback?this.callback:n,error:e.error}))}});var n={url:"",data:"",dataType:"",success:function(){},type:"GET",async:!0,xhr:function(){return e.ActiveXObject?new e.ActiveXObject("Microsoft.XMLHTTP"):new e.XMLHttpRequest}},r=/\?/;t.Xhr=function(e){e.dataType=e.dataType&&e.dataType.toLowerCase()||null;var i=_.isFunction(e.url)?e.url():e.url;if(!(!e.dataType||e.dataType!=="jsonp"&&e.dataType!=="script")){t.Xhr.getJSONP(i,e.success,e.dataType==="script",e.error,e.callback);return}var s=_.extend({},n,e,{url:i});s.ajax=s.xhr();if(s.ajax)return s.type==="GET"&&s.data&&(s.url+=(r.test(s.url)?"&":"?")+s.data,s.data=null),s.ajax.open(s.type,s.url,s.async),s.ajax.send(s.data||null),t.Xhr.httpData(s)},t.Xhr.getJSONP=function(e,t,n,r,i){if(n){var s=document.querySelectorAll('script[src="'+e+'"]');if(s.length){t&&t(!0);return}}var o=document.head||document.getElementsByTagName("head")[0]||document.documentElement,u=document.createElement("script"),a=e.split("?")[1],f=!1,l=[],c;a&&!n&&(l=a.split("&")),l.length&&(c=l[l.length-1].split("="));if(!i){var h=_.uniqueId("callback");i=l.length?c[1]?c[1]:h:h}!a&&!n&&(e+="?");if(!a||!/callback/.test(a))a&&(e+="&"),e+="callback="+i;i&&!n&&(!window[i]||(i=i+ +(new Date)+_.uniqueId()),window[i]=function(e){t&&t(e),f=!0},c&&(e=e.replace(c.join("="),c[0]+"="+i))),u.onload=u.onreadystatechange=function(){if(!u.readyState||/loaded|complete/.test(u.readyState)){n&&t&&t();if(f){try{delete window[i]}catch(e){window[i]=void 0}o.removeChild(u)}}},u.onerror=function(e){r&&r.call(null,e)},u.src=e,o.insertBefore(u,o.firstChild);return},t.Xhr.httpData=function(e){var t,n=null,r;return r=function(){if(e.ajax.readyState===4){try{n=JSON.parse(e.ajax.responseText)}catch(r){}t={xml:e.ajax.responseXML,text:e.ajax.responseText,json:n},e.dataType&&(t=t[e.dataType]),/(2..)/.test(e.ajax.status)?e.success.call(e.ajax,t):e.error&&e.error.call(null,e.ajax.statusText)}},e.ajax.readyState===4?r():e.ajax.onreadystatechange=r,t}}(this,_),function(e,_){var t=e.Miso.Dataset;t.Importers.Polling=function(e){e=e||{},this.interval=e.interval||1e3,this._def=null,t.Importers.Remote.apply(this,[e])},_.extend(t.Importers.Polling.prototype,t.Importers.Remote.prototype,{fetch:function(n){this._def===null&&(this._def=_.Deferred(),this.success_callback=_.bind(function(e){n.success(this.extract(e)),this._def.resolve(this)},this),this.error_callback=_.bind(function(e){n.error(e),this._def.reject(e)},this)),_.when(this._def.promise()).then(function(e){var t=_.bind(function(){this.fetch({success:this.success_callback,error:this.error_callback})},e);e._timeout=setTimeout(t,e.interval),e._def=_.Deferred()}),t.Xhr(_.extend(this.params,{success:this.success_callback,error:this.error_callback})),e.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(e,_){var t=e.Miso.Dataset;t.Importers.GoogleSpreadsheet=function(e){e=e||{};if(e.url)e.url=e.url;else{if(_.isUndefined(e.key))throw new Error("Set options 'key' properties to point to your google document.");e.fast?(e.url="https://spreadsheets.google.com/tq?key="+e.key,typeof e.sheetName=="undefined"&&(e.sheetName="Sheet1"),e.url+="&sheet="+e.sheetName,this.callback="misodsgs"+(new Date).getTime(),e.url+="&tqx=version:0.6;responseHandler:"+this.callback,e.url+=";reqId:0;out:json&tq&_=1335871249558#",delete e.sheetName):e.url="https://spreadsheets.google.com/feeds/cells/"+e.key+"/"+e.worksheet+"/public/basic?alt=json-in-script&callback=",delete e.key}return this.params={type:"GET",url:e.url,dataType:"jsonp"},this},_.extend(t.Importers.GoogleSpreadsheet.prototype,t.Importers.Remote.prototype)}(this,_),function(e,_){var t=e.Miso.Dataset;t.Parsers=function(e){this.options=e||{}},_.extend(t.Parsers.prototype,{parse:function(){}})}(this,_),function(e,_){var t=e.Miso.Dataset;t.Parsers.Strict=function(e){this.options=e||{}},_.extend(t.Parsers.Strict.prototype,t.Parsers.prototype,{parse:function(e){var t={},n=[];return _.each(e.columns,function(e){if(n.indexOf(e.name)!==-1)throw new Error('You have more than one column named "'+e.name+'"');n.push(e.name),t[e.name]=e.data}),{columns:n,data:t}}})}(this,_),function(e,_){var t=e.Miso.Dataset;t.Parsers.Obj=t.Parsers,_.extend(t.Parsers.Obj.prototype,t.Parsers.prototype,{parse:function(e){var t=_.keys(e[0]),n={};return _.each(t,function(e){n[e]=[]}),_.each(t,function(t){_.times(e.length,function(r){n[t].push(e[r][t])})}),{columns:t,data:n}}})}(this,_),function(e,_){var t=e.Miso.Dataset;t.Parsers.GoogleSpreadsheet=function(e){this.fast=e.fast||!1},_.extend(t.Parsers.GoogleSpreadsheet.prototype,t.Parsers.prototype,{parse:function(e){var t=[],n=[],r={},i;if(typeof e.status!="undefined"&&e.status==="error")throw new Error("You can't use the fast importer for this url. Disable the fast flag");if(this.fast){t=_.pluck(e.table.cols,"label");if(_.unique(t).length<t.length){var s="";throw _.inject(t,function(e,t){return e[t]=e[t]+1||1,e[t]>1&&(s=t),e},{}),new Error('You have more than one column named "'+s+'"')}_.each(e.table.rows,function(e){e=e.c;for(i=0;i<e.length;i++)n[i]=n[i]||[],e[i].v===""?n[i].push(null):n[i].push(e[i].v)}),_.each(t,function(e,t){r[e]=n[t]})}else{var o=/([A-Z]+)(\d+)/,u={};_.each(e.feed.entry,function(e){var r=o.exec(e.title.$t),i=r[1],s=parseInt(r[2],10);if(s===1){if(t.indexOf(e.content.$t)!==-1)throw new Error('You have more than one column named "'+e.content.$t+'"');u[i]=n.length,t[u[i]]=e.content.$t,n[u[i]]=[]}else{var a=u[i];n[a][s-1]=e.content.$t}},this),_.each(n,function(e,i){e.length=_.max(_.pluck(n,"length")),e.splice(0,1);for(var s=0;s<e.length;s++)if(_.isUndefined(e[s])||e[s]==="")e[s]=null;r[t[i]]=e})}return{columns:t,data:r}}})}(this,_),function(e,_){var t=e.Miso.Dataset;t.Parsers.Delimited=function(e){e=e||{},this.delimiter=e.delimiter||",",this.skipRows=e.skipRows||0,this.emptyValue=e.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(t.Parsers.Delimited.prototype,t.Parsers.prototype,{parse:function(e){var t=[],n={},r={},i=function(e){r[e]||(r[e]=0);var t=e+r[e];return r[e]+=1,t},s=function(e,r,s,o,u){s=s||",";var a=null,f=0,l=!1,c=-1,h=0;try{r=r.replace(/\s+$/,"").replace(/^[\r|\n|\s]+[\r|\n]/,"\n");if(o>0){var p=0,d=0,v=r.length;while(p<o&&d<v)/\n|\r|\r\n/.test(r.charAt(d))&&p++,d++;r=r.slice(d,v)}function m(e){var r=e[1];if(r.length&&r!==s){h++;if(c<f-1)throw h--,new Error("Not enough items in row");l=!0,c=0}else l||f++,c++;var o=null;e[2]?o=e[2].replace(new RegExp('""',"g"),'"'):o=e[3];if(l){o===""&&(o=u);if(typeof n[t[c]]=="undefined")throw new Error("Too many items in row");n[t[c]].push(o)}else{var a=function(e){var n=i(e);while(t.indexOf(n)!==-1)n=i(e);return n};if(_.isUndefined(o)||o==="")o="X";t.indexOf(o)!==-1&&(o=a(o)),t.push(o),n[o]=[]}}(new RegExp("^"+s)).test(r)&&m(["","",undefined,""]);while(a=e.exec(r))m(a)}catch(g){throw new Error("Error while parsing delimited data on row "+h+". Message: "+g.message)}return{columns:t,data:n}};return s(this.__delimiterPatterns,e,this.delimiter,this.skipRows,this.emptyValue)}})}(this,_),function(e,_){var t=e.Miso||(e.Miso={}),n=t.Dataset;n.Derived=function(e){e=e||{},n.call(this),this.parent=e.parent,this.idAttribute="_id",this.method=e.method,this._addIdColumn(),this.addColumn({name:"_oids",type:"mixed"}),this.parent.syncable&&(_.extend(this,t.Events),this.syncable=!0,this.parent.subscribe("change",this._sync,{context:this}))},n.Derived.prototype=new n,_.extend(n.Derived.prototype,{_sync:function(){this.func.call(this.args),this.publish("change")}}),_.extend(n.DataView.prototype,{movingAverage:function(e,t,r){r=r||{};var i=new n.Derived({parent:this,method:r.method||_.mean,size:t,args:arguments});this.eachColumn(function(e){if(e===this.idAttribute)throw"You can't compute a moving average on the id column";i.addColumn({name:e,type:this.column(e).type,data:[]})},this),n.Builder.cacheColumns(i);var s=function(){typeof e=="string"&&(e=[e]),this.column(this.idAttribute).data=this.parent.column(this.parent.idAttribute).data.slice(t-1,this.parent.length),this.eachColumn(function(n,r){e.indexOf(n)===-1&&n!=="_oids"?r.data=this.parent.column(n).data.slice(t-1,this.parent.length):r.data=_.movingAvg(this.parent.column(n).data,t,this.method)},this),this.length=this.parent.length-t+1;var r=this.column("_oids");r.data=[];for(var i=0;i<this.length;i++)r.data.push(this.parent.column(this.parent.idAttribute).data.slice(i,i+t));return n.Builder.cacheRows(this),this};return i.func=_.bind(s,i),i.func.call(i.args)},countBy:function(e,t){function f(e,t,r){var i;for(i=0;i<e.length;i++)if(n.types[r].compare(e[i],t)===0)return i;return-1}t=t||{};var r=new n.Derived({parent:this,method:_.sum,args:arguments}),i=this.column(e);r.addColumn({name:e,type:i.type}),r.addColumn({name:"count",type:"number"}),r.addColumn({name:"_oids",type:"mixed"}),n.Builder.cacheColumns(r);var s=r.column(e).data,o=r.column("count").data,u=r.column("_oids").data,a=r.column(r.idAttribute).data;return this.each(function(t){var n=f(s,t[e],i.type);n===-1?(s.push(t[e]),a.push(_.uniqueId()),o.push(1),u.push([t[this.parent.idAttribute]])):(o[n]+=1,u[n].push(t[this.parent.idAttribute]))},r),n.Builder.cacheRows(r),r},groupBy:function(e,t,r){r=r||{};var i=new n.Derived({parent:this,method:r.method||_.sum,args:arguments});r&&r.preprocess&&(i.preprocess=r.preprocess);var s=_.union([e],t);_.each(s,function(e){this.addColumn({name:e,type:this.parent.column(e).type})},i),n.Builder.cacheColumns(i);var o=function(){var r=this;n.Builder.clearRowCache(this);var i={},s=0,o=this.parent.column(e);for(var u=0;u<this.parent.length;u++){var a=null;this.preprocess?a=this.preprocess(o.data[u]):a=o.data[u],_.isUndefined(i[a])&&(i[a]=s,_.each(t,function(e){var t=this.column(e),n=this.column(this.idAttribute);t.data[s]=[],n.data[s]=_.uniqueId()},this),this.column(e).data[s]=a,s++),_.each(t,function(e){var t=this.column(e),n=i[a];t.data[n].push(this.parent.rowByPosition(u))},this)}var f=this._columns[this._columnPositionByName._oids];return f.data=[],_.each(t,function(e){var t=this.column(e);_.each(t.data,function(n,i){_.isArray(n)&&(f.data[i]=f.data[i]||[],f.data[i].push(_.map(n,function(e){return e[r.parent.idAttribute]})),f.data[i]=_.flatten(f.data[i]),t.data[i]=this.method(_.map(n,function(t){return t[e]})),this.length++)},this)},this),n.Builder.cacheRows(this),this};return i.func=_.bind(o,i),i.func.call(i.args)}})}(this,_),function(e){var t=e.Miso||{};typeof exports!="undefined"&&(typeof module!="undefined"&&module.exports&&(module.exports=t),exports.miso=t)}(this);
View
2 dist/node/miso.ds.deps.0.4.0.js → dist/node/miso.ds.deps.0.4.1.js
@@ -114,7 +114,7 @@ this.Miso = require("miso.events");
// Include Miso Dataset lib
/**
-* Miso.Dataset - v0.4.0 - 11/16/2012
+* Miso.Dataset - v0.4.1 - 11/19/2012
* http://github.com/misoproject/dataset
* Copyright (c) 2012 Alex Graul, Irene Ros;
* Dual Licensed: MIT, GPL
View
4 package.json
@@ -2,7 +2,7 @@
"name" : "miso.dataset",
"title" : "Miso.Dataset",
"description" : "Dataset is a javascript library makes managing the data behind client-side visualisations easy, including realtime data. It takes care of loading, parsing, sorting, filtering and querying of datasets as well as the creation of derivative datasets. Dataset is part of the Miso Toolkit",
- "version" : "0.4.0",
+ "version" : "0.4.1",
"homepage" : "http://github.com/misoproject/dataset",
"authors" : "Alex Graul, Irene Ros",
@@ -21,7 +21,7 @@
}
],
- "main": "dist/node/miso.ds.deps.0.4.0",
+ "main": "dist/node/miso.ds.deps.0.4.1",
"repository": {
"type": "git",
View
7 src/require.js
@@ -1,7 +1,6 @@
(function(global) {
var Miso = global.Miso || {};
- delete window.Miso;
// CommonJS module is defined
if (typeof exports !== 'undefined') {
@@ -10,12 +9,6 @@
module.exports = Miso;
}
exports.miso = Miso;
-
- } else if (typeof define === 'function' && define.amd) {
- // Register as a named module with AMD.
- define('miso', [], function() {
- return Miso;
- });
}
}(this));

0 comments on commit 68c3546

Please sign in to comment.
Something went wrong with that request. Please try again.