<commit_before>/**
 * @fileoverview Range input replacement
 * @author NathanG
 * @license MIT
 * @version 0.0.6
 */

(function() {
  'use strict';

  /**
   * Manages custom events
   *
   * @class Event
   * @private
   */
  var Event = {
    /** custom event cache */
    _cache: {},

    /**
     * Lazily evaluates which create method needed
     * @param eventName
     */
    create: function(eventName) {
      var method;
      var self = this;

      if (document.createEvent) {
        method = function(eventName) {
          var event = document.createEvent('HTMLEvents');
          event.initEvent(eventName, true, true);
          self.cache(eventName, event);
          return event;
        }
      } else {
        method = function(eventName) {
          var event = document.createEventObject();
          event.eventType = eventName;
          self.cache(eventName, event);
          return event;
        }
      }

      return (self.create = method)(eventName);
    },

    /**
     * @param eventName
     * @param event
     */
    cache: function(eventName, event) {
      event.eventName = eventName;
      this._cache[eventName] = event;
    },

    /**
     * Get or create custom event of name
     * @param {string} name
     * @returns {object} custom event
     */
    get: function(eventName) {
      return this._cache[eventName] || this.create(eventName);
    },

    /**
     * Lazily evaluates which fire event method is needed
     * @param el
     * @param eventName
     */
    fire: function(el, eventName) {
      var method;
      var self = this;

      if(document.createEvent) {
        method = function(el, eventName) {
          console.log(eventName);
          el.dispatchEvent(self.get(eventName));
        };
      } else {
        method = function(el, eventName) {
          el.fire('on' + name, self.get(eventName));
        };
      }

      (self.fire = method)(el, eventName);
    }
  };

  (function(Range) {
    // Expose range
    var define = window.define || null;

    if(typeof define === 'function' && define.amd) {
      define('range', [], function(){ return Range; });
    } else {
      window.Range = Range;
    }
  })((function(document, window, Event) {

    /**
     * Represents a range input
     *
     * @class Range
     * @param {object} el - range input to recieve facade
     */
    var Range = function(el) {
      this.input = el;

      this.value = parseFloat(el.value);
      this.max = parseFloat(el.getAttribute('max')) || 100;
      this.min = parseFloat(el.getAttribute('min')) || 0;
      this.step = parseFloat(el.getAttribute('step')) || 1;
    };

    /** @memberof Range */
    Range.prototype = {
      init: function() {
        this._render();
        this._bindEvents();
        this._setValue(this.value);
        this._list();

        return this;
      },

      _list: function() {
        if(this.input.getAttribute('list')) {
          this._generateTicks();

          var pointerWidth = this.pointerWidth;
          var hpw = pointerWidth / 2;

          this.ticks.style.padding = ['0', hpw, 'px'].join('');
          this.ticks.style.width = '100%';
          this.ticks.style.position = 'absolute';
        }
      },

      _render: function() {
        var input = this.input;
        this.el = this._template();

        input.style.display = 'none';

        input.parentNode.insertBefore(this.el, input.nextSibling);
        this._getDimensions();

        this.track.style.paddingRight = [this.pointerWidth, 'px'].join('');
      },

      _generateTicks: function() {
        var el = document.createElement('div');
        var inner = this._generateTicksInner();

        el.appendChild(inner);

        el.className = 'ticks';

        this._generateTickEls(inner);
        this.ticks = el;

        this.el.appendChild(this.ticks);
      },

      _generateTicksInner: function() {
        var inner = document.createElement('div');

        inner.className = 'ticks-inner';
        inner.style.width = '100%';
        inner.style.position = 'relative';

        return inner;
      },

      _generateTickEls: function(inner) {
        var steps = (this.max - this.min) / this.step;
        var stepPercent = 100 / steps;

        var offset;

        for(var i = 0; i <= steps; i++) {
          offset = stepPercent * i;
          inner.appendChild(this._generateTick(offset));
        }
      },

      /**
       * @private
       * @param {integer} offset - tick offset in %
       */
      _generateTick: function(offset) {
        var tick = document.createElement('div');

        tick.className = 'tick';
        tick.style.position = 'absolute';
        tick.style.left = [offset, '%'].join('');

        return tick;
      },

      _getDimensions: function() {
        this.pointerWidth = this.pointer.offsetWidth;
        var rect = this.el.getBoundingClientRect();

        this.xMin = rect.left;
        this.xMax = rect.right - this.xMin;
      },

      _template: function() {

        var el = this._rangeEl();
        this.track = this._trackEl();
        this.pointer = this._pointerEl();

        el.appendChild(this.track);
        this.track.appendChild(this.pointer);

        return el;
      },

      _rangeEl: function() {
        var  el = document.createElement('div');
        var width = this.pointerWidth || 0;

        el.className = 'range-replacement';
        el.style.position = 'relative';
        el.style.paddingRight = [width, 'px'].join('');

        return el;
      },

      /**
       * generates track html
       * @private
       */
      _trackEl: function() {
        var track = document.createElement('div');
        track.className = 'track';

        return track;
      },

      /**
       * generates pointer html
       * @private
       */
      _pointerEl: function() {
        var pointer = document.createElement('div');

        pointer.className = 'point';
        pointer.style.position = 'relative';

        return pointer;
      },

      _bindEvents: function() {
        var that = this;

        this.el.addEventListener('mousedown', function(e) {
          that._onMouseDown(e);
        });

        this.el.addEventListener('mouseup', function(e) {
          that._onMouseUp(e);
        });
      },

      /**
       * update element dimensions, and reset value and pointer position
       * to that of this.input
       */
      update: function() {
        this.value = this._roundAndLimit(parseFloat(this.input.value));

        this._getDimensions();
        this._setValue(this.value);
      },

      _onMouseDown: function(e) {
        this.oldValue = this.value;

        this._input(e);

        var that = this;

        var onMove = function(e) {
          that._input(e);
        };

        var onUp = function() {
          that._change();

          window.removeEventListener('mousemove',  onMove);
          window.removeEventListener('mouseup', onUp);
        };

        window.addEventListener('mousemove',  onMove);
        window.addEventListener('mouseup', onUp);

        Event.fire(this.input, 'mousedown');
      },

      _onMouseUp: function() {
        this._change();

        Event.fire(this.input, 'mouseup');
        Event.fire(this.input, 'click');
      },

      /**
       * Get x position of mouse during event
       *
       * @private
       * @param {object} e - event instance
       */
      _getMouseX: (function() {
        var out;

        if(typeof window.event === 'undefined') {
          out = function(e) {
            return e.pageX;
          };
        } else {
          out = function() {
            return window.event.clientX;
          };
        }

        return out;
      })(),

      /**
       * Handle input event
       *
       * @private
       */
      _input: function(e) {
        // OPTIMIZE: How not to call this each time?
        // or cache results.
        this._getDimensions();

        var x = this._getMouseX(e);

        var offsetX = x - this.xMin;
        var from = [0, this.xMax];
        var to = [this.min, this.max];

        var scaled = this._scale(offsetX, from, to);

        this._setValue(this._roundAndLimit(scaled));
      },

      /**
       * @param {number} value
       * @private
       */
      _setValue: function(value) {
        // set pointer position only when value changes
        if(value !== this.oldInputValue) {
          this.oldInputValue = this.input.value = this.newValue = value;

          var min = this.min;

          var percent = ((value - min) / (this.max - min) * 100) || 0;
          this.pointer.style.left = [percent, '%'].join('');

          // Do not fire event on first call (initialisation)
          if(this.oldValue) {
            // TODO: ie8 dosent like doing this...
            Event.fire(this.input, 'input');
          }
        }
      },

      /**
       * Handle change of value if changed
       *
       * @private
       */
      _change: function() {
        var newValue = this.newValue;
        var input = this.input;

        if(this.oldValue !== newValue) {
          input.value = this.oldValue = this.value = newValue;
          Event.fire(input, 'change');
        }
      },

      /**
       * Round to nearest step limit between min and max
       * Also ensure same decimal places as step for ie <= 9's sake. >:0
       *
       * @private
       */
      _roundAndLimit: function(n) {

        // count # of decimals in this.step
        var decimals = (this.step + '').split('.')[1];
        var places = (decimals) ? decimals.length : 0;

        var rounded = Math.round(n / this.step) * this.step;
        rounded = rounded.toFixed(places);

        return Math.min(Math.max(rounded, this.min), this.max);
      },

      /**
       * @private
       * @param {number} value - number to be rounded
       * @param {array} rangeFrom - Source range: [srcLow, srcHigh]
       * @param {array} rangeTo - Destination range: [destLow, destHigh]
       * @returns {number} - value scaled between destLow, and destHigh
       */
      _scale: function(value, rangeFrom, rangeTo) {
        var srcLow = rangeFrom[0];
        var destLow = rangeTo[0];
        var destHigh = rangeTo[1];

        var preMapped = (value - srcLow) / (rangeFrom[1] - srcLow);
        return preMapped * (destHigh - destLow) + destLow;
      }
    };

    /**
     * @param {object} el - input to be replaced
     * @returns {object} Range instance
     */
    Range['new'] = function(el) { // ie8 dont like .new
      return new Range(el).init();
    };

    /**
     * @param {string} [selector] - css selector for ranges to replace
     * @returns {array} Range instances
     */
    Range.init = function(selector) {
      selector = selector || 'input[type=range]';
      var els = document.querySelectorAll(selector);
      var ranges = [];

      for(var i = 0, l = els.length; i < l; i++) {
        ranges.push(this['new'](els[i]));
      }

      return ranges;
    };

    return Range;

  })(document, window, Event));
}).call(window);

<commit_msg>do less on load<commit_after>/**
 * @fileoverview Range input replacement
 * @author NathanG
 * @license MIT
 * @version 0.0.6
 */

(function() {
  'use strict';

  /**
   * Manages custom events
   *
   * @class Event
   * @private
   */
  var Event = {
    /** custom event cache */
    _cache: {},

    /**
     * Lazily evaluates which create method needed
     * @param eventName
     */
    create: function(eventName) {
      var method;
      var self = this;

      if (document.createEvent) {
        method = function(eventName) {
          var event = document.createEvent('HTMLEvents');
          event.initEvent(eventName, true, true);
          self.cache(eventName, event);
          return event;
        }
      } else {
        method = function(eventName) {
          var event = document.createEventObject();
          event.eventType = eventName;
          self.cache(eventName, event);
          return event;
        }
      }

      return (self.create = method)(eventName);
    },

    /**
     * @param eventName
     * @param event
     */
    cache: function(eventName, event) {
      event.eventName = eventName;
      this._cache[eventName] = event;
    },

    /**
     * Get or create custom event of name
     * @param {string} name
     * @returns {object} custom event
     */
    get: function(eventName) {
      return this._cache[eventName] || this.create(eventName);
    },

    /**
     * Lazily evaluates which fire event method is needed
     * @param el
     * @param eventName
     */
    fire: function(el, eventName) {
      var method;
      var self = this;

      if(document.createEvent) {
        method = function(el, eventName) {
          console.log(eventName);
          el.dispatchEvent(self.get(eventName));
        };
      } else {
        method = function(el, eventName) {
          el.fire('on' + name, self.get(eventName));
        };
      }

      (self.fire = method)(el, eventName);
    }
  };

  (function(Range) {
    // Expose range
    var define = window.define || null;

    if(typeof define === 'function' && define.amd) {
      define('range', [], function(){ return Range; });
    } else {
      window.Range = Range;
    }
  })((function(document, window, Event) {

    /**
     * Represents a range input
     *
     * @class Range
     * @param {object} el - range input to recieve facade
     */
    var Range = function(el) {
      this.input = el;

      this.value = parseFloat(el.value);
      this.max = parseFloat(el.getAttribute('max')) || 100;
      this.min = parseFloat(el.getAttribute('min')) || 0;
      this.step = parseFloat(el.getAttribute('step')) || 1;
    };

    /** @memberof Range */
    Range.prototype = {
      init: function() {
        this._render();
        this._bindEvents();
        this._setValue(this.value);
        this._list();

        return this;
      },

      _list: function() {
        if(this.input.getAttribute('list')) {
          this._generateTicks();

          var pointerWidth = this.pointerWidth;
          var hpw = pointerWidth / 2;

          this.ticks.style.padding = ['0', hpw, 'px'].join('');
          this.ticks.style.width = '100%';
          this.ticks.style.position = 'absolute';
        }
      },

      _render: function() {
        var input = this.input;
        this.el = this._template();

        input.style.display = 'none';

        input.parentNode.insertBefore(this.el, input.nextSibling);
        this._getDimensions();

        this.track.style.paddingRight = [this.pointerWidth, 'px'].join('');
      },

      _generateTicks: function() {
        var el = document.createElement('div');
        var inner = this._generateTicksInner();

        el.appendChild(inner);

        el.className = 'ticks';

        this._generateTickEls(inner);
        this.ticks = el;

        this.el.appendChild(this.ticks);
      },

      _generateTicksInner: function() {
        var inner = document.createElement('div');

        inner.className = 'ticks-inner';
        inner.style.width = '100%';
        inner.style.position = 'relative';

        return inner;
      },

      _generateTickEls: function(inner) {
        var steps = (this.max - this.min) / this.step;
        var stepPercent = 100 / steps;

        var offset;

        for(var i = 0; i <= steps; i++) {
          offset = stepPercent * i;
          inner.appendChild(this._generateTick(offset));
        }
      },

      /**
       * @private
       * @param {integer} offset - tick offset in %
       */
      _generateTick: function(offset) {
        var tick = document.createElement('div');

        tick.className = 'tick';
        tick.style.position = 'absolute';
        tick.style.left = [offset, '%'].join('');

        return tick;
      },

      _getDimensions: function() {
        this.pointerWidth = this.pointer.offsetWidth;
        var rect = this.el.getBoundingClientRect();

        this.xMin = rect.left;
        this.xMax = rect.right - this.xMin;
      },

      _template: function() {

        var el = this._rangeEl();
        this.track = this._trackEl();
        this.pointer = this._pointerEl();

        el.appendChild(this.track);
        this.track.appendChild(this.pointer);

        return el;
      },

      _rangeEl: function() {
        var  el = document.createElement('div');
        var width = this.pointerWidth || 0;

        el.className = 'range-replacement';
        el.style.position = 'relative';
        el.style.paddingRight = [width, 'px'].join('');

        return el;
      },

      /**
       * generates track html
       * @private
       */
      _trackEl: function() {
        var track = document.createElement('div');
        track.className = 'track';

        return track;
      },

      /**
       * generates pointer html
       * @private
       */
      _pointerEl: function() {
        var pointer = document.createElement('div');

        pointer.className = 'point';
        pointer.style.position = 'relative';

        return pointer;
      },

      _bindEvents: function() {
        var that = this;

        this.el.addEventListener('mousedown', function(e) {
          that._onMouseDown(e);
        });

        this.el.addEventListener('mouseup', function(e) {
          that._onMouseUp(e);
        });
      },

      /**
       * update element dimensions, and reset value and pointer position
       * to that of this.input
       */
      update: function() {
        this.value = this._roundAndLimit(parseFloat(this.input.value));

        this._getDimensions();
        this._setValue(this.value);
      },

      _onMouseDown: function(e) {
        this.oldValue = this.value;

        this._input(e);

        var that = this;

        var onMove = function(e) {
          that._input(e);
        };

        var onUp = function() {
          that._change();

          window.removeEventListener('mousemove',  onMove);
          window.removeEventListener('mouseup', onUp);
        };

        window.addEventListener('mousemove',  onMove);
        window.addEventListener('mouseup', onUp);

        Event.fire(this.input, 'mousedown');
      },

      _onMouseUp: function() {
        this._change();

        Event.fire(this.input, 'mouseup');
        Event.fire(this.input, 'click');
      },

      /**
       * Get x position of mouse during event
       * Lazily evaluate which method needed
       *
       * @private
       * @param {object} e - event instance
       */
      _getMouseX: function(e) {
        var method;

        if(typeof window.event === 'undefined') {
          method = function(e) {
            return e.pageX;
          };
        } else {
          method = function() {
            return window.event.clientX;
          };
        }

        return (this._getMouseX = method)(e);
      },

      /**
       * Handle input event
       *
       * @private
       */
      _input: function(e) {
        // OPTIMIZE: How not to call this each time?
        // or cache results.
        this._getDimensions();

        var x = this._getMouseX(e);

        var offsetX = x - this.xMin;
        var from = [0, this.xMax];
        var to = [this.min, this.max];

        var scaled = this._scale(offsetX, from, to);

        this._setValue(this._roundAndLimit(scaled));
      },

      /**
       * @param {number} value
       * @private
       */
      _setValue: function(value) {
        // set pointer position only when value changes
        if(value !== this.oldInputValue) {
          this.oldInputValue = this.input.value = this.newValue = value;

          var min = this.min;

          var percent = ((value - min) / (this.max - min) * 100) || 0;
          this.pointer.style.left = [percent, '%'].join('');

          // Do not fire event on first call (initialisation)
          if(this.oldValue) {
            // TODO: ie8 dosent like doing this...
            Event.fire(this.input, 'input');
          }
        }
      },

      /**
       * Handle change of value if changed
       *
       * @private
       */
      _change: function() {
        var newValue = this.newValue;
        var input = this.input;

        if(this.oldValue !== newValue) {
          input.value = this.oldValue = this.value = newValue;
          Event.fire(input, 'change');
        }
      },

      /**
       * Round to nearest step limit between min and max
       * Also ensure same decimal places as step for ie <= 9's sake. >:0
       *
       * @private
       */
      _roundAndLimit: function(n) {

        // count # of decimals in this.step
        var decimals = (this.step + '').split('.')[1];
        var places = (decimals) ? decimals.length : 0;

        var rounded = Math.round(n / this.step) * this.step;
        rounded = rounded.toFixed(places);

        return Math.min(Math.max(rounded, this.min), this.max);
      },

      /**
       * @private
       * @param {number} value - number to be rounded
       * @param {array} rangeFrom - Source range: [srcLow, srcHigh]
       * @param {array} rangeTo - Destination range: [destLow, destHigh]
       * @returns {number} - value scaled between destLow, and destHigh
       */
      _scale: function(value, rangeFrom, rangeTo) {
        var srcLow = rangeFrom[0];
        var destLow = rangeTo[0];
        var destHigh = rangeTo[1];

        var preMapped = (value - srcLow) / (rangeFrom[1] - srcLow);
        return preMapped * (destHigh - destLow) + destLow;
      }
    };

    /**
     * @param {object} el - input to be replaced
     * @returns {object} Range instance
     */
    Range['new'] = function(el) { // ie8 dont like .new
      return new Range(el).init();
    };

    /**
     * @param {string} [selector] - css selector for ranges to replace
     * @returns {array} Range instances
     */
    Range.init = function(selector) {
      selector = selector || 'input[type=range]';
      var els = document.querySelectorAll(selector);
      var ranges = [];

      for(var i = 0, l = els.length; i < l; i++) {
        ranges.push(this['new'](els[i]));
      }

      return ranges;
    };

    return Range;

  })(document, window, Event));
}).call(window);

<|endoftext|>


<commit_before>var assign = require('object-assign');
var baseRules = require('./base');
var rules = assign(baseRules, {
  'jsx-quotes': [2, 'prefer-single'],
  'react/sort-comp': 0, // enable when https://github.com/yannickcr/eslint-plugin-react/issues/128 is fixed
});

module.exports = {
  extends: 'airbnb',
  rules: rules
};
<commit_msg>Make jsx-no-bind a warning<commit_after>var assign = require('object-assign');
var baseRules = require('./base');
var rules = assign(baseRules, {
  'jsx-quotes': [2, 'prefer-single'],
  'react/jsx-no-bind': 1,
  'react/sort-comp': 0, // enable when https://github.com/yannickcr/eslint-plugin-react/issues/128 is fixed
});

module.exports = {
  extends: 'airbnb',
  rules: rules
};
<|endoftext|>


<commit_before>/*
  Framento tomado de :
  Joe Harry
  https://twitter.com/joeharry__/
  http://codepen.io/woodwork/
  http://codepen.io/woodwork/pen/pgLvEr
*/
var formContainer = $('#form-container');

bindFormClick();
//Opening the form
function bindFormClick(){
  $(formContainer).on('click', function(e) {
    e.preventDefault();
    toggleForm();
    //Ensure container doesn't togleForm when open
    $(this).off();
  });
}

//Closing the form
$('#form-close').click(function(e) {
  e.stopPropagation();
  e.preventDefault();
  toggleForm();
  bindFormClick();
});

function toggleForm(){
  $(formContainer).toggleClass('expand');
  $(formContainer).children().toggleClass('expand');
  $('.form-contacto').toggleClass('show-form-overlay');
  $('.form-submitted').removeClass('form-submitted');
}

var options = {
    url: "/contacto/",
    type: "POST",
    dataType: "json",
    success: showResponse,
    error: showError,
    resetForm: true
};

//Form validation
$('form').submit(function() {
  var form = $(this);
  form.find('.form-error').removeClass('form-error');
  var formError = false;

  form.find('.input').each(function() {
    if ($(this).val() === '') {
      $(this).addClass('form-error');
      $(this).select();
      formError = true;
      return false;
    }
    else if ($(this).hasClass('email') && !isValidEmail($(this).val())) {
      $(this).addClass('form-error');
      $(this).select();
      formError = true;
      return false;
    }
  });

  if (!formError) {
    $('.form-contacto').addClass('form-submitted');
    $('#form-head').addClass('form-submitted');
    $(this).ajaxSubmit(options);
  }
  return false;
});

// post-submit callback
function showResponse(responseText, statusText, xhr, $form)  {
    $('.thank').fadeIn(300);
    setTimeout(function(){
      toggleForm();
      bindFormClick();
      //$('form').trigger("reset");
    }, 1000);
}

function showError(response){
    $('.form-contacto').removeClass('form-submitted');
    $('#form-head').removeClass('form-submitted');
    console.log(response);
    if (response.status == 400) {
          if (response.responseJSON.nombre) {
              $('input[name="nombre"]').addClass('form-error');
              $('input[name="nombre"]').select();
          } else if (response.responseJSON.email) {
              $('input[name="email"]').addClass('form-error');
              $('input[name="email"]').select();
          } else if (response.responseJSON.asunto) {
              $('input[name="asunto"]').addClass('form-error');
              $('input[name="asunto"]').select();
          else if (response.responseJSON.telefono) {
              $('input[name="telefono"]').addClass('form-error');
              $('input[name="telefono"]').select();
          } else if (response.responseJSON.mensaje) {
              $('input[name="mensaje"]').addClass('form-error');
              $('input[name="mensaje"]').select();
          }
    }else if (response.status == 500) {
      console.log("Error 500");
    }

}

function isValidEmail(email) {
    var pattern = /^([a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+(\.[a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)*|"((([ \t]*\r\n)?[ \t]+)?([\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*(([ \t]*\r\n)?[ \t]+)?")@(([a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.)+([a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.?$/i;
    return pattern.test(email);
}
<commit_msg>contacto.js<commit_after>/*
  Framento tomado de :
  Joe Harry
  https://twitter.com/joeharry__/
  http://codepen.io/woodwork/
  http://codepen.io/woodwork/pen/pgLvEr
*/
var formContainer = $('#form-container');

bindFormClick();
//Opening the form
function bindFormClick(){
  $(formContainer).on('click', function(e) {
    e.preventDefault();
    toggleForm();
    //Ensure container doesn't togleForm when open
    $(this).off();
  });
}

//Closing the form
$('#form-close').click(function(e) {
  e.stopPropagation();
  e.preventDefault();
  toggleForm();
  bindFormClick();
});

function toggleForm(){
  $(formContainer).toggleClass('expand');
  $(formContainer).children().toggleClass('expand');
  $('.form-contacto').toggleClass('show-form-overlay');
  $('.form-submitted').removeClass('form-submitted');
}

var options = {
    url: "/contacto/",
    type: "POST",
    dataType: "json",
    success: showResponse,
    error: showError,
    resetForm: true
};

//Form validation
$('form').submit(function() {
  var form = $(this);
  form.find('.form-error').removeClass('form-error');
  var formError = false;

  form.find('.input').each(function() {
    if ($(this).val() === '') {
      $(this).addClass('form-error');
      $(this).select();
      formError = true;
      return false;
    }
    else if ($(this).hasClass('email') && !isValidEmail($(this).val())) {
      $(this).addClass('form-error');
      $(this).select();
      formError = true;
      return false;
    }
  });

  if (!formError) {
    $('.form-contacto').addClass('form-submitted');
    $('#form-head').addClass('form-submitted');
    $(this).ajaxSubmit(options);
  }
  return false;
});

// post-submit callback
function showResponse(responseText, statusText, xhr, $form)  {
    $('.thank').fadeIn(300);
    setTimeout(function(){
      toggleForm();
      bindFormClick();
      //$('form').trigger("reset");
    }, 1000);
}

function showError(response){
    $('.form-contacto').removeClass('form-submitted');
    $('#form-head').removeClass('form-submitted');
    console.log(response);
    if (response.status == 400) {
          if (response.responseJSON.nombre) {
              $('input[name="nombre"]').addClass('form-error');
              $('input[name="nombre"]').select();
          } else if (response.responseJSON.email) {
              $('input[name="email"]').addClass('form-error');
              $('input[name="email"]').select();
          } else if (response.responseJSON.asunto) {
              $('input[name="asunto"]').addClass('form-error');
              $('input[name="asunto"]').select();
          }else if (response.responseJSON.telefono) {
              $('input[name="telefono"]').addClass('form-error');
              $('input[name="telefono"]').select();
          } else if (response.responseJSON.mensaje) {
              $('input[name="mensaje"]').addClass('form-error');
              $('input[name="mensaje"]').select();
          }
    }else if (response.status == 500) {
      console.log("Error 500");
    }

}

function isValidEmail(email) {
    var pattern = /^([a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+(\.[a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)*|"((([ \t]*\r\n)?[ \t]+)?([\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*(([ \t]*\r\n)?[ \t]+)?")@(([a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.)+([a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.?$/i;
    return pattern.test(email);
}
<|endoftext|>


<commit_before>module.exports = {
  parser: "babel-eslint",

  plugins: ["react"],

  extends: ["./index.js", "./_flow-globals.js"],

  parserOptions: {
    ecmaFeatures: {
      jsx: true
    }
  },

  rules: {
    // no styles rules (=> prettier)
    "jsx-quotes": 0,
    "react/jsx-closing-bracket-location": 0,
    "react/jsx-closing-tag-location": 0,
    "react/jsx-curly-spacing": 0,
    "react/jsx-equals-spacing": 0,
    "react/jsx-first-prop-new-line": 0,
    "react/jsx-indent-props": 0,
    "react/jsx-indent": 0,
    "react/jsx-max-props-per-line": 0,
    "react/jsx-space-before-closing": 0,
    "react/jsx-tag-spacing": 0,
    "react/jsx-wrap-multilines": 0,
    "react/jsx-props-no-multi-spaces": 0,

    "react/jsx-boolean-value": [2, "never"],
    "react/jsx-filename-extension": 0, // .jsx sucks :)
    "react/jsx-handler-names": 2,
    "react/jsx-key": 2,
    "react/jsx-no-bind": 2,
    "react/jsx-no-duplicate-props": 2,
    "react/jsx-no-literals": 2,
    "react/jsx-no-target-blank": 2,
    "react/jsx-pascal-case": 2,
    "react/jsx-no-undef": 2,
    "react/jsx-sort-props": 0, // alpha order is stupid
    "react/jsx-sort-prop-types": 0, // deprecated
    "react/jsx-uses-react": 2,
    "react/jsx-uses-vars": 2,
    "react/jsx-no-comment-textnodes": 2,

    "react/button-has-type": 0,
    "react/destructuring-assignment": 0,
    "react/forbid-dom-props": 0,
    "react/jsx-child-element-spacing": 0,
    "react/jsx-curly-brace-presence": 0,
    "react/jsx-one-expression-per-line": 0,
    "react/jsx-sort-default-props": 0,
    "react/no-access-state-in-setstate": 0,
    "react/no-this-in-sfc": 0,
    "react/boolean-prop-naming": 0,
    "react/default-props-match-prop-types": 2,
    "react/display-name": 0, // transpilers does a good job for now
    "react/forbid-component-props": 0, // I know what I am doing ok?
    "react/forbid-prop-types": 0,
    "react/no-children-prop": 2,
    "react/no-danger-with-children": 2,
    "react/no-danger": 0, // dangerous properties names are clear enough
    "react/no-deprecated": 2,
    "react/no-did-mount-set-state": 0, // sometime it make sense
    "react/no-did-update-set-state": 0, // sometime it make sense
    "react/no-direct-mutation-state": 2,
    "react/no-find-dom-node": 2,
    "react/no-is-mounted": 2,
    "react/no-multi-comp": 2,
    "react/no-render-return-value": 2,
    "react/no-redundant-should-component-update": 2,
    "react/no-set-state": 0, // sometimes it's relevant
    "react/no-string-refs": 2,
    "react/no-typos": 2,
    "react/no-unescaped-entities": 2,
    "react/no-unknown-property": 2,
    "react/no-unused-prop-types": 2,
    "react/no-unused-state": 2,
    "react/no-will-update-set-state": 2,
    "react/prefer-es6-class": 2,
    "react/prefer-stateless-function": 2,
    "react/prop-types": 2,
    "react/react-in-jsx-scope": 2,
    "react/require-optimization": 0, // a bit brutal
    "react/require-render-return": 2,
    "react/self-closing-comp": 2,
    "react/sort-comp": [
      2,
      {
        order: [
          // allow to add props/state on top of react classes
          "props",
          "state",
          "type-annotations",
          "instance-variables",
          "static-methods",
          "lifecycle",
          "everything-else",
          "render"
        ]
      }
    ],
    "react/sort-prop-types": 0, // alpha order is stupid
    "react/style-prop-object": 2,

    // deprecated with v6
    "react/require-extension": 0,
    "react/wrap-multilines": 0,
    "react/no-comment-textnodes": 0,

    // too brutal
    "react/forbid-elements": 0,
    "react/forbid-foreign-prop-types": 0,
    "react/no-array-index-key": 0,
    "react/require-default-props": 0,
    "react/void-dom-elements-no-children": 0,
    "react/jsx-max-depth": 0
  }
};
<commit_msg>reorder react rules (alphabetically) for easier maintenance<commit_after>module.exports = {
  parser: "babel-eslint",

  plugins: ["react"],

  extends: ["./index.js", "./_flow-globals.js"],

  parserOptions: {
    ecmaFeatures: {
      jsx: true
    }
  },

  rules: {
    "jsx-quotes": 0,
    "react/boolean-prop-naming": 0,
    "react/button-has-type": 0,
    "react/default-props-match-prop-types": 2,
    "react/destructuring-assignment": 0,
    "react/display-name": 0, // transpilers does a good job for now
    "react/forbid-component-props": 0, // I know what I am doing ok?
    "react/forbid-dom-props": 0,
    "react/forbid-elements": 0, // too brutal
    "react/forbid-foreign-prop-types": 0, // too brutal
    "react/forbid-prop-types": 0,
    "react/jsx-boolean-value": [2, "never"],
    "react/jsx-child-element-spacing": 0,
    "react/jsx-closing-bracket-location": 0,
    "react/jsx-closing-tag-location": 0,
    "react/jsx-curly-brace-presence": 0,
    "react/jsx-curly-spacing": 0,
    "react/jsx-equals-spacing": 0,
    "react/jsx-filename-extension": 0, // .jsx sucks :)
    "react/jsx-first-prop-new-line": 0,
    "react/jsx-handler-names": 2,
    "react/jsx-indent-props": 0,
    "react/jsx-indent": 0,
    "react/jsx-key": 2,
    "react/jsx-max-depth": 0, // too brutal
    "react/jsx-max-props-per-line": 0,
    "react/jsx-no-bind": 2,
    "react/jsx-no-comment-textnodes": 2,
    "react/jsx-no-duplicate-props": 2,
    "react/jsx-no-literals": 2,
    "react/jsx-no-target-blank": 2,
    "react/jsx-no-undef": 2,
    "react/jsx-one-expression-per-line": 0,
    "react/jsx-pascal-case": 2,
    "react/jsx-props-no-multi-spaces": 0,
    "react/jsx-sort-default-props": 0,
    "react/jsx-sort-prop-types": 0, // deprecated
    "react/jsx-sort-props": 0, // alpha order is stupid
    "react/jsx-space-before-closing": 0,
    "react/jsx-tag-spacing": 0,
    "react/jsx-uses-react": 2,
    "react/jsx-uses-vars": 2,
    "react/jsx-wrap-multilines": 0,
    "react/no-access-state-in-setstate": 0,
    "react/no-array-index-key": 0, // too brutal
    "react/no-children-prop": 2,
    "react/no-comment-textnodes": 0, // deprecated with v6
    "react/no-danger-with-children": 2,
    "react/no-danger": 0, // dangerous properties names are clear enough
    "react/no-deprecated": 2,
    "react/no-did-mount-set-state": 0, // sometime it make sense
    "react/no-did-update-set-state": 0, // sometime it make sense
    "react/no-direct-mutation-state": 2,
    "react/no-find-dom-node": 2,
    "react/no-is-mounted": 2,
    "react/no-multi-comp": 2,
    "react/no-redundant-should-component-update": 2,
    "react/no-render-return-value": 2,
    "react/no-set-state": 0, // sometimes it's relevant
    "react/no-string-refs": 2,
    "react/no-this-in-sfc": 0,
    "react/no-typos": 2,
    "react/no-unescaped-entities": 2,
    "react/no-unknown-property": 2,
    "react/no-unused-prop-types": 2,
    "react/no-unused-state": 2,
    "react/no-will-update-set-state": 2,
    "react/prefer-es6-class": 2,
    "react/prefer-stateless-function": 2,
    "react/prop-types": 2,
    "react/react-in-jsx-scope": 2,
    "react/require-default-props": 0, // too brutal
    "react/require-extension": 0, // deprecated with v6
    "react/require-optimization": 0, // a bit brutal
    "react/require-render-return": 2,
    "react/self-closing-comp": 2,
    "react/sort-comp": [
      2,
      {
        order: [
          "props",
          "state",
          "type-annotations",
          "instance-variables",
          "static-methods",
          "lifecycle",
          "everything-else",
          "render"
        ]
      }
    ],
    "react/sort-prop-types": 0, // alpha order is stupid
    "react/style-prop-object": 2,
    "react/void-dom-elements-no-children": 0, // too brutal
    "react/wrap-multilines": 0 // deprecated with v6
  }
};
<|endoftext|>


<commit_before>var modules = {};
var exports = {};

// Internal Helper Functions
var runModule = function(name) {
  var toexport = modules[name]();
  if (typeof toexport === 'undefined') {
    toexport = {};
  }

  exports[name] = toexport;
};

var use = function(name) {
  if (typeof exports[name] !== 'undefined') {
    return exports[name];
  } else {
    if (modules[name]) {
      runModule(name);
    } else {
      throw 'Cannot use module `'+name+'`, as it does not exist';
    }
  }
};

var register = function(name, module, autorun) {
  if (modules[name]) {
    throw 'Cannot register module `'+name+'`, as it already exists';
  }

  modules[name] = module;

  if (autorun) {
    setTimeout(0, function() {
      // Run the module automatically
      use(name);
    });
  }
};

function module() {
  switch (arguments.length) {
    case 1:
      if (typeof arguments[0] === 'function') {
        // Anonymous module definition
        setTimeout(0, arguments[0]);
      } else {
        // Module usage
        return use(arguments[0]);
      }
      break;
    case 2:
      // Named module definition
      register(arguments[0], arguments[1], true);
      break;
    case 3:
      // Named module definition, with autorun set
      register(arguments[0], arguments[2], arguments[1]);
      break;
    default:
      throw 'module() only accepts 1, 2 or 3 arguments';
  }
}
<commit_msg>Fixed silly bug<commit_after>var modules = {};
var exports = {};

// Internal Helper Functions
var runModule = function(name) {
  var toexport = modules[name]();
  if (typeof toexport === 'undefined') {
    toexport = {};
  }

  exports[name] = toexport;
};

var use = function(name) {
  if (typeof exports[name] !== 'undefined') {
    return exports[name];
  } else {
    if (modules[name]) {
      runModule(name);
    } else {
      throw 'Cannot use module `'+name+'`, as it does not exist';
    }
  }
};

var register = function(name, module, autorun) {
  if (modules[name]) {
    throw 'Cannot register module `'+name+'`, as it already exists';
  }

  modules[name] = module;

  if (autorun) {
    setTimeout(0, function() {
      // Run the module automatically
      use(name);
    });
  }
};

module = function module() {
  switch (arguments.length) {
    case 1:
      if (typeof arguments[0] === 'function') {
        // Anonymous module definition
        setTimeout(0, arguments[0]);
      } else {
        // Module usage
        return use(arguments[0]);
      }
      break;
    case 2:
      // Named module definition
      register(arguments[0], arguments[1], true);
      break;
    case 3:
      // Named module definition, with autorun set
      register(arguments[0], arguments[2], arguments[1]);
      break;
    default:
      throw 'module() only accepts 1, 2 or 3 arguments';
  }
};
<|endoftext|>


<commit_before>var modules = {};
var exports = {};

// Internal Helper Functions
var runModule = function(name) {
  var toexport = modules[name]();
  if (typeof toexport === 'undefined') {
    toexport = {};
  }

  exports[name] = toexport;
};

var use = function(name) {
  if (typeof exports[name] !== 'undefined') {
    return exports[name];
  } else {
    if (modules[name]) {
      runModule(name);
    } else {
      throw 'Cannot use module `'+name+'`, as it does not exist';
    }
  }
};

var register = function(name, module, autorun) {
  if (modules[name]) {
    throw 'Cannot register module `'+name+'`, as it already exists';
  }

  modules[name] = module;

  if (autorun) {
    Meteor.defer(function() {
      use(name);
    });
  }
};

module = function module() {
  switch (arguments.length) {
    case 1:
      if (typeof arguments[0] === 'function') {
        // Anonymous module definition
        Meteor.defer(arguments[0]);
      } else {
        // Module usage
        return use(arguments[0]);
      }
      break;
    case 2:
      // Named module definition
      register(arguments[0], arguments[1], true);
      break;
    case 3:
      // Named module definition, with autorun set
      register(arguments[0], arguments[2], arguments[1]);
      break;
    default:
      throw 'module() only accepts 1, 2 or 3 arguments';
  }
};
<commit_msg>Fixed problem with using module for the first time<commit_after>var modules = {};
var exports = {};

// Internal Helper Functions
var runModule = function(name) {
  var toexport = modules[name]();
  if (typeof toexport === 'undefined') {
    toexport = {};
  }

  exports[name] = toexport;
  return toexport;
};

var use = function(name) {
  if (typeof exports[name] !== 'undefined') {
    return exports[name];
  } else {
    if (modules[name]) {
      return runModule(name);
    } else {
      throw 'Cannot use module `'+name+'`, as it does not exist';
    }
  }
};

var register = function(name, module, autorun) {
  if (modules[name]) {
    throw 'Cannot register module `'+name+'`, as it already exists';
  }

  modules[name] = module;

  if (autorun) {
    Meteor.defer(function() {
      use(name);
    });
  }
};

module = function module() {
  switch (arguments.length) {
    case 1:
      if (typeof arguments[0] === 'function') {
        // Anonymous module definition
        Meteor.defer(arguments[0]);
      } else {
        // Module usage
        return use(arguments[0]);
      }
      break;
    case 2:
      // Named module definition
      register(arguments[0], arguments[1], true);
      break;
    case 3:
      // Named module definition, with autorun set
      register(arguments[0], arguments[2], arguments[1]);
      break;
    default:
      throw 'module() only accepts 1, 2 or 3 arguments';
  }
};
<|endoftext|>


<commit_before>{ senderid: '4deadb0f4fe7d013dc0555f1',
  text: 'This is a test',
  userid: '4e685aac14169c225510e99d',
  command: 'pmmed',
  time: 1329875886.41 }
<commit_msg>Update turntable_data/pmmed.js<commit_after>{ senderid: '4deadb0f4fe7d013dc0555f1', // Person that sent PM.
  text: 'This is a test',
  userid: '4e685aac14169c225510e99d', // Person that received PM.
  command: 'pmmed',
  time: 1329875886.41 }
<|endoftext|>


<commit_before>Q = require('q');

var redis,
    rtg;

/* For using RedisToGo on Heroku. If you're not using RedisToGo or Heroku,
* feel free to remove this part and just use
* redis = require("redis").createClient();
*/
if(process.env.REDISTOGO_URL) {
  rtg   = require("url").parse(process.env.REDISTOGO_URL);
  redis = require("redis").createClient(rtg.port, rtg.hostname);

  redis.auth(rtg.auth.split(":")[1]);
} else {
  //then we're running locally
  redis = require("redis").createClient();
}

QRedis = {};

QRedis.sadd = Q.nbind(redis.sadd, redis);
QRedis.hmset = Q.nbind(redis.hmset, redis);
QRedis.hgetall = Q.nbind(redis.hgetall, redis);
QRedis.exists = Q.nbind(redis.exists, redis);
QRedis.del = Q.nbind(redis.del, redis);
QRedis.set = Q.nbind(redis.set, redis);
QRedis.get = Q.nbind(redis.get, redis);
QRedis.decrby = Q.nbind(redis.decrby, redis);
QRedis.smembers = Q.nbind(redis.smembers, redis);

module.exports = {};

var ret = null;

module.exports.newMatch = function(playerName, targetName) {
	var a, b;
	QRedis.exists(playerName)
    .then(function(exists){
      if(!exists) {
        a = 'no person found';
      } else {
        b = 'something exists';
      }
    })

	// console.log('a = ' + a);
	// console.log('b = ' + b);

	if (redis.exists(playerName)) {
		console.log('added new player: ' + playerName);
		console.log('added new target: ' + targetName);
      	// create a running game for the player who started the match
      	var success = redis.hmset(playerName, {
      		"targetName" : targetName,
      		"playersChoice" : "not chosen",
      		"targetsChoice" : "not chosen"
      	});
      	// create a running game for the targeted player
      	redis.hmset(targetName, {
      		"targetName" : playerName,
      		"playersChoice" : null,
      		"targetsChoice" : null
      	});

      	// return message to tell users game started
        return "Rock, Paper, Scissors, SHOOT!";
     } else {
      	ret = "You are already in a match";
      	console.log('already in a match');
        return ret;
    }
}

module.exports.shoot = function(playerName, playersChoice) {
	if ( QRedis.exists(playerName) ) {
        console.log('shoot');
        var targetName = null, targetsChoice = null;

    	// get your game
		redis.hgetall(playerName, function (err, results) {
		   if (err) {
		   		console.log('There was an error in hgetall in shoot');
		   } else {
		    	// do something with results
		    	console.log("1: " + results.targetName);
		    	targetName = results.targetName;

		    	// see if your target has chosen something yet
				if (targetName) {
					console.log("Checking for targets choice");
					redis.hgetall(targetName, function (err, results) {
						if (err) {
							console.log('There was an error');
						} else {
							console.log("2: " + results);
							if (results.playersChoice) {
								// can obtain the other person's play
								targetsChoice = results.playersChoice;

								// set your choice
						    	redis.hmset(playerName, {
						    		"targetName" : targetName,
						    		"playersChoice" : playersChoice,
						    		"targetsChoice" : targetsChoice
						    	});

						    	console.log("playersChoice: " + playersChoice);
						    	console.log("targetsChoice: " + targetsChoice);

						    	// if both choices are filled in, return who won
						    	if (playersChoice && targetsChoice) {
						    		if (playersChoice === targetsChoice) {
						    			redis.del(targetName);
						    			redis.del(playerName);
						    			return 'It\'s a tie!';
						    		} else if (playersChoice == 'paper' && targetsChoice == 'rock'
						    			|| playersChoice == 'rock' && targetsChoice == 'scissors'
						    			|| playersChoice == 'scissors' && targetsChoice) {
						    			redis.del(targetName);
						    			redis.del(playerName);
						    			return playerName + 'Wins!';

						    		} else {
						    			redis.del(targetName);
						    			redis.del(playerName);
						    			return targetName + "Wins!";
						    		}
						    	}
							} else {
								// set your choice
						    	redis.hmset(playerName, {
						    		"targetName" : targetName,
						    		"playersChoice" : playersChoice,
						    		"targetsChoice" : targetsChoice
						    	});

								// player has not chosen yet
								return "Waiting for other player to shoot";
							}
						}
					})
				}
		   }
		});
    } else {
      	console.log('a new match needs to be started');
        ret = "Start a new match: 'rps I challenge ____'";
        return ret;
    }
}

module.exports.del = function(playerName) {
	return QRedis.exists(playerName)
	    .then(function(exists){
	      if(exists) {
	      	console.log('key deleted');
	      	return QRedis.del(playerName);
	      } else {
	      	console.log('nothing to delete');
	        throw new Error("No match by that player found");
	    }
    })
}<commit_msg>null check<commit_after>Q = require('q');

var redis,
    rtg;

/* For using RedisToGo on Heroku. If you're not using RedisToGo or Heroku,
* feel free to remove this part and just use
* redis = require("redis").createClient();
*/
if(process.env.REDISTOGO_URL) {
  rtg   = require("url").parse(process.env.REDISTOGO_URL);
  redis = require("redis").createClient(rtg.port, rtg.hostname);

  redis.auth(rtg.auth.split(":")[1]);
} else {
  //then we're running locally
  redis = require("redis").createClient();
}

QRedis = {};

QRedis.sadd = Q.nbind(redis.sadd, redis);
QRedis.hmset = Q.nbind(redis.hmset, redis);
QRedis.hgetall = Q.nbind(redis.hgetall, redis);
QRedis.exists = Q.nbind(redis.exists, redis);
QRedis.del = Q.nbind(redis.del, redis);
QRedis.set = Q.nbind(redis.set, redis);
QRedis.get = Q.nbind(redis.get, redis);
QRedis.decrby = Q.nbind(redis.decrby, redis);
QRedis.smembers = Q.nbind(redis.smembers, redis);

module.exports = {};

var ret = null;

module.exports.newMatch = function(playerName, targetName) {
	var a, b;
	QRedis.exists(playerName)
    .then(function(exists){
      if(!exists) {
        a = 'no person found';
      } else {
        b = 'something exists';
      }
    })

	// console.log('a = ' + a);
	// console.log('b = ' + b);

	if (redis.exists(playerName)) {
		console.log('added new player: ' + playerName);
		console.log('added new target: ' + targetName);
      	// create a running game for the player who started the match
      	var success = redis.hmset(playerName, {
      		"targetName" : targetName,
      		"playersChoice" : "not chosen",
      		"targetsChoice" : "not chosen"
      	});
      	// create a running game for the targeted player
      	redis.hmset(targetName, {
      		"targetName" : playerName,
      		"playersChoice" : null,
      		"targetsChoice" : null
      	});

      	// return message to tell users game started
        return "Rock, Paper, Scissors, SHOOT!";
     } else {
      	ret = "You are already in a match";
      	console.log('already in a match');
        return ret;
    }
}

module.exports.shoot = function(playerName, playersChoice) {
	if ( QRedis.exists(playerName) ) {
        console.log('shoot');
        var targetName = null, targetsChoice = null;

    	// get your game
		redis.hgetall(playerName, function (err, results) {
		   if (err) {
		   		console.log('There was an error in hgetall in shoot');
		   } else {
		    	// do something with results
		    	if (results.targetName) {
			    	console.log("1: " + results.targetName);
			    	targetName = results.targetName;

			    	// see if your target has chosen something yet
					if (targetName) {
						console.log("Checking for targets choice");
						redis.hgetall(targetName, function (err, results) {
							if (err) {
								console.log('There was an error');
							} else {
								console.log("2: " + results);
								if (results.playersChoice) {
									// can obtain the other person's play
									targetsChoice = results.playersChoice;

									// set your choice
							    	redis.hmset(playerName, {
							    		"targetName" : targetName,
							    		"playersChoice" : playersChoice,
							    		"targetsChoice" : targetsChoice
							    	});

							    	console.log("playersChoice: " + playersChoice);
							    	console.log("targetsChoice: " + targetsChoice);

							    	// if both choices are filled in, return who won
							    	if (playersChoice && targetsChoice) {
							    		if (playersChoice === targetsChoice) {
							    			redis.del(targetName);
							    			redis.del(playerName);
							    			return 'It\'s a tie!';
							    		} else if (playersChoice == 'paper' && targetsChoice == 'rock'
							    			|| playersChoice == 'rock' && targetsChoice == 'scissors'
							    			|| playersChoice == 'scissors' && targetsChoice) {
							    			redis.del(targetName);
							    			redis.del(playerName);
							    			return playerName + 'Wins!';

							    		} else {
							    			redis.del(targetName);
							    			redis.del(playerName);
							    			return targetName + "Wins!";
							    		}
							    	}
								} else {
									// set your choice
							    	redis.hmset(playerName, {
							    		"targetName" : targetName,
							    		"playersChoice" : playersChoice,
							    		"targetsChoice" : targetsChoice
							    	});

									// player has not chosen yet
									return "Waiting for other player to shoot";
								}
							}
						})
					}
		    	}
		   }
		});
    } else {
      	console.log('a new match needs to be started');
        ret = "Start a new match: 'rps I challenge ____'";
        return ret;
    }
}

module.exports.del = function(playerName) {
	return QRedis.exists(playerName)
	    .then(function(exists){
	      if(exists) {
	      	console.log('key deleted');
	      	return QRedis.del(playerName);
	      } else {
	      	console.log('nothing to delete');
	        throw new Error("No match by that player found");
	    }
    })
}<|endoftext|>


<commit_before>/**
 * Copyright 2011 Jeffrey Finkelstein
 *
 * This file is part of Ophot.
 *
 * Ophot is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Ophot is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with Ophot.  If not, see <http://www.gnu.org/licenses/>.
 */
(function() {
  "use strict";

  function generateCategoryRow(name, id) {
    return '
\n'
      + '' + name + '	\n'
      + '\n'
      + 'rename\n'
      + 'delete\n'
      + '	\n'
      + '
\n';
  }

  function addedCategory(data, textStatus, xhr) {
    var name, id, categoryRow, added;
    //if (data.added) {
      name = data.name;
      id = data.id;

      // replace the text input box with the "new category..." link again
      $("input#new-cat").replaceWith(
        'new category…');

      // insert in alphabetical order code adapted from
      // http://stackoverflow.com/questions/2886739/using-jquery-to-dynamically-insert-into-list-alphabetically/2890810#2890810
      categoryRow = generateCategoryRow(name, id);
      added = false;
      $("tr.category-row").each(function() {
        if ($(this).children(".cat-name").text() > name) {
          $(this).before(categoryRow);
          added = true;
          return false;
        }
      });
      if (!added) {
        $("tr#new-cat-row").before(categoryRow);
      }
    //} else {
    // TODO do something
    //  alert("could not add category with name " + data.name);
    //}
  }

  function deleteCategory(data, textStatus, xhr) {
  }

  function renamedCategory(data, textStatus, xhr) {
    // intentionally unimplemented
  }

  function spacingChanged(data, textStatus, xhr) {
    // TODO show a little "saved" message
  }

  function updatedPersonalInfo(data, textStatus, xhr) {
    // TODO show a little "saved" message
  }

  $(document).ready(function() {
    var textareaSelectors;
    $(".delete-dialog").hide();
    $("#settings-shadow").hide();

    $("a#new-cat").live("click", function(event) {
      event.preventDefault();
      $(this).replaceWith('<input type="text" id="new-cat" '
                          + 'placeholder="new category…">');
    });

    $("input#new-cat").live("keyup", function(event) {
      // 13 is the keycode for the enter key
      if (event.keyCode === 13 && $(this).val() !== "") {
        var categoryName = $(this).val();
        $.post(SCRIPT_ROOT + '/categories',
               { name: categoryName },
               addedCategory,
               "json");
      }
    });

    $(".rename-cat").live("click", function(event) {
      var nameCell, name, categoryId;
      event.preventDefault();
      nameCell = $(this).parent().siblings(".cat-name");
      name = nameCell.html();
      categoryId = nameCell.attr('id');
      nameCell.html('<input type="text" value="' + name + '"/>');
      nameCell.children("input").focus();
      //var deleteLink = $(this).parent().siblings(".delete-cat");
      //deleteLink.replaceWith('cancel');
      $(this).replaceWith('save');
    });

    $(".confirm-name-change").live("click", function(event) {
      var nameCell, categoryId, input, categoryName;
      event.preventDefault();
      nameCell = $(this).parent().siblings(".cat-name");
      categoryId = nameCell.attr('id');
      input = nameCell.children("input");
      categoryName = input.val();
      nameCell.html(categoryName);
      $(this).replaceWith('rename');
      $.post(SCRIPT_ROOT + '/categories/' + categoryId,
             { name: categoryName },
             renamedCategory,
             "json");
    });

    $(".delete-cat").live("click", function(event) {
      event.preventDefault();
      $(this).addClass("selected");
      $(".delete-dialog").fadeIn();
      var newHeight = $("#settings-container").height();
      $("#settings-shadow").height(newHeight);
      $("#settings-shadow").fadeIn();
    });

    $(".cancel").click(function(event) {
      event.preventDefault();
      $(".delete-dialog").fadeOut();
      $("#settings-shadow").fadeOut();
      $(".delete-cat.selected").removeClass("selected");
    });

    $(".confirm-delete").click(function(event) {
      var id;
      event.preventDefault();
      $(".delete-dialog").fadeOut();
      $("#settings-shadow").fadeOut();
      id = $(".delete-cat.selected").attr("id");
      $(".selected").removeClass("selected");
      $.ajax({
        type: 'DELETE',
        url: SCRIPT_ROOT + '/categories/' + id,
        dataType: "json",
        success: function(data, textStatus, xhr) {
          // TODO test that HTTP status is 204
          var row;
          row = $("a.delete-cat[id=" + id + "]").parents("tr.category-row");
          row.fadeOut(400, function() {
            $(this).remove();
          });
        }});
    });

    // the spacing input should save on changes
    // NOTE the change event is not triggered until focus leaves this!
    $("#spacing").change($.debounce(500, function() {
      $.post(SCRIPT_ROOT + '/user',
             { spacing: $(this).val() },
             spacingChanged,
             "json");
    }));

    // the bio and contact info textarea elements should save every half a
    // second on key presses
    $('textarea[name~="bio"]').keypress($.debounce(500, function() {
      $.post(SCRIPT_ROOT + '/user',
             { bio: $(this).val() },
             updatedBio,
             "json");
    }));
    $('textarea[name~="contact"]').keypress($.debounce(500, function() {
      $.post(SCRIPT_ROOT + '/user',
             { contact: $(this).val() },
             updatedContact,
             "json");
    }));

    // the 'paste' event is undocumented but may work in some browsers
    textareaSelectors = 'textarea[name~="contact"], textarea[name~="bio"]';
    $(textareaSelectors).bind('paste', function() {
      // just trigger the keypress event
      $(this).keypress();
    });
  });
}());
<commit_msg>fixed bugs and added ability to press enter to save name<commit_after>/**
 * Copyright 2011 Jeffrey Finkelstein
 *
 * This file is part of Ophot.
 *
 * Ophot is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Ophot is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with Ophot.  If not, see <http://www.gnu.org/licenses/>.
 */
(function() {
  "use strict";

  function generateCategoryRow(name, id) {
    return '
\n'
      + '' + name + '	\n'
      + '\n'
      + 'rename\n'
      + 'delete\n'
      + '	\n'
      + '
\n';
  }

  function addedCategory(data, textStatus, xhr) {
    var name, id, categoryRow, added;
    //if (data.added) {
      name = data.name;
      id = data.id;

      // replace the text input box with the "new category..." link again
      $("input#new-cat").replaceWith(
        'new category…');

      // insert in alphabetical order code adapted from
      // http://stackoverflow.com/questions/2886739/using-jquery-to-dynamically-insert-into-list-alphabetically/2890810#2890810
      categoryRow = generateCategoryRow(name, id);
      added = false;
      $("tr.category-row").each(function() {
        if ($(this).children(".cat-name").text() > name) {
          $(this).before(categoryRow);
          added = true;
          return false;
        }
      });
      if (!added) {
        $("tr#new-cat-row").before(categoryRow);
      }
    //} else {
    // TODO do something
    //  alert("could not add category with name " + data.name);
    //}
  }

  function deleteCategory(data, textStatus, xhr) {
  }

  function renamedCategory(data, textStatus, xhr) {
    // intentionally unimplemented
  }

  function spacingChanged(data, textStatus, xhr) {
    // TODO show a little "saved" message
  }

  function updatedContact(data, textStatus, xhr) {
    // TODO show a little "saved" message
  }

  function updatedBio(data, textStatus, xhr) {
    // TODO show a little "saved" message
  }

  $(document).ready(function() {
    var textareaSelectors;
    $(".delete-dialog").hide();
    $("#settings-shadow").hide();

    $("a#new-cat").live("click", function(event) {
      event.preventDefault();
      $(this).replaceWith('<input type="text" id="new-cat" '
                          + 'placeholder="new category…">');
    });

    $("input#new-cat").live("keyup", function(event) {
      // 13 is the keycode for the enter key
      if (event.keyCode === 13 && $(this).val() !== "") {
        var categoryName = $(this).val();
        $.post(SCRIPT_ROOT + '/categories',
               { name: categoryName },
               addedCategory,
               "json");
      }
    });

    $(".rename-cat").live("click", function(event) {
      var nameCell, name, categoryId;
      event.preventDefault();
      nameCell = $(this).parent().siblings(".cat-name");
      name = nameCell.html();
      categoryId = nameCell.attr('id');
      nameCell.html('<input class="rename" type="text" value="' + name
                    + '"/>');
      nameCell.children("input").focus();
      //var deleteLink = $(this).parent().siblings(".delete-cat");
      //deleteLink.replaceWith('cancel');
      $(this).replaceWith('save');
    });

    $(".rename").live("keypress", function(event) {
      // if someone presses enter, trigger a click on the "save" link
      if (event.keyCode === 13) {
        var catOptions = $(this).parent().siblings(".cat-options");
        catOptions.children(".confirm-name-change").click();
      }
    })

    $(".confirm-name-change").live("click", function(event) {
      var nameCell, categoryId, input, categoryName;
      event.preventDefault();
      nameCell = $(this).parent().siblings(".cat-name");
      categoryId = nameCell.attr('id');
      input = nameCell.children("input");
      categoryName = input.val();
      nameCell.html(categoryName);
      $(this).replaceWith('rename');
      $.post(SCRIPT_ROOT + '/categories/' + categoryId,
             { name: categoryName },
             renamedCategory,
             "json");
    });

    $(".delete-cat").live("click", function(event) {
      event.preventDefault();
      $(this).addClass("selected");
      $(".delete-dialog").fadeIn();
      var newHeight = $("#settings-container").height();
      $("#settings-shadow").height(newHeight);
      $("#settings-shadow").fadeIn();
    });

    $(".cancel").click(function(event) {
      event.preventDefault();
      $(".delete-dialog").fadeOut();
      $("#settings-shadow").fadeOut();
      $(".delete-cat.selected").removeClass("selected");
    });

    $(".confirm-delete").click(function(event) {
      var id;
      event.preventDefault();
      $(".delete-dialog").fadeOut();
      $("#settings-shadow").fadeOut();
      id = $(".delete-cat.selected").attr("id");
      $(".selected").removeClass("selected");
      $.ajax({
        type: 'DELETE',
        url: SCRIPT_ROOT + '/categories/' + id,
        dataType: "json",
        success: function(data, textStatus, xhr) {
          // TODO test that HTTP status is 204
          var row;
          row = $("a.delete-cat[id=" + id + "]").parents("tr.category-row");
          row.fadeOut(400, function() {
            $(this).remove();
          });
        }});
    });

    // the spacing input should save on changes
    // NOTE the change event is not triggered until focus leaves this!
    $("#spacing").change($.debounce(500, function() {
      $.post(SCRIPT_ROOT + '/user',
             { spacing: $(this).val() },
             spacingChanged,
             "json");
    }));

    // the bio and contact info textarea elements should save every half a
    // second on key presses
    $('textarea[name~="bio"]').keypress($.debounce(500, function() {
      $.post(SCRIPT_ROOT + '/user',
             { bio: $(this).val() },
             updatedBio,
             "json");
    }));
    $('textarea[name~="contact"]').keypress($.debounce(500, function() {
      $.post(SCRIPT_ROOT + '/user',
             { contact: $(this).val() },
             updatedContact,
             "json");
    }));

    // the 'paste' event is undocumented but may work in some browsers
    textareaSelectors = 'textarea[name~="contact"], textarea[name~="bio"]';
    $(textareaSelectors).bind('paste', function() {
      // just trigger the keypress event
      $(this).keypress();
    });
  });
}());
<|endoftext|>


<commit_before>/* See license.txt for terms of usage */

(function() {
// ********************************************************************************************* //

// Inside scripts/main.js
function getModuleLoaderConfig(baseConfig)
{
    // Set configuration defaults.
    baseConfig.baseLoaderUrl = baseConfig.baseLoaderUrl || "resource://moduleLoader/";
    baseConfig.prefDomain = baseConfig.prefDomain || "extensions.firebug";
    baseConfig.arch = baseConfig.arch ||  "firebug_rjs/inProcess";
    baseConfig.baseUrl = baseConfig.baseUrl || "resource://";
    baseConfig.paths = baseConfig.paths || {"arch": baseConfig.arch, "firebug": "firebug_rjs"};

    // to give each XUL window its own loader (for now)
    var uid = Math.random();

    var config =
    {
        context: "Firebug " + uid, // TODO XUL window id on FF4.0+
        baseUrl: baseConfig.baseUrl,
        paths: baseConfig.paths,
        onDebug: function()
        {
            try
            {
                if (!this.FBTrace)
                {
                    // traceConsoleService is a global of |window| frome trace.js.
                    // on the first call we use it to get a ref to the Cu.import module object
                    this.FBTrace = traceConsoleService.getTracer(baseConfig.prefDomain);
                }

                if (this.FBTrace.DBG_MODULES)
                    this.FBTrace.sysout.apply(this.FBTrace,arguments);
            }
            catch(exc)
            {
                var msg = "";
                for (var i = 0; i < arguments.length; i++)
                    msg += arguments[i]+", ";

                Components.utils.reportError("Loader; onDebug:"+msg);  // put something out for sure
                window.dump("Loader; onDebug:"+msg+"\n");
            }
        },
        onError: function()
        {
            var msg = "";
            for (var i = 0; i < arguments.length; i++)
                msg += arguments[i]+", ";

            Components.utils.reportError("Loader; onError:"+msg);  // put something out for sure
            window.dump("Loader; onError:"+msg+"\n");
            if (!this.FBTrace)
            {
                // traceConsoleService is a global of |window| frome trace.js.
                // on the first call we use it to get a ref to the Cu.import module object
                this.FBTrace = traceConsoleService.getTracer(baseConfig.prefDomain);
            }

            if (this.FBTrace.DBG_ERRORS || this.FBTrace.DBG_MODULES)
                this.FBTrace.sysout.apply(this.FBTrace, arguments);

            throw arguments[0];
        },
        //waitSeconds: 0,
        //debug: false,
        /* edit: function(errorMsg, errorURL, errorLineNumber)
        {
            window.alert(errorMsg+" "+errorURL+"@"+errorLineNumber);
        },
        edit: function(context, url, module)
        {
            FBTrace.sysout("opening window modal on "+url);
            var a = {url: url};
            return window.showModalDialog("chrome://firebug/content/external/editors.xul",{},
                "resizable:yes;scroll:yes;dialogheight:480;dialogwidth:600;center:yes");
        }
        */
    };

    return config;
}

require.analyzeFailure = function(context, managers, specified, loaded)
{
    for (var i = 0; i < managers.length; i++)
    {
        var manager = managers[i];
        context.config.onDebug("require.js ERROR failed to complete "+manager.fullName+
            " isDone:"+manager.isDone+" #defined: "+manager.depCount+" #required: "+
            manager.depMax);

        var theNulls = [];
        var theUndefineds = [];
        var theUnstrucks = manager.strikeList;
        var depsTotal = 0;

        for (var depName in manager.deps)
        {
            if (typeof (manager.deps[depName]) === "undefined")
                theUndefineds.push(depName);
            if (manager.deps[depName] === null)
                theNulls.push(depName);

            var strikeIndex = manager.strikeList.indexOf(depName);
            manager.strikeList.splice(strikeIndex, 1);
        }

        context.config.onDebug("require.js: "+theNulls.length+" null dependencies "+
            theNulls.join(',')+" << check module ids.", theNulls);
        context.config.onDebug("require.js: "+theUndefineds.length+" undefined dependencies: "+
            theUndefineds.join(',')+" << check module return values.", theUndefineds);
        context.config.onDebug("require.js: "+theUnstrucks.length+" unstruck dependencies "+
            theUnstrucks.join(',')+" << check duplicate requires", theUnstrucks);

        for (var j = 0; j < manager.depArray.length; j++)
        {
            var id = manager.depArray[j];
            var module = manager.deps[id];
            context.config.onDebug("require.js: "+j+" specified: "+specified[id]+" loaded: "+
                loaded[id]+" "+id+" "+module);
        }
    }
}

// ********************************************************************************************* //
// Modules

var config = getModuleLoaderConfig({});

if (FBTrace.DBG_INITIALIZE || FBTrace.DBG_MODULES)
{
    if (FBTrace.DBG_MODULES)
        config.debug = true;

    FBTrace.sysout("main.js; Loading Firebug modules...");
    var startLoading = new Date().getTime();
}

require(config,
[
    "firebug/lib",
    "firebug/domplate",
    "firebug/firebug",
    "firebug/lib/options",
    "arch/tools",
    "arch/firebugadapter",
    "firebug/debugger",
    "arch/javascripttool",
    "firebug/traceModule",
    "firebug/lib/xpcom",
    "firebug/dragdrop",
    "firebug/tabWatcher",
    "firebug/sourceBox",
    "firebug/script",
    "firebug/memoryProfiler",
    "firebug/commandLine",
    "firebug/navigationHistory",
    "firebug/html",
    "firebug/css",
    "firebug/consoleInjector",
    "firebug/inspector",
    "firebug/layout",
    "firebug/net",
    "firebug/knownIssues",
    "firebug/tabCache",
    "firebug/activation",
    "firebug/sourceFile",
    "firebug/navigationHistory",
    "firebug/a11y",
    "firebug/shortcuts",
    "firebug/start-button/startButtonOverlay",
    "firebug/external/externalEditors",
    "firebug/callstack",
    "firebug/spy",
    "firebug/tableRep",
    "firebug/commandLinePopup",
    "firebug/commandLineExposed",
    "firebug/consoleExposed"
],
function()
{
    if (FBTrace.DBG_INITIALIZE || FBTrace.DBG_MODULES)
    {
        var delta = (new Date().getTime()) - startLoading;
        FBTrace.sysout("main.js; Firebug modules loaded using RequireJS in "+delta+" ms");
    }

    Firebug.Options.initialize("extensions.firebug");
    FirebugChrome.waitForPanelBar(true);

    // xxxHonza: the only global should be Firebug object.
    // for extensions compatibility
    top.FirebugReps = Firebug.Reps;
});

// ********************************************************************************************* //
})();
<commit_msg>[1.8] remove require.js config properties we should not mess with<commit_after>/* See license.txt for terms of usage */

(function() {
// ********************************************************************************************* //

// Inside scripts/main.js
function getModuleLoaderConfig(baseConfig)
{
    // Set configuration defaults.
    baseConfig.baseLoaderUrl = baseConfig.baseLoaderUrl || "resource://moduleLoader/";
    baseConfig.prefDomain = baseConfig.prefDomain || "extensions.firebug";
    baseConfig.arch = baseConfig.arch ||  "firebug_rjs/inProcess";
    baseConfig.baseUrl = baseConfig.baseUrl || "resource://";
    baseConfig.paths = baseConfig.paths || {"arch": baseConfig.arch, "firebug": "firebug_rjs"};

    // to give each XUL window its own loader (for now)
    var uid = Math.random();

    var config =
    {
        context: "Firebug " + uid, // TODO XUL window id on FF4.0+
        baseUrl: baseConfig.baseUrl,
        paths: baseConfig.paths,
        onDebug: function()
        {
            try
            {
                if (!this.FBTrace)
                {
                    // traceConsoleService is a global of |window| frome trace.js.
                    // on the first call we use it to get a ref to the Cu.import module object
                    this.FBTrace = traceConsoleService.getTracer(baseConfig.prefDomain);
                }

                if (this.FBTrace.DBG_MODULES)
                    this.FBTrace.sysout.apply(this.FBTrace,arguments);
            }
            catch(exc)
            {
                var msg = "";
                for (var i = 0; i < arguments.length; i++)
                    msg += arguments[i]+", ";

                Components.utils.reportError("Loader; onDebug:"+msg);  // put something out for sure
                window.dump("Loader; onDebug:"+msg+"\n");
            }
        },
        onError: function()
        {
            var msg = "";
            for (var i = 0; i < arguments.length; i++)
                msg += arguments[i]+", ";

            Components.utils.reportError("Loader; onError:"+msg);  // put something out for sure
            window.dump("Loader; onError:"+msg+"\n");
            if (!this.FBTrace)
            {
                // traceConsoleService is a global of |window| frome trace.js.
                // on the first call we use it to get a ref to the Cu.import module object
                this.FBTrace = traceConsoleService.getTracer(baseConfig.prefDomain);
            }

            if (this.FBTrace.DBG_ERRORS || this.FBTrace.DBG_MODULES)
                this.FBTrace.sysout.apply(this.FBTrace, arguments);

            throw arguments[0];
        },
    };

    return config;
}

require.analyzeFailure = function(context, managers, specified, loaded)
{
    for (var i = 0; i < managers.length; i++)
    {
        var manager = managers[i];
        context.config.onDebug("require.js ERROR failed to complete "+manager.fullName+
            " isDone:"+manager.isDone+" #defined: "+manager.depCount+" #required: "+
            manager.depMax);

        var theNulls = [];
        var theUndefineds = [];
        var theUnstrucks = manager.strikeList;
        var depsTotal = 0;

        for (var depName in manager.deps)
        {
            if (typeof (manager.deps[depName]) === "undefined")
                theUndefineds.push(depName);
            if (manager.deps[depName] === null)
                theNulls.push(depName);

            var strikeIndex = manager.strikeList.indexOf(depName);
            manager.strikeList.splice(strikeIndex, 1);
        }

        context.config.onDebug("require.js: "+theNulls.length+" null dependencies "+
            theNulls.join(',')+" << check module ids.", theNulls);
        context.config.onDebug("require.js: "+theUndefineds.length+" undefined dependencies: "+
            theUndefineds.join(',')+" << check module return values.", theUndefineds);
        context.config.onDebug("require.js: "+theUnstrucks.length+" unstruck dependencies "+
            theUnstrucks.join(',')+" << check duplicate requires", theUnstrucks);

        for (var j = 0; j < manager.depArray.length; j++)
        {
            var id = manager.depArray[j];
            var module = manager.deps[id];
            context.config.onDebug("require.js: "+j+" specified: "+specified[id]+" loaded: "+
                loaded[id]+" "+id+" "+module);
        }
    }
}

// ********************************************************************************************* //
// Modules

var config = getModuleLoaderConfig({});
require.onError = config.onError;

if (FBTrace.DBG_INITIALIZE || FBTrace.DBG_MODULES)
{
    if (FBTrace.DBG_MODULES)
        config.debug = true;

    FBTrace.sysout("main.js; Loading Firebug modules...");
    var startLoading = new Date().getTime();
}

require(config,
[
    "firebug/lib",
    "firebug/domplate",
    "firebug/firebug",
    "firebug/lib/options",
    "arch/tools",
    "arch/firebugadapter",
    "firebug/debugger",
    "arch/javascripttool",
    "firebug/traceModule",
    "firebug/lib/xpcom",
    "firebug/dragdrop",
    "firebug/tabWatcher",
    "firebug/sourceBox",
    "firebug/script",
    "firebug/memoryProfiler",
    "firebug/commandLine",
    "firebug/navigationHistory",
    "firebug/html",
    "firebug/css",
    "firebug/consoleInjector",
    "firebug/inspector",
    "firebug/layout",
    "firebug/net",
    "firebug/knownIssues",
    "firebug/tabCache",
    "firebug/activation",
    "firebug/sourceFile",
    "firebug/navigationHistory",
    "firebug/a11y",
    "firebug/shortcuts",
    "firebug/start-button/startButtonOverlay",
    "firebug/external/externalEditors",
    "firebug/callstack",
    "firebug/spy",
    "firebug/tableRep",
    "firebug/commandLinePopup",
    "firebug/commandLineExposed",
    "firebug/consoleExposed"
],
function()
{
    if (FBTrace.DBG_INITIALIZE || FBTrace.DBG_MODULES)
    {
        var delta = (new Date().getTime()) - startLoading;
        FBTrace.sysout("main.js; Firebug modules loaded using RequireJS in "+delta+" ms");
    }

    Firebug.Options.initialize("extensions.firebug");
    FirebugChrome.waitForPanelBar(true);

    // xxxHonza: the only global should be Firebug object.
    // for extensions compatibility
    top.FirebugReps = Firebug.Reps;
});

// ********************************************************************************************* //
})();
<|endoftext|>