Example #1
0
  initialize: function(){
    _.bindAll(this, 'addSystem','initSystems','render','renderSystems');

    this.empireCount = random.from1to(3);

    this.empires = new App.Collections.Empires([]);
    this.initEmpires();

    this.systemCount = this.empires.length + 5 + random.from1to(5);
    //this.systemCount = this.empires.length;
    //this.systemCount = 1;
    
    this.systems = new App.Collections.Systems([]);
    this.initSystems();

    this.render();

    console.log('=== Universe has ' + this.empires.length + ' Empires');
    console.log('                 ' + this.systems.length + ' Systems');
    console.log('                 ' + this.systems.reduce(function(a, system){
      a = a + system.planets.length;
      return a;
    }, 0) + ' Planets');

  },
Example #2
0
  initialize: function(vals, opts) {
    _.bindAll(this, 'run','runSpace','runPlanet','runSpace','stop','systemPhysics');
    this.set({
      id: uuid.v4()
    });

    // ship belongs to this empire
    this.empire = opts.empire;

    // ship is in orbit at this planet (starts with birth planet)
    this.planet = opts.planet;
    
    // ship is in this system
    this.system = opts.planet.system;

    this.target_planet = null;
    this.target_system = null;

    console.log(' ~ NEW SHIP ', this.get('id'), this.empire.get('name'));
    
    this.ticks = 0;

    // this.set({
    // });

    this.timer = false;
    this.run();

  },
Example #3
0
function BranchStatus(db) {
  this._db = db;
  this._pollInterval = null;
  this.SYNC_URL = "http://jenkinstein.herokuapp.com/branches.json";

  _.bindAll(this, "sync");

  EventEmitter.call(this);
}
	initialize: function(args) {
		client_models.Session.prototype.initialize.call(this, args)
        _.bindAll(this, "onHangoutStarted", "onHangoutStopped")

		// make sure not to overwrite the built-in session-key
		// if we've loaded one through the db.
		if(_.isNull(this.get("session-key"))) {
			var shasum = crypto.createHash('sha256');
			shasum.update(this.get("id") + "");
			shasum.update(new Date().getTime() + "");
			this.set("session-key", shasum.digest('hex'));
		}

		// these listeners are for responding to messages from connected, currently
		// live hangouts. 

		// this particular event triggers when the server makes a change to this 
		// session's hangoutConnected field. It could be changing it in either direction,
		// so we need to disambiguate between starting and stopping by checking
		// the previous state.
		this.on("change:hangoutConnected", _.bind(function() {
			if(this.get("hangoutConnected")) {
                this.onHangoutStarted();
			} else {
                this.onHangoutStopped();
			}
		}, this));
        
        // now check to see if the hangout is already connected when we
        // initialize the serversession. This happens in situations where the
        // server crashes while hangouts are running, and the sockets
        // re-connect.
		if(this.get("hangoutConnected")) {
			logger.debug("server-models triggering hangout-started on load.");

            // this is an annoying hack. it turns out that
            // ServerSession.collection isn't set, because in the
            // initialization process sessions are created before they're
            // assigned to events.  This means that if we try to do a broadcast
            // (the second line of hangout-started event above) it will fail.
            // Instead, we wait until the collection is assigned to do this.
            // (this is triggered manually in Event.addSession, because
            // backbone doesn't seem to fire this event on its own)

            // if it's a permalink session, just start immediately. No need to
            // do the collection hack.
			if(this.get("isPermalinkSession")) {
				this.onHangoutStarted();
			} else {
				this.on("change:collection", _.bind(function() {
                    this.onHangoutStarted
				}, this));
			}
		}
    },
Example #5
0
 Backbone.Collection = function(models, options) {
   options || (options = {});
   if (options.comparator) {
     this.comparator = options.comparator;
     delete options.comparator;
   }
   _.bindAll(this, '_onModelEvent', '_removeReference');
   this._reset();
   if (models) this.refresh(models, {silent: true});
   this.initialize(models, options);
 };
Example #6
0
function TrayMenu(db, prefsDb, branchStatus) {
  this._db = db;
  this._prefsDb = prefsDb;
  this._branchStatus = branchStatus;
  this._tray = new Tray(__dirname + "/imgs/icon.png");

  EventEmitter.call(this);
  _.bindAll(this, "_initEvents", "_createMenu", "_createBranchSubmenu", "_openBranchPromptWindow", "_openBranchManagementWindow");

  this._initEvents();
  this._branchStatus.startPolling();
}
Example #7
0
    initialize: function(args) {
        client_models.Session.prototype.initialize.call(this, args)
        _.bindAll(this, "onHangoutStarted", "onHangoutStopped")

        // Set up a hash to maintain timeouts for joinng users.
        this.joiningTimeouts = {};

        // make sure not to overwrite the built-in session-key
        // if we've loaded one through the db.
        if(_.isNull(this.get("session-key"))) {
            var shasum = crypto.createHash('sha256');
            shasum.update(this.get("id") + "");
            shasum.update(new Date().getTime() + "");
            this.set("session-key", shasum.digest('hex'));
        }
    },
var Format = function(worker, data) {
    _.bindAll(this, 'update', 'complete', 'setup', 'render');
    var that = this;
    this.worker = worker;
    this.data = data;
    Step(
        function() {
            that.setup(this);
        },
        function() {
            that.render(this);
        },
        function() {
            that.complete(this);
        }
    );
}
Example #9
0
  initialize: function() {
    _.bindAll(this, 'addPlanet','initPlanets');

    this.set({
      id: uuid.v4()
    });

    this.starCount = 1;

    this.planetCount = random.from1to(3);
    //this.planetCount = 1;

    this.stars = new App.Collections.Stars();
    this.planets = new App.Collections.Planets();
    this.ships = new App.Collections.Ships();

    this.initStars();
    this.initPlanets();
    //console.log( ' * ' + ' ' + this.get('name') + ' has ' + this.planets.length + ' planets')

  },
Example #10
0
 initialize: function(attributes) {
   this.setTypeFromSubject();
   this.setLabelsFromSubject();
   this.setNameFromSubject();
   _.bindAll(this, 'saveCallback', 'createAttachments', 'createAttachmentFromFile', 'getUserNameFromXML');
 },
Example #11
0
 Backbone.History = function() {
   this.handlers = [];
   this.fragment = this.getFragment();
   _.bindAll(this, 'checkUrl');
 };