Sha256: 16472dd4382fdf77b8024c983145275617284c71f35c86ed73c6b035e78dcfd6

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

var bowl = new (function(){
  var self = this;
  this.io = null;

  this.load_script_tag = function(url, onload){
    var script = document.createElement("script");
    script.src = url;
    if(typeof onload === "function"){
      script.onload = onload;
      script.onreadystatechange = function(){
        if(readyState=="loaded" || readyState=="complete"){
          onload();
        }
      };
    }
    document.body.appendChild(script);
  };

  this.init = function(){
    self.load_script_tag("<%= cometio_js %>", function(){
      self.io = new CometIO().connect();
      self.io.on("connect", function(session_id){
        console.log("bowl connect : "+session_id);
      });
    });
  };

  this.plugin = function(name, data, callback){
    if(typeof callback === "function"){
      var callback_name = "plugin_"+name+'_callback_'+Date.now();
      self.io.once(callback_name, callback);
      data["__callback"] = callback_name;
    }
    self.io.push("plugin_"+name, data);
  };
})();

$(function(){
  bowl.init();
});

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bowl-0.0.2 lib/bowl/app/js/bowl.js
bowl-0.0.1 lib/bowl/app/js/bowl.js