Skip to content

Instantly share code, notes, and snippets.

@dnoiz1
Forked from deoxxa/pilot.js
Created February 18, 2012 05:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dnoiz1/1857557 to your computer and use it in GitHub Desktop.
Save dnoiz1/1857557 to your computer and use it in GitHub Desktop.
pilot object
var Pilot = function(data) {
this.charID = 0;
this.charName = null;
this.solarSystemID = null;
this.solarSystemName = null;
this.shipTypeID = null;
this.shipTypeName = null;
this.shipID = null;
this.shipName = null;
this.stationID = null;
this.stationName = null;
this.corpID = null;
this.corpName = null;
this.allianceID = null;
this.allianceName = null;
if (typeof data === "object") {
this.setAll(data);
}
};
Pilot.prototype.setAll = function(data, _this) {
if(!_this) _this = this;
_this.charID = data.charID;
_this.charName = data.charName;
_this.solarSystemID = data.solarSystemID;
_this.solarSystemName = data.solarSystemName;
_this.shipTypeID = data.shipTypeID;
_this.shipTypeName = data.shitTypeName;
_this.shipID = data.shipID;
_this.shipName = data.shipName;
_this.stationID = data.stationID;
_this.stationName = data.stationName;
_this.corpID = data.corpID;
_this.corpName = data.corpName;
_this.allianceID = data.allianceID;
_this.allianceName = data.allianceName;
console.log(this, _this); // <--- window, Pilot
return this;
};
var storedCallback;
var ajax = function(callback) {
if(typeof callback == 'function') storedCallback = callback;
onSuccess: function(data) {
//someshit
storedCallback(data, p)
}
});
var p = new Pilot();
ajax(p.setAll)
console.log(p);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment