vendor/opentok.js
function (options, completion) {
    var Proto = function PluginProxy() {},
        api = new Proto(),
        waitForReadySignal = pluginEventingBehaviour(api);

    refCountBehaviour(api);

    // Assign +plugin+ to this object and setup all the public
    // accessors that relate to the DOM Object.
    //
    var setPlugin = function setPlugin (plugin) {
          if (plugin) {
            api._ = plugin;
            api.parentElement = plugin.parentElement;
            api.$ = $(plugin);
          }
          else {
            api._ = null;
            api.parentElement = null;
            api.$ = $();
          }
        };


    api.uuid = generateCallbackID();

    api.isValid = function() {
      return api._.valid;
    };

    api.destroy = function() {
      api.removeAllRefs();
      setPlugin(null);

      // Let listeners know that they should do any final book keeping
      // that relates to us.
      api.emit('destroy');
    };



    /// Initialise


    // The next statement creates the raw plugin object accessor on the Proxy.
    // This is null until we actually have created the Object.
    setPlugin(null);

    waitOnGlobalCallback(api.uuid, function(err) {
      if (err) {
        completion('The plugin with the mimeType of ' +
                        options.mimeType + ' timed out while loading: ' + err);

        api.destroy();
        return;
      }

      api._.setAttribute('id', 'tb_plugin_' + api._.uuid);
      api._.removeAttribute('tb_callback_id');
      api.uuid = api._.uuid;
      api.id = api._.id;

      waitForReadySignal(function(err) {
        if (err) {
          completion('Error while starting up plugin ' + api.uuid + ': ' + err);
          api.destroy();
          return;
        }

        completion(void 0, api);
      });
    });

    createObject(api.uuid, options, function(err, plugin) {
      setPlugin(plugin);
    });

    return api;
  }
function (options, completion) {
    var Proto = function PluginProxy() {},
        api = new Proto(),
        waitForReadySignal = pluginEventingBehaviour(api);

    refCountBehaviour(api);

    // Assign +plugin+ to this object and setup all the public
    // accessors that relate to the DOM Object.
    //
    var setPlugin = function setPlugin (plugin) {
          if (plugin) {
            api._ = plugin;
            api.parentElement = plugin.parentElement;
            api.$ = $(plugin);
          }
          else {
            api._ = null;
            api.parentElement = null;
            api.$ = $();
          }
        };


    api.uuid = generateCallbackID();

    api.isValid = function() {
      return api._.valid;
    };

    api.destroy = function() {
      api.removeAllRefs();
      setPlugin(null);

      // Let listeners know that they should do any final book keeping
      // that relates to us.
      api.emit('destroy');
    };



    /// Initialise


    // The next statement creates the raw plugin object accessor on the Proxy.
    // This is null until we actually have created the Object.
    setPlugin(null);

    waitOnGlobalCallback(api.uuid, function(err) {
      if (err) {
        completion('The plugin with the mimeType of ' +
                        options.mimeType + ' timed out while loading: ' + err);

        api.destroy();
        return;
      }

      api._.setAttribute('id', 'tb_plugin_' + api._.uuid);
      api._.removeAttribute('tb_callback_id');
      api.uuid = api._.uuid;
      api.id = api._.id;

      waitForReadySignal(function(err) {
        if (err) {
          completion('Error while starting up plugin ' + api.uuid + ': ' + err);
          api.destroy();
          return;
        }

        completion(void 0, api);
      });
    });

    createObject(api.uuid, options, function(err, plugin) {
      setPlugin(plugin);
    });

    return api;
  }
function ( options , completion ) { var Proto = function PluginProxy ( ) { } , api = new Proto ( ) , waitForReadySignal = pluginEventingBehaviour ( api ) ; refCountBehaviour ( api ) ; // Assign +plugin+ to this object and setup all the public // accessors that relate to the DOM Object. // var setPlugin = function setPlugin ( plugin ) { if ( plugin ) { api . _ = plugin ; api . parentElement = plugin . parentElement ; api . $ = $ ( plugin ) ; } else { api . _ = null ; api . parentElement = null ; api . $ = $ ( ) ; } } ; api . uuid = generateCallbackID ( ) ; api . isValid = function ( ) { return api . _ . valid ; } ; api . destroy = function ( ) { api . removeAllRefs ( ) ; setPlugin ( null ) ; // Let listeners know that they should do any final book keeping // that relates to us. api . emit ( 'destroy' ) ; } ; /// Initialise // The next statement creates the raw plugin object accessor on the Proxy. // This is null until we actually have created the Object. setPlugin ( null ) ; waitOnGlobalCallback ( api . uuid , function ( err ) { if ( err ) { completion ( 'The plugin with the mimeType of ' + options . mimeType + ' timed out while loading: ' + err ) ; api . destroy ( ) ; return ; } api . _ . setAttribute ( 'id' , 'tb_plugin_' + api . _ . uuid ) ; api . _ . removeAttribute ( 'tb_callback_id' ) ; api . uuid = api . _ . uuid ; api . id = api . _ . id ; waitForReadySignal ( function ( err ) { if ( err ) { completion ( 'Error while starting up plugin ' + api . uuid + ': ' + err ) ; api . destroy ( ) ; return ; } completion ( void 0 , api ) ; } ) ; } ) ; createObject ( api . uuid , options , function ( err , plugin ) { setPlugin ( plugin ) ; } ) ; return api ; }
Reference counted wrapper for a plugin object
Reference counted wrapper for a plugin object