javascript classes are built upon backbone.js and are meant to mimic the java classes. currently implemented: Encounter.js, MarkedIndividual.js, SinglePhotoVideo.js. These are all based upon a common Base.js class.

Examples

(Click CODE snippet to execute. More detailed output in javascript console of browser too.)
[some output will go here]
creates and then fetches (using rest api) a single encounter (based on Backbone Model).
enc = new wildbook.Model.Encounter({catalogNumber: '4f085ee0-e16e-4a4a-ad5b-6f9e2d0ae289'}); enc.fetch({success: function() { output( enc.get('guid') ); }});
gets the images associated with the encounter (assuming enc is fetched above). sets enc.images to a Collection of SinglePhotoVideos.
enc.getImages( function() { output( enc.images.models[0].url() ); } );
get the MarkedIndividual in the Encounter (assuming enc is fetched above). sets enc.individual.
enc.getIndividual( function() { output( enc.individual.id ); } );
get the Encounters for a MarkedIndividual. sets .encounters to a Collection of Encounters.
enc.individual.getEncounters( function() { output( "found " + enc.individual.encounters.models.length + " encounters"); } );
standard Backbone Collection.fetch() has been overridden to extend to allow the jdoql support used by our rest api. (i.e. /jdoql?QUERY)
inds = new wildbook.Collection.MarkedIndividuals(); inds.fetch({ jdoql: 'WHERE individualID.startsWith("n")', success: function(mods) { output("found " + mods.length + " individual"); } });
Collection.fetch() also supports an alternate field/value based query.
inds = new wildbook.Collection.MarkedIndividuals(); inds.fetch({ fields: { sex: "female", seriesCode: "None" }, success: function(mods) { output("found " + mods.length + " individuals"); } });