<commit_before>/*
 * Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
 * Copyright [2016] EMBL-European Bioinformatics Institute
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

var Ensembl = new Base();

Ensembl.extend({
  constructor: null,

  initialize: function () {
    var hints       = this.cookie.get('ENSEMBL_HINTS');
    var imagePanels = $('.image_panel');
    var modalOpen   = window.location.hash.match(/(modal_.+)/);

    if (!window.name) {
      window.name = 'ensembl_' + new Date().getTime() + '_' + Math.floor(Math.random() * 10000);
    }

    this.setSpecies();

    this.locationURL        = typeof window.history.pushState === 'function' ? 'search' : 'hash';
    this.hashParamRegex     = '([#?;&])(__PARAM__=)[^;&]+((;&)?)';
    this.locationMatch      = new RegExp(/[#?;&]r=([^;&]+)/);
    this.markLocationMatch  = new RegExp(/[#?;&]mr=([^;&]+)/);
    this.locationReplace    = new RegExp(this.hashParamRegex.replace('__PARAM__', 'r'));
    this.width              = parseInt(this.cookie.get('ENSEMBL_WIDTH'), 10) || this.setWidth(undefined, 1);
    this.dynamicWidth       = !!this.cookie.get('DYNAMIC_WIDTH');
    this.hideHints          = {};
    this.initialPanels      = $('.initial_panel');
    this.minWidthEl         = $('#min_width_container');
    this.maxRegionLength    = parseInt($('#max_region_length').val() || 0, 10);
    this.images             = { total: imagePanels.length, last: imagePanels.last()[0] }; // Store image panel details for highlighting
    this.markedLocation     = this.getMarkedLocation();
    this.lastMarkedLocation = false;

    this.browser = (function(ua) {
      var b = {};
      if (ua.match(/webkit/i)) {
        b.webkit = true;
        if (ua.match(/chrome/i)) {
          b.chrome = true;
        } else if (ua.match(/safari/i)) {
          b.safari = true;
        }
      } else if (ua.match(/firefox/)) {
        b.firefox = true;
      } else if (ua.match(/msie/i)) {
        b.ie = true;
      }
      return b;
    })(navigator.userAgent || '');

    if (this.dynamicWidth && !window.name.match(/^popup_/)) {
      var width = this.imageWidth();

      if (width > 0 && this.width !== width) {
        this.width = width;
        this.cookie.set('ENSEMBL_WIDTH', width);
      }
    }

    this.cookie.set('WINDOW_WIDTH', $(window).width());

    if (hints) {
      $.each(hints.split(/:/), function () {
        Ensembl.hideHints[this] = 1;
      });
    }

    imagePanels = null;

    this.setCoreParams();

    this.LayoutManager.initialize();

    // If there's a hash in the URL with a new location in it, and the browser supports history API,
    // update window.location.search to contain the new location.
    // Also change all ajax_load values, so panels are loaded matching the new location.
    var removeHash = this.locationURL === 'hash' ? '' : window.location.hash.match('=');
    var hashChange = removeHash ? window.location.hash.match(this.locationMatch) : false;

    $('input.ajax_load').val(function (i, val) { return Ensembl.urlFromHash(val); });

    if (removeHash) {
      window.history.replaceState({}, '', Ensembl.urlFromHash(window.location.search));
    }

    this.PanelManager.initialize();

    if (modalOpen) {
      this.EventManager.deferTrigger('modalOpen', { className: 'force', rel: modalOpen[1] });
      window.location.hash = '';
    }

    if (hashChange) {
      this.EventManager.trigger('hashChange', hashChange[1]); // update links and HTML for the new location
    }
  },

  setSpecies: function () {
    this.speciesPath        = $('#species_path').val()        || '';
    this.speciesCommon      = $('#species_common_name').val() || '';
    this.species            = this.speciesPath.split('/').pop();
  },

  cookie: {
    set: function (name, value, expiry, unescaped) {
      var cookie = [
        unescaped === true ? (name + '=' + (value || '')) : (escape(name) + '=' + escape(value || '')),
        '; expires=',
        ((expiry === -1 || value === '') ? 'Thu, 01 Jan 1970' : expiry ? expiry : 'Tue, 19 Jan 2038'),
        ' 00:00:00 GMT; path=/'
      ].join('');
      document.cookie = cookie;

      return value;
    },

    get: function (name, unescaped) {
      var cookie = document.cookie.match(new RegExp('(^|;)\\s*' + (unescaped === true ? name : escape(name)) + '=([^;\\s]*)'));
      return cookie ? unescape(cookie[2]) : '';
    }
  },

  imageWidth: function () {
    return Math.floor(($(window).width() - 240) / 100) * 100;
  },

  setWidth: function (w, changed) {
    var numeric = !isNaN(w);

    w = numeric ? w : this.imageWidth();

    this.width = w < 500 ? 500 : w;

    if (changed) {
      this.cookie.set('ENSEMBL_WIDTH', this.width);
      this.cookie.set('DYNAMIC_WIDTH', numeric ? '' : 1);
      this.dynamicWidth = !numeric;
    }

    return this.width;
  },

  setCoreParams: function () {
    var regex       = '[#?;&]%s=([^;&]+)';
    var url         = window.location.search;
    var hash        = window.location.hash;
    var locationURL = this.locationURL === 'hash' ? hash : url;
    var lastR       = this.coreParams ? this.coreParams.r : '';
    var match, m, i, r;

    this.hash         = hash;
    this.coreParams   = {};
    this.initialR     = $('input[name=r]', '#core_params').val();
    this.location     = { length: 100000 };
    this.multiSpecies = {};

    $('input', '#core_params').each(function () {
      var hashMatch = locationURL.match(regex.replace('%s', this.name));
      Ensembl.coreParams[this.name] = hashMatch ? unescape(hashMatch[1]) : this.value;
    });

    this.lastR = lastR || (hash ? this.coreParams.r : this.initialR);

    match = this.coreParams.r ? this.coreParams.r.match(/(.+):(\d+)-(\d+)/) : false;

    if (match) {
      this.location = { name: match[1], start: parseInt(match[2], 10), end: parseInt(match[3], 10) };
      this.location.length = this.location.end - this.location.start + 1;
    }

    match = url.match(/s\d+=([^;&]+)/g);

    if (match) {
      $.each(match, function () {
        m = this.split('=');
        i = m[0].substr(1);

        Ensembl.multiSpecies[i] = {};

        $.each(['r', 'g', 's'], function (j, param) {
          Ensembl.multiSpecies[i][param] = url.match(regex.replace('%s', param + i));

          if (Ensembl.multiSpecies[i][param]) {
            Ensembl.multiSpecies[i][param] = unescape(Ensembl.multiSpecies[i][param][1]);
          }

          if (param === 'r' && Ensembl.multiSpecies[i].r) {
            r = Ensembl.multiSpecies[i].r.match(/(.+):(\d+)-(\d+)/);

            Ensembl.multiSpecies[i].location = { name: r[1], start: parseInt(r[2], 10), end: parseInt(r[3], 10) };
          }
        });
      });
    }
  },

  changeCoreParam: function (param, value) {
    var inp = $('#core_params input[name=' + param + ']');

    if (!inp.length) {
      inp = $('<input name=' + param + '>').appendTo($('#core_params'));
    }

    if (value === false) {
      inp.remove();
    } else {
      inp.val(value);
    }
  },

  cleanURL: function (url) {
    return url.replace(/&/g, ';').replace(/#.*$/g, '').replace(/([?;])time=[^;]+;?/g, '$1').replace(/[?;]$/g, '');
  },

  // Remove the old time stamp from a URL and replace with a new one
  replaceTimestamp: function (url) {
    var d    = new Date();
    var time = d.getTime() + d.getMilliseconds() / 1000;

    url  = this.cleanURL(url);
    url += (url.match(/\?/) ? ';' : '?') + 'time=' + time;

    return url;
  },

  prepareRequestParams: function (url) {
    var data = {};
    var type;

    if(url.length > 1500){
      $.each((url.split(/\?/)[1] || '').split(/&|;/), function(i, param) {
        param = param.split('=');
         if (typeof param[0] !== 'undefined' && !(param[0] in data)) {
           data[param[0]] = param[1];
         }
      });
      url  = url.split(/\?/)[0];
      type = 'POST';
    }
    else {
      url  = this.replaceTimestamp(url);
      type = 'GET';
    }

    return {
        requestURL: url,
        requestType: type,
        requestData: data
      };

  },

  redirect: function (url) {
    for (var p in this.PanelManager.panels) {
      this.PanelManager.panels[p].destructor('cleanup');
    }

    url = url || this.replaceTimestamp(window.location.href);

    if (window.location.hash) {
      url = this.urlFromHash(url);
    }

    window.location = url;
  },

  updateLocation: function (r) {
    this.historyReady = true;

    if (this.updateURL({ r: r }) === true && this.locationURL === 'search') {
      this.setCoreParams();
      this.EventManager.trigger('hashChange', r);
    }
  },

  getMarkedLocation: function(url) {
    var r = ((url || window.location.href).match(this.markLocationMatch) || ['']).pop().match(/(.+):(\d+)-(\d+)/);

    return r ? [ r[0], r[1], parseInt(r[2]), parseInt(r[3]) ] : null;
  },

  markLocation: function (r) {

    if (r && typeof r === 'string') { // r can be false to clear marked area, or can be an object already
      r = this.getMarkedLocation(r);
    }

    if (r || r === false) {
      this.updateURL({ mr: r && r[0] });
      this.changeCoreParam('mr', r[0]);
      this.setCoreParams();
      this.lastMarkedLocation = this.markedLocation || this.lastMarkedLocation;
      this.markedLocation     = r;
      this.EventManager.trigger('markLocation', r);
    }
  },

  updateURL: function (params, inputURL) {
    var url = inputURL || window.location[this.locationURL];
    if (!url.match(/\?/)) {
      url += '?';
    }

    for (var i in params) {
      if (params[i] === false) {
        url = url.replace(new RegExp(this.hashParamRegex.replace('__PARAM__', i)), '$1');
      } else if (url.match(i + '=')) {
        var regex = new RegExp(this.hashParamRegex.replace('__PARAM__', i));

        if (url.match(regex)) {
          url = url.replace(regex, '$1$2' + params[i] + '$3');
        } else {
          url = url.replace(i + '=', i + '=' + params[i]);
        }
      } else {
        url += (url ? ';' : '') + i + '=' + params[i];
      }
    }

    url = url.replace(/([?;]);+/g, '$1').replace(/[?;&]$/, '');

    if (inputURL) {
      return url;
    }

    if (this.locationURL === 'hash') {
      url = url.replace(/^\?/, '');
      if (window.location.hash !== url) {
        window.location.hash = url;
        return true;
      }
    } else if (window.location.search !== url) {
      window.history.pushState({}, '', url);
      window.location.reload();
      return true;
    }
  },

  urlFromHash: function (url, paramOnly) {
    var location = window.location[this.locationURL].replace(/^#/, '?') + ';';
    var match    = location.match(this.locationMatch);
    var r        = match ? match[1] : this.initialR || '';

    if (paramOnly) {
      return r;
    }

    var hash = r && this.locationURL === 'search' ? { r: r } : {};

    if (hash.r) {
      $.each(['g', 'db', 'mr'], function (i, param) {
        if (Ensembl.coreParams[param]) {
          hash[param] = Ensembl.coreParams[param];
        }
      });
    }

    $.each(window.location.hash.replace('#', '').split(/[;&]/), function () {
      var param = this.split('=');

      if (param.length === 2) {
        hash[param[0]] = param[1];
      }
    });

    return this.updateURL(hash, url);
  },

  thousandify: function (str) {
    str += '';

    var rgx = /(\d+)(\d{3})/;
    var x   = str.split('.');
    var x1  = x[0];
    var x2  = x.length > 1 ? '.' + x[1] : '';

    while (rgx.test(x1)) {
      x1 = x1.replace(rgx, '$1' + ',' + '$2');
    }

    return x1 + x2;
  }
});

Ensembl.Class = {}; // sub namespace for "Base" based classes to keep Ensembl in their namespace

window.Ensembl = Ensembl; // Make Ensembl namespace available on window - needed for upload iframes because the minifier will compress the variable name Ensembl
<commit_msg>Revert "Fix #ENSWEB-2672 Fix Location Navbar functionality"<commit_after>/*
 * Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
 * Copyright [2016] EMBL-European Bioinformatics Institute
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

var Ensembl = new Base();

Ensembl.extend({
  constructor: null,

  initialize: function () {
    var hints       = this.cookie.get('ENSEMBL_HINTS');
    var imagePanels = $('.image_panel');
    var modalOpen   = window.location.hash.match(/(modal_.+)/);

    if (!window.name) {
      window.name = 'ensembl_' + new Date().getTime() + '_' + Math.floor(Math.random() * 10000);
    }

    this.setSpecies();

    this.locationURL        = typeof window.history.pushState === 'function' ? 'search' : 'hash';
    this.hashParamRegex     = '([#?;&])(__PARAM__=)[^;&]+((;&)?)';
    this.locationMatch      = new RegExp(/[#?;&]r=([^;&]+)/);
    this.markLocationMatch  = new RegExp(/[#?;&]mr=([^;&]+)/);
    this.locationReplace    = new RegExp(this.hashParamRegex.replace('__PARAM__', 'r'));
    this.width              = parseInt(this.cookie.get('ENSEMBL_WIDTH'), 10) || this.setWidth(undefined, 1);
    this.dynamicWidth       = !!this.cookie.get('DYNAMIC_WIDTH');
    this.hideHints          = {};
    this.initialPanels      = $('.initial_panel');
    this.minWidthEl         = $('#min_width_container');
    this.maxRegionLength    = parseInt($('#max_region_length').val() || 0, 10);
    this.images             = { total: imagePanels.length, last: imagePanels.last()[0] }; // Store image panel details for highlighting
    this.markedLocation     = this.getMarkedLocation();
    this.lastMarkedLocation = false;

    this.browser = (function(ua) {
      var b = {};
      if (ua.match(/webkit/i)) {
        b.webkit = true;
        if (ua.match(/chrome/i)) {
          b.chrome = true;
        } else if (ua.match(/safari/i)) {
          b.safari = true;
        }
      } else if (ua.match(/firefox/)) {
        b.firefox = true;
      } else if (ua.match(/msie/i)) {
        b.ie = true;
      }
      return b;
    })(navigator.userAgent || '');

    if (this.dynamicWidth && !window.name.match(/^popup_/)) {
      var width = this.imageWidth();

      if (width > 0 && this.width !== width) {
        this.width = width;
        this.cookie.set('ENSEMBL_WIDTH', width);
      }
    }

    this.cookie.set('WINDOW_WIDTH', $(window).width());

    if (hints) {
      $.each(hints.split(/:/), function () {
        Ensembl.hideHints[this] = 1;
      });
    }

    imagePanels = null;

    this.setCoreParams();

    this.LayoutManager.initialize();

    // If there's a hash in the URL with a new location in it, and the browser supports history API,
    // update window.location.search to contain the new location.
    // Also change all ajax_load values, so panels are loaded matching the new location.
    var removeHash = this.locationURL === 'hash' ? '' : window.location.hash.match('=');
    var hashChange = removeHash ? window.location.hash.match(this.locationMatch) : false;

    $('input.ajax_load').val(function (i, val) { return Ensembl.urlFromHash(val); });

    if (removeHash) {
      window.history.replaceState({}, '', Ensembl.urlFromHash(window.location.search));
    }

    this.PanelManager.initialize();

    if (modalOpen) {
      this.EventManager.deferTrigger('modalOpen', { className: 'force', rel: modalOpen[1] });
      window.location.hash = '';
    }

    if (hashChange) {
      this.EventManager.trigger('hashChange', hashChange[1]); // update links and HTML for the new location
    }
  },

  setSpecies: function () {
    this.speciesPath        = $('#species_path').val()        || '';
    this.speciesCommon      = $('#species_common_name').val() || '';
    this.species            = this.speciesPath.split('/').pop();
  },

  cookie: {
    set: function (name, value, expiry, unescaped) {
      var cookie = [
        unescaped === true ? (name + '=' + (value || '')) : (escape(name) + '=' + escape(value || '')),
        '; expires=',
        ((expiry === -1 || value === '') ? 'Thu, 01 Jan 1970' : expiry ? expiry : 'Tue, 19 Jan 2038'),
        ' 00:00:00 GMT; path=/'
      ].join('');
      document.cookie = cookie;

      return value;
    },

    get: function (name, unescaped) {
      var cookie = document.cookie.match(new RegExp('(^|;)\\s*' + (unescaped === true ? name : escape(name)) + '=([^;\\s]*)'));
      return cookie ? unescape(cookie[2]) : '';
    }
  },

  imageWidth: function () {
    return Math.floor(($(window).width() - 240) / 100) * 100;
  },

  setWidth: function (w, changed) {
    var numeric = !isNaN(w);

    w = numeric ? w : this.imageWidth();

    this.width = w < 500 ? 500 : w;

    if (changed) {
      this.cookie.set('ENSEMBL_WIDTH', this.width);
      this.cookie.set('DYNAMIC_WIDTH', numeric ? '' : 1);
      this.dynamicWidth = !numeric;
    }

    return this.width;
  },

  setCoreParams: function () {
    var regex       = '[#?;&]%s=([^;&]+)';
    var url         = window.location.search;
    var hash        = window.location.hash;
    var locationURL = this.locationURL === 'hash' ? hash : url;
    var lastR       = this.coreParams ? this.coreParams.r : '';
    var match, m, i, r;

    this.hash         = hash;
    this.coreParams   = {};
    this.initialR     = $('input[name=r]', '#core_params').val();
    this.location     = { length: 100000 };
    this.multiSpecies = {};

    $('input', '#core_params').each(function () {
      var hashMatch = locationURL.match(regex.replace('%s', this.name));
      Ensembl.coreParams[this.name] = hashMatch ? unescape(hashMatch[1]) : this.value;
    });

    this.lastR = lastR || (hash ? this.coreParams.r : this.initialR);

    match = this.coreParams.r ? this.coreParams.r.match(/(.+):(\d+)-(\d+)/) : false;

    if (match) {
      this.location = { name: match[1], start: parseInt(match[2], 10), end: parseInt(match[3], 10) };
      this.location.length = this.location.end - this.location.start + 1;
    }

    match = url.match(/s\d+=([^;&]+)/g);

    if (match) {
      $.each(match, function () {
        m = this.split('=');
        i = m[0].substr(1);

        Ensembl.multiSpecies[i] = {};

        $.each(['r', 'g', 's'], function (j, param) {
          Ensembl.multiSpecies[i][param] = url.match(regex.replace('%s', param + i));

          if (Ensembl.multiSpecies[i][param]) {
            Ensembl.multiSpecies[i][param] = unescape(Ensembl.multiSpecies[i][param][1]);
          }

          if (param === 'r' && Ensembl.multiSpecies[i].r) {
            r = Ensembl.multiSpecies[i].r.match(/(.+):(\d+)-(\d+)/);

            Ensembl.multiSpecies[i].location = { name: r[1], start: parseInt(r[2], 10), end: parseInt(r[3], 10) };
          }
        });
      });
    }
  },

  changeCoreParam: function (param, value) {
    var inp = $('#core_params input[name=' + param + ']');

    if (!inp.length) {
      inp = $('<input name=' + param + '>').appendTo($('#core_params'));
    }

    if (value === false) {
      inp.remove();
    } else {
      inp.val(value);
    }
  },

  cleanURL: function (url) {
    return url.replace(/&/g, ';').replace(/#.*$/g, '').replace(/([?;])time=[^;]+;?/g, '$1').replace(/[?;]$/g, '');
  },

  // Remove the old time stamp from a URL and replace with a new one
  replaceTimestamp: function (url) {
    var d    = new Date();
    var time = d.getTime() + d.getMilliseconds() / 1000;

    url  = this.cleanURL(url);
    url += (url.match(/\?/) ? ';' : '?') + 'time=' + time;

    return url;
  },

  prepareRequestParams: function (url) {
    var data = {};
    var type;

    if(url.length > 1500){
      $.each((url.split(/\?/)[1] || '').split(/&|;/), function(i, param) {
        param = param.split('=');
         if (typeof param[0] !== 'undefined' && !(param[0] in data)) {
           data[param[0]] = param[1];
         }
      });
      url  = url.split(/\?/)[0];
      type = 'POST';
    }
    else {
      url  = this.replaceTimestamp(url);
      type = 'GET';
    }

    return {
        requestURL: url,
        requestType: type,
        requestData: data
      };

  },

  redirect: function (url) {
    for (var p in this.PanelManager.panels) {
      this.PanelManager.panels[p].destructor('cleanup');
    }

    url = url || this.replaceTimestamp(window.location.href);

    if (window.location.hash) {
      url = this.urlFromHash(url);
    }

    window.location = url;
  },

  updateLocation: function (r) {
    this.historyReady = true;

    if (this.updateURL({ r: r }) === true && this.locationURL === 'search') {
      this.setCoreParams();
      this.EventManager.trigger('hashChange', r);
    }
  },

  getMarkedLocation: function(url) {
    var r = ((url || window.location.href).match(this.markLocationMatch) || ['']).pop().match(/(.+):(\d+)-(\d+)/);

    return r ? [ r[0], r[1], parseInt(r[2]), parseInt(r[3]) ] : null;
  },

  markLocation: function (r) {

    if (r && typeof r === 'string') { // r can be false to clear marked area, or can be an object already
      r = this.getMarkedLocation(r);
    }

    if (r || r === false) {
      this.updateURL({ mr: r && r[0] });
      this.changeCoreParam('mr', r[0]);
      this.setCoreParams();
      this.lastMarkedLocation = this.markedLocation || this.lastMarkedLocation;
      this.markedLocation     = r;
      this.EventManager.trigger('markLocation', r);
    }
  },

  updateURL: function (params, inputURL) {
    var url = inputURL || window.location[this.locationURL];
    if (!url.match(/\?/)) {
      url += '?';
    }

    for (var i in params) {
      if (params[i] === false) {
        url = url.replace(new RegExp(this.hashParamRegex.replace('__PARAM__', i)), '$1');
      } else if (url.match(i + '=')) {
        var regex = new RegExp(this.hashParamRegex.replace('__PARAM__', i));

        if (url.match(regex)) {
          url = url.replace(regex, '$1$2' + params[i] + '$3');
        } else {
          url = url.replace(i + '=', i + '=' + params[i]);
        }
      } else {
        url += (url ? ';' : '') + i + '=' + params[i];
      }
    }

    url = url.replace(/([?;]);+/g, '$1').replace(/[?;&]$/, '');

    if (inputURL) {
      return url;
    }

    if (this.locationURL === 'hash') {
      url = url.replace(/^\?/, '');
      if (window.location.hash !== url) {
        window.location.hash = url;
        return true;
      }
    } else if (window.location.search !== url) {
      window.history.pushState({}, '', url);
      return true;
    }
  },

  urlFromHash: function (url, paramOnly) {
    var location = window.location[this.locationURL].replace(/^#/, '?') + ';';
    var match    = location.match(this.locationMatch);
    var r        = match ? match[1] : this.initialR || '';

    if (paramOnly) {
      return r;
    }

    var hash = r && this.locationURL === 'search' ? { r: r } : {};

    if (hash.r) {
      $.each(['g', 'db', 'mr'], function (i, param) {
        if (Ensembl.coreParams[param]) {
          hash[param] = Ensembl.coreParams[param];
        }
      });
    }

    $.each(window.location.hash.replace('#', '').split(/[;&]/), function () {
      var param = this.split('=');

      if (param.length === 2) {
        hash[param[0]] = param[1];
      }
    });

    return this.updateURL(hash, url);
  },

  thousandify: function (str) {
    str += '';

    var rgx = /(\d+)(\d{3})/;
    var x   = str.split('.');
    var x1  = x[0];
    var x2  = x.length > 1 ? '.' + x[1] : '';

    while (rgx.test(x1)) {
      x1 = x1.replace(rgx, '$1' + ',' + '$2');
    }

    return x1 + x2;
  }
});

Ensembl.Class = {}; // sub namespace for "Base" based classes to keep Ensembl in their namespace

window.Ensembl = Ensembl; // Make Ensembl namespace available on window - needed for upload iframes because the minifier will compress the variable name Ensembl
<|endoftext|>


<commit_before>// Generated on 2015-03-03 using generator-jekyllrb 1.2.1
'use strict';

// Directory reference:
//   css: css
//   compass: _scss
//   javascript: js
//   coffeescript: _src
//   images: img
//   fonts: fonts

module.exports = function (grunt) {
  // Show elapsed time after tasks run
  require('time-grunt')(grunt);
  // Load all Grunt tasks
  require('load-grunt-tasks')(grunt);

  grunt.initConfig({
    // Configurable paths
    yeoman: {
      app: 'app',
      dist: 'dist'
    },
    watch: {
      compass: {  // Build scss and sass files when changed or added. Then, autoprefix built css
        files: ['<%= yeoman.app %>/_scss/**/*.{scss,sass}'],
        tasks: ['compass:server', 'newer:autoprefixer:server', 'newer:csslint:check'],
        options: {
          event: ['added', 'changed']
        }
      },
      css: { // Copy css files when changed or added. Then, autoprefix pasted css
        files: ['<%= yeoman.app %>/css/**/*.css'],
        tasks: ['newer:copy:stageCss', 'newer:autoprefixer:server', 'newer:csslint:check'],
        options: {
          event: ['added', 'changed']
        }
      },
      js: { // js_hint js files when added and changed
        files: ['<%= yeoman.app %>/js/**/*.js'],
        tasks: ['newer:jshint:all'],
        options: {
          event: ['added', 'changed'],
        }
      },
      coffee: { // Build coffee files when added or changed
        files: ['<%= yeoman.app %>/_src/**/*.coffee'],
        tasks: ['coffee:dist', 'newer:coffeelint:check'],
        options: {
          event: ['added', 'changed']
        }
      },
      coffeeTest: { // Run tests
        files: ['test/spec/**/*.coffee'],
        tasks: ['coffee:test']
      },
      addedStylesScripts: { // Inject new css and js files as references into html files
        files: [
          '.tmp/css/**/*.css',
          '.tmp/js/**/*.js',
          '<%= yeoman.app %>/js/**/*.js'
        ],
        tasks: ['injector'],
        options: {
          event: ['added']
        }
      },
      deletedStylesScripts: { // Rebuild everything when a source css/scss/sass/coffee file is deleted (it's hard to remove only a target source+built couple)
        files: [
          '<%= yeoman.app %>/_src/**/*.coffee',
          '<%= yeoman.app %>/css/**/*.css',
          '<%= yeoman.app %>/_scss/**/*.{scss,sass}'
        ],
        tasks: ['local'],
        options: {
          event: ['deleted']
        }
      },
      deletedJs: {  // Source js deletion it's easier to manage. Running the injector it's enough.
        files: ['<%= yeoman.app %>/js/**/*.js'],
        tasks: ['injector'],
        options: {
          event: ['deleted']
        }
      },
      config: { // Rebuild everything when a config file is changed
        files: [
          'Gruntfile.js',
          '_config.build.yml',
          '_config.yml',
          'bower.json',
          '.bowerrc'
        ],
        tasks: ['local']
      },
      jshint: { // js_hint everything when the jshintrc file is changed
        files: ['.jshintrc'],
        tasks: ['jshint:all']
      },
      csslint: { // js_hint everything when the jshintrc file is changed
        files: ['.csslintrc'],
        tasks: ['csslint:check']
      },
      jekyll: { // Run jekyll when source html content change
        files: [
          '<%= yeoman.app %>/**/*.{html,yml,md,mkd,markdown}',
          '!<%= yeoman.app %>/_bower_components/**/*'
        ],
        tasks: ['jekyll:server']
      },
      livereload: { // Livereload target files
        options: {
          livereload: '<%= connect.options.livereload %>'
        },
        files: [
          '.jekyll/**/*.html',
          '.tmp/css/**/*{.css,.css.map}',
          '.tmp/js/**/*{.js,.js.map}',
          '<%= yeoman.app %>/js/**/*.js',
          '<%= yeoman.app %>/img/**/*.{gif,jpg,jpeg,png,svg,webp}'
        ]
      }
    },
    connect: {
      options: {
        port: 9000,
        livereload: 35729,
        // change this to '0.0.0.0' to access the server from outside
        hostname: 'localhost'
      },
      livereload: {
        options: {
          open: true,
          base: [
            '.tmp',
            '.jekyll',
            '<%= yeoman.app %>'
          ]
        }
      },
      dist: {
        options: {
          open: true,
          base: [
            '<%= yeoman.dist %>'
          ]
        }
      },
      test: {
        options: {
          base: [
            '.tmp',
            '.jekyll',
            'test',
            '<%= yeoman.app %>'
          ]
        }
      }
    },
    clean: {
      dist: {
        files: [{
          dot: true,
          src: [
            '<%= yeoman.dist %>/*',
            // Running Jekyll also cleans the target directory.  Exclude any
            // non-standard `keep_files` here (e.g., the generated files
            // directory from Jekyll Picture Tag).
            '!<%= yeoman.dist %>/.git*'
          ]
        }]
      },
      js: ['.tmp/js/*'],
      css: ['.tmp/css'],
      server: [
        '.tmp',
        '.jekyll'
      ]
    },
    compass: {
      options: {
        // If you're using global Sass gems, require them here.
        // require: ['singularity', 'jacket'],
        bundleExec: true,
        sourcemap: true,
        sassDir: '<%= yeoman.app %>/_scss',
        cssDir: '.tmp/css',
        imagesDir: '<%= yeoman.app %>/img',
        javascriptsDir: '<%= yeoman.app %>/js',
        relativeAssets: false,
        httpImagesPath: '/img',
        httpGeneratedImagesPath: '/img/generated',
        outputStyle: 'expanded',
        raw: 'extensions_dir = "<%= yeoman.app %>/_bower_components"\n'
      },
      dist: {
        options: {
          generatedImagesDir: '<%= yeoman.dist %>/img/generated'
        }
      },
      server: {
        options: {
          debugInfo: true,
          generatedImagesDir: '.tmp/img/generated'
        }
      }
    },
    autoprefixer: {
      options: {
        browsers: ['last 2 versions']
      },
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>/css',
          src: '**/*.css',
          dest: '<%= yeoman.dist %>/css'
        }]
      },
      server: {
        files: [{
          expand: true,
          cwd: '.tmp/css',
          src: '**/*.css',
          dest: '.tmp/css'
        }]
      }
    },
    coffee: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/_src',
          src: '**/*.coffee',
          dest: '.tmp/js',
          ext: '.js'
        }]
      },
      test: {
        files: [{
          expand: true,
          cwd: 'test/spec',
          src: '**/*.coffee',
          dest: '.tmp/spec',
          ext: '.js'
        }]
      }
    },
    injector: {
        local_dependencies: {
          files: {
            '<%= yeoman.app %>/_includes/styles.html': [
                '.tmp/css/**/*.css'
              ],
            '<%= yeoman.app %>/_includes/scripts.html': [
                '<%= yeoman.app %>/js/**/*.js',
                '.tmp/js/**/*.js'
              ],
          },
        },
        options: {
          ignorePath: [
            '<%= yeoman.app %>',
            '.tmp'
          ]
        }
    },
    wiredep: {
      inject:{
        src: [
          '<%= yeoman.app %>/_includes/styles.html',
          '<%= yeoman.app %>/_includes/scripts.html'
        ],
        exclude: [
          '<%= yeoman.app %>/_bower_components/bootstrap/dist/css/', // Include the src files directly with Compass
          '<%= yeoman.app %>/_bower_components/modernizr'
        ],
        dependencies: true,
        devDependencies: true,
        includeSelf: false,
        ignorePath: '../',
        fileTypes: {
          html: {
            replace: {
              js: '<script src="/{{filePath}}"></script>',
              css: '<link rel="stylesheet" href="/{{filePath}}" />'
            }
          }
        }
      }
    },

    jekyll: {
      options: {
        bundleExec: true,
        config: '_config.yml,_config.build.yml',
        src: '<%= yeoman.app %>'
      },
      dist: {
        options: {
          dest: '<%= yeoman.dist %>',
        }
      },
      server: {
        options: {
          config: '_config.yml',
          dest: '.jekyll'
        }
      },
      check: {
        options: {
          doctor: true
        }
      }
    },
    useminPrepare: {
      options: {
        dest: '<%= yeoman.dist %>'
      },
      html: '<%= yeoman.dist %>/index.html'
    },
    usemin: {
      options: {
        assetsDirs: '<%= yeoman.dist %>',
      },
      html: ['<%= yeoman.dist %>/**/*.html'],
      css: ['<%= yeoman.dist %>/css/**/*.css']
    },
    htmlmin: {
      dist: {
        options: {
          collapseWhitespace: true,
          collapseBooleanAttributes: true,
          removeAttributeQuotes: true,
          removeRedundantAttributes: true
        },
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>',
          src: '**/*.html',
          dest: '<%= yeoman.dist %>'
        }]
      }
    },
    // Usemin adds files to concat
    concat: {},
    // Usemin adds files to uglify
    uglify: {},
    // Usemin adds files to cssmin
    cssmin: {
      dist: {
        options: {
          check: 'gzip'
        }
      }
    },
    imagemin: {
      dist: {
        options: {
          progressive: true
        },
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>',
          src: '**/*.{jpg,jpeg,png}',
          dest: '<%= yeoman.dist %>'
        }]
      }
    },
    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>',
          src: '**/*.svg',
          dest: '<%= yeoman.dist %>'
        }]
      }
    },
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>',
          src: [
            // Jekyll processes and moves HTML and text files.
            // Usemin moves CSS and javascript inside of Usemin blocks.
            // Copy moves asset files and directories.
            'img/**/*',
            'fonts/**/*',
            // Like Jekyll, exclude files & folders prefixed with an underscore.
            '!**/_*{,/**}',
            'favicon.ico',
            'apple-touch*.png'
          ],
          dest: '<%= yeoman.dist %>'
        }]
      },
      // Copy CSS into .tmp directory for Autoprefixer processing
      stageCss: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>/css',
          src: '**/*.css',
          dest: '.tmp/css'
        }]
      }
    },
    filerev: {
      options: {
        length: 4
      },
      dist: {
        files: [{
          src: [
            '<%= yeoman.dist %>/js/**/*.js',
            '<%= yeoman.dist %>/css/**/*.css',
            '<%= yeoman.dist %>/img/**/*.{gif,jpg,jpeg,png,svg,webp}',
            '<%= yeoman.dist %>/fonts/**/*.{eot*,otf,svg,ttf,woff}'
          ]
        }]
      }
    },
    buildcontrol: {
      dist: {
        options: {
          remote: '../',
          branch: 'gh-pages',
          commit: true,
          push: true
        }
      }
    },
    coffeelint: {
      options: {
        'max_line_length': {
          'level': 'ignore'
        }
      },
      check: ['<%= yeoman.app %>/_src/*.coffee']
    },
    jshint: {
      options: {
        jshintrc: '.jshintrc',
        reporter: require('jshint-stylish')
      },
      all: [
        'Gruntfile.js',
        '<%= yeoman.app %>/js/**/*.js',
        'test/spec/**/*.js'
      ]
    },
    csslint: {
      options: {
        csslintrc: '.csslintrc'
      },
      check: {
        src: [
          '<%= yeoman.app %>/css/**/*.css',
          '<%= yeoman.app %>/_scss/**/*.scss'
        ]
      }
    },
    concurrent: {
      server: [
        'compass:server',
        'coffee:dist',
        'copy:stageCss',
      ],
      dist: [
        'compass:dist',
        'coffee:dist',
        'copy:dist',
      ]
    },
    shell: {
      bower: {
        command: 'bower install'
      }
    }
  });

  // Define Tasks
  grunt.registerTask('serve', function (target) {
    if (target === 'dist') {
      return grunt.task.run(['build', 'connect:dist:keepalive']);
    }

    grunt.task.run([
      'local',
      'notify_hooks',
      'connect:livereload',
      'watch'
    ]);
  });

  grunt.registerTask('server', function () {
    grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
    grunt.task.run(['serve']);
  });

  grunt.registerTask('local', [
    'shell:bower',
    'clean:server',
    'concurrent:server',
    'injectDependencies',
    'jekyll:server',
    'autoprefixer:server'
  ]);

  // No real tests yet. Add your own.
  grunt.registerTask('test', [
  //   'clean:server',
  //   'concurrent:test',
  //   'connect:test'
  ]);

  grunt.registerTask('injectDependencies', [
    'injector',
    'wiredep'
  ]);

  grunt.registerTask('check', [
    'clean:server',
    'jekyll:check',
    'compass:server',
    'coffeelint:check',
    'coffee:dist',
    'jshint:all',
    'csslint:check'
  ]);

  grunt.registerTask('build', [
    'shell:bower',
    'clean',
    // Jekyll cleans files from the target directory, so must run first
    'concurrent:dist',
    'injectDependencies',
    'jekyll:dist',
    'useminPrepare',
    'concat',
    'autoprefixer:dist',
    'cssmin',
    'uglify',
    'imagemin',
    'svgmin',
    'filerev',
    'usemin',
    'htmlmin'
    ]);

  grunt.registerTask('deploy', [
    'check',
    'test',
    'build',
    'buildcontrol'
    ]);

  grunt.registerTask('default', [
    'check',
    'test',
    'build'
  ]);
};
<commit_msg>Gruntfile updated<commit_after>// Generated on 2015-03-03 using generator-jekyllrb 1.2.1
'use strict';

// Directory reference:
//   css: css
//   compass: _scss
//   javascript: js
//   coffeescript: _src
//   images: img
//   fonts: fonts

module.exports = function (grunt) {
  // Show elapsed time after tasks run
  require('time-grunt')(grunt);
  // Load all Grunt tasks
  require('load-grunt-tasks')(grunt);

  grunt.initConfig({
    // Configurable paths
    yeoman: {
      app: 'app',
      dist: 'dist'
    },
    watch: {
      compass: {  // Build scss and sass files when changed or added. Then, autoprefix built css
        files: ['<%= yeoman.app %>/_scss/**/*.{scss,sass}'],
        tasks: ['compass:server', 'newer:autoprefixer:server', 'newer:csslint:check'],
        options: {
          event: ['added', 'changed']
        }
      },
      css: { // Copy css files when changed or added. Then, autoprefix pasted css
        files: ['<%= yeoman.app %>/css/**/*.css'],
        tasks: ['newer:copy:stageCss', 'newer:autoprefixer:server', 'newer:csslint:check'],
        options: {
          event: ['added', 'changed']
        }
      },
      js: { // js_hint js files when added and changed
        files: ['<%= yeoman.app %>/js/**/*.js'],
        tasks: ['newer:jshint:all'],
        options: {
          event: ['added', 'changed'],
        }
      },
      coffee: { // Build coffee files when added or changed
        files: ['<%= yeoman.app %>/_src/**/*.coffee'],
        tasks: ['coffee:dist', 'newer:coffeelint:check'],
        options: {
          event: ['added', 'changed']
        }
      },
      coffeeTest: { // Run tests
        files: ['test/spec/**/*.coffee'],
        tasks: ['coffee:test']
      },
      addedStylesScripts: { // Inject new css and js files as references into html files
        files: [
          '.tmp/css/**/*.css',
          '.tmp/js/**/*.js',
          '<%= yeoman.app %>/js/**/*.js'
        ],
        tasks: ['injector'],
        options: {
          event: ['added']
        }
      },
      deletedStylesScripts: { // Rebuild everything when a source css/scss/sass/coffee file is deleted (it's hard to remove only a target source+built couple)
        files: [
          '<%= yeoman.app %>/_src/**/*.coffee',
          '<%= yeoman.app %>/css/**/*.css',
          '<%= yeoman.app %>/_scss/**/*.{scss,sass}'
        ],
        tasks: ['local'],
        options: {
          event: ['deleted']
        }
      },
      deletedJs: {  // Source js deletion it's easier to manage. Running the injector it's enough.
        files: ['<%= yeoman.app %>/js/**/*.js'],
        tasks: ['injector'],
        options: {
          event: ['deleted']
        }
      },
      config: { // Rebuild everything when a config file is changed
        files: [
          'Gruntfile.js',
          '_config.build.yml',
          '_config.yml',
          'bower.json',
          '.bowerrc'
        ],
        tasks: ['local']
      },
      jshint: { // js_hint everything when the jshintrc file is changed
        files: ['.jshintrc'],
        tasks: ['jshint:all']
      },
      csslint: { // js_hint everything when the jshintrc file is changed
        files: ['.csslintrc'],
        tasks: ['csslint:check']
      },
      jekyll: { // Run jekyll when source html content change
        files: [
          '<%= yeoman.app %>/**/*.{html,yml,md,mkd,markdown}',
          '!<%= yeoman.app %>/_bower_components/**/*'
        ],
        tasks: ['jekyll:server']
      },
      livereload: { // Livereload target files
        options: {
          livereload: '<%= connect.options.livereload %>'
        },
        files: [
          '.jekyll/**/*.html',
          '.tmp/css/**/*{.css,.css.map}',
          '.tmp/js/**/*{.js,.js.map}',
          '<%= yeoman.app %>/js/**/*.js',
          '<%= yeoman.app %>/img/**/*.{gif,jpg,jpeg,png,svg,webp}'
        ]
      }
    },
    connect: {
      options: {
        port: 9000,
        livereload: 35729,
        // change this to '0.0.0.0' to access the server from outside
        hostname: 'localhost'
      },
      livereload: {
        options: {
          open: true,
          base: [
            '.tmp',
            '.jekyll',
            '<%= yeoman.app %>'
          ]
        }
      },
      dist: {
        options: {
          open: true,
          base: [
            '<%= yeoman.dist %>'
          ]
        }
      },
      test: {
        options: {
          base: [
            '.tmp',
            '.jekyll',
            'test',
            '<%= yeoman.app %>'
          ]
        }
      }
    },
    clean: {
      dist: {
        files: [{
          dot: true,
          src: [
            '<%= yeoman.dist %>/*',
            // Running Jekyll also cleans the target directory.  Exclude any
            // non-standard `keep_files` here (e.g., the generated files
            // directory from Jekyll Picture Tag).
            '!<%= yeoman.dist %>/.git*'
          ]
        }]
      },
      js: ['.tmp/js/*'],
      css: ['.tmp/css'],
      server: [
        '.tmp',
        '.jekyll'
      ]
    },
    compass: {
      options: {
        // If you're using global Sass gems, require them here.
        // require: ['singularity', 'jacket'],
        bundleExec: true,
        sourcemap: true,
        sassDir: '<%= yeoman.app %>/_scss',
        cssDir: '.tmp/css',
        imagesDir: '<%= yeoman.app %>/img',
        javascriptsDir: '<%= yeoman.app %>/js',
        relativeAssets: false,
        httpImagesPath: '/img',
        httpGeneratedImagesPath: '/img/generated',
        outputStyle: 'expanded',
        raw: 'extensions_dir = "<%= yeoman.app %>/_bower_components"\n'
      },
      dist: {
        options: {
          generatedImagesDir: '<%= yeoman.dist %>/img/generated'
        }
      },
      server: {
        options: {
          debugInfo: true,
          generatedImagesDir: '.tmp/img/generated'
        }
      }
    },
    autoprefixer: {
      options: {
        browsers: ['last 2 versions']
      },
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>/css',
          src: '**/*.css',
          dest: '<%= yeoman.dist %>/css'
        }]
      },
      server: {
        files: [{
          expand: true,
          cwd: '.tmp/css',
          src: '**/*.css',
          dest: '.tmp/css'
        }]
      }
    },
    coffee: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/_src',
          src: '**/*.coffee',
          dest: '.tmp/js',
          ext: '.js'
        }]
      },
      test: {
        files: [{
          expand: true,
          cwd: 'test/spec',
          src: '**/*.coffee',
          dest: '.tmp/spec',
          ext: '.js'
        }]
      }
    },
    injector: {
        local_dependencies: {
          files: {
            '<%= yeoman.app %>/_includes/styles.html': [
                '.tmp/css/**/*.css'
              ],
            '<%= yeoman.app %>/_includes/scripts.html': [
                '<%= yeoman.app %>/js/**/*.js',
                '.tmp/js/**/*.js'
              ],
          },
        },
        options: {
          ignorePath: [
            '<%= yeoman.app %>',
            '.tmp'
          ]
        }
    },
    wiredep: {
      inject:{
        src: [
          '<%= yeoman.app %>/_includes/styles.html',
          '<%= yeoman.app %>/_includes/scripts.html'
        ],
        exclude: [
          '<%= yeoman.app %>/_bower_components/bootstrap/dist/css/', // Include the src files directly with Compass
          '<%= yeoman.app %>/_bower_components/modernizr'
        ],
        dependencies: true,
        devDependencies: true,
        includeSelf: false,
        ignorePath: '../',
        fileTypes: {
          html: {
            replace: {
              js: '<script src="/{{filePath}}"></script>',
              css: '<link rel="stylesheet" href="/{{filePath}}" />'
            }
          }
        }
      }
    },

    jekyll: {
      options: {
        bundleExec: true,
        config: '_config.yml,_config.build.yml',
        src: '<%= yeoman.app %>'
      },
      dist: {
        options: {
          dest: '<%= yeoman.dist %>',
        }
      },
      server: {
        options: {
          config: '_config.yml',
          dest: '.jekyll'
        }
      },
      check: {
        options: {
          doctor: true
        }
      }
    },
    useminPrepare: {
      options: {
        dest: '<%= yeoman.dist %>'
      },
      html: '<%= yeoman.dist %>/index.html'
    },
    usemin: {
      options: {
        assetsDirs: '<%= yeoman.dist %>',
      },
      html: ['<%= yeoman.dist %>/**/*.html'],
      css: ['<%= yeoman.dist %>/css/**/*.css']
    },
    htmlmin: {
      dist: {
        options: {
          collapseWhitespace: true,
          collapseBooleanAttributes: true,
          removeAttributeQuotes: true,
          removeRedundantAttributes: true
        },
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>',
          src: '**/*.html',
          dest: '<%= yeoman.dist %>'
        }]
      }
    },
    // Usemin adds files to concat
    concat: {},
    // Usemin adds files to uglify
    uglify: {},
    // Usemin adds files to cssmin
    cssmin: {
      dist: {
        options: {
          check: 'gzip'
        }
      }
    },
    imagemin: {
      dist: {
        options: {
          progressive: true
        },
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>',
          src: '**/*.{jpg,jpeg,png}',
          dest: '<%= yeoman.dist %>'
        }]
      }
    },
    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>',
          src: '**/*.svg',
          dest: '<%= yeoman.dist %>'
        }]
      }
    },
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>',
          src: [
            // Jekyll processes and moves HTML and text files.
            // Usemin moves CSS and javascript inside of Usemin blocks.
            // Copy moves asset files and directories.
            'img/**/*',
            'fonts/**/*',
            // Like Jekyll, exclude files & folders prefixed with an underscore.
            '!**/_*{,/**}',
            'favicon.ico',
            'apple-touch*.png'
          ],
          dest: '<%= yeoman.dist %>'
        }]
      },
      // Copy CSS into .tmp directory for Autoprefixer processing
      stageCss: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>/css',
          src: '**/*.css',
          dest: '.tmp/css'
        }]
      }
    },
    filerev: {
      options: {
        length: 4
      },
      dist: {
        files: [{
          src: [
            '<%= yeoman.dist %>/js/**/*.js',
            '<%= yeoman.dist %>/css/**/*.css',
            '<%= yeoman.dist %>/img/**/*.{gif,jpg,jpeg,png,svg,webp}',
            '<%= yeoman.dist %>/fonts/**/*.{eot*,otf,svg,ttf,woff}'
          ]
        }]
      }
    },
    buildcontrol: {
      dist: {
        options: {
          dir: 'dist',
          remote: 'git@bitbucket.org:Chosko/jekyll-project-compiled',
          branch: 'gh-pages',
          commit: true,
          push: true,
          message: 'Built %sourceName% from commit %sourceCommit%'
        }
      }
    },
    coffeelint: {
      options: {
        'max_line_length': {
          'level': 'ignore'
        }
      },
      check: ['<%= yeoman.app %>/_src/*.coffee']
    },
    jshint: {
      options: {
        jshintrc: '.jshintrc',
        reporter: require('jshint-stylish')
      },
      all: [
        'Gruntfile.js',
        '<%= yeoman.app %>/js/**/*.js',
        'test/spec/**/*.js'
      ]
    },
    csslint: {
      options: {
        csslintrc: '.csslintrc'
      },
      check: {
        src: [
          '<%= yeoman.app %>/css/**/*.css',
          '<%= yeoman.app %>/_scss/**/*.scss'
        ]
      }
    },
    concurrent: {
      server: [
        'compass:server',
        'coffee:dist',
        'copy:stageCss',
      ],
      dist: [
        'compass:dist',
        'coffee:dist',
        'copy:dist',
      ]
    },
    shell: {
      bower: {
        command: 'bower install'
      }
    }
  });

  // Define Tasks
  grunt.registerTask('serve', function (target) {
    if (target === 'dist') {
      return grunt.task.run(['build', 'connect:dist:keepalive']);
    }

    grunt.task.run([
      'local',
      'notify_hooks',
      'connect:livereload',
      'watch'
    ]);
  });

  grunt.registerTask('server', function () {
    grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
    grunt.task.run(['serve']);
  });

  grunt.registerTask('local', [
    'shell:bower',
    'clean:server',
    'concurrent:server',
    'injectDependencies',
    'jekyll:server',
    'autoprefixer:server'
  ]);

  // No real tests yet. Add your own.
  grunt.registerTask('test', [
  //   'clean:server',
  //   'concurrent:test',
  //   'connect:test'
  ]);

  grunt.registerTask('injectDependencies', [
    'injector',
    'wiredep'
  ]);

  grunt.registerTask('check', [
    'clean:server',
    'jekyll:check',
    'compass:server',
    'coffeelint:check',
    'coffee:dist',
    'jshint:all',
    'csslint:check'
  ]);

  grunt.registerTask('build', [
    'shell:bower',
    'clean',
    // Jekyll cleans files from the target directory, so must run first
    'concurrent:dist',
    'injectDependencies',
    'jekyll:dist',
    'useminPrepare',
    'concat',
    'autoprefixer:dist',
    'cssmin',
    'uglify',
    'imagemin',
    'svgmin',
    'filerev',
    'usemin',
    'htmlmin'
    ]);

  grunt.registerTask('deploy', [
    'check',
    'test',
    'build',
    'buildcontrol'
    ]);

  grunt.registerTask('default', [
    'check',
    'test',
    'build'
  ]);
};
<|endoftext|>


<commit_before>// $Revision$

var Ensembl = new Base();

Ensembl.extend({
  constructor: null,

  initialize: function () {
    var myself = this;

    var hints = this.cookie.get('ENSEMBL_HINTS');

    if (!window.name) {
      window.name = 'ensembl_' + new Date().getTime() + '_' + Math.floor(Math.random() * 10000);
    }

    this.ajax  = this.cookie.get('ENSEMBL_AJAX')  || this.setAjax();
    this.width = this.cookie.get('ENSEMBL_WIDTH') || this.setWidth();

    this.hideHints = {};

    if (hints) {
      $.each(hints.split(/:/), function () {
        myself.hideHints[this] = 1;
      });
    }

    // Store image panel details for highlighting
    this.images = {
      total: $('.image_panel').length,
      last: $('.image_panel:last')[0]
    }

    this.setCoreParams();

    this.LayoutManager.initialize();
    this.PanelManager.initialize();
  },

  cookie: {
    set: function (name, value, expiry) {
      document.cookie = escape(name) + '=' + escape(value || '') +
      '; expires=' + (expiry == -1 ? 'Thu, 01 Jan 1970' : 'Tue, 19 Jan 2038') +
      ' 00:00:00 GMT; path=/';
    },

    get: function (name) {
      var cookie = document.cookie.match(new RegExp('(^|;)\\s*' + escape(name) + '=([^;\\s]*)'));
      return cookie ? unescape(cookie[2]) : '';
    }
  },

  setAjax: function () {
    this.ajax = ($.ajaxSettings.xhr() || false) ? 'enabled' : 'none';
    this.cookie.set('ENSEMBL_AJAX', this.ajax);
  },

  setWidth: function () {
    var w = Math.floor(($(window).width() - 250) / 100) * 100;

    this.width = w < 500 ? 500 : w;
    this.cookie.set('ENSEMBL_WIDTH', this.width);
  },

  setCoreParams: function () {
    var myself = this;

    var regex = '[;&?]%s=(.+?)[;&]';
    var url = window.location.search + ';';

    this.coreParams = {};
    this.location = { width: 100000 };
    this.species = window.location.pathname.split('/')[1];
    this.multiSpecies = {};

    $.each(['r', 'g', 't', 'v'], function () {
      myself.coreParams[this] = url.match(regex.replace('%s', this));

      if (myself.coreParams[this]) {
        myself.coreParams[this] = unescape(myself.coreParams[this][1]);
      }
    });

    var match = (this.coreParams.r ? this.coreParams.r.match(/(\w+):(\d+)-(\d+)/) : false) || ($('a', '#tab_location').html() || '').replace(/,/g, '').match(/^Location: (.+):(\d+)-(\d+)$/);

    if (match) {
      this.location = { name: match[1], start: parseInt(match[2]), end: parseInt(match[3]) };
      this.location.width = this.location.end - this.location.start + 1;

      if (this.location.width > 1000000) {
        this.location.width = 1000000;
      }
    }

    match = url.match(/s\d+=.+?[;&]/g);

    if (match) {
      var m, i, s, r;

      $.each(match, function () {
        m = this.split('=');
        i = m[0].substr(1);
        s = m[1].replace(/[;&]/, '');

        myself.multiSpecies[s] = {};

        $.each(['r', 'g'], function () {
          myself.multiSpecies[s][this] = url.match(regex.replace('%s', this + i));

          if (myself.multiSpecies[s][this]) {
            myself.multiSpecies[s][this] = unescape(myself.multiSpecies[s][this][1]);
          }

          if (this == 'r' && myself.multiSpecies[s].r) {
            r = myself.multiSpecies[s].r.split(/\b/);

            myself.multiSpecies[s].location = { name: r[0], start: parseInt(r[2]), end: parseInt(r[4]) };
          }
        });
      });
    }
  },

  // Remove the old time stamp from a URL and replace with a new one
  replaceTimestamp: function (url) {
    var d = new Date();
    var time = d.getTime() + d.getMilliseconds() / 1000;

    url = url.replace(/&/g, ';').replace(/#.*$/g, '').replace(/\?time=[^;]+;?/g, '?').replace(/;time=[^;]+;?/g, ';').replace(/[\?;]$/g, '');
    url += (url.match(/\?/) ? ';' : '?') + 'time=' + time;

    return url;
  }
});
<commit_msg>actually store ajax and width parameters<commit_after>// $Revision$

var Ensembl = new Base();

Ensembl.extend({
  constructor: null,

  initialize: function () {
    var myself = this;

    var hints = this.cookie.get('ENSEMBL_HINTS');

    if (!window.name) {
      window.name = 'ensembl_' + new Date().getTime() + '_' + Math.floor(Math.random() * 10000);
    }

    (this.ajax  = this.cookie.get('ENSEMBL_AJAX'))  || this.setAjax();
    (this.width = this.cookie.get('ENSEMBL_WIDTH')) || this.setWidth();

    this.hideHints = {};

    if (hints) {
      $.each(hints.split(/:/), function () {
        myself.hideHints[this] = 1;
      });
    }

    // Store image panel details for highlighting
    this.images = {
      total: $('.image_panel').length,
      last: $('.image_panel:last')[0]
    }

    this.setCoreParams();

    this.LayoutManager.initialize();
    this.PanelManager.initialize();
  },

  cookie: {
    set: function (name, value, expiry) {
      document.cookie = escape(name) + '=' + escape(value || '') +
      '; expires=' + (expiry == -1 ? 'Thu, 01 Jan 1970' : 'Tue, 19 Jan 2038') +
      ' 00:00:00 GMT; path=/';
    },

    get: function (name) {
      var cookie = document.cookie.match(new RegExp('(^|;)\\s*' + escape(name) + '=([^;\\s]*)'));
      return cookie ? unescape(cookie[2]) : '';
    }
  },

  setAjax: function () {
    this.ajax = ($.ajaxSettings.xhr() || false) ? 'enabled' : 'none';
    this.cookie.set('ENSEMBL_AJAX', this.ajax);
  },

  setWidth: function () {
    var w = Math.floor(($(window).width() - 250) / 100) * 100;

    this.width = w < 500 ? 500 : w;
    this.cookie.set('ENSEMBL_WIDTH', this.width);
  },

  setCoreParams: function () {
    var myself = this;

    var regex = '[;&?]%s=(.+?)[;&]';
    var url = window.location.search + ';';

    this.coreParams = {};
    this.location = { width: 100000 };
    this.species = window.location.pathname.split('/')[1];
    this.multiSpecies = {};

    $.each(['r', 'g', 't', 'v'], function () {
      myself.coreParams[this] = url.match(regex.replace('%s', this));

      if (myself.coreParams[this]) {
        myself.coreParams[this] = unescape(myself.coreParams[this][1]);
      }
    });

    var match = (this.coreParams.r ? this.coreParams.r.match(/(\w+):(\d+)-(\d+)/) : false) || ($('a', '#tab_location').html() || '').replace(/,/g, '').match(/^Location: (.+):(\d+)-(\d+)$/);

    if (match) {
      this.location = { name: match[1], start: parseInt(match[2]), end: parseInt(match[3]) };
      this.location.width = this.location.end - this.location.start + 1;

      if (this.location.width > 1000000) {
        this.location.width = 1000000;
      }
    }

    match = url.match(/s\d+=.+?[;&]/g);

    if (match) {
      var m, i, s, r;

      $.each(match, function () {
        m = this.split('=');
        i = m[0].substr(1);
        s = m[1].replace(/[;&]/, '');

        myself.multiSpecies[s] = {};

        $.each(['r', 'g'], function () {
          myself.multiSpecies[s][this] = url.match(regex.replace('%s', this + i));

          if (myself.multiSpecies[s][this]) {
            myself.multiSpecies[s][this] = unescape(myself.multiSpecies[s][this][1]);
          }

          if (this == 'r' && myself.multiSpecies[s].r) {
            r = myself.multiSpecies[s].r.split(/\b/);

            myself.multiSpecies[s].location = { name: r[0], start: parseInt(r[2]), end: parseInt(r[4]) };
          }
        });
      });
    }
  },

  // Remove the old time stamp from a URL and replace with a new one
  replaceTimestamp: function (url) {
    var d = new Date();
    var time = d.getTime() + d.getMilliseconds() / 1000;

    url = url.replace(/&/g, ';').replace(/#.*$/g, '').replace(/\?time=[^;]+;?/g, '?').replace(/;time=[^;]+;?/g, ';').replace(/[\?;]$/g, '');
    url += (url.match(/\?/) ? ';' : '?') + 'time=' + time;

    return url;
  }
});
<|endoftext|>


<commit_before>// browsers to test in saucelabs
var browsers = [{
  browserName: "firefox",
  version: "19",
  platform: "XP"
}, {
  browserName: "chrome",
  platform: "XP"
}, {
  browserName: "internet explorer",
  platform: "XP",
  version: "6"
}, {
  browserName: "internet explorer",
  platform: "XP",
  version: "7"
}, {
  browserName: "internet explorer",
  platform: "XP",
  version: "8"
}, {
  browserName: "internet explorer",
  platform: "VISTA",
  version: "9"
}, {
  browserName: "internet explorer",
  platform: "VISTA",
  version: "10"
}, {
  browserName: "opera",
  platform: "XP",
  version: "12"
}];

module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

    exec_jshint: {
      all: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js']
    },

    powerbuild: {
      options: {
        sourceMap: true
      },
      test: {
        files: [{
          src: 'test/**/*.js', dest: 'build/test-bundle.js'
        }]
      }
    },

    mocha_debug: {
      options: {
        reporter: 'dot',
        check: ['src/**/*.js', 'test/**/*.js']
      },
      nodejs: {
        options: {
          src: ['src/**/*.js', 'test/**/*.js']
        }
      },
      browser: {
        options: {
          listenAddress: '127.0.0.1',
          listenPort: 9999,
          phantomjs: true,
          src: ['build/test-bundle.js']
        }
      }
    },

    'saucelabs-mocha': {
      all: {
        options: {
          urls: ["http://127.0.0.1:9999"],
          tunnelTimeout: 5,
          build: process.env.TRAVIS_JOB_ID,
          concurrency: 3,
          browsers: browsers,
          testname: "tarruda/classic tests",
          tags: ["master"]
        }
      }
    },

    watch: {
      options: {
        nospawn: true
      },
      all: {
        files: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js'],
        tasks: ['test']
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-exec-jshint');
  grunt.loadNpmTasks('grunt-mocha-debug');
  grunt.loadNpmTasks('powerbuild');
  grunt.loadNpmTasks('grunt-newer');
  grunt.loadNpmTasks('grunt-release');
  grunt.loadNpmTasks('grunt-saucelabs');
  grunt.registerTask('test', ['newer:exec_jshint', 'powerbuild', 'mocha_debug']);

  grunt.registerTask('publish', ['mocha_debug', 'release']);
  grunt.registerTask('travis', ['test', 'saucelabs-mocha']);
  grunt.registerTask('default', ['test', 'watch']);
};
<commit_msg>Remove IE6 and leave only working browsers<commit_after>// browsers to test in saucelabs
var browsers = [{
  browserName: "internet explorer",
  platform: "XP",
  version: "7"
}, {
  browserName: "internet explorer",
  platform: "WIN7",
  version: "8"
}, {
  browserName: "internet explorer",
  platform: "WIN7",
  version: "9"
}, {
  browserName: "internet explorer",
  platform: "WIN7",
  version: "10"
}, {
  browserName: "firefox",
  platform: "WIN7"
}, {
  browserName: "chrome",
  platform: "WIN7"
}, {
  browserName: "opera",
  platform: "WIN7"
}];

module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

    exec_jshint: {
      all: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js']
    },

    powerbuild: {
      options: {
        sourceMap: true
      },
      test: {
        files: [{
          src: 'test/**/*.js', dest: 'build/test-bundle.js'
        }]
      }
    },

    mocha_debug: {
      options: {
        reporter: 'dot',
        check: ['src/**/*.js', 'test/**/*.js']
      },
      nodejs: {
        options: {
          src: ['src/**/*.js', 'test/**/*.js']
        }
      },
      browser: {
        options: {
          listenAddress: '0.0.0.0',
          listenPort: 9999,
          phantomjs: true,
          src: ['build/test-bundle.js']
        }
      }
    },

    'saucelabs-mocha': {
      all: {
        options: {
          urls: ["http://127.0.0.1:9999"],
          tunnelTimeout: 5,
          build: process.env.TRAVIS_JOB_ID,
          concurrency: 3,
          browsers: browsers,
          testname: "tarruda/classic tests",
          tags: ["master"]
        }
      }
    },

    watch: {
      options: {
        nospawn: true
      },
      all: {
        files: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js'],
        tasks: ['test']
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-exec-jshint');
  grunt.loadNpmTasks('grunt-mocha-debug');
  grunt.loadNpmTasks('powerbuild');
  grunt.loadNpmTasks('grunt-newer');
  grunt.loadNpmTasks('grunt-release');
  grunt.loadNpmTasks('grunt-saucelabs');
  grunt.registerTask('test', ['newer:exec_jshint', 'powerbuild', 'mocha_debug']);

  grunt.registerTask('publish', ['mocha_debug', 'release']);
  grunt.registerTask('travis', ['test', 'saucelabs-mocha']);
  grunt.registerTask('default', ['test', 'watch']);
};
<|endoftext|>


<commit_before>module.exports = function(grunt) {

	grunt.loadNpmTasks('grunt-contrib-clean');
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-contrib-qunit');
	grunt.loadNpmTasks('grunt-contrib-watch');
	grunt.loadNpmTasks('grunt-rename');

	var srcFiles = [
		'./signal.js',
	];

	grunt.initConfig({
		pkg: grunt.file.readJSON('package.json'),
		banner:
			'/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
			'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
			'<%= pkg.homepage ? " * " + pkg.homepage + "\\n" : "" %>' +
			' * Copyright (c) 2013-<%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
			' License: <%= pkg.license %> */\n',
		directories: {
			dist: 'dist/<%= pkg.version %>'
		},
		filenames: {
			full: '<%= pkg.name %>-<%= pkg.version %>.js',
			minified: '<%= pkg.name %>-<%= pkg.version %>.min.js',
			sourcemap: '<%= pkg.name %>-<%= pkg.version %>.min.map'
		},
		clean: {
			files: [ '<%= directories.dist %>', '<%= filenames.full %>', '<%= filenames.minified %>', '<%= filenames.sourcemap %>' ]
		},
		jshint: {
			beforeconcat: [ 'src/**/*.js' ],
			afterconcat: [ '<%= filenames.full %>' ],
			options: {
				'-W093': true, // Disable "Did you mean to return a conditional instead of an assignment?" warning
				ignores: [ 'src/Intro.js', 'src/Outro.js' ]
			}
		},
		concat: {
			options: {
				banner: '<%= banner %>',
				stripBanners: true,
				separator: '\n\n//----\n\n'
			},
			dist: {
				src: srcFiles,
				dest: '<%= filenames.full %>'
			}
		},
		uglify: {
			options: {
				// Grunt-contrib-uglify does not support adding a banner alongside sourcemaps. Add the banner to your unminified source and then uglify.
				// banner: '<%= banner %>',

				sourceMap: '<%= filenames.sourcemap %>'
			},
			dist: {
				src: '<%= filenames.full %>',
				dest: '<%= filenames.minified %>'
			}
		},
		rename: {
			full: {
				src: '<%= filenames.full %>',
				dest: '<%= directories.dist %>/<%= filenames.full %>'
			},
			minified: {
				src: '<%= filenames.minified %>',
				dest: '<%= directories.dist %>/<%= filenames.minified %>'
			},
			sourcemap: {
				src: '<%= filenames.sourcemap %>',
				dest: '<%= directories.dist %>/<%= filenames.sourcemap %>'
			}
		}
	});

	grunt.registerTask('default', ['clean', 'jshint', 'concat', 'uglify', 'rename']);

};<commit_msg>remove the grunt file<commit_after><|endoftext|>


<commit_before>/*global module:false*/

module.exports = function(grunt) {

  var srcFiles = [
    'src/SIP.js',
    'src/LoggerFactory.js',
    'src/EventEmitter.js',
    'src/Constants.js',
    'src/Exceptions.js',
    'src/Timers.js',
    'src/Transport.js',
    'src/Parser.js',
    'src/SIPMessage.js',
    'src/URI.js',
    'src/NameAddrHeader.js',
    'src/Transactions.js',
    'src/Dialogs.js',
    'src/RequestSender.js',
    'src/RegisterContext.js',
    'src/MessageContext.js',
    'src/ClientContext.js',
    'src/ServerContext.js',
    'src/InviteContext.js',
    'src/UA.js',
    'src/Utils.js',
    'src/SanityCheck.js',
    'src/DigestAuthentication.js',
    'src/WebRTC.js',
    'src/tail.js'
  ];

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    meta: {
      banner: '\
/*\n\
 * SIP version <%= pkg.version %>\n\
 * Copyright (c) 2012-<%= grunt.template.today("yyyy") %> José Luis Millán - Versatica <http://www.versatica.com>\n\
 * Homepage: http://jssip.net\n\
 * License: http://jssip.net/license\n\
 */\n\n\n'
    },
    concat: {
      dist: {
        src: srcFiles,
        dest: 'dist/<%= pkg.name %>-<%= pkg.version %>.js',
        options: {
          banner: '<%= meta.banner %>',
          separator: '\n\n',
          process: true
        },
        nonull: true
      },
      post_dist: {
        src: [
          'dist/<%= pkg.name %>-<%= pkg.version %>.js',
          'src/Grammar/dist/Grammar.js',
          'src/SDP/dist/SDP.js'
        ],
        dest: 'dist/<%= pkg.name %>-<%= pkg.version %>.js',
        nonull: true
      },
      devel: {
        src: srcFiles,
        dest: 'dist/<%= pkg.name %>-devel.js',
        options: {
          banner: '<%= meta.banner %>',
          separator: '\n\n',
          process: true
        },
        nonull: true
      },
      post_devel: {
        src: [
          'dist/<%= pkg.name %>-devel.js',
          'src/Grammar/dist/Grammar.js',
          'src/SDP/dist/SDP.js'
        ],
        dest: 'dist/<%= pkg.name %>-devel.js',
        nonull: true
      }
    },
    includereplace: {
      dist: {
        files: {
          'dist': 'dist/<%= pkg.name %>-<%= pkg.version %>.js'
        }
      },
      devel: {
        files: {
          'dist': 'dist/<%= pkg.name %>-devel.js'
        }
      }
    },
    jshint: {
      dist: 'dist/<%= pkg.name %>-<%= pkg.version %>.js',
      devel: 'dist/<%= pkg.name %>-devel.js',
      options: {
        browser: true,
        curly: true,
        eqeqeq: true,
        immed: true,
        latedef: true,
        newcap: false,
        noarg: true,
        sub: true,
        undef: true,
        boss: true,
        eqnull: true,
        onecase: true,
        unused: true,
        supernew: true,
        globals: {
          module: true,
          define: true
        }
      }
    },
    uglify: {
      dist: {
        files: {
          'dist/<%= pkg.name %>-<%= pkg.version %>.min.js': ['dist/<%= pkg.name %>-<%= pkg.version %>.js']
        }
      },
      options: {
        banner: '<%= meta.banner %>'
      }
    },
    jasmine: {
      components: {
        src: [
        'dist/sip-devel.js'
        ],
        options: {
          specs: 'test/spec/Spec*.js',
          keepRunner : true,
          //helpers: 'test/spec/*.js'
        }
      }
    }
  });

  // Load Grunt plugins.
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-include-replace');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-jasmine');

  // Task for building JsSIP Grammar.js and Grammar.min.js files.
  grunt.registerTask('grammar', function(){
    var done = this.async();  // This is an async task.
    var sys = require('sys');
    var exec = require('child_process').exec;
    var child;

    // First compile JsSIP grammar with PEGjs.
    console.log('"grammar" task: compiling JsSIP PEGjs grammar into Grammar.js ...');
    child = exec('if [ -x "./node_modules/pegjs/bin/pegjs" ] ; then PEGJS="./node_modules/pegjs/bin/pegjs"; else PEGJS="pegjs" ; fi && $PEGJS -e SIP.Grammar src/Grammar/src/Grammar.pegjs src/Grammar/dist/Grammar.js', function(error, stdout, stderr) {
      if (error) {
        sys.print('ERROR: ' + stderr);
        done(false);  // Tell grunt that async task has failed.
      }
      console.log('OK');

      // Then modify the generated Grammar.js file with custom changes.
      console.log('"grammar" task: applying custom changes to Grammar.js ...');
      var fs = require('fs');
      var grammar = fs.readFileSync('src/Grammar/dist/Grammar.js').toString();
      var modified_grammar = grammar.replace(/throw new this\.SyntaxError\(([\s\S]*?)\);([\s\S]*?)}([\s\S]*?)return result;/, 'new this.SyntaxError($1);\n        return -1;$2}$3return data;');
      fs.writeFileSync('src/Grammar/dist/Grammar.js', modified_grammar);
      console.log('OK');
      done();  // Tell grunt that async task has succeeded.

    });
  });

  // Task for building JsSIP SDP.js and SDP.min.js files.
  grunt.registerTask('sdp', function(){
    var done = this.async();  // This is an async task.
    var sys = require('sys');
    var exec = require('child_process').exec;
    var child;

    // Build a bundle of 'sdp-transform' for the browser.
    console.log('"sdp" task: getting SIP parser from "sdp-transform" ...');
    child = exec('browserify src/SDP/main.js -o src/SDP/dist/SDP.js', function(error, stdout, stderr) {
      if (error) {
        sys.print('ERROR: ' + stderr);
        done(false);  // Tell grunt that async task has failed.
      }
      console.log('OK');
      done();  // Tell grunt that async task has succeeded.
    });
  });

  // Task for building jssip-devel.js (uncompressed), sip-X.Y.Z.js (uncompressed)
  // and sip-X.Y.Z.min.js (minified).
  // Both sip-devel.js and sip-X.Y.Z.js are the same file with different name.
  grunt.registerTask('build', ['concat:devel', 'includereplace:devel', 'jshint:devel', 'concat:post_devel', 'concat:dist', 'includereplace:dist', 'jshint:dist', 'concat:post_dist', 'uglify:dist']);

  // Task for building sip-devel.js (uncompressed).
  grunt.registerTask('devel', ['concat:devel', 'includereplace:devel', 'jshint:devel', 'concat:post_devel']);

  // Test tasks.
  grunt.registerTask('test',['jasmine']);

  // Travis CI task.
  // Doc: http://manuel.manuelles.nl/blog/2012/06/22/integrate-travis-ci-into-grunt/
  grunt.registerTask('travis', ['grammar', 'devel', 'test']);

  // Default task is an alias for 'build'.
  // I know this is annoying... but you could always do grunt build. This encourages better code testing! --Eric Green
  grunt.registerTask('default', ['test','build']);

};
<commit_msg>Change order of grunt default to build before testing<commit_after>/*global module:false*/

module.exports = function(grunt) {

  var srcFiles = [
    'src/SIP.js',
    'src/LoggerFactory.js',
    'src/EventEmitter.js',
    'src/Constants.js',
    'src/Exceptions.js',
    'src/Timers.js',
    'src/Transport.js',
    'src/Parser.js',
    'src/SIPMessage.js',
    'src/URI.js',
    'src/NameAddrHeader.js',
    'src/Transactions.js',
    'src/Dialogs.js',
    'src/RequestSender.js',
    'src/RegisterContext.js',
    'src/MessageContext.js',
    'src/ClientContext.js',
    'src/ServerContext.js',
    'src/InviteContext.js',
    'src/UA.js',
    'src/Utils.js',
    'src/SanityCheck.js',
    'src/DigestAuthentication.js',
    'src/WebRTC.js',
    'src/tail.js'
  ];

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    meta: {
      banner: '\
/*\n\
 * SIP version <%= pkg.version %>\n\
 * Copyright (c) 2012-<%= grunt.template.today("yyyy") %> José Luis Millán - Versatica <http://www.versatica.com>\n\
 * Homepage: http://jssip.net\n\
 * License: http://jssip.net/license\n\
 */\n\n\n'
    },
    concat: {
      dist: {
        src: srcFiles,
        dest: 'dist/<%= pkg.name %>-<%= pkg.version %>.js',
        options: {
          banner: '<%= meta.banner %>',
          separator: '\n\n',
          process: true
        },
        nonull: true
      },
      post_dist: {
        src: [
          'dist/<%= pkg.name %>-<%= pkg.version %>.js',
          'src/Grammar/dist/Grammar.js',
          'src/SDP/dist/SDP.js'
        ],
        dest: 'dist/<%= pkg.name %>-<%= pkg.version %>.js',
        nonull: true
      },
      devel: {
        src: srcFiles,
        dest: 'dist/<%= pkg.name %>-devel.js',
        options: {
          banner: '<%= meta.banner %>',
          separator: '\n\n',
          process: true
        },
        nonull: true
      },
      post_devel: {
        src: [
          'dist/<%= pkg.name %>-devel.js',
          'src/Grammar/dist/Grammar.js',
          'src/SDP/dist/SDP.js'
        ],
        dest: 'dist/<%= pkg.name %>-devel.js',
        nonull: true
      }
    },
    includereplace: {
      dist: {
        files: {
          'dist': 'dist/<%= pkg.name %>-<%= pkg.version %>.js'
        }
      },
      devel: {
        files: {
          'dist': 'dist/<%= pkg.name %>-devel.js'
        }
      }
    },
    jshint: {
      dist: 'dist/<%= pkg.name %>-<%= pkg.version %>.js',
      devel: 'dist/<%= pkg.name %>-devel.js',
      options: {
        browser: true,
        curly: true,
        eqeqeq: true,
        immed: true,
        latedef: true,
        newcap: false,
        noarg: true,
        sub: true,
        undef: true,
        boss: true,
        eqnull: true,
        onecase: true,
        unused: true,
        supernew: true,
        globals: {
          module: true,
          define: true
        }
      }
    },
    uglify: {
      dist: {
        files: {
          'dist/<%= pkg.name %>-<%= pkg.version %>.min.js': ['dist/<%= pkg.name %>-<%= pkg.version %>.js']
        }
      },
      options: {
        banner: '<%= meta.banner %>'
      }
    },
    jasmine: {
      components: {
        src: [
        'dist/sip-devel.js'
        ],
        options: {
          specs: 'test/spec/Spec*.js',
          keepRunner : true,
          //helpers: 'test/spec/*.js'
        }
      }
    }
  });

  // Load Grunt plugins.
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-include-replace');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-jasmine');

  // Task for building JsSIP Grammar.js and Grammar.min.js files.
  grunt.registerTask('grammar', function(){
    var done = this.async();  // This is an async task.
    var sys = require('sys');
    var exec = require('child_process').exec;
    var child;

    // First compile JsSIP grammar with PEGjs.
    console.log('"grammar" task: compiling JsSIP PEGjs grammar into Grammar.js ...');
    child = exec('if [ -x "./node_modules/pegjs/bin/pegjs" ] ; then PEGJS="./node_modules/pegjs/bin/pegjs"; else PEGJS="pegjs" ; fi && $PEGJS -e SIP.Grammar src/Grammar/src/Grammar.pegjs src/Grammar/dist/Grammar.js', function(error, stdout, stderr) {
      if (error) {
        sys.print('ERROR: ' + stderr);
        done(false);  // Tell grunt that async task has failed.
      }
      console.log('OK');

      // Then modify the generated Grammar.js file with custom changes.
      console.log('"grammar" task: applying custom changes to Grammar.js ...');
      var fs = require('fs');
      var grammar = fs.readFileSync('src/Grammar/dist/Grammar.js').toString();
      var modified_grammar = grammar.replace(/throw new this\.SyntaxError\(([\s\S]*?)\);([\s\S]*?)}([\s\S]*?)return result;/, 'new this.SyntaxError($1);\n        return -1;$2}$3return data;');
      fs.writeFileSync('src/Grammar/dist/Grammar.js', modified_grammar);
      console.log('OK');
      done();  // Tell grunt that async task has succeeded.

    });
  });

  // Task for building JsSIP SDP.js and SDP.min.js files.
  grunt.registerTask('sdp', function(){
    var done = this.async();  // This is an async task.
    var sys = require('sys');
    var exec = require('child_process').exec;
    var child;

    // Build a bundle of 'sdp-transform' for the browser.
    console.log('"sdp" task: getting SIP parser from "sdp-transform" ...');
    child = exec('browserify src/SDP/main.js -o src/SDP/dist/SDP.js', function(error, stdout, stderr) {
      if (error) {
        sys.print('ERROR: ' + stderr);
        done(false);  // Tell grunt that async task has failed.
      }
      console.log('OK');
      done();  // Tell grunt that async task has succeeded.
    });
  });

  // Task for building jssip-devel.js (uncompressed), sip-X.Y.Z.js (uncompressed)
  // and sip-X.Y.Z.min.js (minified).
  // Both sip-devel.js and sip-X.Y.Z.js are the same file with different name.
  grunt.registerTask('build', ['concat:devel', 'includereplace:devel', 'jshint:devel', 'concat:post_devel', 'concat:dist', 'includereplace:dist', 'jshint:dist', 'concat:post_dist', 'uglify:dist']);

  // Task for building sip-devel.js (uncompressed).
  grunt.registerTask('devel', ['concat:devel', 'includereplace:devel', 'jshint:devel', 'concat:post_devel']);

  // Test tasks.
  grunt.registerTask('test',['jasmine']);

  // Travis CI task.
  // Doc: http://manuel.manuelles.nl/blog/2012/06/22/integrate-travis-ci-into-grunt/
  grunt.registerTask('travis', ['grammar', 'devel', 'test']);

  // Default task is an alias for 'build'.
  // I know this is annoying... but you could always do grunt build. This encourages better code testing! --Eric Green
  grunt.registerTask('default', ['build','test']);

};
<|endoftext|>


<commit_before>#!/usr/bin/env node

/*!
 * MeltXpert®
 * Improved Nucleic Acid homo & hetero duplexes thermal behavior analysis program.
 * ________________________________________________________________________________
 *
 * Grunt, http://gruntjs.com/.
 * The JavaScript Task Runner.
 * ________________________________________________________________________________
 *
 * Architecture and Code Handcrafted by Prabhat Kumar.
 * Architectuur en Code handgemaakt door Prabhat Kumar.
 * @author    : Prabhat Kumar [http://prabhatkumar.org/].
 * @copyright : Prabhat Kumar [http://prabhatkumar.org/].
 * @copyright : Sequømics Research [http://research.sequomics.com/].
 * @copyright : Sequømics Corporation [http://sequomics.com/].
 * ________________________________________________________________________________
 *
 * @date      : 11-Nov-2016
 * @license   : Apache, version 2.0
 * @require   : Node.js®
 * @require   : NPM
 * @require   : grunt-cli
 * @build     : SEED™ — Umeå
 *              └────── A Sequømics Product — http://sequomics.com/.
 * ________________________________________________________________________________
 *
 * --/The Heart of Build System/-- of "MeltXpert®".
 * ________________________________________________________________________________
 */

// "disallowMultipleSpaces": {"allowEOLComments": true}
// "disallowSemicolons": false
// "requireSemicolons": true
// "requireSpaceAfterLineComment": { "allExcept": ["#", "="] }

// global __dirname: true
// global require: true
<commit_msg>Initial commit<commit_after>#!/usr/bin/env node

/*!
 * MeltXpert®
 * Improved Nucleic Acid homo & hetero duplexes thermal behavior analysis program.
 * ________________________________________________________________________________
 *
 * Grunt, http://gruntjs.com/.
 * The JavaScript Task Runner.
 * ________________________________________________________________________________
 *
 * Architecture and Code Handcrafted by Prabhat Kumar.
 * Architectuur en Code handgemaakt door Prabhat Kumar.
 * @author    : Prabhat Kumar [http://prabhatkumar.org/].
 * @copyright : Prabhat Kumar [http://prabhatkumar.org/].
 * @copyright : Sequømics Research [http://research.sequomics.com/].
 * @copyright : Sequømics Corporation [http://sequomics.com/].
 * ________________________________________________________________________________
 *
 * @date      : 11-Nov-2016
 * @license   : Apache, version 2.0
 * @require   : Node.js®
 * @require   : NPM
 * @require   : grunt-cli
 * @build     : SEED™ — Umeå
 *              └────── A Sequømics Product — http://sequomics.com/.
 * ________________________________________________________________________________
 *
 * --/The Heart of Build System/-- of "MeltXpert®".
 * ________________________________________________________________________________
 */

// "disallowMultipleSpaces": {"allowEOLComments": true}
// "disallowSemicolons": false
// "requireSemicolons": true
// "requireSpaceAfterLineComment": { "allExcept": ["#", "="] }

// global __dirname: true
// global require: true

//# Usage: $ node -v
//# Usage: $ npm -v
//# Usage: $ grunt -version
<|endoftext|>


<commit_before>module.exports = function(grunt) {
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-mocha-cov');
  grunt.loadNpmTasks('grunt-mocha-test');
  grunt.loadNpmTasks('grunt-open');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-travis-matrix');
  grunt.loadTasks('tasks');

  grunt.initConfig({
    clean: {
      coverage: 'coverage'
    },
    jshint: {
      options: {
        reporter: require('jshint-stylish'),
        eqeqeq: true,
        es3: true,
        indent: 2,
        newcap: true,
        quotmark: 'single',
        boss: true
      },
      all: ['tasks/**/*.js']
    },
    matrix: {
      v4: 'codeclimate-test-reporter < coverage/lcov.info'
    },
    travis: {
      options: {
        targets: {
          test: '{{ version }}',
          when: 'v4',
          tasks: ['istanbul:unit', 'matrix:v4']
        }
      }
    },
    mochaTest: {
      options: {
        reporter: 'spec',
        ui: 'mocha-given',
        require: 'coffee-script/register'
      },
      test: {
        src: ['test/helpers/**/*.coffee', 'test/**/*.coffee', '!test/int*']
      },
      intSingle: {
        src: ['test/int-single.coffee']
      },
      intMulti: {
        src: ['test/int-multi.coffee']
      },
      intClear: {
        src: ['test/int-clear.coffee']
      }
    },
    mochacov: {
      lcov: {
        options: {
          reporter: 'mocha-lcov-reporter',
          ui: 'mocha-given',
          instrument: true,
          require: 'coffee-script/register',
          output: 'coverage/coverage.lcov'
        },
        src: ['test/**/*.coffee'],
      },
      html: {
        options: {
          reporter: 'html-cov',
          ui: 'mocha-given',
          require: 'coffee-script/register',
          output: 'coverage/coverage.html'
        },
        src: ['test/**/*.coffee']
      }
    },
    open: {
      coverage: {
        path: 'coverage/coverage.html'
      }
    },
    watch: {
      tests: {
        files: ['tasks/**/*.js', 'test/**/*.coffee'],
        tasks: ['mocha'],
        options: {
          atBegin: true
        }
      }
    },
    require: {
      single: {
        src: ['test/fixtures/foo.js']
      },
      multi: {
        src: ['test/fixtures/**/*.js', '!test/fixtures/foo.js']
      },
      clear: {
        options: {
          clearCache: true
        },
        src: ['test/fixtures/foo.js']
      }
    }
  });

  grunt.registerTask('mocha', ['mochaTest:test']);
  grunt.registerTask('default', ['jshint:all', 'mochaTest:test', 'int:single', 'int:multi', 'int:clear']);
  grunt.registerTask('coverage', ['mochacov:html']);
  grunt.registerTask('ci', ['default', 'travis']);
  grunt.registerTask('int:single', ['require:single', 'mochaTest:intSingle']);
  grunt.registerTask('int:multi', ['require:multi', 'mochaTest:intMulti']);
  grunt.registerTask('int:clear', ['require:clear', 'mochaTest:intClear']);
};
<commit_msg>Change version that travis looks for<commit_after>module.exports = function(grunt) {
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-mocha-cov');
  grunt.loadNpmTasks('grunt-mocha-test');
  grunt.loadNpmTasks('grunt-open');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-travis-matrix');
  grunt.loadTasks('tasks');

  grunt.initConfig({
    clean: {
      coverage: 'coverage'
    },
    jshint: {
      options: {
        reporter: require('jshint-stylish'),
        eqeqeq: true,
        es3: true,
        indent: 2,
        newcap: true,
        quotmark: 'single',
        boss: true
      },
      all: ['tasks/**/*.js']
    },
    matrix: {
      'v4.0': 'codeclimate-test-reporter < coverage/lcov.info'
    },
    travis: {
      options: {
        targets: {
          test: '{{ version }}',
          when: 'v4.0',
          tasks: ['istanbul:unit', 'matrix:v4']
        }
      }
    },
    mochaTest: {
      options: {
        reporter: 'spec',
        ui: 'mocha-given',
        require: 'coffee-script/register'
      },
      test: {
        src: ['test/helpers/**/*.coffee', 'test/**/*.coffee', '!test/int*']
      },
      intSingle: {
        src: ['test/int-single.coffee']
      },
      intMulti: {
        src: ['test/int-multi.coffee']
      },
      intClear: {
        src: ['test/int-clear.coffee']
      }
    },
    mochacov: {
      lcov: {
        options: {
          reporter: 'mocha-lcov-reporter',
          ui: 'mocha-given',
          instrument: true,
          require: 'coffee-script/register',
          output: 'coverage/coverage.lcov'
        },
        src: ['test/**/*.coffee'],
      },
      html: {
        options: {
          reporter: 'html-cov',
          ui: 'mocha-given',
          require: 'coffee-script/register',
          output: 'coverage/coverage.html'
        },
        src: ['test/**/*.coffee']
      }
    },
    open: {
      coverage: {
        path: 'coverage/coverage.html'
      }
    },
    watch: {
      tests: {
        files: ['tasks/**/*.js', 'test/**/*.coffee'],
        tasks: ['mocha'],
        options: {
          atBegin: true
        }
      }
    },
    require: {
      single: {
        src: ['test/fixtures/foo.js']
      },
      multi: {
        src: ['test/fixtures/**/*.js', '!test/fixtures/foo.js']
      },
      clear: {
        options: {
          clearCache: true
        },
        src: ['test/fixtures/foo.js']
      }
    }
  });

  grunt.registerTask('mocha', ['mochaTest:test']);
  grunt.registerTask('default', ['jshint:all', 'mochaTest:test', 'int:single', 'int:multi', 'int:clear']);
  grunt.registerTask('coverage', ['mochacov:html']);
  grunt.registerTask('ci', ['default', 'travis']);
  grunt.registerTask('int:single', ['require:single', 'mochaTest:intSingle']);
  grunt.registerTask('int:multi', ['require:multi', 'mochaTest:intMulti']);
  grunt.registerTask('int:clear', ['require:clear', 'mochaTest:intClear']);
};
<|endoftext|>


<commit_before>'use strict';

module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    // Metadata.
    pkg: grunt.file.readJSON('jquery.filter.jquery.json'),
    banner: '/*!\n* <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
      '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
      '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>\n' +
      '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;\n' +
      '* Licensed under the <%= _.pluck(pkg.licenses, "type").join(", ") %> License.\n*/\n',
    // Task configuration.
    clean: {
      files: ['dist']
    },
    concat: {
      options: {
        banner: '<%= banner %>',
        stripBanners: true
      },
      dist: {
        src: ['src/<%= pkg.name %>.js'],
        dest: 'dist/<%= pkg.name %>.js'
      },
    },
    uglify: {
      options: {
        banner: '<%= banner %>'
      },
      dist: {
    	files: {
    		'dist/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
    	}
      },
    },
    qunit: {
      files: ['test/**/*.html']
    },
    jshint: {
      gruntfile: {
        options: {
          jshintrc: '.jshintrc'
        },
        src: 'Gruntfile.js'
      },
      src: {
        options: {
          jshintrc: 'src/.jshintrc'
        },
        src: ['src/**/*.js']
      },
      test: {
        options: {
          jshintrc: 'test/.jshintrc'
        },
        src: ['test/**/*.js']
      },
    },
    watch: {
      gruntfile: {
        files: '<%= jshint.gruntfile.src %>',
        tasks: ['jshint:gruntfile']
      },
      src: {
        files: '<%= jshint.src.src %>',
        tasks: ['jshint:src', 'qunit']
      },
      test: {
        files: '<%= jshint.test.src %>',
        tasks: ['jshint:test', 'qunit']
      },
    },
  });

  // These plugins provide necessary tasks.
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-qunit');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');

  // Default task.
  grunt.registerTask('default', ['jshint', 'qunit', 'clean', 'concat', 'uglify']);

};
<commit_msg>Use spaces instead of tabs<commit_after>'use strict';

module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    // Metadata.
    pkg: grunt.file.readJSON('jquery.filter.jquery.json'),
    banner: '/*!\n* <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
      '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
      '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>\n' +
      '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;\n' +
      '* Licensed under the <%= _.pluck(pkg.licenses, "type").join(", ") %> License.\n*/\n',
    // Task configuration.
    clean: {
      files: ['dist']
    },
    concat: {
      options: {
        banner: '<%= banner %>',
        stripBanners: true
      },
      dist: {
        src: ['src/<%= pkg.name %>.js'],
        dest: 'dist/<%= pkg.name %>.js'
      },
    },
    uglify: {
      options: {
        banner: '<%= banner %>'
      },
      dist: {
        files: {
            'dist/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
        }
      },
    },
    qunit: {
      files: ['test/**/*.html']
    },
    jshint: {
      gruntfile: {
        options: {
          jshintrc: '.jshintrc'
        },
        src: 'Gruntfile.js'
      },
      src: {
        options: {
          jshintrc: 'src/.jshintrc'
        },
        src: ['src/**/*.js']
      },
      test: {
        options: {
          jshintrc: 'test/.jshintrc'
        },
        src: ['test/**/*.js']
      },
    },
    watch: {
      gruntfile: {
        files: '<%= jshint.gruntfile.src %>',
        tasks: ['jshint:gruntfile']
      },
      src: {
        files: '<%= jshint.src.src %>',
        tasks: ['jshint:src', 'qunit']
      },
      test: {
        files: '<%= jshint.test.src %>',
        tasks: ['jshint:test', 'qunit']
      },
    },
  });

  // These plugins provide necessary tasks.
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-qunit');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');

  // Default task.
  grunt.registerTask('default', ['jshint', 'qunit', 'clean', 'concat', 'uglify']);

};
<|endoftext|>


<commit_before>/*jslint node: true*/
'use strict';

module.exports = function(grunt) {
	require('load-grunt-tasks')(grunt);

	grunt.initConfig({
		babel: {
			options: {
				modules: 'amd',
				sourceMap: true
			},
			dist: {
				files: {
					'js/oop.js':		'src/js/oop.js',
					'js/attribute.js':	'src/js/attribute.js',
					'js/eventTarget.js':'src/js/eventTarget.js',
					'js/widget.js':		'src/js/widget.js',
					'js/button.js':		'src/js/button.js',

					'example/widgets.js': 		'src/example/widgets.js',

					'test/oop-test.js': 		'src/test/oop-test.js',
					'test/eventTarget-test.js':	'src/test/eventTarget-test.js',
					'test/attribute-test.js':	'src/test/attribute-test.js',
					'test/button-test.js':		'src/test/button-test.js'
				}
			}
		},

		clean: {
			babel: ['js/*', 'test/*.js*']
		}
	});

	grunt.registerTask('default', ['clean:babel', 'babel']);
};
<commit_msg>improved babel config in grunt, added watch<commit_after>/*jslint node: true*/
'use strict';

module.exports = function(grunt) {
	require('load-grunt-tasks')(grunt);

	grunt.initConfig({
		watch: {
			files: ['src/**/*.js'],
			tasks: ['babel']
		},
		babel: {
			options: {
				modules: 'amd',
				sourceMap: true
			},
			dist: {
				files: [{
					expand: true,
					cwd: 'src/',
					src: ['**/*.js'],
					dest: '.'
				}]
			}
		},

		clean: {
			babel: ['js/*', 'test/*.js*']
		}
	});

	grunt.loadNpmTasks('grunt-contrib-watch');
	grunt.registerTask('default', ['clean:babel', 'babel']);
};
<|endoftext|>