Team:Team:Freiburg software/Code/qooxdoo/WaveFactory.js

From 2009.igem.org

Revision as of 11:57, 21 October 2009 by Davidn (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

/* ************************************************************************
 * Thanks to Fabian Jakobs
 */

qx.Class.define("qooxwaveclient.wave.WaveFactory", 
{
  extend : qx.core.Object,

  members :
  {
    getWave : function()
    {
      if (this.isInWaveContainer())  //check if application runs in wave
      {
        return wave;
      }
      else  //create emulated wave so the application works outside wave
      {
        var state = new qooxwaveclient.wave.State();
        var participants = [
          new qooxwaveclient.wave.Participant("Fabian Jakobs", "http://www.gravatar.com/avatar/a6d98536d90d2987d40a6abe731805ca")
        ];
        
        return new qooxwaveclient.wave.Wave(state, participants);
      }
    },
    
    //checks if qooxdoo application runs in wave
    isInWaveContainer : function() {
    	var isInWave = typeof window.wave != "undefined" && wave.isInWaveContainer();
    	isInWave ? this.debug("Application runs Wave") : this.debug("Application runs outside waveContainer");
        return isInWave;
    }
  }
});