Skip to content

Commit

Permalink
#37 new method queries() to set and get a query
Browse files Browse the repository at this point in the history
  • Loading branch information
tracend committed Jun 13, 2013
1 parent 797f929 commit 778605e
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 28 deletions.
4 changes: 2 additions & 2 deletions build/cloudvisio-min.js

Large diffs are not rendered by default.

33 changes: 19 additions & 14 deletions build/cloudvisio.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @name cloudvisio - 0.5.0 (Thu, 13 Jun 2013 09:42:15 GMT)
// @name cloudvisio - 0.5.0 (Thu, 13 Jun 2013 10:33:10 GMT)
// @url https://github.com/makesites/cloudvisio

// @author makesites
Expand Down Expand Up @@ -226,6 +226,19 @@ Cloudvisio.prototype.select = function( field ){
return this;
};

// set or retrieve the queries applied
Cloudvisio.prototype.queries = function( query ){
if (!arguments.length) return this._queries;
// get a query if given string
if(typeof query == "string") return this._queries[ query ];
// set a query if given object
// create a new field for the query
var id = "__query_"+ utils.uid();
this._queries[id] = query;
// return the id for further use...
return id;
};

// calculate axis based on the queries
Cloudvisio.prototype.amount = function( options ){
// fallback
Expand Down Expand Up @@ -349,8 +362,6 @@ Cloudvisio.prototype._filterNumber = function( number, options ){
if(typeof number != "number") return;
// get the data
var data = this.data(null, { raw : true });
// create a new field for the query;
var id = "__query_"+ utils.uid();
//
for( var i in data ){
var opt = {
Expand All @@ -377,15 +388,14 @@ Cloudvisio.prototype._filterNumber = function( number, options ){
} else if( options.filter && data[i].__filter !== false ){
data[i].__filter = result;
}
// create a new query
var id = { field: field, type: type, query: number };
// add a new query key
data[i][id] = result;
//
opt.key = i;
// update the existing data
this.data( data[i], opt);
// save the query
this._queries[id] = { field: field, type: type, query: number };

}

};
Expand Down Expand Up @@ -561,8 +571,6 @@ Cloudvisio.prototype._filterString = function( string, options ){
//if(typeof string != "string") return;
// get the data
var data = this.data(null, { raw : true });
// create a new field for the query
var id = "__query_"+ utils.uid();
//
for( var i in data ){
var opt = {
Expand All @@ -586,21 +594,18 @@ Cloudvisio.prototype._filterString = function( string, options ){
} else if( options.filter && data[i].__filter !== false ){
data[i].__filter = result;
}
// create a new query
var id = this.queries({ field: field, type: type, query: string });
// add a new query key
data[i][id] = result;
//
opt.key = i;
//opt.filter = true;
// update the existing data
this.data( data[i], opt);
// save the query
this._queries[id] = { field: field, type: type, query: string };
}
};




};

// convert the regular expression into a string
Cloudvisio.prototype.verbalize = function( query ){
Expand Down
13 changes: 13 additions & 0 deletions lib/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,19 @@ Cloudvisio.prototype.select = function( field ){
return this;
};

// set or retrieve the queries applied
Cloudvisio.prototype.queries = function( query ){
if (!arguments.length) return this._queries;
// get a query if given string
if(typeof query == "string") return this._queries[ query ];
// set a query if given object
// create a new field for the query
var id = "__query_"+ utils.uid();
this._queries[id] = query;
// return the id for further use...
return id;
};

// calculate axis based on the queries
Cloudvisio.prototype.amount = function( options ){
// fallback
Expand Down
7 changes: 2 additions & 5 deletions lib/math.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ Cloudvisio.prototype._filterNumber = function( number, options ){
if(typeof number != "number") return;
// get the data
var data = this.data(null, { raw : true });
// create a new field for the query;
var id = "__query_"+ utils.uid();
//
for( var i in data ){
var opt = {
Expand All @@ -72,15 +70,14 @@ Cloudvisio.prototype._filterNumber = function( number, options ){
} else if( options.filter && data[i].__filter !== false ){
data[i].__filter = result;
}
// create a new query
var id = { field: field, type: type, query: number };
// add a new query key
data[i][id] = result;
//
opt.key = i;
// update the existing data
this.data( data[i], opt);
// save the query
this._queries[id] = { field: field, type: type, query: number };

}

};
10 changes: 3 additions & 7 deletions lib/regex.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,6 @@ Cloudvisio.prototype._filterString = function( string, options ){
//if(typeof string != "string") return;
// get the data
var data = this.data(null, { raw : true });
// create a new field for the query
var id = "__query_"+ utils.uid();
//
for( var i in data ){
var opt = {
Expand All @@ -195,17 +193,15 @@ Cloudvisio.prototype._filterString = function( string, options ){
} else if( options.filter && data[i].__filter !== false ){
data[i].__filter = result;
}
// create a new query
var id = this.queries({ field: field, type: type, query: string });
// add a new query key
data[i][id] = result;
//
opt.key = i;
//opt.filter = true;
// update the existing data
this.data( data[i], opt);
// save the query
this._queries[id] = { field: field, type: type, query: string };
}
};



};

0 comments on commit 778605e

Please sign in to comment.