Alice

 view release on metacpan or  search on metacpan

share/static/alice.js  view on Meta::CPAN

			}
	  },

    submit: function(form) {
      var params = form.serialize(true);
      form.select(".channelselect").each(function(select) {
        params[select.name] = $A(select.options).map(function(opt){return opt.value});
      });

      new Ajax.Request('/save', {
        method: 'post',
        parameters: params,
        onSuccess: function(){Alice.connections.remove()}
      });

      return false;
    },

    remove: function() {
      alice.input.disabled = false;
      $('servers').remove();
    },

    serverConnection: function(alias, action) {
      alice.connection.sendMessage({
        msg: '/' + action + ' ' + alias,
        source: alice.activeWindow().id,
      });

      return false;
    }
  }
});


Element.addMethods({
  redraw: function(element){
    element = $(element);
    var n = document.createTextNode(' ');
    element.appendChild(n);
    (function(){n.parentNode.removeChild(n)}).defer();
    return element;
  }
});
Alice.Application = Class.create({
  initialize: function() {
    this.options = {};
    this.isFocused = true;
    this.window_map = new Hash();
    this.previousFocus = 0;
    this.selectedSet = '';
    this.tabs = $('tabs');
    this.topic = $('topic');
    this.nicklist = $('nicklist');
    this.overlayVisible = false;
    this.lastnotify = 0;
    this.topic_height = "14px";
    this.beep = new Audio("/static/beep.mp3");

    this.oembeds = [];
    this.jsonp_callbacks = {};

    this.connection = window.WebSocket && !window.location.search.match(/&?stream=xhr/) ?
      new Alice.Connection.WebSocket(this)
      : new Alice.Connection.XHR(this);

    this.tabs_width = $('tabs_container').getWidth();
    this.tabs_layout = this.tabs.getLayout();

    this.base_filters = this.baseFilters();
    this.message_filters = [];

    this.supportsTouch = 'createTouch' in document;

    this.isPhone = window.navigator.userAgent.match(/(android|iphone|wosbrowser)/i) ? true : false;
    this.isMobile = this.isPhone || Prototype.Browser.MobileSafari;
    this.loadDelay = this.isMobile ? 3000 : 1000;
    if (window.navigator.standalone || window.navigator.userAgent.match(/Fluid/)) this.loadDelay = 0;

    this.keyboard = new Alice.Keyboard(this);

    this.input = new Alice.Input(this, "msg");
    this.submit = $("submit");

    this.submit.observe("click", function (e) {
        this.input.send(); e.stop()}.bind(this));

    this.tabs.observe("webkitTransitionEnd", this.shiftEnd.bind(this));
    this.tabs.observe("transitionend", this.shiftEnd.bind(this));

    this.makeSortable();
    this.setupTopic();
    this.setupNicklist();
    this.setupMenus();
  },

  getBacklog: function (win, max, limit) {
    this.connection.requestChunk(win.id, limit, max);
  },

  fetchOembeds: function(cb) {
    var req = new XMLHttpRequest();
    req.open("GET", "https://noembed.com/providers");
    req.onreadystatechange = function(){
      if (req.readyState == 4) {
        try {
          var providers = req.responseText.evalJSON();
          this.oembeds = providers.inject([], function(acc, site){
            return acc.concat(site.patterns.map(function(pat){return new RegExp(pat)}));
          });
        } catch (e) {}
        setTimeout(this.fetchOembeds.bind(this), 1000 * 60 * 5);
        if (cb) cb();
      }
    }.bind(this);
    req.send();
  },

  embed: function(a, win) {
    var params = {
      url: a.href,



( run in 0.766 second using v1.01-cache-2.11-cpan-39bf76dae61 )