Skip to content

Commit

Permalink
First working version of the DataSet. It wasn't working before as pen…
Browse files Browse the repository at this point in the history
…dingRequest needs to be set to null to give the region the heads up the data is done.

Path selection works really fine, what is left to do is object flattening and probably setPath / getPath / setQuery / getQuery methods
  • Loading branch information
3rd-Eden committed May 13, 2010
1 parent b5a1647 commit 09e24cb
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions SpryDataYQLDataSet.js
Expand Up @@ -11,7 +11,7 @@
this.timeout = 10000;
this.query = query;
this.prefix = "yql_";
this.path = path || "";
this.path = path || false;
this.doc = null;
this.preparseFunc = null;

Expand Down Expand Up @@ -155,12 +155,18 @@
if( this.preparseFunc )
result = this.preparseFunc( result );

// execute the path, in search for data :)!
if( this.path )
result = Spry.Utils.getObjectByName( this.path, result );

// todo process the data based on path

this.data = dataset.concat( result );
this.dataHash = hash;

// process completed and notify the user
this.dataWasLoaded = true;
this.pendingRequest = false;
this.pendingRequest = null;

this.syncColumnTypesToData();
this.applyColumnTypes();
Expand Down Expand Up @@ -209,4 +215,21 @@
Spry.Data.YQLDataSet.receiver[ that.prefix + "" + id ] = function(){ delete Spry.Data.YQLDataSet.receiver[ that.prefix + "" + id ]; };

}

// modified from the origional to be used with a context argument to search for "paths"
Spry.Utils.getObjectByName = function( name, context ){
var result = null,
lu = context || window, objPath, i, length;

if (name) {

objPath = name.split(".");

for ( i = 0, length = objPath.length; lu && i < length; i++ ){
result = lu[ objPath[i] ];
lu = result;
}
}
return result;
};
})()

0 comments on commit 09e24cb

Please sign in to comment.