<commit_before>var RomoSelect = function(element) {
  this.elem = $(element);

  this.defaultCaretClass     = undefined;
  this.defaultCaretPaddingPx = 5;
  this.defaultCaretPosition  = 'right'

  this.doInit();
  this._bindElem();

  this.doSetValue(this._elemValues());

  if (this.elem.attr('id') !== undefined) {
    $('label[for="'+this.elem.attr('id')+'"]').on('click', $.proxy(function(e) {
      this.romoSelectDropdown.doFocus();
    }, this));
  }

  $(window).on("pageshow", $.proxy(function(e) {
    this._refreshUI();
  }, this));

  this.elem.on('select:triggerSetValue', $.proxy(function(e, value) {
    this.doSetValue(value)
  }, this));

  this.elem.trigger('select:ready', [this]);
}

RomoSelect.prototype.doInit = function() {
  // override as needed
}

RomoSelect.prototype.doSetValue = function(value) {
  var values = Romo.array(value).filter($.proxy(function(v) {
    return this.elem.find('OPTION[value="'+v+'"]')[0] !== undefined;
  }, this));

  this._setValues(values);
  if (this.romoSelectedOptionsList !== undefined) {
    var items = values.map($.proxy(function(value) {
      return {
        'value':       value,
        'displayText': this.elem.find('OPTION[value="'+value+'"]').text().trim()
      };
    }, this));
    this.romoSelectedOptionsList.doSetItems(items);
  } else {
    this.romoSelectDropdown.doSetSelectedItem(values[0]);
  }
  this._refreshUI();
}

/* private */

RomoSelect.prototype._bindElem = function() {
  this._bindSelectDropdown();
  this._bindSelectedOptionsList();

  this.elem.on('select:triggerToggle', $.proxy(function(e) {
    this.romoSelectDropdown.elem.trigger('romoSelectDropdown:triggerToggle', []);
  }, this));
  this.elem.on('select:triggerPopupOpen', $.proxy(function(e) {
    this.romoSelectDropdown.elem.trigger('romoSelectDropdown:triggerPopupOpen', []);
  }, this));
  this.elem.on('select:triggerPopupClose', $.proxy(function(e) {
    this.romoSelectDropdown.elem.trigger('romoSelectDropdown:triggerPopupClose', []);
  }, this));
}

RomoSelect.prototype._bindSelectedOptionsList = function() {
  this.romoSelectedOptionsList = undefined;
  if (this.elem.prop('multiple') === true) {
    if (this.elem.data('romo-select-multiple-item-class') !== undefined) {
      this.romoSelectDropdown.elem.attr('data-romo-selected-options-list-item-class', this.elem.data('romo-select-multiple-item-class'));
    }
    if (this.elem.data('romo-select-multiple-max-rows') !== undefined) {
      this.romoSelectDropdown.elem.attr('data-romo-selected-options-list-max-rows', this.elem.data('romo-select-multiple-max-rows'));
    }

    this.romoSelectedOptionsList = new RomoSelectedOptionsList(this.romoSelectDropdown.elem);
    this.romoSelectedOptionsList.elem.on('romoSelectedOptionsList:itemClick', $.proxy(function(e, itemValue, romoSelectedOptionsList) {
      var currentValues = this._elemValues();
      var index         = currentValues.indexOf(itemValue);
      if (index > -1) {
        currentValues.splice(index, 1);
        this._setValues(currentValues);
      }
      this.romoSelectedOptionsList.doRemoveItem(itemValue);
      this._refreshUI();
    }, this));
    this.romoSelectedOptionsList.elem.on('romoSelectedOptionsList:listClick', $.proxy(function(e, romoSelectedOptionsList) {
      this.romoSelectDropdown.elem.trigger('romoDropdown:triggerPopupClose', []);
      this.romoSelectDropdown.doFocus(false);
    }, this));

    this.elemWrapper.before(this.romoSelectedOptionsList.elem);
    this.romoSelectedOptionsList.doRefreshUI();
  }
}

RomoSelect.prototype._bindSelectDropdown = function() {
  this.romoSelectDropdown = new RomoSelectDropdown(this._buildSelectDropdownElem());

  this.romoSelectDropdown.elem.on('romoSelectDropdown:romoDropdown:toggle', $.proxy(function(e, romoDropdown, romoSelectDropdown) {
    this.elem.trigger('select:romoDropdown:toggle', [romoDropdown, this]);
  }, this));
  this.romoSelectDropdown.elem.on('romoSelectDropdown:romoDropdown:popupOpen', $.proxy(function(e, romoDropdown, romoSelectDropdown) {
    this.elem.trigger('select:romoDropdown:popupOpen', [romoDropdown, this]);
  }, this));
  this.romoSelectDropdown.elem.on('romoSelectDropdown:romoDropdown:popupClose', $.proxy(function(e, romoDropdown, romoSelectDropdown) {
    this.elem.trigger('select:romoDropdown:popupClose', [romoDropdown, this]);
  }, this));

  this.romoSelectDropdown.elem.on('romoSelectDropdown:itemSelected', $.proxy(function(e, itemValue, itemDisplayText, romoSelectDropdown) {
    this.romoSelectDropdown.doFocus();
    this.elem.trigger('select:itemSelected', [itemValue, itemDisplayText, this]);
  }, this));
  this.romoSelectDropdown.elem.on('romoSelectDropdown:newItemSelected', $.proxy(function(e, itemValue, itemDisplayText, romoSelectDropdown) {
    if (this.romoSelectedOptionsList !== undefined) {
      var currentValues = this._elemValues();
      if (!currentValues.includes(itemValue)) {
        this._setValues(currentValues.concat([itemValue]));
        this.romoSelectedOptionsList.doAddItem({
          'value':       itemValue,
          'displayText': itemDisplayText
        });
      }
    } else {
      this._setValues([itemValue]);
    }
    this._refreshUI();
    this.elem.trigger('select:newItemSelected', [itemValue, itemDisplayText, this]);
  }, this));
  this.romoSelectDropdown.elem.on('romoSelectDropdown:change', $.proxy(function(e, newValue, prevValue, romoSelectDropdown) {
    this.elem.trigger('change');
    this.elem.trigger('select:change', [newValue, prevValue, this]);
  }, this));
}

RomoSelect.prototype._buildSelectDropdownElem = function() {
  var romoSelectDropdownElem = $('

');

  romoSelectDropdownElem.attr('data-romo-dropdown-position', this.elem.data('romo-select-dropdown-position'));
  romoSelectDropdownElem.attr('data-romo-dropdown-style-class', this.elem.data('romo-select-dropdown-style-class'));
  romoSelectDropdownElem.attr('data-romo-dropdown-min-height', this.elem.data('romo-select-dropdown-min-height'));
  romoSelectDropdownElem.attr('data-romo-dropdown-max-height', this.elem.data('romo-select-dropdown-max-height'));
  romoSelectDropdownElem.attr('data-romo-dropdown-height', this.elem.data('romo-select-dropdown-height'));
  romoSelectDropdownElem.attr('data-romo-dropdown-overflow-x', 'hidden');
  romoSelectDropdownElem.attr('data-romo-dropdown-width', 'elem');
  if (romoSelectDropdownElem.data('romo-dropdown-max-height') === undefined) {
    romoSelectDropdownElem.attr('data-romo-dropdown-max-height', 'detect');
  }
  if (this.elem.data('romo-select-filter-placeholder') !== undefined) {
    romoSelectDropdownElem.attr('data-romo-select-dropdown-filter-placeholder', this.elem.data('romo-select-filter-placeholder'));
  }
  if (this.elem.data('romo-select-filter-indicator') !== undefined) {
    romoSelectDropdownElem.attr('data-romo-select-dropdown-filter-indicator', this.elem.data('romo-select-filter-indicator'));
  }
  if (this.elem.data('romo-select-filter-indicator-width-px') !== undefined) {
    romoSelectDropdownElem.attr('data-romo-select-dropdown-filter-indicator-width-px', this.elem.data('romo-select-filter-indicator-width-px'));
  }
  if (this.elem.data('romo-select-no-filter') !== undefined) {
    romoSelectDropdownElem.attr('data-romo-select-dropdown-no-filter', this.elem.data('romo-select-no-filter'));
  }
  if (this.elem.data('romo-select-custom-option') !== undefined) {
    romoSelectDropdownElem.attr('data-romo-select-dropdown-custom-option', this.elem.data('romo-select-custom-option'));
  }
  if (this.elem.data('romo-select-custom-option-prompt') !== undefined) {
    romoSelectDropdownElem.attr('data-romo-select-dropdown-custom-option-prompt', this.elem.data('romo-select-custom-option-prompt'));
  }
  if (this.elem.data('romo-select-open-on-focus') !== undefined) {
    romoSelectDropdownElem.attr('data-romo-select-dropdown-open-on-focus', this.elem.data('romo-select-open-on-focus'));
  }

  var classList = this.elem.attr('class') !== undefined ? this.elem.attr('class').split(/\s+/) : [];
  $.each(classList, function(idx, classItem) {
    romoSelectDropdownElem.addClass(classItem);
  });
  if (this.elem.attr('style') !== undefined) {
    romoSelectDropdownElem.attr('style', this.elem.attr('style'));
  }
  romoSelectDropdownElem.css({'width': this.elem.css('width')});
  if (this.elem.attr('disabled') !== undefined) {
    this.romoSelectDropdown.elem.attr('disabled', this.elem.attr('disabled'));
  }

  this.elem.after(romoSelectDropdownElem);
  this.elem.hide();

  this.elemWrapper = $('

');
  if (this.elem.data('romo-select-btn-group') === true) {
    this.elemWrapper.addClass('romo-btn-group');
  }
  romoSelectDropdownElem.before(this.elemWrapper);
  this.elemWrapper.append(romoSelectDropdownElem);

  // the elem wrapper should be treated like a child elem.  add it to Romo's
  // parent-child elems so it will be removed when the elem (select) is removed.
  // delay adding it b/c other components may `append` generated selects
  // meaning the select is removed and then re-added.  if added immediately
  // the "remove" part will incorrectly remove the wrapper.
  setTimeout($.proxy(function() {
    Romo.parentChildElems.add(this.elem, [this.elemWrapper]);
  }, this), 1);

  this.caretElem = $();
  var caretClass = this.elem.data('romo-select-caret') || this.defaultCaretClass;
  if (caretClass !== undefined && caretClass !== 'none') {
    this.caretElem = $('');
    this.caretElem.css('line-height', parseInt(Romo.getComputedStyle(romoSelectDropdownElem[0], "line-height"), 10)+'px');
    this.caretElem.on('click', $.proxy(this._onCaretClick, this));
    romoSelectDropdownElem.append(this.caretElem);

    var caretPaddingPx = this._getCaretPaddingPx();
    var caretWidthPx   = this._getCaretWidthPx();
    var caretPosition  = this._getCaretPosition();

    // add a pixel to account for the default input border
    this.caretElem.css(caretPosition, caretPaddingPx+1);

    // left-side padding
    // + caret width
    // + right-side padding
    var dropdownPaddingPx = caretPaddingPx + caretWidthPx + caretPaddingPx;
    romoSelectDropdownElem.css('padding-'+caretPosition, dropdownPaddingPx+'px');
  }

  return romoSelectDropdownElem;
}

RomoSelect.prototype._setValues = function(newValues) {
  var currentValues = this._elemValues();

  var unsetValues = currentValues.filter(function(value) {
    return newValues.indexOf(value) === -1;
  });
  var setValues = newValues.filter(function(value) {
    return currentValues.indexOf(value) === -1;
  });
  var unsetElems = unsetValues.reduce($.proxy(function(elems, value) {
    return elems.add(this.elem.find('OPTION[value="'+value+'"]'));
  }, this), $());
  var setElems = setValues.reduce($.proxy(function(elems, value) {
    return elems.add(this.elem.find('OPTION[value="'+value+'"]'));
  }, this), $());

  unsetElems.removeAttr('selected');
  unsetElems.prop('selected', false);
  setElems.attr('selected', 'selected');
  setElems.prop('selected', true);
}

RomoSelect.prototype._elemValues = function() {
  var selectedNodes = this.elem.find('OPTION[selected]').get();
  if (selectedNodes.length === 0 && this.romoSelectedOptionsList === undefined) {
    // if a non-multi select has no selected options, treat the first option as selected
    selectedNodes = [this.elem.find('OPTION')[0]];
  }
  return selectedNodes.map(function(node) {
    return ($(node).attr('value') || '');
  });
}

RomoSelect.prototype._refreshUI = function() {
  var text = undefined;
  if (this.romoSelectedOptionsList !== undefined) {
    text = '';
    this.romoSelectedOptionsList.doRefreshUI();
  } else {
    text = this.elem.find('OPTION[value="'+this._elemValues()[0]+'"]').text().trim();
  }
  if (text === '') {
    text = ' '
  }
  this.romoSelectDropdown.elem.find('.romo-select-text').html(text);
}

RomoSelect.prototype._onCaretClick = function(e) {
  if (this.elem.prop('disabled') === false) {
    this.romoSelectDropdown.doFocus();
    this.elem.trigger('select:triggerPopupOpen');
  }
}

RomoSelect.prototype._getCaretPaddingPx = function() {
  return (
    this.elem.data('romo-select-caret-padding-px') ||
    this.defaultCaretPaddingPx
  );
}

RomoSelect.prototype._getCaretWidthPx = function() {
  return (
    this.elem.data('romo-select-caret-width-px') ||
    parseInt(Romo.getComputedStyle(this.caretElem[0], "width"), 10)
  );
}

RomoSelect.prototype._getCaretPosition = function() {
  return (
    this.elem.data('romo-select-caret-position') ||
    this.defaultCaretPosition
  );
}

Romo.onInitUI(function(elem) {
  Romo.initUIElems(elem, '[data-romo-select-auto="true"]').forEach(function(elem) { new RomoSelect(elem); });
});
<commit_msg>Update `RomoSelect` component to not use jquery<commit_after>var RomoSelect = function(elem) {
  this.elem = elem;

  this.defaultCaretClass     = undefined;
  this.defaultCaretPaddingPx = 5;
  this.defaultCaretPosition  = 'right'

  this.doInit();
  this._bindElem();

  this.doSetValue(this._elemValues());

  if (Romo.attr(this.elem, 'id') !== undefined) {
    var labelElem = Romo.f('label[for="'+Romo.attr(this.elem, 'id')+'"]')[0]
    labelElem.on('click', Romo.proxy(function(e) {
      this.romoSelectDropdown.doFocus();
    }, this));
  }

  Romo.on(window, "pageshow", Romo.proxy(function(e) {
    this._refreshUI();
  }, this));

  Romo.on(this.elem, 'romoSelect:triggerSetValue', Romo.proxy(function(e, value) {
    this.doSetValue(value)
  }, this));

  Romo.trigger(this.elem, 'romoSelect:ready', [this]);
}

RomoSelect.prototype.doInit = function() {
  // override as needed
}

RomoSelect.prototype.doSetValue = function(value) {
  var values = Romo.array(value).filter(Romo.proxy(function(v) {
    return Romo.find(this.elem, 'OPTION[value="'+v+'"]')[0] !== undefined;
  }, this));

  this._setValues(values);
  if (this.romoSelectedOptionsList !== undefined) {
    var items = values.map(Romo.proxy(function(value) {
      return {
        'value':       value,
        'displayText': Romo.find(this.elem, 'OPTION[value="'+value+'"]')[0].innerText.trim()
      };
    }, this));
    this.romoSelectedOptionsList.doSetItems(items);
  } else {
    this.romoSelectDropdown.doSetSelectedItem(values[0]);
  }
  this._refreshUI();
}

/* private */

RomoSelect.prototype._bindElem = function() {
  this._bindSelectDropdown();
  this._bindSelectedOptionsList();

  Romo.on(this.elem, 'romoSelect:triggerToggle', Romo.proxy(function(e) {
    Romo.trigger(this.romoSelectDropdown.elem, 'romoSelectDropdown:triggerToggle', []);
  }, this));
  Romo.on(this.elem, 'romoSelect:triggerPopupOpen', Romo.proxy(function(e) {
    Romo.trigger(this.romoSelectDropdown.elem, 'romoSelectDropdown:triggerPopupOpen', []);
  }, this));
  Romo.on(this.elem, 'romoSelect:triggerPopupClose', Romo.proxy(function(e) {
    Romo.trigger(this.romoSelectDropdown.elem, 'romoSelectDropdown:triggerPopupClose', []);
  }, this));
}

RomoSelect.prototype._bindSelectedOptionsList = function() {
  this.romoSelectedOptionsList = undefined;
  if (this.elem.multiple === true) {
    if (Romo.data(this.elem, 'romo-select-multiple-item-class') !== undefined) {
      Romo.setData(this.romoSelectDropdown.elem, 'romo-selected-options-list-item-class', Romo.data(this.elem, 'romo-select-multiple-item-class'));
    }
    if (Romo.data(this.elem, 'romo-select-multiple-max-rows') !== undefined) {
      Romo.setData(this.romoSelectDropdown.elem, 'romo-selected-options-list-max-rows', Romo.data(this.elem, 'romo-select-multiple-max-rows'));
    }

    this.romoSelectedOptionsList = new RomoSelectedOptionsList(this.romoSelectDropdown.elem);
    Romo.on(this.romoSelectedOptionsList.elem, 'romoSelectedOptionsList:itemClick', Romo.proxy(function(e, itemValue, romoSelectedOptionsList) {
      var currentValues = this._elemValues();
      var index         = currentValues.indexOf(itemValue);
      if (index > -1) {
        currentValues.splice(index, 1);
        this._setValues(currentValues);
      }
      this.romoSelectedOptionsList.doRemoveItem(itemValue);
      this._refreshUI();
    }, this));
    Romo.on(this.romoSelectedOptionsList.elem, 'romoSelectedOptionsList:listClick', Romo.proxy(function(e, romoSelectedOptionsList) {
      Romo.trigger(this.romoSelectDropdown.elem, 'romoDropdown:triggerPopupClose', []);
      this.romoSelectDropdown.doFocus(false);
    }, this));

    Romo.before(this.elemWrapper, this.romoSelectedOptionsList.elem);
    this.romoSelectedOptionsList.doRefreshUI();
  }
}

RomoSelect.prototype._bindSelectDropdown = function() {
  this.romoSelectDropdown = new RomoSelectDropdown(this._buildSelectDropdownElem());

  Romo.on(this.romoSelectDropdown.elem, 'romoSelectDropdown:romoDropdown:toggle', Romo.proxy(function(e, romoDropdown, romoSelectDropdown) {
    Romo.trigger(this.elem, 'romoSelect:romoDropdown:toggle', [romoDropdown, this]);
  }, this));
  Romo.on(this.romoSelectDropdown.elem, 'romoSelectDropdown:romoDropdown:popupOpen', Romo.proxy(function(e, romoDropdown, romoSelectDropdown) {
    Romo.trigger(this.elem, 'romoSelect:romoDropdown:popupOpen', [romoDropdown, this]);
  }, this));
  Romo.on(this.romoSelectDropdown.elem, 'romoSelectDropdown:romoDropdown:popupClose', Romo.proxy(function(e, romoDropdown, romoSelectDropdown) {
    Romo.trigger(this.elem, 'romoSelect:romoDropdown:popupClose', [romoDropdown, this]);
  }, this));

  Romo.on(this.romoSelectDropdown.elem, 'romoSelectDropdown:itemSelected', Romo.proxy(function(e, itemValue, itemDisplayText, romoSelectDropdown) {
    this.romoSelectDropdown.doFocus();
    Romo.trigger(this.elem, 'romoSelect:itemSelected', [itemValue, itemDisplayText, this]);
  }, this));
  Romo.on(this.romoSelectDropdown.elem, 'romoSelectDropdown:newItemSelected', Romo.proxy(function(e, itemValue, itemDisplayText, romoSelectDropdown) {
    if (this.romoSelectedOptionsList !== undefined) {
      var currentValues = this._elemValues();
      if (!currentValues.includes(itemValue)) {
        this._setValues(currentValues.concat([itemValue]));
        this.romoSelectedOptionsList.doAddItem({
          'value':       itemValue,
          'displayText': itemDisplayText
        });
      }
    } else {
      this._setValues([itemValue]);
    }
    this._refreshUI();
    Romo.trigger(this.elem, 'romoSelect:newItemSelected', [itemValue, itemDisplayText, this]);
  }, this));
  Romo.on(this.romoSelectDropdown.elem, 'romoSelectDropdown:change', Romo.proxy(function(e, newValue, prevValue, romoSelectDropdown) {
    Romo.trigger(this.elem, 'change');
    Romo.trigger(this.elem, 'romoSelect:change', [newValue, prevValue, this]);
  }, this));
}

RomoSelect.prototype._buildSelectDropdownElem = function() {
  var romoSelectDropdownElem = Romo.elems('

')[0];

  Romo.setData(romoSelectDropdownElem, 'romo-dropdown-position',    Romo.data(this.elem, 'romo-select-dropdown-position'));
  Romo.setData(romoSelectDropdownElem, 'romo-dropdown-style-class', Romo.data(this.elem, 'romo-select-dropdown-style-class'));
  Romo.setData(romoSelectDropdownElem, 'romo-dropdown-min-height',  Romo.data(this.elem, 'romo-select-dropdown-min-height'));
  Romo.setData(romoSelectDropdownElem, 'romo-dropdown-max-height',  Romo.data(this.elem, 'romo-select-dropdown-max-height'));
  Romo.setData(romoSelectDropdownElem, 'romo-dropdown-height',      Romo.data(this.elem, 'romo-select-dropdown-height'));
  Romo.setData(romoSelectDropdownElem, 'romo-dropdown-overflow-x',  'hidden');
  Romo.setData(romoSelectDropdownElem, 'romo-dropdown-width',       'elem');
  if (Romo.data(romoSelectDropdownElem, 'romo-dropdown-max-height') === undefined) {
    Romo.setData(romoSelectDropdownElem, 'romo-dropdown-max-height', 'detect');
  }
  if (Romo.data(this.elem, 'romo-select-filter-placeholder') !== undefined) {
    Romo.setData(romoSelectDropdownElem, 'romo-select-dropdown-filter-placeholder', Romo.data(this.elem, 'romo-select-filter-placeholder'));
  }
  if (Romo.data(this.elem, 'romo-select-filter-indicator') !== undefined) {
    Romo.setData(romoSelectDropdownElem, 'romo-select-dropdown-filter-indicator', Romo.data(this.elem, 'romo-select-filter-indicator'));
  }
  if (Romo.data(this.elem, 'romo-select-filter-indicator-width-px') !== undefined) {
    Romo.setData(romoSelectDropdownElem, 'romo-select-dropdown-filter-indicator-width-px', Romo.data(this.elem, 'romo-select-filter-indicator-width-px'));
  }
  if (Romo.data(this.elem, 'romo-select-no-filter') !== undefined) {
    Romo.setData(romoSelectDropdownElem, 'romo-select-dropdown-no-filter', Romo.data(this.elem, 'romo-select-no-filter'));
  }
  if (Romo.data(this.elem, 'romo-select-custom-option') !== undefined) {
    Romo.setData(romoSelectDropdownElem, 'romo-select-dropdown-custom-option', Romo.data(this.elem, 'romo-select-custom-option'));
  }
  if (Romo.data(this.elem, 'romo-select-custom-option-prompt') !== undefined) {
    Romo.setData(romoSelectDropdownElem, 'romo-select-dropdown-custom-option-prompt', Romo.data(this.elem, 'romo-select-custom-option-prompt'));
  }
  if (Romo.data(this.elem, 'romo-select-open-on-focus') !== undefined) {
    Romo.setData(romoSelectDropdownElem, 'romo-select-dropdown-open-on-focus', Romo.data(this.elem, 'romo-select-open-on-focus'));
  }

  var classList = Romo.attr(this.elem, 'class') !== undefined ? Romo.attr(this.elem, 'class').split(/\s+/) : [];
  classList.forEach(Romo.proxy(function(classItem) {
    Romo.addClass(romoSelectDropdownElem, classItem);
  }, this));
  if (Romo.attr(this.elem, 'style') !== undefined) {
    Romo.setAttr(romoSelectDropdownElem, 'style', Romo.attr(this.elem, 'style'));
  }
  Romo.setStyle(romoSelectDropdownElem, 'width', Romo.css(this.elem, 'width'));
  if (Romo.attr(this.elem, 'disabled') !== undefined) {
    Romo.setAttr(this.romoSelectDropdown.elem, 'disabled', Romo.attr(this.elem, 'disabled'));
  }

  Romo.after(this.elem, romoSelectDropdownElem);
  Romo.hide(this.elem);

  this.elemWrapper = Romo.elems('

')[0];
  if (Romo.data(this.elem, 'romo-select-btn-group') === true) {
    Romo.addClass(this.elemWrapper, 'romo-btn-group');
  }
  Romo.before(romoSelectDropdownElem, this.elemWrapper);
  Romo.append(this.elemWrapper, romoSelectDropdownElem);

  // the elem wrapper should be treated like a child elem.  add it to Romo's
  // parent-child elems so it will be removed when the elem (select) is removed.
  // delay adding it b/c other components may `append` generated selects
  // meaning the select is removed and then re-added.  if added immediately
  // the "remove" part will incorrectly remove the wrapper.
  setTimeout(Romo.proxy(function() {
    Romo.parentChildElems.add(this.elem, [this.elemWrapper]);
  }, this), 1);

  this.caretElem = undefined;
  var caretClass = Romo.data(this.elem, 'romo-select-caret') || this.defaultCaretClass;
  if (caretClass !== undefined && caretClass !== 'none') {
    this.caretElem = Romo.elems('')[0];
    Romo.setStyle(this.caretElem, 'line-height', parseInt(Romo.css(romoSelectDropdownElem, "line-height"), 10)+'px');
    Romo.on(this.caretElem, 'click', Romo.proxy(this._onCaretClick, this));
    Romo.append(romoSelectDropdownElem, this.caretElem);

    var caretPaddingPx = this._getCaretPaddingPx();
    var caretWidthPx   = this._getCaretWidthPx();
    var caretPosition  = this._getCaretPosition();

    // add a pixel to account for the default input border
    Romo.setStyle(this.caretElem, caretPosition, caretPaddingPx+1);

    // left-side padding
    // + caret width
    // + right-side padding
    var dropdownPaddingPx = caretPaddingPx + caretWidthPx + caretPaddingPx;
    Romo.setStyle(romoSelectDropdownElem, 'padding-'+caretPosition, dropdownPaddingPx+'px');
  }

  return romoSelectDropdownElem;
}

RomoSelect.prototype._setValues = function(newValues) {
  var currentValues = this._elemValues();

  var unsetValues = currentValues.filter(function(value) {
    return newValues.indexOf(value) === -1;
  });
  var setValues = newValues.filter(function(value) {
    return currentValues.indexOf(value) === -1;
  });
  var unsetElems = unsetValues.map(Romo.proxy(function(value) {
    return Romo.find(this.elem, 'OPTION[value="'+value+'"]')[0];
  }, this));
  var setElems = setValues.reduce(Romo.proxy(function(value) {
    return Romo.find(this.elem, 'OPTION[value="'+value+'"]')[0];
  }, this));

  unsetElems.forEach(Romo.proxy(function(unsetElem) {
    Romo.rmAttr(unsetElem, 'selected');
    unsetElem.selected = false;
  }, this));
  setElems.forEach(Romo.proxy(function(setElem) {
    Romo.setAttr(setElem, 'selected', 'selected');
    setElem.selected = true;
  }, this));
}

RomoSelect.prototype._elemValues = function() {
  var selectedOptElems = Romo.find(this.elem, 'OPTION[selected]');
  if (selectedOptElems.length === 0 && this.romoSelectedOptionsList === undefined) {
    // if a non-multi select has no selected options, treat the first option as selected
    selectedOptElems = [Romo.find(this.elem, 'OPTION')[0]];
  }
  return selectedOptElems.map(function(selectedOptElem) {
    return (Romo.attr(selectedOptElem, 'value') || '');
  });
}

RomoSelect.prototype._refreshUI = function() {
  var text = undefined;
  if (this.romoSelectedOptionsList !== undefined) {
    text = '';
    this.romoSelectedOptionsList.doRefreshUI();
  } else {
    text = Romo.find(this.elem, 'OPTION[value="'+this._elemValues()[0]+'"]').innerText.trim();
  }
  if (text === '') {
    text = ' '
  }
  Romo.find(this.romoSelectDropdown.elem, '.romo-select-text')[0].innerText = text;
}

RomoSelect.prototype._onCaretClick = function(e) {
  if (this.elem.disabled === false) {
    this.romoSelectDropdown.doFocus();
    Romo.trigger(this.elem, 'romoSelect:triggerPopupOpen');
  }
}

RomoSelect.prototype._getCaretPaddingPx = function() {
  return (
    Romo.data(this.elem, 'romo-select-caret-padding-px') ||
    this.defaultCaretPaddingPx
  );
}

RomoSelect.prototype._getCaretWidthPx = function() {
  return (
    Romo.data(this.elem, 'romo-select-caret-width-px') ||
    parseInt(Romo.css(this.caretElem, "width"), 10)
  );
}

RomoSelect.prototype._getCaretPosition = function() {
  return (
    Romo.data(this.elem, 'romo-select-caret-position') ||
    this.defaultCaretPosition
  );
}

Romo.onInitUI(function(elem) {
  Romo.initUIElems(elem, '[data-romo-select-auto="true"]').forEach(function(elem) { new RomoSelect(elem); });
});
<|endoftext|>


<commit_before>$(document).ready(function() {
  // Stitch

  // Tags
  function tags() {
    const clientPromise = stitch.StitchClientFactory.create('tags-lmqzn');
    const targetEIN = $('h1.org-name').data('ein').toString();

    $('.chips').material_chip();

    let client;
    let db;

    function displayTagsOnLoad() {
      clientPromise.then(stitchClient => {
        client = stitchClient;
        db = client.service('mongodb', 'mongodb-atlas').db('grantmakers');
        console.log('Connected to tags data source');
        return client.login().then(displayTags);
      });
    }

    function displayTags() {
      db.collection('tags').findOne({'_id': targetEIN}).then(docs => {
        if (docs) {
          const tagData = docs.tags;
          const html = tagData.map(c => '
' + c.term + '
').join('');
          document.getElementById('tags').innerHTML = html;
          console.log('Tags fetched successfully');
        }
      });
    }

    displayTagsOnLoad();
  }
  tags();
});
<commit_msg>Fixes per Materialize upgrade<commit_after>$(document).ready(function() {
  // Stitch

  // Tags
  function tags() {
    const clientPromise = stitch.StitchClientFactory.create('tags-lmqzn');
    const targetEIN = $('h1.org-name').data('ein').toString();

    $('.chips').chips();

    let client;
    let db;

    function displayTagsOnLoad() {
      clientPromise.then(stitchClient => {
        client = stitchClient;
        db = client.service('mongodb', 'mongodb-atlas').db('grantmakers');
        console.log('Connected to tags data source');
        return client.login().then(displayTags);
      });
    }

    function displayTags() {
      db.collection('tags').findOne({'_id': targetEIN}).then(docs => {
        if (docs) {
          const tagData = docs.tags;
          const html = tagData.map(c => '
' + c.term + '
').join('');
          document.getElementById('tags').innerHTML = html;
          console.log('Tags fetched successfully');
        }
      });
    }

    displayTagsOnLoad();
  }
  tags();
});
<|endoftext|>


<commit_before><commit_msg>correctly added repeater failsafe<commit_after><|endoftext|>


<commit_before><commit_msg>comment out something silly<commit_after><|endoftext|>


<commit_before>Components.utils.import("resource://hatenabookmark/modules/00-utils.jsm");
loadPrecedingModules();

const EXPORTED_SYMBOLS = [];

// XXX ToDo: SITEINFOの外部ファイル化及びその外部ファイルの自動更新

let paragraphs = new SiteInfoSet("domain");

paragraphs.addData([
    /*
    {
        domain:
                A regular expression that matches the URL of the target page
                or a string that express a regular expression pattern.
        paragraph:
                An XPath expression that mathes article parts of the page
                or a function that returns an array of elements.
        link:
                An XPath expression that matches a link that the article
                refers to or a function that returns a element.  This parameter
                is optional.  If you omit this, the article specified in
                paragraph is used.
        annotation:
                An XPath expression that matches an element where Hatena
                Bookmark widgets are inserted or a function that returns an
                element.  This parameter is optional.  If you omit this, the
                link is used.
        annotationPosition:
                One of the strings: "before", "after", "first", "last".  This
                indicates the position where widgets are inserted, relative to
                the annotation element.  This parameter is optinal and the
                default value is "after".
        isPage:
                An XPath expression that evaluates to a boolean value that
                indicates whether the inserted element is inserted by
                AutoPagerize or such scripts, or a function that returns a
                boolean value.  This parameter is optional.  This is used for
                efficiency.
    },
    */
    { // Google Web Search
        domain:     /^http:\/\/www\.google(?:\.\w+){1,2}\/search\?/,
        paragraph:  'id("res")/div/ol/li[contains(concat(" ", @class, " "), " g ")]',
        link:       'descendant::a[contains(concat(" ", @class, " "), "l")]',
        //annotation: 'descendant::cite',
        annotation: 'descendant::span[@class = "gl"]',
        isPage:     'self::div[ol and parent::div[@id = "res"]]',
    },
    { // Yahoo Web Search
        domain:     /^http:\/\/search\.yahoo(?:\.\w+){1,2}\/search\?/,
        paragraph:  'id("yschcont")/descendant::div[@class = "web"]',
        link: function (context) {
            let link = context.getElementsByClassName("yschttl")[0];
            if (!link || !link.href) return null;
            link = link.cloneNode(true);
            let match = link.href.match(/\/\*-(.+)/);
            try {
                link.href = decodeURIComponent(match[1]);
            } catch (ex) {
                return null;
            }
            return link;
        },
        annotation: 'descendant::div[@class = "sinf"]',
        annotationPosition: 'last',
        isPage:     'self::div[@id = "yschpri"]',
    },
]);

SiteInfoSet.Paragraphs = paragraphs;
<commit_msg>検索結果でのウィジェット表示: Googleニュースを追加。<commit_after>Components.utils.import("resource://hatenabookmark/modules/00-utils.jsm");
loadPrecedingModules();

const EXPORTED_SYMBOLS = [];

// XXX ToDo: SITEINFOの外部ファイル化及びその外部ファイルの自動更新

let paragraphs = new SiteInfoSet("domain");

paragraphs.addData([
    /*
    {
        domain:
                A regular expression that matches the URL of the target page
                or a string that express a regular expression pattern.
        paragraph:
                An XPath expression that mathes article parts of the page
                or a function that returns an array of elements.
        link:
                An XPath expression that matches a link that the article
                refers to or a function that returns a element.  This parameter
                is optional.  If you omit this, the article specified in
                paragraph is used.
        annotation:
                An XPath expression that matches an element where Hatena
                Bookmark widgets are inserted or a function that returns an
                element.  This parameter is optional.  If you omit this, the
                link is used.
        annotationPosition:
                One of the strings: "before", "after", "first", "last".  This
                indicates the position where widgets are inserted, relative to
                the annotation element.  This parameter is optinal and the
                default value is "after".
        isPage:
                An XPath expression that evaluates to a boolean value that
                indicates whether the inserted element is inserted by
                AutoPagerize or such scripts, or a function that returns a
                boolean value.  This parameter is optional.  This is used for
                efficiency.
    },
    */
    { // Google Web Search
        domain:     /^http:\/\/www\.google(?:\.\w+){1,2}\/search\?/,
        paragraph:  'id("res")/div/ol/li[contains(concat(" ", @class, " "), " g ")]',
        link:       'descendant::a[contains(concat(" ", @class, " "), "l")]',
        //annotation: 'descendant::cite',
        annotation: 'descendant::span[@class = "gl"]',
        isPage:     'self::div[ol and parent::div[@id = "res"]]',
    },
    { // Google News
        domain:     /^http:\/\/news\.google(?:\.\w+){1,2}\//,
        paragraph:  'descendant::div[contains(concat(" ", @class, " "), " story ")]',
        link:       'descendant::a[starts-with(concat(" ", @class), " usg-")]',
        //annotation: 'descendant::div[contains(concat(" ", @class, " "), " sources ")]',
        //annotationPosition: 'last',
        annotation: function (context) {
            let sources = context.getElementsByClassName("sources")[0];
            return sources &&
                   (sources.getElementsByClassName("moreLinks")[0] ||
                    sources.lastChild);
        },
        isPage:     'self::*[@id = "search-stories"]',
    },
    { // Yahoo Web Search
        domain:     /^http:\/\/search\.yahoo(?:\.\w+){1,2}\/search\?/,
        paragraph:  'id("yschcont")/descendant::div[@class = "web"]',
        link: function (context) {
            let link = context.getElementsByClassName("yschttl")[0];
            if (!link || !link.href) return null;
            link = link.cloneNode(true);
            let match = link.href.match(/\/\*-(.+)/);
            try {
                link.href = decodeURIComponent(match[1]);
            } catch (ex) {
                return null;
            }
            return link;
        },
        annotation: 'descendant::div[@class = "sinf"]',
        annotationPosition: 'last',
        isPage:     'self::div[@id = "yschpri"]',
    },
]);

SiteInfoSet.Paragraphs = paragraphs;
<|endoftext|>


<commit_before>var chatPanel = document.getElementById("chatPanel");
var avatarBox = document.getElementById("imgAvatar");
var nameField = document.getElementById("ninjaName");
var mentorField = document.getElementById("mentorName");

var firstPhase = document.getElementById("chatFirstPhase");
var secondPhase = document.getElementById("chatSecondPhase");
var thirdPhase = document.getElementById("chatThirdPhase");

var opts = {};
opts.localCamBox = document.getElementById("localCamBox");
opts.remoteCamBox = document.getElementById("remoteCamBox");
opts.screenBox = document.getElementById("localScreenBox");

var firstPhaseButton = document.getElementById("firstPhaseButton");
var firstPhaseText = document.getElementById("firstPhaseText");

var secondPhaseButton = document.getElementById("secondPhaseButton");
var shareButton = document.getElementById("shareButton");
var finishButton = document.getElementById("finishButton");

var tempRoom;

var socket = io();
var webrtc;

/*
	Function to handle the receiving of ice server info.
	This the data packet should be exactly what is returned by xirsys concerning ICE connection details. Hence, all the data will be in the data.d field.
*/

function handleIceServers(data) {
	console.log(data);
	console.log(data.d);
	webrtc = webrtcInit(data.d, opts);
}

function firstPhaseClick() {
	socket.emit('requestHelp', {ninja: getParameterByName('user')});
	$(firstPhaseButton).hide();
	$(firstPhaseText).text('You are waiting in queue to be helped');
}

/*	Function to handle the changing of room.
	The data should include fields defining the name of the room and the name of ninja who will be joining
*/
function handleRoomChange (data) {
	console.log('Changing to room: ' + data.room);
	tempRoom = data.room;
	$(mentorField).text(data.mentor);
	$(firstPhase).hide();
	$(secondPhase).show();
	$(opts.localCamBox).empty();
	$(chatWindow).empty();
	webrtc.startLocalVideo();
}

function shareButtonClick() {
	webrtc.shareScreen(function (err) {
		if (err)
			console.log('Share Screen Error: ',err);
	});
}

function secondPhaseClick() {
	$(firstPhase).hide();
	document.getElementById("localCamBox").childNodes[0].muted = true;
	room = tempRoom;
	webrtc.testReadiness();
	$(secondPhase).hide();
	$(thirdPhase).show();
}

function handleMentorDisconnect (data) {
	webrtc.leaveRoom();
	webrtc.stopLocalVideo();
	webrtc.stopScreenShare();
	$(firstPhase).show();
	$(secondPhase).hide();
	$(thirdPhase).hide();
	$(firstPhaseButton).show();
	$(firstPhaseText).text("To chat with the mentor, click on 'Chat' button");
	alert("The mentor you were working with disconnected");
}

function finishChatClick() {
	$(firstPhase).show();
	$(secondPhase).hide();
	$(thirdPhase).hide();
	$(firstPhaseButton).show();
	$(firstPhaseText).text("To chat with the mentor, click on 'Chat' button");
	webrtc.leaveRoom();
	webrtc.stopLocalVideo();
	webrtc.stopScreenShare();
	socket.emit('leaving', {});
}

socket.on('iceServers',handleIceServers);
firstPhaseButton.onclick = firstPhaseClick;
socket.on('changeRoom', handleRoomChange);
shareButton.onclick = shareButtonClick;
secondPhaseButton.onclick = secondPhaseClick;
socket.on('otherDisconnect', handleMentorDisconnect);
finishButton.onclick = finishChatClick;

$(localCamBox).hide();
$(firstPhase).show();
$(secondPhase).hide();
$(thirdPhase).hide();
$(nameField).text(getParameterByName('user'));
$('#collapseTwo').collapse("hide");
socket.emit('iceRequest', {ninja : getParameterByName('user')});

<commit_msg>Update ninja.js<commit_after>var chatPanel = document.getElementById("chatPanel");
var avatarBox = document.getElementById("imgAvatar");
var nameField = document.getElementById("ninjaName");
var mentorField = document.getElementById("mentorName");

var firstPhase = document.getElementById("chatFirstPhase");
var secondPhase = document.getElementById("chatSecondPhase");
var thirdPhase = document.getElementById("chatThirdPhase");

var opts = {};
opts.localCamBox = document.getElementById("localCamBox");
opts.remoteCamBox = document.getElementById("remoteCamBox");
opts.screenBox = document.getElementById("localScreenBox");

var firstPhaseButton = document.getElementById("firstPhaseButton");
var firstPhaseText = document.getElementById("firstPhaseText");

var secondPhaseButton = document.getElementById("secondPhaseButton");
var shareButton = document.getElementById("shareButton");
var finishButton = document.getElementById("finishButton");

var tempRoom;

var socket = io();
var webrtc;

/*
	Function to handle the receiving of ice server info.
	This the data packet should be exactly what is returned by xirsys concerning ICE connection details. Hence, all the data will be in the data.d field.
*/

function handleIceServers(data) {
	console.log(data);
	console.log(data.d);
	webrtc = webrtcInit(data.d, opts);
}

function firstPhaseClick() {
	socket.emit('requestHelp', {ninja: getParameterByName('user')});
	$(firstPhaseButton).hide();
	$(firstPhaseText).text('You are waiting in queue to be helped');
}

/*	Function to handle the changing of room.
	The data should include fields defining the name of the room and the name of ninja who will be joining
*/
function handleRoomChange (data) {
	console.log('Changing to room: ' + data.room);
	tempRoom = data.room;
	$(mentorField).text(data.mentor);
	$(firstPhase).hide();
	$(secondPhase).show();
	$(opts.localCamBox).empty();
	$(chatWindow).empty();
	webrtc.startLocalVideo();
}

function shareButtonClick() {

	webrtc.stopScreenShare();
	webrtc.shareScreen(function (err) {
		if (err)
			console.log('Share Screen Error: ',err);
	});
}

function secondPhaseClick() {
	$(firstPhase).hide();
	document.getElementById("localCamBox").childNodes[0].muted = true;
	room = tempRoom;
	webrtc.testReadiness();
	$(secondPhase).hide();
	$(thirdPhase).show();
}

function handleMentorDisconnect (data) {
	webrtc.leaveRoom();
	webrtc.stopLocalVideo();
	webrtc.stopScreenShare();
	$(firstPhase).show();
	$(secondPhase).hide();
	$(thirdPhase).hide();
	$(firstPhaseButton).show();
	$(firstPhaseText).text("To chat with the mentor, click on 'Chat' button");
	alert("The mentor you were working with disconnected");
}

function finishChatClick() {
	$(firstPhase).show();
	$(secondPhase).hide();
	$(thirdPhase).hide();
	$(firstPhaseButton).show();
	$(firstPhaseText).text("To chat with the mentor, click on 'Chat' button");
	webrtc.leaveRoom();
	webrtc.stopLocalVideo();
	webrtc.stopScreenShare();
	socket.emit('leaving', {});
}

socket.on('iceServers',handleIceServers);
firstPhaseButton.onclick = firstPhaseClick;
socket.on('changeRoom', handleRoomChange);
shareButton.onclick = shareButtonClick;
secondPhaseButton.onclick = secondPhaseClick;
socket.on('otherDisconnect', handleMentorDisconnect);
finishButton.onclick = finishChatClick;

$(localCamBox).hide();
$(firstPhase).show();
$(secondPhase).hide();
$(thirdPhase).hide();
$(nameField).text(getParameterByName('user'));
$('#collapseTwo').collapse("hide");
socket.emit('iceRequest', {ninja : getParameterByName('user')});

<|endoftext|>


<commit_before>var name, position, bio, photo;
var photoRegex = /src=([a-z0-9\.\/]*)/;
//var sentenceRegex = /(\. t)|(^t)/g;
var nameSpaceRegex = /\w\S*/g;
//var nameRegex = /^[a-z]*/i;
var people = [];

function biography(name, position, bio, photo){
	var person = {position: position, bio: bio/*, anonBio: anonymize_bio(name, bio)*/};
	person.name = name.replace(nameSpaceRegex, function(txt){
		return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
	});
	person.photo = "https://imo.im/" + photoRegex.exec(photo)[1];
	people.push(person);
}
/*
function anonymize_bio(name, bio){
	var firstName = nameRegex.exec(name)[0];
	bio = bio.replace(new RegExp(name, "gi"), firstName);
	bio = bio.replace(new RegExp(firstName, "gi"), "this person");
	return bio.replace(sentenceRegex, function(v){
		return v.toUpperCase();
	});
}
*/
function render_profile(i, opts, element, anonymized){
	if(anonymized === undefined)
		anonymized = true;

	var el = $(element);
	el.html("").addClass("selected").removeClass("disabled");

	if(opts.photo){
		var img = document.createElement("img");
		img.src = people[i].photo;
		el.append(img);
	}

	if(opts.name){
		var div = document.createElement("div");
		if(!opts.photo && !opts.bio)
			$(div).html(people[i].name.replace(" ", "
"));
		else
			$(div).text(people[i].name);
		el.append(div);
	}

	if(opts.position){
		var em = document.createElement("em");
		$(em).text(people[i].position);
		el.append(em);
	}

	if(opts.bio){
		var bio = document.createElement("blockquote");
		if(anonymized)
			$(bio).text(people[i].anonBio);
		else
			$(bio).text(people[i].bio);
		el.append(bio).addClass("bio");
	}else
		el.removeClass("bio");
	el.removeClass("hidden");
}

function hide_profile(element, disabled){
	$(element).html("").addClass("hidden").removeClass("selected");
	if(disabled === true)
		$(element).addClass("disabled");
	else if(disabled !== true)
		$(element).removeClass("disabled");
}

name="ralph harik";
position="founder";
bio="Ralph has a Bachelor's and Master's degree in computer science from MIT. He spends his free time playing ice hockey, soccer, and tennis.";
photo="";
biography (name, position, bio, photo);

name="john rizzo";
position="engineer";
bio="John is currently on leave from the Computer Science Ph.D. program at Stony Brook University so that he can work full-time at imo. He has bachelor's degree in Computer Science from the University of North Texas, where he first studied music for a year. Aside from hacking and programming competitions (and working at imo!), he enjoys traveling, eating, movies, poker, and dogs.";
photo="";
biography (name, position, bio, photo);

name="nikola borisov";
position="engineer";
bio="Nikola recently graduated with a BS from Northwestern University in Computer Science, and has liked programming since middle school. He is from Sofia, Bulgaria, and likes to watch Formula 1, WRC, and other motor sports. Nikola also enjoys playing volleyball, soccer, some computer games, and card games. He also likes participating in programming and other science and robotics competitions.";
photo="";
biography (name, position, bio, photo);

name="georgios papoutsis";
position="engineer";
bio="Georgios worked as a software engineer in Germany before joining the imo team. He enjoys spending his free time with his wife and two children. When he has some more spare time (when everybody else is sleeping), he likes solving puzzles or taking part in programming competitions.";
photo="";
biography (name, position, bio, photo);

name="johan de ruiter";
position="engineer";
bio="Johan studied Computer Science at Leiden University in The Netherlands. He likes going to the gym and running, and he is very passionate about puzzles and programming competitions.";
photo="";
biography (name, position, bio, photo);

name="marissa senzaki";
position="recruiting";
bio="Marissa is a native of San Francisco and obtained her BA in Psychology from SFSU. She has worked for Facebook and Skype, and also has experience in agency recruiting, where she staffed projects for Google. When she isn't busy helping job applicants, she enjoys learning new skills like mushroom foraging and fantasy football. The two things that can always make her smile are monkeys and ice cream.";
photo="";
biography (name, position, bio, photo);

name="lorraine lee";
position="marketing";
bio="Lorraine received her Bachelor of Science in Journalism from Northwestern University's Medill School of Journalism, with a minor in French. She enjoys listening to EDM & top 40, watching shows on Netflix and spending time with friends.";
photo="";
biography (name, position, bio, photo);

name="michelle yu";
position="recruiting";
bio="Michelle is originally from Los Angeles, and received her bachelors from UC Irvine. Prior to imo.im, she worked at Google and LivingSocial. She enjoys reading, baking, traveling, and karaoke.";
photo="";
biography (name, position, bio, photo);

name="aneta willis";
position="user safety operations";
bio="Aneta grew up in Poland and Germany. She graduated from Mills College with a degree in Biopsychology. Before joining the imo team, she worked for Facebook. In her spare time, Aneta enjoys traveling, reading, science, watching movies, and spending time with her family.";
photo="";
biography (name, position, bio, photo);

name="dave keller";
position="ux designer";
bio="Dave grew up in Hawaii, New Zealand, and finally settled in California. When he's not scouring dribbble for inspiration and awesome design, he's reading comics, hanging with friends, and going to midnight showings of the latest movies.";
photo="";
biography (name, position, bio, photo);

name="greg clayman";
position="recruiting";
bio="Greg comes to imo from Zynga, where he spent a year and a half recruiting for a variety of technical roles. He received a BA in linguistics and communication from Tulane University (after some time at Brown University) and an MS at Pepperdine in intercultural communication. A former track and field athlete (and briefly a football kicker) at Tulane, Greg now spends his free time cycling, playing Boggle, guitar, drums, and keyboard, and listening to awful folk metal music.";
photo="";
biography (name, position, bio, photo);

name="georges harik";
position="founder";
bio="Georges Harik was Director of Googlettes and a Distinguished Engineer at Google. As Director of Googlettes, his team was responsible for the product management and strategy efforts surrounding many starting Google initiatives including Gmail, Google Talk, Google Video, Picasa, Orkut, Google Groups and Google Mobile.

As a Distinguished Engineer, Georges was the co-developer of the technology behind AdSense, the first engineering manager of the Google Search Appliance, and the co-author of the original product plan for the AdWords Online system. Georges has contributed to numerous patents covering Google's search engine and advertising networks.";
photo="";
biography (name, position, bio, photo);

name="erdal tuleu";
position="engineer";
bio="Erdal likes playing basketball, working at imo, and traveling. His favorite place is his hometown, Constanta. He also holds a Computer Science and Mathematics degree from Florida Tech.";
photo="";
biography (name, position, bio, photo);

name="xuan luo";
position="engineer";
bio="Xuan likes eating, sleeping, watching Naruto, updating the Internet, and helping friends.";
photo="";
biography (name, position, bio, photo);

name="brandi kolmer";
position="marketing";
bio="Brandi manages marketing and public relations activities for imo. She graduated from the University of California, Davis with a bachelors degree in International Relations. In her spare time she enjoys watching movies, reading tech blogs and playing with her pug.";
photo="";
biography (name, position, bio, photo);

name="max kulakov";
position="ux designer";
bio="Max is an experienced web designer who is passionate about beautiful yet usable and friendly interfaces. He strives to create web sites with positive user experiences that will make people happy.";
photo="";
biography (name, position, bio, photo);

name="hamza ibrahim";
position="engineer";
bio="Hamza has a BS in Computer Science from Cairo University. Besides working at imo, Hamza enjoys reading, practicing/watching sports and doing programming competitions.";
photo="";
biography (name, position, bio, photo);

name="patrick horn";
position="engineer";
bio="Patrick is a UC Berkeley EECS alumnus who enjoys biking and hiking in parks around Palo Alto. When not hacking or with his brother Daniel, he cares for his two cats, Sister and Tibby, while enjoying music, sci-fi, RPGs, and combinations thereof.";
photo="";
biography (name, position, bio, photo);

name="nhat lam";
position="engineer";
bio="Nhat has a Master's degree in computer science from UTD and now is studying towards his PhD. He'd love to join programming contests and play soccer in his free time.";
photo="";
biography (name, position, bio, photo);

name="iskren chernev";
position="engineer";
bio="Iskren has a bachelor's degree in CS from Sofia University in Bulgaria. He likes biking, skiing, and working on open source projects.";
photo="";
biography (name, position, bio, photo);

name="sarah best";
position="office manager";
bio="Sarah likes to go to Shasta Lake in the Summer to hike, swim, and wakeboard. She likes to laugh, chat with friends or spend the day in Santa Cruz going to the beach or reading a good book in a coffee shop downtown.";
photo="";
biography (name, position, bio, photo);
<commit_msg>Removed former employees; tweaked memory management<commit_after>var name, position, bio, photo;
var photoRegex = /src=([a-z0-9\.\/]*)/;
//var sentenceRegex = /(\. t)|(^t)/g;
var nameSpaceRegex = /\w\S*/g;
//var nameRegex = /^[a-z]*/i;
var people = [];

function biography(name, position, bio, photo){
	var person = {position: position, bio: bio/*, anonBio: anonymize_bio(name, bio)*/};
	person.name = name.replace(nameSpaceRegex, function(txt){
		return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
	});
	person.photo = "https://imo.im/" + photoRegex.exec(photo)[1];
	people.push(person);
}
/*
function anonymize_bio(name, bio){
	var firstName = nameRegex.exec(name)[0];
	bio = bio.replace(new RegExp(name, "gi"), firstName);
	bio = bio.replace(new RegExp(firstName, "gi"), "this person");
	return bio.replace(sentenceRegex, function(v){
		return v.toUpperCase();
	});
}
*/
function render_profile(i, opts, element, anonymized){
	if(anonymized === undefined)
		anonymized = true;

	var el = $(element);
	el.html("").addClass("selected").removeClass("disabled");

	if(opts.photo){
		var img = document.createElement("img");
		img.src = people[i].photo;
		el.append(img);
	}

	if(opts.name){
		var div = document.createElement("div");
		if(!opts.photo && !opts.bio)
			$(div).html(people[i].name.replace(" ", "
"));
		else
			$(div).text(people[i].name);
		el.append(div);
	}

	if(opts.position){
		var em = document.createElement("em");
		$(em).text(people[i].position);
		el.append(em);
	}

	if(opts.bio){
		var bio = document.createElement("blockquote");
		if(anonymized)
			$(bio).text(people[i].anonBio);
		else
			$(bio).text(people[i].bio);
		el.append(bio).addClass("bio");
	}else
		el.removeClass("bio");
	el.removeClass("hidden");
}

function hide_profile(element, disabled){
	$(element).html("").addClass("hidden").removeClass("selected");
	if(disabled === true)
		$(element).addClass("disabled");
	else if(disabled !== true)
		$(element).removeClass("disabled");
}

name="ralph harik";
position="founder";
bio="Ralph has a Bachelor's and Master's degree in computer science from MIT. He spends his free time playing ice hockey, soccer, and tennis.";
photo="";
biography (name, position, bio, photo);

name="nikola borisov";
position="engineer";
bio="Nikola recently graduated with a BS from Northwestern University in Computer Science, and has liked programming since middle school. He is from Sofia, Bulgaria, and likes to watch Formula 1, WRC, and other motor sports. Nikola also enjoys playing volleyball, soccer, some computer games, and card games. He also likes participating in programming and other science and robotics competitions.";
photo="";
biography (name, position, bio, photo);

name="georgios papoutsis";
position="engineer";
bio="Georgios worked as a software engineer in Germany before joining the imo team. He enjoys spending his free time with his wife and two children. When he has some more spare time (when everybody else is sleeping), he likes solving puzzles or taking part in programming competitions.";
photo="";
biography (name, position, bio, photo);

name="johan de ruiter";
position="engineer";
bio="Johan studied Computer Science at Leiden University in The Netherlands. He likes going to the gym and running, and he is very passionate about puzzles and programming competitions.";
photo="";
biography (name, position, bio, photo);

name="marissa senzaki";
position="recruiting";
bio="Marissa is a native of San Francisco and obtained her BA in Psychology from SFSU. She has worked for Facebook and Skype, and also has experience in agency recruiting, where she staffed projects for Google. When she isn't busy helping job applicants, she enjoys learning new skills like mushroom foraging and fantasy football. The two things that can always make her smile are monkeys and ice cream.";
photo="";
biography (name, position, bio, photo);

name="michelle yu";
position="recruiting";
bio="Michelle is originally from Los Angeles, and received her bachelors from UC Irvine. Prior to imo.im, she worked at Google and LivingSocial. She enjoys reading, baking, traveling, and karaoke.";
photo="";
biography (name, position, bio, photo);

name="aneta willis";
position="user safety operations";
bio="Aneta grew up in Poland and Germany. She graduated from Mills College with a degree in Biopsychology. Before joining the imo team, she worked for Facebook. In her spare time, Aneta enjoys traveling, reading, science, watching movies, and spending time with her family.";
photo="";
biography (name, position, bio, photo);

name="dave keller";
position="ux designer";
bio="Dave grew up in Hawaii, New Zealand, and finally settled in California. When he's not scouring dribbble for inspiration and awesome design, he's reading comics, hanging with friends, and going to midnight showings of the latest movies.";
photo="";
biography (name, position, bio, photo);

name="greg clayman";
position="recruiting";
bio="Greg comes to imo from Zynga, where he spent a year and a half recruiting for a variety of technical roles. He received a BA in linguistics and communication from Tulane University (after some time at Brown University) and an MS at Pepperdine in intercultural communication. A former track and field athlete (and briefly a football kicker) at Tulane, Greg now spends his free time cycling, playing Boggle, guitar, drums, and keyboard, and listening to awful folk metal music.";
photo="";
biography (name, position, bio, photo);

name="georges harik";
position="founder";
bio="Georges Harik was Director of Googlettes and a Distinguished Engineer at Google. As Director of Googlettes, his team was responsible for the product management and strategy efforts surrounding many starting Google initiatives including Gmail, Google Talk, Google Video, Picasa, Orkut, Google Groups and Google Mobile.

As a Distinguished Engineer, Georges was the co-developer of the technology behind AdSense, the first engineering manager of the Google Search Appliance, and the co-author of the original product plan for the AdWords Online system. Georges has contributed to numerous patents covering Google's search engine and advertising networks.";
photo="";
biography (name, position, bio, photo);

name="erdal tuleu";
position="engineer";
bio="Erdal likes playing basketball, working at imo, and traveling. His favorite place is his hometown, Constanta. He also holds a Computer Science and Mathematics degree from Florida Tech.";
photo="";
biography (name, position, bio, photo);

name="xuan luo";
position="engineer";
bio="Xuan likes eating, sleeping, watching Naruto, updating the Internet, and helping friends.";
photo="";
biography (name, position, bio, photo);

name="brandi kolmer";
position="marketing";
bio="Brandi manages marketing and public relations activities for imo. She graduated from the University of California, Davis with a bachelors degree in International Relations. In her spare time she enjoys watching movies, reading tech blogs and playing with her pug.";
photo="";
biography (name, position, bio, photo);

name="max kulakov";
position="ux designer";
bio="Max is an experienced web designer who is passionate about beautiful yet usable and friendly interfaces. He strives to create web sites with positive user experiences that will make people happy.";
photo="";
biography (name, position, bio, photo);

name="hamza ibrahim";
position="engineer";
bio="Hamza has a BS in Computer Science from Cairo University. Besides working at imo, Hamza enjoys reading, practicing/watching sports and doing programming competitions.";
photo="";
biography (name, position, bio, photo);

name="patrick horn";
position="engineer";
bio="Patrick is a UC Berkeley EECS alumnus who enjoys biking and hiking in parks around Palo Alto. When not hacking or with his brother Daniel, he cares for his two cats, Sister and Tibby, while enjoying music, sci-fi, RPGs, and combinations thereof.";
photo="";
biography (name, position, bio, photo);

name="nhat lam";
position="engineer";
bio="Nhat has a Master's degree in computer science from UTD and now is studying towards his PhD. He'd love to join programming contests and play soccer in his free time.";
photo="";
biography (name, position, bio, photo);

name="iskren chernev";
position="engineer";
bio="Iskren has a bachelor's degree in CS from Sofia University in Bulgaria. He likes biking, skiing, and working on open source projects.";
photo="";
biography (name, position, bio, photo);

name="sarah best";
position="office manager";
bio="Sarah likes to go to Shasta Lake in the Summer to hike, swim, and wakeboard. She likes to laugh, chat with friends or spend the day in Santa Cruz going to the beach or reading a good book in a coffee shop downtown.";
photo="";
biography (name, position, bio, photo);

// Clean up some variables we won't be using again
delete name;
delete position;
delete bio;
delete photo;
delete photoRegex;
delete nameSpaceRegex;
delete biography;
<|endoftext|>


<commit_before>$(function(){
	var app = {
		init: function() {
			app.init_effect();
			app.init_event();
		},

		init_effect: function() {
			$("#head_tagline h1").hide().fadeIn(700);
		},

		init_event: function() {

		}

	};
	app.init();
});
<commit_msg>no message<commit_after>$(function(){
	var app = {
		init: function() {
			app.init_effect();
			app.init_event();
		},

		init_effect: function() {
			$("#head_tagline>h1").hide().fadeIn(700);
		},

		init_event: function() {

		}

	};
	app.init();
});
<|endoftext|>


<commit_before>var assert = require('assert');

//function plus (A,B) {
//    if(A == "zero") {
//        return 0;
//    }else if (A == "one"){
//        return 1;
//    }else if (A == "two") {
//        return 2;
//    }else if (A == "three") {
//        return 3;
//    }else if (A == "four") {
//        return 4;
//    }
//}
//
//it('should add "zero" and "one"', function () {
//    assert.equal(plus("zero", "two"), 0);
//});
//
//it('should add "one" and "two"', function () {
//    assert.equal(plus("one", "two"), 1);
//});
//
//it('should add "two" and "three"', function () {
//    assert.equal(plus("two", "three"), 2);
//});
//
//it('should add "three" and "four"', function () {
//    assert.equal(plus("three", "four"), 3);
//});
//
//it('should add "four" and "five"', function () {
//    assert.equal(plus("four", "five"), 4);
//});

var stringNumbers = ["zero","one","two","three","four","five","six","seven","eight","nine","ten"];

function plus (A,B) {
    var stringNumbers = {
        "zero": 0,
        "one": 1,
        "two": 2,
        "three": 3,
        "four": 4,
        "five": 5,
        "six": 6,
        "seven": 7,
        "eight": 8,
        "nine": 9,
        "ten": 10,
    }

    return stringNumbers[B];
}<commit_msg>more string-calculator tests<commit_after>var assert = require('assert');

//function plus (A,B) {
//    if(A == "zero") {
//        return 0;
//    }else if (A == "one"){
//        return 1;
//    }else if (A == "two") {
//        return 2;
//    }else if (A == "three") {
//        return 3;
//    }else if (A == "four") {
//        return 4;
//    }
//}
//
//it('should add "zero" and "one"', function () {
//    assert.equal(plus("zero", "two"), 0);
//});
//
//it('should add "one" and "two"', function () {
//    assert.equal(plus("one", "two"), 1);
//});
//
//it('should add "two" and "three"', function () {
//    assert.equal(plus("two", "three"), 2);
//});
//
//it('should add "three" and "four"', function () {
//    assert.equal(plus("three", "four"), 3);
//});
//
//it('should add "four" and "five"', function () {
//    assert.equal(plus("four", "five"), 4);
//});

//var stringNumbers = ["zero","one","two","three","four","five","six","seven","eight","nine","ten"];

function plus (A,B) {
    var stringNumbers = {
        "zero": 0,
        "one": 1,
        "two": 2,
        "three": 3,
        "four": 4,
        "five": 5,
        "six": 6,
        "seven": 7,
        "eight": 8,
        "nine": 9,
        "ten": 10,
    }

    return stringNumbers[B];
}

it('should add "zero" to everything', function(){
  assert.equal(plus("zero", "zero"), 0);
  assert.equal(plus("zero", "one"), 1);
  assert.equal(plus("zero", "two"), 2);
  assert.equal(plus("zero", "three"), 3);
  assert.equal(plus("zero", "four"), 4);
  assert.equal(plus("zero", "five"), 5);
  assert.equal(plus("zero", "six"), 6);
  assert.equal(plus("zero", "seven"), 7);
  assert.equal(plus("zero", "eight"), 8);
  assert.equal(plus("zero", "nine"), 9);
  assert.equal(plus("zero", "ten"), 10);
});

it('should add "one" to everything', function (){
    assert.equal(plus("one", "zero"), 0);
    assert.equal(plus("one", "one"), 1);
    assert.equal(plus("one", "two"), 2);
    assert.equal(plus("one", "three"), 3);
    assert.equal(plus("one", "four"), 4);
    assert.equal(plus("one", "five"), 5);
    assert.equal(plus("one", "six"), 6);
    assert.equal(plus("one", "seven"), 7);
    assert.equal(plus("one", "eight"), 8);
    assert.equal(plus("one", "nine"), 9);
    assert.equal(plus("one", "ten"), 10);
})

it('should add "two" to everything', function (){
    assert.equal(plus("two","zero"), 0);
    assert.equal(plus("two","one"), 1);
    assert.equal(plus("two","two"), 2);
    assert.equal(plus("two","three"), 3);
    assert.equal(plus("two","four"), 4);
    assert.equal(plus("two","five"), 5);
    assert.equal(plus("two","six"), 6);
    assert.equal(plus("two","seven"), 7);
    assert.equal(plus("two","eight"), 8);
    assert.equal(plus("two","nine"), 9);
    assert.equal(plus("two","ten"), 10);
})

it('should add "three" to everything', function(){
    assert.equal(plus("three","zero"), 0);
    assert.equal(plus("three","one"), 1);
    assert.equal(plus("three","two"), 2);
    assert.equal(plus("three","three"), 3);
    assert.equal(plus("three","four"), 4);
    assert.equal(plus("three","five"), 5);
    assert.equal(plus("three","six"), 6);
    assert.equal(plus("three","seven"), 7);
    assert.equal(plus("three","eight"), 8);
    assert.equal(plus("three","nine"), 9);
    assert.equal(plus("three","ten"), 10);
})

it('should add "four" to everything', function(){
    assert.equal(plus("four","zero"), 0);
    assert.equal(plus("four","one"), 1);
    assert.equal(plus("four","two"), 2);
    assert.equal(plus("four","three"), 3);
    assert.equal(plus("four","four"), 4);
    assert.equal(plus("four","five"), 5);
    assert.equal(plus("four","six"), 6);
    assert.equal(plus("four","seven"), 7);
    assert.equal(plus("four","eight"), 8);
    assert.equal(plus("four","nine"), 9);
    assert.equal(plus("four","ten"), 10);
})

it('should add "five" to everything', function(){
    assert.equal(plus("five","zero"), 0);
    assert.equal(plus("five","one"), 1);
    assert.equal(plus("five","two"), 2);
    assert.equal(plus("five","three"), 3);
    assert.equal(plus("five","four"), 4);
    assert.equal(plus("five","five"), 5);
    assert.equal(plus("five","six"), 6);
    assert.equal(plus("five","seven"), 7);
    assert.equal(plus("five","eight"), 8);
    assert.equal(plus("five","nine"), 9);
    assert.equal(plus("five","ten"), 10);
})<|endoftext|>


<commit_before>'use strict';

const bundleTypes = {
  UMD_DEV: 'UMD_DEV',
  UMD_PROD: 'UMD_PROD',
  NODE_DEV: 'NODE_DEV',
  NODE_PROD: 'NODE_PROD',
  FB_DEV: 'FB_DEV',
  FB_PROD: 'FB_PROD',
  RN_DEV: 'RN_DEV',
  RN_PROD: 'RN_PROD',
};

const UMD_DEV = bundleTypes.UMD_DEV;
const UMD_PROD = bundleTypes.UMD_PROD;
const NODE_DEV = bundleTypes.NODE_DEV;
const NODE_PROD = bundleTypes.NODE_PROD;
const FB_DEV = bundleTypes.FB_DEV;
const FB_PROD = bundleTypes.FB_PROD;
const RN_DEV = bundleTypes.RN_DEV;
const RN_PROD = bundleTypes.RN_PROD;

const moduleTypes = {
  ISOMORPHIC: 'ISOMORPHIC',
  RENDERER: 'RENDERER',
  RENDERER_UTILS: 'RENDERER_UTILS',
  RECONCILER: 'RECONCILER',
};

// React
const ISOMORPHIC = moduleTypes.ISOMORPHIC;
// Individual renderers. They bundle the reconciler. (e.g. ReactDOM)
const RENDERER = moduleTypes.RENDERER;
// Helper packages that access specific renderer's internals. (e.g. TestUtils)
const RENDERER_UTILS = moduleTypes.RENDERER_UTILS;
// Standalone reconciler for third-party renderers.
const RECONCILER = moduleTypes.RECONCILER;

const bundles = [
  /******* Isomorphic *******/
  {
    label: 'core',
    bundleTypes: [UMD_DEV, UMD_PROD, NODE_DEV, NODE_PROD, FB_DEV, FB_PROD],
    moduleType: ISOMORPHIC,
    entry: 'react',
    global: 'React',
    externals: [],
  },

  /******* React DOM *******/
  {
    label: 'dom-client',
    bundleTypes: [UMD_DEV, UMD_PROD, NODE_DEV, NODE_PROD, FB_DEV, FB_PROD],
    moduleType: RENDERER,
    entry: 'react-dom',
    global: 'ReactDOM',
    externals: ['react'],
  },

  //******* Test Utils *******/
  {
    label: 'dom-test-utils',
    moduleType: RENDERER_UTILS,
    bundleTypes: [FB_DEV, NODE_DEV, NODE_PROD, UMD_DEV, UMD_PROD],
    entry: 'react-dom/test-utils',
    global: 'ReactTestUtils',
    externals: ['react', 'react-dom'],
  },

  /* React DOM internals required for react-native-web (e.g., to shim native events from react-dom) */
  {
    label: 'dom-unstable-native-dependencies',
    bundleTypes: [UMD_DEV, UMD_PROD, NODE_DEV, NODE_PROD, FB_DEV, FB_PROD],
    moduleType: RENDERER_UTILS,
    entry: 'react-dom/unstable-native-dependencies',
    global: 'ReactDOMUnstableNativeDependencies',
    externals: ['react', 'react-dom'],
  },

  /******* React DOM Server *******/
  {
    label: 'dom-server-browser',
    bundleTypes: [UMD_DEV, UMD_PROD, NODE_DEV, NODE_PROD, FB_DEV, FB_PROD],
    moduleType: RENDERER,
    entry: 'react-dom/server.browser',
    global: 'ReactDOMServer',
    externals: ['react'],
  },

  {
    label: 'dom-server-node',
    bundleTypes: [NODE_DEV, NODE_PROD],
    moduleType: RENDERER,
    entry: 'react-dom/server.node',
    externals: ['react', 'stream'],
  },

  /******* React ART *******/
  {
    label: 'art',
    bundleTypes: [UMD_DEV, UMD_PROD, NODE_DEV, NODE_PROD, FB_DEV, FB_PROD],
    moduleType: RENDERER,
    entry: 'react-art',
    global: 'ReactART',
    externals: ['react'],
    babel: opts =>
      Object.assign({}, opts, {
        // Include JSX
        presets: opts.presets.concat([require.resolve('babel-preset-react')]),
      }),
  },

  /******* React Native *******/
  {
    label: 'native',
    bundleTypes: [RN_DEV, RN_PROD],
    moduleType: RENDERER,
    entry: 'react-native-renderer',
    global: 'ReactNativeRenderer',
    externals: [
      'ExceptionsManager',
      'InitializeCore',
      'Platform',
      'RCTEventEmitter',
      'TextInputState',
      'UIManager',
      'View',
      'deepDiffer',
      'deepFreezeAndThrowOnMutationInDev',
      'flattenStyle',
    ],
  },

  /******* React Native Fabric *******/
  {
    label: 'native-fabric',
    bundleTypes: [RN_DEV, RN_PROD],
    moduleType: RENDERER,
    entry: 'react-native-renderer/fabric',
    global: 'ReactFabric',
    externals: [
      'ExceptionsManager',
      'InitializeCore',
      'Platform',
      'RCTEventEmitter',
      'TextInputState',
      'UIManager',
      'FabricUIManager',
      'View',
      'deepDiffer',
      'deepFreezeAndThrowOnMutationInDev',
      'flattenStyle',
    ],
  },

  /******* React Test Renderer *******/
  {
    label: 'test',
    bundleTypes: [FB_DEV, NODE_DEV, NODE_PROD],
    moduleType: RENDERER,
    entry: 'react-test-renderer',
    global: 'ReactTestRenderer',
    externals: ['react'],
  },

  {
    label: 'test-shallow',
    bundleTypes: [FB_DEV, NODE_DEV, NODE_PROD],
    moduleType: RENDERER,
    entry: 'react-test-renderer/shallow',
    global: 'ReactShallowRenderer',
    externals: ['react'],
  },

  /******* React Noop Renderer (used for tests) *******/
  {
    label: 'noop',
    bundleTypes: [NODE_DEV, NODE_PROD],
    moduleType: RENDERER,
    entry: 'react-noop-renderer',
    global: 'ReactNoopRenderer',
    externals: ['react', 'expect'],
    // React Noop uses generators. However GCC currently
    // breaks when we attempt to use them in the output.
    // So we precompile them with regenerator, and include
    // it as a runtime dependency of React Noop. In practice
    // this isn't an issue because React Noop is only used
    // in our tests. We wouldn't want to do this for any
    // public package though.
    babel: opts =>
      Object.assign({}, opts, {
        plugins: opts.plugins.concat([
          require.resolve('babel-plugin-transform-regenerator'),
        ]),
      }),
  },

  /******* React Reconciler *******/
  {
    label: 'react-reconciler',
    bundleTypes: [NODE_DEV, NODE_PROD],
    moduleType: RECONCILER,
    entry: 'react-reconciler',
    global: 'ReactReconciler',
    externals: ['react'],
  },

  /******* React Persistent Reconciler *******/
  {
    label: 'react-reconciler-persistent',
    bundleTypes: [NODE_DEV, NODE_PROD],
    moduleType: RECONCILER,
    entry: 'react-reconciler/persistent',
    global: 'ReactPersistentReconciler',
    externals: ['react'],
  },

  /******* Reflection *******/
  {
    label: 'reconciler-reflection',
    moduleType: RENDERER_UTILS,
    bundleTypes: [NODE_DEV, NODE_PROD],
    entry: 'react-reconciler/reflection',
    global: 'ReactFiberTreeReflection',
    externals: [],
  },

  /******* React Call Return (experimental) *******/
  {
    label: 'react-call-return',
    bundleTypes: [NODE_DEV, NODE_PROD],
    moduleType: ISOMORPHIC,
    entry: 'react-call-return',
    global: 'ReactCallReturn',
    externals: [],
  },

  /******* React Is *******/
  {
    label: 'react-is',
    bundleTypes: [NODE_DEV, NODE_PROD, UMD_DEV, UMD_PROD],
    moduleType: ISOMORPHIC,
    entry: 'react-is',
    global: 'ReactIs',
    externals: [],
  },

  /******* Simple Cache Provider (experimental) *******/
  {
    label: 'simple-cache-provider',
    bundleTypes: [NODE_DEV, NODE_PROD],
    moduleType: ISOMORPHIC,
    entry: 'simple-cache-provider',
    global: 'SimpleCacheProvider',
    externals: ['react'],
  },

  /******* createComponentWithSubscriptions (experimental) *******/
  {
    label: 'create-subscription',
    bundleTypes: [NODE_DEV, NODE_PROD],
    moduleType: ISOMORPHIC,
    entry: 'create-subscription',
    global: 'createSubscription',
    externals: ['react'],
  },
];

// Based on deep-freeze by substack (public domain)
function deepFreeze(o) {
  Object.freeze(o);
  Object.getOwnPropertyNames(o).forEach(function(prop) {
    if (
      o[prop] !== null &&
      (typeof o[prop] === 'object' || typeof o[prop] === 'function') &&
      !Object.isFrozen(o[prop])
    ) {
      deepFreeze(o[prop]);
    }
  });
  return o;
}

// Don't accidentally mutate config as part of the build
deepFreeze(bundles);

module.exports = {
  bundleTypes,
  moduleTypes,
  bundles,
};
<commit_msg>Include react-is in FB build targets (#12458)<commit_after>'use strict';

const bundleTypes = {
  UMD_DEV: 'UMD_DEV',
  UMD_PROD: 'UMD_PROD',
  NODE_DEV: 'NODE_DEV',
  NODE_PROD: 'NODE_PROD',
  FB_DEV: 'FB_DEV',
  FB_PROD: 'FB_PROD',
  RN_DEV: 'RN_DEV',
  RN_PROD: 'RN_PROD',
};

const UMD_DEV = bundleTypes.UMD_DEV;
const UMD_PROD = bundleTypes.UMD_PROD;
const NODE_DEV = bundleTypes.NODE_DEV;
const NODE_PROD = bundleTypes.NODE_PROD;
const FB_DEV = bundleTypes.FB_DEV;
const FB_PROD = bundleTypes.FB_PROD;
const RN_DEV = bundleTypes.RN_DEV;
const RN_PROD = bundleTypes.RN_PROD;

const moduleTypes = {
  ISOMORPHIC: 'ISOMORPHIC',
  RENDERER: 'RENDERER',
  RENDERER_UTILS: 'RENDERER_UTILS',
  RECONCILER: 'RECONCILER',
};

// React
const ISOMORPHIC = moduleTypes.ISOMORPHIC;
// Individual renderers. They bundle the reconciler. (e.g. ReactDOM)
const RENDERER = moduleTypes.RENDERER;
// Helper packages that access specific renderer's internals. (e.g. TestUtils)
const RENDERER_UTILS = moduleTypes.RENDERER_UTILS;
// Standalone reconciler for third-party renderers.
const RECONCILER = moduleTypes.RECONCILER;

const bundles = [
  /******* Isomorphic *******/
  {
    label: 'core',
    bundleTypes: [UMD_DEV, UMD_PROD, NODE_DEV, NODE_PROD, FB_DEV, FB_PROD],
    moduleType: ISOMORPHIC,
    entry: 'react',
    global: 'React',
    externals: [],
  },

  /******* React DOM *******/
  {
    label: 'dom-client',
    bundleTypes: [UMD_DEV, UMD_PROD, NODE_DEV, NODE_PROD, FB_DEV, FB_PROD],
    moduleType: RENDERER,
    entry: 'react-dom',
    global: 'ReactDOM',
    externals: ['react'],
  },

  //******* Test Utils *******/
  {
    label: 'dom-test-utils',
    moduleType: RENDERER_UTILS,
    bundleTypes: [FB_DEV, NODE_DEV, NODE_PROD, UMD_DEV, UMD_PROD],
    entry: 'react-dom/test-utils',
    global: 'ReactTestUtils',
    externals: ['react', 'react-dom'],
  },

  /* React DOM internals required for react-native-web (e.g., to shim native events from react-dom) */
  {
    label: 'dom-unstable-native-dependencies',
    bundleTypes: [UMD_DEV, UMD_PROD, NODE_DEV, NODE_PROD, FB_DEV, FB_PROD],
    moduleType: RENDERER_UTILS,
    entry: 'react-dom/unstable-native-dependencies',
    global: 'ReactDOMUnstableNativeDependencies',
    externals: ['react', 'react-dom'],
  },

  /******* React DOM Server *******/
  {
    label: 'dom-server-browser',
    bundleTypes: [UMD_DEV, UMD_PROD, NODE_DEV, NODE_PROD, FB_DEV, FB_PROD],
    moduleType: RENDERER,
    entry: 'react-dom/server.browser',
    global: 'ReactDOMServer',
    externals: ['react'],
  },

  {
    label: 'dom-server-node',
    bundleTypes: [NODE_DEV, NODE_PROD],
    moduleType: RENDERER,
    entry: 'react-dom/server.node',
    externals: ['react', 'stream'],
  },

  /******* React ART *******/
  {
    label: 'art',
    bundleTypes: [UMD_DEV, UMD_PROD, NODE_DEV, NODE_PROD, FB_DEV, FB_PROD],
    moduleType: RENDERER,
    entry: 'react-art',
    global: 'ReactART',
    externals: ['react'],
    babel: opts =>
      Object.assign({}, opts, {
        // Include JSX
        presets: opts.presets.concat([require.resolve('babel-preset-react')]),
      }),
  },

  /******* React Native *******/
  {
    label: 'native',
    bundleTypes: [RN_DEV, RN_PROD],
    moduleType: RENDERER,
    entry: 'react-native-renderer',
    global: 'ReactNativeRenderer',
    externals: [
      'ExceptionsManager',
      'InitializeCore',
      'Platform',
      'RCTEventEmitter',
      'TextInputState',
      'UIManager',
      'View',
      'deepDiffer',
      'deepFreezeAndThrowOnMutationInDev',
      'flattenStyle',
    ],
  },

  /******* React Native Fabric *******/
  {
    label: 'native-fabric',
    bundleTypes: [RN_DEV, RN_PROD],
    moduleType: RENDERER,
    entry: 'react-native-renderer/fabric',
    global: 'ReactFabric',
    externals: [
      'ExceptionsManager',
      'InitializeCore',
      'Platform',
      'RCTEventEmitter',
      'TextInputState',
      'UIManager',
      'FabricUIManager',
      'View',
      'deepDiffer',
      'deepFreezeAndThrowOnMutationInDev',
      'flattenStyle',
    ],
  },

  /******* React Test Renderer *******/
  {
    label: 'test',
    bundleTypes: [FB_DEV, NODE_DEV, NODE_PROD],
    moduleType: RENDERER,
    entry: 'react-test-renderer',
    global: 'ReactTestRenderer',
    externals: ['react'],
  },

  {
    label: 'test-shallow',
    bundleTypes: [FB_DEV, NODE_DEV, NODE_PROD],
    moduleType: RENDERER,
    entry: 'react-test-renderer/shallow',
    global: 'ReactShallowRenderer',
    externals: ['react'],
  },

  /******* React Noop Renderer (used for tests) *******/
  {
    label: 'noop',
    bundleTypes: [NODE_DEV, NODE_PROD],
    moduleType: RENDERER,
    entry: 'react-noop-renderer',
    global: 'ReactNoopRenderer',
    externals: ['react', 'expect'],
    // React Noop uses generators. However GCC currently
    // breaks when we attempt to use them in the output.
    // So we precompile them with regenerator, and include
    // it as a runtime dependency of React Noop. In practice
    // this isn't an issue because React Noop is only used
    // in our tests. We wouldn't want to do this for any
    // public package though.
    babel: opts =>
      Object.assign({}, opts, {
        plugins: opts.plugins.concat([
          require.resolve('babel-plugin-transform-regenerator'),
        ]),
      }),
  },

  /******* React Reconciler *******/
  {
    label: 'react-reconciler',
    bundleTypes: [NODE_DEV, NODE_PROD],
    moduleType: RECONCILER,
    entry: 'react-reconciler',
    global: 'ReactReconciler',
    externals: ['react'],
  },

  /******* React Persistent Reconciler *******/
  {
    label: 'react-reconciler-persistent',
    bundleTypes: [NODE_DEV, NODE_PROD],
    moduleType: RECONCILER,
    entry: 'react-reconciler/persistent',
    global: 'ReactPersistentReconciler',
    externals: ['react'],
  },

  /******* Reflection *******/
  {
    label: 'reconciler-reflection',
    moduleType: RENDERER_UTILS,
    bundleTypes: [NODE_DEV, NODE_PROD],
    entry: 'react-reconciler/reflection',
    global: 'ReactFiberTreeReflection',
    externals: [],
  },

  /******* React Call Return (experimental) *******/
  {
    label: 'react-call-return',
    bundleTypes: [NODE_DEV, NODE_PROD],
    moduleType: ISOMORPHIC,
    entry: 'react-call-return',
    global: 'ReactCallReturn',
    externals: [],
  },

  /******* React Is *******/
  {
    label: 'react-is',
    bundleTypes: [NODE_DEV, NODE_PROD, FB_DEV, FB_PROD, UMD_DEV, UMD_PROD],
    moduleType: ISOMORPHIC,
    entry: 'react-is',
    global: 'ReactIs',
    externals: [],
  },

  /******* Simple Cache Provider (experimental) *******/
  {
    label: 'simple-cache-provider',
    bundleTypes: [NODE_DEV, NODE_PROD],
    moduleType: ISOMORPHIC,
    entry: 'simple-cache-provider',
    global: 'SimpleCacheProvider',
    externals: ['react'],
  },

  /******* createComponentWithSubscriptions (experimental) *******/
  {
    label: 'create-subscription',
    bundleTypes: [NODE_DEV, NODE_PROD],
    moduleType: ISOMORPHIC,
    entry: 'create-subscription',
    global: 'createSubscription',
    externals: ['react'],
  },
];

// Based on deep-freeze by substack (public domain)
function deepFreeze(o) {
  Object.freeze(o);
  Object.getOwnPropertyNames(o).forEach(function(prop) {
    if (
      o[prop] !== null &&
      (typeof o[prop] === 'object' || typeof o[prop] === 'function') &&
      !Object.isFrozen(o[prop])
    ) {
      deepFreeze(o[prop]);
    }
  });
  return o;
}

// Don't accidentally mutate config as part of the build
deepFreeze(bundles);

module.exports = {
  bundleTypes,
  moduleTypes,
  bundles,
};
<|endoftext|>


<commit_before>/**
 * Query objects that specify keys and values in an array where all values are objects.
 * @param   {array}         array   An array where all values are objects, like [{key:1},{key:2}].
 * @param   {string}        key     The key of the object that needs to be queried.
 * @param   {string}        value   The value of the object that needs to be queried.
 * @return  {object|undefined}   Return frist object when query success.
 */
export function queryArray(array, key, value) {
  if (!Array.isArray(array)) {
    return
  }
  return array.filter(_ => _[key] === value)
}

export function randomNumber(min, max) {
  return Math.floor(Math.random() * (max - min) + min)
}

export function randomAvatar() {
  // https://uifaces.co
  const avatarList = [
    'https://randomuser.me/api/portraits/men/32.jpg',
    'https://images.pexels.com/photos/415829/pexels-photo-415829.jpeg?h=350&auto=compress&cs=tinysrgb',
    'https://d3iw72m71ie81c.cloudfront.net/female-17.jpg',
    'https://randomuser.me/api/portraits/men/35.jpg',
    'https://pbs.twimg.com/profile_images/835224725815246848/jdMBCxHS.jpg',
    'https://pbs.twimg.com/profile_images/584098247641300992/N25WgvW_.png',
    'https://d3iw72m71ie81c.cloudfront.net/male-5.jpg',
    'https://images.pexels.com/photos/413723/pexels-photo-413723.jpeg?h=350&auto=compress&cs=tinysrgb',
    'https://randomuser.me/api/portraits/women/44.jpg',
    'https://randomuser.me/api/portraits/women/68.jpg',
    'https://randomuser.me/api/portraits/women/65.jpg',
    'https://randomuser.me/api/portraits/men/43.jpg',
    'https://tinyfac.es/data/avatars/475605E3-69C5-4D2B-8727-61B7BB8C4699-500w.jpeg',
    'https://pbs.twimg.com/profile_images/943227488292962306/teiNNAiy.jpg',
    'https://randomuser.me/api/portraits/men/46.jpg'
  ]
  return avatarList[randomNumber(0, avatarList.length - 1)]
}

export const Constant = {
  ApiPrefix: '/api/v1',
  NotFound: {
    message: 'Not Found',
    documentation_url: '',
  },
  Color: {
    green: '#64ea91',
    blue: '#8fc9fb',
    purple: '#d897eb',
    red: '#f69899',
    yellow: '#f8c82e',
    peach: '#f797d6',
    borderBase: '#e5e5e5',
    borderSplit: '#f4f4f4',
    grass: '#d6fbb5',
    sky: '#c1e0fc',
  },
}

export Mock from 'mockjs'
export qs from 'qs'
<commit_msg>✨  Updating mock avatar image.<commit_after>/**
 * Query objects that specify keys and values in an array where all values are objects.
 * @param   {array}         array   An array where all values are objects, like [{key:1},{key:2}].
 * @param   {string}        key     The key of the object that needs to be queried.
 * @param   {string}        value   The value of the object that needs to be queried.
 * @return  {object|undefined}   Return frist object when query success.
 */
export function queryArray(array, key, value) {
  if (!Array.isArray(array)) {
    return
  }
  return array.filter(_ => _[key] === value)
}

export function randomNumber(min, max) {
  return Math.floor(Math.random() * (max - min) + min)
}

export function randomAvatar() {
  const avatarList = [
    'photo-1549492864-2ec7d66ffb04.jpeg',
    'photo-1480535339474-e083439a320d.jpeg',
    'photo-1523419409543-a5e549c1faa8.jpeg',
    'photo-1519648023493-d82b5f8d7b8a.jpeg',
    'photo-1523307730650-594bc63f9d67.jpeg',
    'photo-1522962506050-a2f0267e4895.jpeg',
    'photo-1489779162738-f81aed9b0a25.jpeg',
    'photo-1534308143481-c55f00be8bd7.jpeg',
    'photo-1519336555923-59661f41bb45.jpeg',
    'photo-1551438632-e8c7d9a5d1b7.jpeg',
    'photo-1525879000488-bff3b1c387cf.jpeg',
    'photo-1487412720507-e7ab37603c6f.jpeg',
    'photo-1510227272981-87123e259b17.jpeg'
  ]
  return `//image.zuiidea.com/${avatarList[randomNumber(0, avatarList.length - 1)]}?imageView2/1/w/200/h/200/format/webp/q/75|imageslim`
}

export const Constant = {
  ApiPrefix: '/api/v1',
  NotFound: {
    message: 'Not Found',
    documentation_url: '',
  },
  Color: {
    green: '#64ea91',
    blue: '#8fc9fb',
    purple: '#d897eb',
    red: '#f69899',
    yellow: '#f8c82e',
    peach: '#f797d6',
    borderBase: '#e5e5e5',
    borderSplit: '#f4f4f4',
    grass: '#d6fbb5',
    sky: '#c1e0fc',
  },
}

export Mock from 'mockjs'
export qs from 'qs'
<|endoftext|>