<commit_before>var groupId;
var selfIdentity;
var clientId;

var hub = mixinEvents({});

addon.port.on("init", function (options) {
  groupId = options.groupName;
  selfIdentity = options.selfIdentity;
  clientId = options.selfIdentity.clientId;
  //$("#header").text("Hotdish " + groupName);
  if (docReady) {
    init();
  }
});

addon.port.emit("ready-init");

var list = {
  _peers: {},
  get: function (clientId) {
    if (! this._peers[clientId]) {
      var peer = Peer(clientId);
      this._peers[clientId] = peer;
    }
    return this._peers[clientId];
  }
};

var Peer = Class({
  constructor: function (id) {
    this.clientId = id;
    this.avatar = null;
    this.name = null;
    this.color = null;
    this.isSelf = this.clientId == clientId;
    this.element = getTemplate("peer");
    $("#peers").append(this.element);
    this.update({});
    this.tabs = {};
    this.activeTabId = null;
  },

  update: function (msg) {
    this.avatar = msg.avatar || this.avatar;
    this.name = msg.name || this.name;
    this.color = msg.color || this.color;
    if (this.name) {
      this.element.find(".name").text(this.name);
    }
    if (this.color) {
      this.element.find(".bgcolor").css("background-color", this.color);
    }
    if (this.avatar) {
      this.element.find(".avatar").show().attr("src", this.avatar);
    } else {
      this.element.find(".avatar").hide();
    }
    if (this.isSelf) {
      this.element.find("if-self").show();
    } else {
      this.element.find("if-self").hide();
    }
  },

  updateTab: function (msg) {
    if (! this.tabs[msg.tabid]) {
      this.tabs[msg.tabid] = {id: msg.tabid};
    }
    var t = this.tabs[msg.tabid];
    assert(t.id == msg.tabid);
    t.windowid = msg.windowid;
    t.index = msg.index;
    if (msg.pinned !== undefined) {
      t.pinned = msg.pinned;
    }
    if (msg.title !== undefined) {
      t.title = msg.title;
    }
    if (msg.url !== undefined) {
      t.url = msg.url;
    }
    if (msg.favicon !== undefined) {
      t.favicon = msg.favicon;
    }
    this.viewTabs();
  },

  tabEl: function (tabId) {
    return $("#tab-" + this.clientId + "-" + tabId);
  },

  makeTabEl: function (tabId) {
    var el = getTemplate("tab");
    el.attr("id", "tab-" + this.clientId + "-" + tabId);
    return el;
  },

  activateTab: function (msg) {
    var t;
    if (this.activeTabId) {
      t = this.tabEl(this.activeTabId);
      t.removeClass("active-tab");
    }
    this.activeTabId = msg.tabid;
    t = this.tabEl(this.activeTabId);
    var parent = t.closest("ul, ol");
    t.remove();
    parent.prepend(t);
  },

  viewTabs: function () {
    var tabs = [];
    var urlList = this.element.find(".url-list");<commit_msg>Add active-tab class<commit_after>var groupId;
var selfIdentity;
var clientId;

var hub = mixinEvents({});

addon.port.on("init", function (options) {
  groupId = options.groupName;
  selfIdentity = options.selfIdentity;
  clientId = options.selfIdentity.clientId;
  //$("#header").text("Hotdish " + groupName);
  if (docReady) {
    init();
  }
});

addon.port.emit("ready-init");

var list = {
  _peers: {},
  get: function (clientId) {
    if (! this._peers[clientId]) {
      var peer = Peer(clientId);
      this._peers[clientId] = peer;
    }
    return this._peers[clientId];
  }
};

var Peer = Class({
  constructor: function (id) {
    this.clientId = id;
    this.avatar = null;
    this.name = null;
    this.color = null;
    this.isSelf = this.clientId == clientId;
    this.element = getTemplate("peer");
    $("#peers").append(this.element);
    this.update({});
    this.tabs = {};
    this.activeTabId = null;
  },

  update: function (msg) {
    this.avatar = msg.avatar || this.avatar;
    this.name = msg.name || this.name;
    this.color = msg.color || this.color;
    if (this.name) {
      this.element.find(".name").text(this.name);
    }
    if (this.color) {
      this.element.find(".bgcolor").css("background-color", this.color);
    }
    if (this.avatar) {
      this.element.find(".avatar").show().attr("src", this.avatar);
    } else {
      this.element.find(".avatar").hide();
    }
    if (this.isSelf) {
      this.element.find("if-self").show();
    } else {
      this.element.find("if-self").hide();
    }
  },

  updateTab: function (msg) {
    if (! this.tabs[msg.tabid]) {
      this.tabs[msg.tabid] = {id: msg.tabid};
    }
    var t = this.tabs[msg.tabid];
    assert(t.id == msg.tabid);
    t.windowid = msg.windowid;
    t.index = msg.index;
    if (msg.pinned !== undefined) {
      t.pinned = msg.pinned;
    }
    if (msg.title !== undefined) {
      t.title = msg.title;
    }
    if (msg.url !== undefined) {
      t.url = msg.url;
    }
    if (msg.favicon !== undefined) {
      t.favicon = msg.favicon;
    }
    this.viewTabs();
  },

  tabEl: function (tabId) {
    return $("#tab-" + this.clientId + "-" + tabId);
  },

  makeTabEl: function (tabId) {
    var el = getTemplate("tab");
    el.attr("id", "tab-" + this.clientId + "-" + tabId);
    return el;
  },

  activateTab: function (msg) {
    var t;
    if (this.activeTabId) {
      t = this.tabEl(this.activeTabId);
      t.removeClass("active-tab");
    }
    this.activeTabId = msg.tabid;
    t = this.tabEl(this.activeTabId);
    t.addClass("active-tab");
    var parent = t.closest("ul, ol");
    t.remove();
    parent.prepend(t);
  },

  viewTabs: function () {
    var tabs = [];
    var urlList = this.element.find(".url-list");
{'fraction_non_alphanumeric': 0.18627630375114365, 'fraction_numerical': 0.0, 'mean_word_length': 2.528728211749516, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '209935', 'n_tokens_mistral': 1995, 'n_tokens_neox': 1970, 'n_words': 356}