<commit_before>var util = require('util');
var moment = require('moment');
var mysql = require('mysql');
var Base = require('./base');
var type = require('../data_type');
var log = require('../log');

var MysqlDriver = Base.extend({
  init: function(connection) {
    this._super();
    this.connection = connection;
  },

  mapDataType: function(spec) {
    var len;
    switch(spec.type) {
      case type.TEXT:
        len = parseInt(spec.length, 10) || 1000;
        if(len > 16777216) {
          return 'LONGTEXT';
        }
        if(len > 65536) {
          return 'MEDIUMTEXT';
        }
        if(len > 256) {
          return 'TEXT';
        }
        return 'TINYTEXT';
      case type.DATE_TIME:
        return 'DATETIME';
      case type.BLOB:
        len = parseInt(spec.length, 10) || 1000;
        if(len > 16777216) {
          return 'LONGBLOB';
        }
        if(len > 65536) {
          return 'MEDIUMBLOB';
        }
        if(len > 256) {
          return 'BLOB';
        }
        return 'TINYBLOB';
      case type.BOOLEAN:
        return 'TINYINT(1)';
    }
    return this._super(spec.type);
  },

  createColumnDef: function(name, spec, options) {
    name = util.format('`%s`', name);
    var t = this.mapDataType(spec);
    var len;
    if(spec.type !== type.TEXT && spec.type !== type.BLOB) {
      len = spec.length ? util.format('(%s)', spec.length) : '';
      if (t === 'VARCHAR' && len === '') {
        len = '(255)';
      }
    }
    var constraint = this.createColumnConstraint(spec, options);
    return [name, t, len, constraint].join(' ');
  },

  createColumnConstraint: function(spec, options) {
    var constraint = [];
    if (spec.unsigned) {
      constraint.push('UNSIGNED');
    }

    if (spec.primaryKey) {
      if (!options || options.emitPrimaryKey) {
        constraint.push('PRIMARY KEY');
      }
      if (spec.autoIncrement) {
        constraint.push('AUTO_INCREMENT');
      }
    }

    if (spec.notNull) {
      constraint.push('NOT NULL');
    }

    if (spec.unique) {
      constraint.push('UNIQUE');
    }

    if (spec.null) {
      constraint.push('NULL');
    }

    if (spec.defaultValue !== undefined) {
      constraint.push('DEFAULT');

      if (typeof spec.defaultValue === 'string'){
        constraint.push("'" + spec.defaultValue + "'");
      } else {
        constraint.push(spec.defaultValue);
      }
    }

    return constraint.join(' ');
  },

  createTable: function(tableName, options, callback) {
    log.verbose('creating table:', tableName);
    var columnSpecs = options;
    var tableOptions = {};

    if (options.columns !== undefined) {
      columnSpecs = options.columns;
      delete options.columns;
      tableOptions = options;
    }

    var ifNotExistsSql = "";
    if(tableOptions.ifNotExists) {
      ifNotExistsSql = "IF NOT EXISTS";
    }

    var primaryKeyColumns = [];
    var columnDefOptions = {
      emitPrimaryKey: false
    };

    for (var columnName in columnSpecs) {
      var columnSpec = this.normalizeColumnSpec(columnSpecs[columnName]);
      columnSpecs[columnName] = columnSpec;
      if (columnSpec.primaryKey) {
        primaryKeyColumns.push(columnName);
      }
    }

    var pkSql = '';
    if (primaryKeyColumns.length > 1) {
      pkSql = util.format(', PRIMARY KEY (`%s`)', primaryKeyColumns.join('`, `'));
    } else {
      columnDefOptions.emitPrimaryKey = true;
    }

    var columnDefs = [];
    for (var columnName in columnSpecs) {
      var columnSpec = columnSpecs[columnName];
      columnDefs.push(this.createColumnDef(columnName, columnSpec, columnDefOptions));
    }

    var sql = util.format('CREATE TABLE %s `%s` (%s%s)', ifNotExistsSql, tableName, columnDefs.join(', '), pkSql);
    this.runSql(sql, callback);
  },

  renameTable: function(tableName, newTableName, callback) {
    var sql = util.format('RENAME TABLE `%s` TO `%s`', tableName, newTableName);
    this.runSql(sql, callback);
  },

  addColumn: function(tableName, columnName, columnSpec, callback) {
    var def = this.createColumnDef(columnName, this.normalizeColumnSpec(columnSpec));
    var sql = util.format('ALTER TABLE `%s` ADD COLUMN %s', tableName, def);
    this.runSql(sql, callback);
  },

  removeColumn: function(tableName, columnName, callback) {
    var sql = util.format('ALTER TABLE `%s` DROP COLUMN `%s`', tableName, columnName);
    this.runSql(sql, callback);
  },

  addIndex: function(tableName, indexName, columns, unique, callback) {
    if (typeof(unique) === 'function') {
      callback = unique;
      unique = false;
    }

    if (!Array.isArray(columns)) {
      columns = [columns];
    }
    var sql = util.format('ALTER TABLE `%s` ADD %s INDEX `%s` (`%s`)', tableName, (unique ? 'UNIQUE ' : ''), indexName, columns.join('`, `'));
    this.runSql(sql, callback);
  },

  insert: function(tableName, columnNameArray, valueArray, callback) {
    if (columnNameArray.length !== valueArray.length) {
      return callback(new Error('The number of columns does not match the number of values.'));
    }

    var sql = util.format('INSERT INTO `%s` ', tableName);
    var columnNames = '(';
    var values = 'VALUES (';

    for (var index in columnNameArray) {
      columnNames += '`' + columnNameArray[index] + '`';

      if (typeof(valueArray[index]) === 'string') {
        values += "'" + this.escape(valueArray[index]) + "'";
      } else {
        values += valueArray[index];
      }

      if (index != columnNameArray.length - 1) {
        columnNames += ",";
        values +=  ",";
      }
    }

    sql += columnNames + ') '+ values + ');';
    this.runSql(sql, callback);
  },

  removeIndex: function(tableName, indexName, callback) {
    // tableName is optional for other drivers, but required for mySql. So, check the args to ensure they are valid
    if (arguments.length === 2 && typeof(indexName) === 'function') {
      callback = indexName;
      process.nextTick(function () {
        callback(new Error('Illegal arguments, must provide "tableName" and "indexName"'));
      });

      return;
    }

    var sql = util.format('DROP INDEX `%s` ON `%s`', indexName, tableName);
    this.runSql(sql, callback);
  },

  renameColumn: function(tableName, oldColumnName, newColumnName, callback) {
    var self = this, columnTypeSql = util.format("SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '%s' AND COLUMN_NAME = '%s'", tableName, oldColumnName);
    this.all(columnTypeSql, function(err, result) {
      var columnType = result[0].COLUMN_TYPE;
      var alterSql = util.format("ALTER TABLE `%s` CHANGE `%s` `%s` %s", tableName, oldColumnName, newColumnName, columnType);
      self.runSql(alterSql, callback);
    });
  },

  changeColumn: function(tableName, columnName, columnSpec, callback) {
    var constraint = this.createColumnDef(columnName, columnSpec);
    var sql = util.format('ALTER TABLE `%s` CHANGE COLUMN `%s` %s', tableName, columnName, constraint);
    this.runSql(sql, callback);
  },

  addMigrationRecord: function (name, callback) {
    var formattedDate = moment(new Date()).format('YYYY-MM-DD HH:mm:ss');
    this.runSql('INSERT INTO migrations (`name`, `run_on`) VALUES (?, ?)', [name, formattedDate], callback);
  },

  addForeignKey: function(tableName, referencedTableName, keyName, fieldMapping, rules, callback) {
    if(arguments.length === 5 && typeof(rules) === 'function') {
      callback = rules;
      rules = {};
    }
    var columns = Object.keys(fieldMapping);
    var referencedColumns = columns.map(function (key) { return fieldMapping[key]; });
    var sql = util.format('ALTER TABLE `%s` ADD CONSTRAINT `%s` FOREIGN KEY (`%s`) REFERENCES `%s` (%s) ON DELETE %s ON UPDATE %s',
      tableName, keyName, columns, referencedTableName, referencedColumns, rules.onDelete || 'NO ACTION', rules.onUpdate || 'NO ACTION');
    this.runSql(sql, callback);
  },

  removeForeignKey: function(tableName, keyName, callback) {
    var sql = util.format('ALTER TABLE `%s` DROP FOREIGN KEY `%s`', tableName, keyName);
    this.runSql(sql, callback());
  },

  runSql: function() {
    var args = this._makeParamArgs(arguments);
    var callback = args[2];
    log.sql.apply(null, arguments);
    if(global.dryRun) {
      return callback();
    }
    return this.connection.query.apply(this.connection, args);
  },

  _makeParamArgs: function(args) {
    var params = Array.prototype.slice.call(args);
    var sql = params.shift();
    var callback = params.pop();

    if (params.length > 0 && Array.isArray(params[0])) {
      params = params[0];
    }

    return [sql, params, callback];
  },

  all: function() {
    var args = this._makeParamArgs(arguments);
    return this.connection.query.apply(this.connection, args);
  },

  close: function(callback) {
    this.connection.end(callback);
  }

});

exports.connect = function(config, callback) {
  var db;
  if (typeof(mysql.createConnection) === 'undefined') {
    db = config.db || new mysql.createClient(config);
  } else {
    db = config.db || new mysql.createConnection(config);
  }
  callback(null, new MysqlDriver(db));
};
<commit_msg>reserved direct drop<commit_after>var util = require('util');
var moment = require('moment');
var mysql = require('mysql');
var Base = require('./base');
var type = require('../data_type');
var log = require('../log');

var MysqlDriver = Base.extend({
  init: function(connection) {
    this._super();
    this.connection = connection;
  },

  mapDataType: function(spec) {
    var len;
    switch(spec.type) {
      case type.TEXT:
        len = parseInt(spec.length, 10) || 1000;
        if(len > 16777216) {
          return 'LONGTEXT';
        }
        if(len > 65536) {
          return 'MEDIUMTEXT';
        }
        if(len > 256) {
          return 'TEXT';
        }
        return 'TINYTEXT';
      case type.DATE_TIME:
        return 'DATETIME';
      case type.BLOB:
        len = parseInt(spec.length, 10) || 1000;
        if(len > 16777216) {
          return 'LONGBLOB';
        }
        if(len > 65536) {
          return 'MEDIUMBLOB';
        }
        if(len > 256) {
          return 'BLOB';
        }
        return 'TINYBLOB';
      case type.BOOLEAN:
        return 'TINYINT(1)';
    }
    return this._super(spec.type);
  },

  createColumnDef: function(name, spec, options) {
    name = util.format('`%s`', name);
    var t = this.mapDataType(spec);
    var len;
    if(spec.type !== type.TEXT && spec.type !== type.BLOB) {
      len = spec.length ? util.format('(%s)', spec.length) : '';
      if (t === 'VARCHAR' && len === '') {
        len = '(255)';
      }
    }
    var constraint = this.createColumnConstraint(spec, options);
    return [name, t, len, constraint].join(' ');
  },

  createColumnConstraint: function(spec, options) {
    var constraint = [];
    if (spec.unsigned) {
      constraint.push('UNSIGNED');
    }

    if (spec.primaryKey) {
      if (!options || options.emitPrimaryKey) {
        constraint.push('PRIMARY KEY');
      }
      if (spec.autoIncrement) {
        constraint.push('AUTO_INCREMENT');
      }
    }

    if (spec.notNull) {
      constraint.push('NOT NULL');
    }

    if (spec.unique) {
      constraint.push('UNIQUE');
    }

    if (spec.null) {
      constraint.push('NULL');
    }

    if (spec.defaultValue !== undefined) {
      constraint.push('DEFAULT');

      if (typeof spec.defaultValue === 'string'){
        constraint.push("'" + spec.defaultValue + "'");
      } else {
        constraint.push(spec.defaultValue);
      }
    }

    return constraint.join(' ');
  },

  createTable: function(tableName, options, callback) {
    log.verbose('creating table:', tableName);
    var columnSpecs = options;
    var tableOptions = {};

    if (options.columns !== undefined) {
      columnSpecs = options.columns;
      delete options.columns;
      tableOptions = options;
    }

    var ifNotExistsSql = "";
    if(tableOptions.ifNotExists) {
      ifNotExistsSql = "IF NOT EXISTS";
    }

    var primaryKeyColumns = [];
    var columnDefOptions = {
      emitPrimaryKey: false
    };

    for (var columnName in columnSpecs) {
      var columnSpec = this.normalizeColumnSpec(columnSpecs[columnName]);
      columnSpecs[columnName] = columnSpec;
      if (columnSpec.primaryKey) {
        primaryKeyColumns.push(columnName);
      }
    }

    var pkSql = '';
    if (primaryKeyColumns.length > 1) {
      pkSql = util.format(', PRIMARY KEY (`%s`)', primaryKeyColumns.join('`, `'));
    } else {
      columnDefOptions.emitPrimaryKey = true;
    }

    var columnDefs = [];
    for (var columnName in columnSpecs) {
      var columnSpec = columnSpecs[columnName];
      columnDefs.push(this.createColumnDef(columnName, columnSpec, columnDefOptions));
    }

    var sql = util.format('CREATE TABLE %s `%s` (%s%s)', ifNotExistsSql, tableName, columnDefs.join(', '), pkSql);
    this.runSql(sql, callback);
  },

  renameTable: function(tableName, newTableName, callback) {
    var sql = util.format('RENAME TABLE `%s` TO `%s`', tableName, newTableName);
    this.runSql(sql, callback);
  },

  addColumn: function(tableName, columnName, columnSpec, callback) {
    var def = this.createColumnDef(columnName, this.normalizeColumnSpec(columnSpec));
    var sql = util.format('ALTER TABLE `%s` ADD COLUMN %s', tableName, def);
    this.runSql(sql, callback);
  },

  removeColumn: function(tableName, columnName, callback) {
    var sql = util.format('ALTER TABLE `%s` DROP COLUMN `%s`', tableName, columnName);
    this.runSql(sql, callback);
  },

  addIndex: function(tableName, indexName, columns, unique, callback) {
    if (typeof(unique) === 'function') {
      callback = unique;
      unique = false;
    }

    if (!Array.isArray(columns)) {
      columns = [columns];
    }
    var sql = util.format('ALTER TABLE `%s` ADD %s INDEX `%s` (`%s`)', tableName, (unique ? 'UNIQUE ' : ''), indexName, columns.join('`, `'));
    this.runSql(sql, callback);
  },

  insert: function(tableName, columnNameArray, valueArray, callback) {
    if (columnNameArray.length !== valueArray.length) {
      return callback(new Error('The number of columns does not match the number of values.'));
    }

    var sql = util.format('INSERT INTO `%s` ', tableName);
    var columnNames = '(';
    var values = 'VALUES (';

    for (var index in columnNameArray) {
      columnNames += '`' + columnNameArray[index] + '`';

      if (typeof(valueArray[index]) === 'string') {
        values += "'" + this.escape(valueArray[index]) + "'";
      } else {
        values += valueArray[index];
      }

      if (index != columnNameArray.length - 1) {
        columnNames += ",";
        values +=  ",";
      }
    }

    sql += columnNames + ') '+ values + ');';
    this.runSql(sql, callback);
  },

  removeIndex: function(tableName, indexName, callback) {
    // tableName is optional for other drivers, but required for mySql. So, check the args to ensure they are valid
    if (arguments.length === 2 && typeof(indexName) === 'function') {
      callback = indexName;
      process.nextTick(function () {
        callback(new Error('Illegal arguments, must provide "tableName" and "indexName"'));
      });

      return;
    }

    var sql = util.format('DROP INDEX `%s` ON `%s`', indexName, tableName);
    this.runSql(sql, callback);
  },

  renameColumn: function(tableName, oldColumnName, newColumnName, callback) {
    var self = this, columnTypeSql = util.format("SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '%s' AND COLUMN_NAME = '%s'", tableName, oldColumnName);
    this.all(columnTypeSql, function(err, result) {
      var columnType = result[0].COLUMN_TYPE;
      var alterSql = util.format("ALTER TABLE `%s` CHANGE `%s` `%s` %s", tableName, oldColumnName, newColumnName, columnType);
      self.runSql(alterSql, callback);
    });
  },

  changeColumn: function(tableName, columnName, columnSpec, callback) {
    var constraint = this.createColumnDef(columnName, columnSpec);
    var sql = util.format('ALTER TABLE `%s` CHANGE COLUMN `%s` %s', tableName, columnName, constraint);
    this.runSql(sql, callback);
  },

  addMigrationRecord: function (name, callback) {
    var formattedDate = moment(new Date()).format('YYYY-MM-DD HH:mm:ss');
    this.runSql('INSERT INTO migrations (`name`, `run_on`) VALUES (?, ?)', [name, formattedDate], callback);
  },

  addForeignKey: function(tableName, referencedTableName, keyName, fieldMapping, rules, callback) {
    if(arguments.length === 5 && typeof(rules) === 'function') {
      callback = rules;
      rules = {};
    }
    var columns = Object.keys(fieldMapping);
    var referencedColumns = columns.map(function (key) { return fieldMapping[key]; });
    var sql = util.format('ALTER TABLE `%s` ADD CONSTRAINT `%s` FOREIGN KEY (`%s`) REFERENCES `%s` (%s) ON DELETE %s ON UPDATE %s',
      tableName, keyName, columns, referencedTableName, referencedColumns, rules.onDelete || 'NO ACTION', rules.onUpdate || 'NO ACTION');
    this.runSql(sql, callback);
  },

  removeForeignKey: function(tableName, keyName, options, callback) {
    var sql = util.format('ALTER TABLE `%s` DROP FOREIGN KEY `%s`', tableName, keyName);
    this.runSql(sql, function () {

      if( typeof(options) === 'function' ) {

          options();
      }
      else if(options.dropIndex === true) {

        sql = util.format('ALTER TABLE `%s` DROP INDEX `%s`', tableName, keyName);
        this.runSql(sql, function () {
          callback();
        });
      }
      else
        callback();

    }.bind(this));
    var sql = util.format('ALTER TABLE `%s` DROP FOREIGN KEY `%s`', tableName, keyName);
    this.runSql(sql, callback());
  },

  runSql: function() {
    var args = this._makeParamArgs(arguments);
    var callback = args[2];
    log.sql.apply(null, arguments);
    if(global.dryRun) {
      return callback();
    }
    return this.connection.query.apply(this.connection, args);
  },

  _makeParamArgs: function(args) {
    var params = Array.prototype.slice.call(args);
    var sql = params.shift();
    var callback = params.pop();

    if (params.length > 0 && Array.isArray(params[0])) {
      params = params[0];
    }

    return [sql, params, callback];
  },

  all: function() {
    var args = this._makeParamArgs(arguments);
    return this.connection.query.apply(this.connection, args);
  },

  close: function(callback) {
    this.connection.end(callback);
  }

});

exports.connect = function(config, callback) {
  var db;
  if (typeof(mysql.createConnection) === 'undefined') {
    db = config.db || new mysql.createClient(config);
  } else {
    db = config.db || new mysql.createConnection(config);
  }
  callback(null, new MysqlDriver(db));
};
<|endoftext|>


<commit_before>function ComponentTextfield( id ) {
	var self = _ComponentFormControl(id);

	self.setDefaultState('text-value');
	self.bind = function() {
		self.attachChangeAction( self.node(), self.identifier() );
	};
	self.registerAction('change', function() {
		self.setState('text-value', self.node().value);
	});
	self.select = function() {
		if( self.node() ) {
			self.node().select();
		}
	};
	return self;
}<commit_msg>Change that should fix an issue allers are having with reply to addresses not working<commit_after>function ComponentTextfield( id ) {
	var self = _ComponentFormControl(id);

	self.setDefaultState('text-value');
	self.bind = function() {
		self.attachChangeAction( self.node(), self.identifier() );
	};
	self.registerAction('change', function() {
		self.setState('text-value', self.node().value);
	});
	self.select = function() {
		if( self.node() ) {
			self.node().select();
		}
	};
	self.textValue = function() {
		self.setState('text-value', self.node().value);
		return self.getState('text-value');
	};
	return self;
}<|endoftext|>


<commit_before>function EPlayer(){
  this.sectionList = [];  // 播放列表 {['actionURL': 'data/1.mp3']}
  this.sectionPos = 0;    // 播放列表中第几个
  this.isLoop = false;      // 是否循环
  this.totalTime = 0;     // 总时间
  this.currentTime = 0;   // 当前时间
}

EPlayer.prototype = {
  doinit : function(){
    Eden.player.init();
  },
  doPlay : function(__url, __breakpoint){
    var me = this;
    this.sectionList = this._translateActionURL(__url);
    this.currentTime = __breakpoint || 0;
    this.playDelayTimer = window.setTimeout(function(){
      Eden.player.ready({
        me : me,
        id : "",
        url : me.sectionList[me.sectionPos], //视频地址
        beginTime : __breakpoint, //开始播放时间
      });
    },200);
  },
  //私有方法，翻译url
  _translateActionURL : function(__url){
    console.log("player.js _translateActionURL __url :" + __url);
    var tmpPlayList =(__url && typeof __url == 'string') ? [__url] : __url;
    return tmpPlayList;
  },
  doPause : function(){
    return Eden.player.pause();
  },
  doResume : function(){
    return Eden.player.resume();
  },
  doStop : function(){
    return Eden.player.stop();
  },
  init : function(__sectionList, __sectionPos, __isLoop){
    var me = this;
    if(__sectionList && __sectionList instanceof Array == true){
      this.sectionList = __sectionList;
    }
    this.sectionPos = __sectionPos || 0;
    this.isLoop = __isLoop == true ? true : false;
  },
  run : function(__actionURL, __breakpoint){
    this.currentTime = __breakpoint || 0;
    this.doPlay(this.sectionList[this.sectionPos].actionURL, this.currentTime);
  },
  stop : function(){
    this.doStop();
  },
  destory : function(){
    this.sectionList = [];
    this.sectionPos = 0;
    this.isLoop = false;
    this.breakpoint = 0;
  }
}

var Eden = window.Eden = {};
Eden.player = function(){
  var playerCore = {};
  var loop = false;      // 是否循环
  var totalTime = 0;     // 总时间
  var currentTime = 0;   // 当前时间
  var mediaUrl = '';     // 播放地址
  var mediaObj = null;   // 播放器对象

  var opt = {
    me : null,
    id : "", //播放控件ID
    url : "", //视频地址
    timeout : 0, //超时时间
    beginTime : 0, //开始播放时间
    onReady : "", //参数处理结束回调函数
    onPlay : "", //进入播放状态的回调函数
    onBuffer : "", //进入缓冲状态时的回调函数
    onPause : "", //进入暂停状态的回调函数
    onResume : "", //进入唤醒状态的回调函数
    onStop : "", //视频播被停止后的回调函数
    onOver : "", //视频播放结束后的回调函数
    onException : "", //发生异常时的回调函数
    onError : "", //发生错误时的回调函数
    onstatusChange : ""	//状态改变时的回调函数
  };

  // 创建一个新的播放器插件
  function createNewMediaPlayer(){
    console.log('createNewMediaPlayer start');
    var option = arguments && arguments[0];
    var objId = typeof opt.id == 'string' && (opt.id) ? opt.id : 'TVPlayer';
    var parentArea = (opt && ( typeof opt.id == "string") && (opt.id) && $(opt.id)) ? $(opt.id).parentNode : document.body;
    mediaObj = document.createElement("audio");
    mediaObj.setAttribute("id", objId);
    parentArea.appendChild(mediaObj);
    console.log('createNewMediaPlayer end');
  }

  // 移除页面上的所有播放器插件
  function removeAllMediaPlayer(){
    console.log('removeAllMediaPlayer start');
    var target = [];
    var audios = [];
    var i;
    audios = document.getElementsByTagName("audio");
    for( i = 0; i < audios.length; i++) {
      target.push(embeds[i]);
    };
    for( i = 0; i < target.length; i++) {
      target[i].parentNode.removeChild(target[i]);
    };
    console.log('removeAllMediaPlayer end');
  }

  function onPlayReady(){

  }

  playerCore.init = function(){
    var loop = false;      // 是否循环
    var totalTime = 0;     // 总时间
    var currentTime = 0;   // 当前时间
  }

  playerCore.ready = function(){
    console.log('playerCore ready');
    var options = (arguments && arguments[0]) || {};
    currentTime = totalTime = 0;
    opt.me = options.me || null;
    if( typeof options.id == 'string' && (options.id)){
      mediaObj = document.getElementById(options.id);
      if(!mediaObj) {
        opt.id = options.id;
        removeAllMediaPlayer();
        createNewMediaPlayer();
      }
    }else{//no id,so remove old and create a new audio
      if(!mediaObj){
        removeAllMediaPlayer();
        createNewMediaPlayer();
      }
    }

    mediaObj.addEventListener('loadeddata',onPlayReady)

    mediaObj.addEventListener('abort',playerCore.stop);
    // mediaObj.addEventListener('play',)
    mediaObj.addEventListener('pause',playerCore.pause);

    //handle options.url,set mediaUrl;
    if(options.url && typeof options.url == 'string') {
      mediaUrl = options.url;
      opt.url = options.url;
    } else {
      console.log('playerCore:url err');
      return false;
    }
    //handle beginTime
    opt.beginTime = typeof (options.beginTime = parseInt(options.beginTime)) == 'number' ? options.beginTime : 0;
    mediaObj.src = opt.url;
    mediaObj.currentTime = opt.beginTime;
    mediaObj.play();
  }

  playerCore.pause = function(){
    console.log('playerCore pause');
    if(!mediaObj.paused){
      mediaObj.pause();
    }
  }

  playerCore.resume = function(){
    console.log('playerCore resume');
    if(mediaObj.paused){
      mediaObj.paused = false;
    }
  }

  playerCore.stop = function(){
    console.log('playerCore stop');
    if(mediaObj){
      mediaObj.src = null;
      removeAllMediaPlayer();
    }
  }

  playerCore.getTotalTime = function(){
    console.log('playerCore getTotalTime');
    return totalTime = mediaObj.duration || 0;
  }

  playerCore.getCurentTime = function(){
    console.log('playerCore getCurrentTime');
    return currentTime = mediaObj.currenttime || 0;
  }
  return playerCore;
}();
<commit_msg>mediaObj.loop = true in edenenen_music<commit_after>function EPlayer(){
  this.sectionList = [];  // 播放列表 {['actionURL': 'data/1.mp3']}
  this.sectionPos = 0;    // 播放列表中第几个
  this.isLoop = false;      // 是否循环
  this.totalTime = 0;     // 总时间
  this.currentTime = 0;   // 当前时间
}

EPlayer.prototype = {
  doinit : function(){
    Eden.player.init();
  },
  doPlay : function(__url, __breakpoint){
    var me = this;
    this.sectionList = this._translateActionURL(__url);
    this.currentTime = __breakpoint || 0;
    this.playDelayTimer = window.setTimeout(function(){
      Eden.player.ready({
        me : me,
        id : "",
        url : me.sectionList[me.sectionPos], //视频地址
        beginTime : __breakpoint, //开始播放时间
      });
    },200);
  },
  //私有方法，翻译url
  _translateActionURL : function(__url){
    console.log("player.js _translateActionURL __url :" + __url);
    var tmpPlayList =(__url && typeof __url == 'string') ? [__url] : __url;
    return tmpPlayList;
  },
  doPause : function(){
    return Eden.player.pause();
  },
  doResume : function(){
    return Eden.player.resume();
  },
  doStop : function(){
    return Eden.player.stop();
  },
  init : function(__sectionList, __sectionPos, __isLoop){
    var me = this;
    if(__sectionList && __sectionList instanceof Array == true){
      this.sectionList = __sectionList;
    }
    this.sectionPos = __sectionPos || 0;
    this.isLoop = __isLoop == true ? true : false;
  },
  run : function(__actionURL, __breakpoint){
    this.currentTime = __breakpoint || 0;
    this.doPlay(this.sectionList[this.sectionPos].actionURL, this.currentTime);
  },
  stop : function(){
    this.doStop();
  },
  destory : function(){
    this.sectionList = [];
    this.sectionPos = 0;
    this.isLoop = false;
    this.breakpoint = 0;
  }
}

var Eden = window.Eden = {};
Eden.player = function(){
  var playerCore = {};
  var loop = false;      // 是否循环
  var totalTime = 0;     // 总时间
  var currentTime = 0;   // 当前时间
  var mediaUrl = '';     // 播放地址
  var mediaObj = null;   // 播放器对象

  var opt = {
    me : null,
    id : "", //播放控件ID
    url : "", //视频地址
    timeout : 0, //超时时间
    beginTime : 0, //开始播放时间
    onReady : "", //参数处理结束回调函数
    onPlay : "", //进入播放状态的回调函数
    onBuffer : "", //进入缓冲状态时的回调函数
    onPause : "", //进入暂停状态的回调函数
    onResume : "", //进入唤醒状态的回调函数
    onStop : "", //视频播被停止后的回调函数
    onOver : "", //视频播放结束后的回调函数
    onException : "", //发生异常时的回调函数
    onError : "", //发生错误时的回调函数
    onstatusChange : ""	//状态改变时的回调函数
  };

  // 创建一个新的播放器插件
  function createNewMediaPlayer(){
    console.log('createNewMediaPlayer start');
    var option = arguments && arguments[0];
    var objId = typeof opt.id == 'string' && (opt.id) ? opt.id : 'TVPlayer';
    var parentArea = (opt && ( typeof opt.id == "string") && (opt.id) && $(opt.id)) ? $(opt.id).parentNode : document.body;
    mediaObj = document.createElement("audio");
    mediaObj.setAttribute("id", objId);
    parentArea.appendChild(mediaObj);
    console.log('createNewMediaPlayer end');
  }

  // 移除页面上的所有播放器插件
  function removeAllMediaPlayer(){
    console.log('removeAllMediaPlayer start');
    var target = [];
    var audios = [];
    var i;
    audios = document.getElementsByTagName("audio");
    for( i = 0; i < audios.length; i++) {
      target.push(embeds[i]);
    };
    for( i = 0; i < target.length; i++) {
      target[i].parentNode.removeChild(target[i]);
    };
    console.log('removeAllMediaPlayer end');
  }

  function onPlayReady(){

  }

  playerCore.init = function(){
    var loop = false;      // 是否循环
    var totalTime = 0;     // 总时间
    var currentTime = 0;   // 当前时间
  }

  playerCore.ready = function(){
    console.log('playerCore ready');
    var options = (arguments && arguments[0]) || {};
    currentTime = totalTime = 0;
    opt.me = options.me || null;
    if( typeof options.id == 'string' && (options.id)){
      mediaObj = document.getElementById(options.id);
      if(!mediaObj) {
        opt.id = options.id;
        removeAllMediaPlayer();
        createNewMediaPlayer();
      }
    }else{//no id,so remove old and create a new audio
      if(!mediaObj){
        removeAllMediaPlayer();
        createNewMediaPlayer();
      }
    }

    mediaObj.addEventListener('loadeddata',onPlayReady)

    mediaObj.addEventListener('abort',playerCore.stop);
    // mediaObj.addEventListener('play',)
    mediaObj.addEventListener('pause',playerCore.pause);

    //handle options.url,set mediaUrl;
    if(options.url && typeof options.url == 'string') {
      mediaUrl = options.url;
      opt.url = options.url;
    } else {
      console.log('playerCore:url err');
      return false;
    }
    //handle beginTime
    opt.beginTime = typeof (options.beginTime = parseInt(options.beginTime)) == 'number' ? options.beginTime : 0;
    mediaObj.src = opt.url;
    mediaObj.currentTime = opt.beginTime;
    mediaObj.loop = true;
    mediaObj.play();
  }

  playerCore.pause = function(){
    console.log('playerCore pause');
    if(!mediaObj.paused){
      mediaObj.pause();
    }
  }

  playerCore.resume = function(){
    console.log('playerCore resume');
    if(mediaObj.paused){
      mediaObj.paused = false;
    }
  }

  playerCore.stop = function(){
    console.log('playerCore stop');
    if(mediaObj){
      mediaObj.src = null;
      removeAllMediaPlayer();
    }
  }

  playerCore.getTotalTime = function(){
    console.log('playerCore getTotalTime');
    return totalTime = mediaObj.duration || 0;
  }

  playerCore.getCurentTime = function(){
    console.log('playerCore getCurrentTime');
    return currentTime = mediaObj.currenttime || 0;
  }
  return playerCore;
}();
<|endoftext|>


<commit_before>export const child = `\uD83D\uDC69\uD83C\uDFFC\u200D\uD83C\uDF3E`;
export const protector = `\uD83D\uDC6E\uD83C\uDFFF\u200D\u2640\uFE0F`;
export const persecutor = `\uD83D\uDD75\uD83C\uDFFD`;
export const avenger = `\uD83D\uDC69\uD83C\uDFFB\u200D\uD83C\uDFA4`;
export const demon = `\uD83D\uDC79`;
export const tree = `\uD83C\uDF32`;
export const treeAlt = `\uD83C\uDF33`;
export const cloud = `\u2601\uFE0F`;
export const mountain = `\uD83C\uDFD4`;
export const pointRight = `\uD83D\uDC49\uD83C\uDFFB`;
export const ghost = `\uD83D\uDC7B`;
export const pool = `\uD83C\uDF75`;
export const gem = `\uD83D\uDC8E`;
export const blackHeart = `\uD83D\uDDA4`;
export const heart = `\u2764\uFE0F`;
<commit_msg>Protector emoji fix.<commit_after>export const child = `\uD83D\uDC69\uD83C\uDFFC\u200D\uD83C\uDF3E`;
export const protector = `\uD83D\uDC6E\uD83C\uDFFF\u200D`;
export const persecutor = `\uD83D\uDD75\uD83C\uDFFD`;
export const avenger = `\uD83D\uDC69\uD83C\uDFFB\u200D\uD83C\uDFA4`;
export const demon = `\uD83D\uDC79`;
export const tree = `\uD83C\uDF32`;
export const treeAlt = `\uD83C\uDF33`;
export const cloud = `\u2601\uFE0F`;
export const mountain = `\uD83C\uDFD4`;
export const pointRight = `\uD83D\uDC49\uD83C\uDFFB`;
export const ghost = `\uD83D\uDC7B`;
export const pool = `\uD83C\uDF75`;
export const gem = `\uD83D\uDC8E`;
export const blackHeart = `\uD83D\uDDA4`;
export const heart = `\u2764\uFE0F`;
<|endoftext|>


<commit_before>'use strict';

var XD = require('./postmessage.js');
var EventEmitter = require('events').EventEmitter;
var util = require('util');

var Tapcite = function() {
    EventEmitter.call(this);

    var self = this;
    var parent_url;
    var id;

    XD.receiveMessage(function(event) {
        if(event.data === 'slide:start' || event.data === 'slide:stop' || typeof event.data !== 'object' || !event.data.event) {
            return false;
        }

        parent_url = event.origin;
        id = event.data.id;
        self.emit(event.data.event, event.data.data);
    });

    this.send = function(eventName,data) {
        XD.postMessage({
            event: eventName,
            id: id,
            data: data
        }, parent_url, window.parent);
    };

    this.text = function(key,value) {
        this.send('text',{
            key: key,
            value: value
        });
    };

    this.data = function(key,value) {
        this.send('data',{
            key: key,
            value: value
        });
    };

    this.go = function(target) {
        this.send('go',{
            target: target
        });
    };

};
util.inherits(Tapcite, EventEmitter);

global.Tapcite = new Tapcite();<commit_msg>Added ability to change state of buttons in mobile<commit_after>'use strict';

var XD = require('./postmessage.js');
var EventEmitter = require('events').EventEmitter;
var util = require('util');

var Tapcite = function() {
    EventEmitter.call(this);

    var self = this;
    var parent_url;
    var id;

    XD.receiveMessage(function(event) {
        if(event.data === 'slide:start' || event.data === 'slide:stop' || typeof event.data !== 'object' || !event.data.event) {
            return false;
        }

        parent_url = event.origin;
        id = event.data.id;
        self.emit(event.data.event, event.data.data);
    });

    this.send = function(eventName,data) {
        XD.postMessage({
            event: eventName,
            id: id,
            data: data
        }, parent_url, window.parent);
    };

    this.text = function(key,value) {
        this.send('text',{
            key: key,
            value: value
        });
    };

    this.data = function(key,value) {
        this.send('data',{
            key: key,
            value: value
        });
    };

    this.go = function(target) {
        this.send('go',{
            target: target
        });
    };

    this.state = function(id,state) {
        this.send('state',{
            id: id,
            state: state ? true : false
        });
    };

    this.disable = function(id) {
        this.state(id,false);
    };

    this.enable = function(id) {
        this.state(id,true);
    };

};
util.inherits(Tapcite, EventEmitter);

global.Tapcite = new Tapcite();<|endoftext|>


<commit_before>/**
 * Farbtastic Color Picker 1.2
 * © 2008 Steven Wittens
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

jQuery.fn.farbtastic = function (callback) {
  $.farbtastic(this, callback);
  return this;
};

jQuery.farbtastic = function (container, callback) {
  var container = $(container).get(0);
  return container.farbtastic || (container.farbtastic = new jQuery._farbtastic(container, callback));
}

jQuery._farbtastic = function (container, callback) {
  // Store farbtastic object
  var fb = this;

  // Insert markup
  $(container).html('

');
  var e = $('.farbtastic', container);
  fb.wheel = $('.wheel', container).get(0);
  // Dimensions
  fb.radius = 84;
  fb.square = 100;
  fb.width = 194;

  // Fix background PNGs in IE6
  if (navigator.appVersion.match(/MSIE [0-6]\./)) {
    $('*', e).each(function () {
      if (this.currentStyle.backgroundImage != 'none') {
        var image = this.currentStyle.backgroundImage;
        image = this.currentStyle.backgroundImage.substring(5, image.length - 2);
        $(this).css({
          'backgroundImage': 'none',
          'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='" + image + "')"
        });
      }
    });
  }

  /**
   * Link to the given element(s) or callback.
   */
  fb.linkTo = function (callback) {
    // Unbind previous nodes
    if (typeof fb.callback == 'object') {
      $(fb.callback).unbind('keyup', fb.updateValue);
    }

    // Reset color
    fb.color = null;

    // Bind callback or elements
    if (typeof callback == 'function') {
      fb.callback = callback;
    }
    else if (typeof callback == 'object' || typeof callback == 'string') {
      fb.callback = $(callback);
      fb.callback.bind('keyup', fb.updateValue);
      if (fb.callback.get(0).value) {
        fb.setColor(fb.callback.get(0).value);
      }
    }
    return this;
  }
  fb.updateValue = function (event) {
    if (this.value && this.value != fb.color) {
      fb.setColor(this.value);
    }
  }

  /**
   * Change color with HTML syntax #123456
   */
  fb.setColor = function (color) {
    var unpack = fb.unpack(color);
    if (fb.color != color && unpack) {
      fb.color = color;
      fb.rgb = unpack;
      fb.hsl = fb.RGBToHSL(fb.rgb);
      fb.updateDisplay();
    }
    return this;
  }

  /**
   * Change color with HSL triplet [0..1, 0..1, 0..1]
   */
  fb.setHSL = function (hsl) {
    fb.hsl = hsl;
    fb.rgb = fb.HSLToRGB(hsl);
    fb.color = fb.pack(fb.rgb);
    fb.updateDisplay();
    return this;
  }

  /////////////////////////////////////////////////////

  /**
   * Retrieve the coordinates of the given event relative to the center
   * of the widget.
   */
  fb.widgetCoords = function (event) {
    var x, y;
    var el = event.target || event.srcElement;
    var reference = fb.wheel;

    if (typeof event.offsetX != 'undefined') {
      // Use offset coordinates and find common offsetParent
      var pos = { x: event.offsetX, y: event.offsetY };

      // Send the coordinates upwards through the offsetParent chain.
      var e = el;
      while (e) {
        e.mouseX = pos.x;
        e.mouseY = pos.y;
        pos.x += e.offsetLeft;
        pos.y += e.offsetTop;
        e = e.offsetParent;
      }

      // Look for the coordinates starting from the wheel widget.
      var e = reference;
      var offset = { x: 0, y: 0 }
      while (e) {
        if (typeof e.mouseX != 'undefined') {
          x = e.mouseX - offset.x;
          y = e.mouseY - offset.y;
          break;
        }
        offset.x += e.offsetLeft;
        offset.y += e.offsetTop;
        e = e.offsetParent;
      }

      // Reset stored coordinates
      e = el;
      while (e) {
        e.mouseX = undefined;
        e.mouseY = undefined;
        e = e.offsetParent;
      }
    }
    else {
      // Use absolute coordinates
      var pos = fb.absolutePosition(reference);
      x = (event.pageX || 0*(event.clientX + $('html').get(0).scrollLeft)) - pos.x;
      y = (event.pageY || 0*(event.clientY + $('html').get(0).scrollTop)) - pos.y;
    }
    // Subtract distance to middle
    return { x: x - fb.width / 2, y: y - fb.width / 2 };
  }

  /**
   * Mousedown handler
   */
  fb.mousedown = function (event) {
    // Capture mouse
    if (!document.dragging) {
      $(document).bind('mousemove', fb.mousemove).bind('mouseup', fb.mouseup);
      document.dragging = true;
    }

    // Check which area is being dragged
    var pos = fb.widgetCoords(event);
    fb.circleDrag = Math.max(Math.abs(pos.x), Math.abs(pos.y)) * 2 > fb.square;

    // Process
    fb.mousemove(event);
    return false;
  }

  /**
   * Mousemove handler
   */
  fb.mousemove = function (event) {
    // Get coordinates relative to color picker center
    var pos = fb.widgetCoords(event);

    // Set new HSL parameters
    if (fb.circleDrag) {
      var hue = Math.atan2(pos.x, -pos.y) / 6.28;
      if (hue < 0) hue += 1;
      fb.setHSL([hue, fb.hsl[1], fb.hsl[2]]);
    }
    else {
      var sat = Math.max(0, Math.min(1, -(pos.x / fb.square) + .5));
      var lum = Math.max(0, Math.min(1, -(pos.y / fb.square) + .5));
      fb.setHSL([fb.hsl[0], sat, lum]);
    }
    return false;
  }

  /**
   * Mouseup handler
   */
  fb.mouseup = function () {
    // Uncapture mouse
    $(document).unbind('mousemove', fb.mousemove);
    $(document).unbind('mouseup', fb.mouseup);
    document.dragging = false;
  }

  /**
   * Update the markers and styles
   */
  fb.updateDisplay = function () {
    // Markers
    var angle = fb.hsl[0] * 6.28;
    $('.h-marker', e).css({
      left: Math.round(Math.sin(angle) * fb.radius + fb.width / 2) + 'px',
      top: Math.round(-Math.cos(angle) * fb.radius + fb.width / 2) + 'px'
    });

    $('.sl-marker', e).css({
      left: Math.round(fb.square * (.5 - fb.hsl[1]) + fb.width / 2) + 'px',
      top: Math.round(fb.square * (.5 - fb.hsl[2]) + fb.width / 2) + 'px'
    });

    // Saturation/Luminance gradient
    $('.color', e).css('backgroundColor', fb.pack(fb.HSLToRGB([fb.hsl[0], 1, 0.5])));

    // Linked elements or callback
    if (typeof fb.callback == 'object') {
      // Set background/foreground color
      $(fb.callback).css({
        backgroundColor: fb.color,
        color: fb.hsl[2] > 0.5 ? '#000' : '#fff'
      });

      // Change linked value
      $(fb.callback).each(function() {
        if (this.value && this.value != fb.color) {
          this.value = fb.color;
        }
      });
    }
    else if (typeof fb.callback == 'function') {
      fb.callback.call(fb, fb.color);
    }
  }

  /**
   * Get absolute position of element
   */
  fb.absolutePosition = function (el) {
    var r = { x: el.offsetLeft, y: el.offsetTop };
    // Resolve relative to offsetParent
    if (el.offsetParent) {
      var tmp = fb.absolutePosition(el.offsetParent);
      r.x += tmp.x;
      r.y += tmp.y;
    }
    return r;
  };

  /* Various color utility functions */
  fb.pack = function (rgb) {
    var r = Math.round(rgb[0] * 255);
    var g = Math.round(rgb[1] * 255);
    var b = Math.round(rgb[2] * 255);
    return '#' + (r < 16 ? '0' : '') + r.toString(16) +
           (g < 16 ? '0' : '') + g.toString(16) +
           (b < 16 ? '0' : '') + b.toString(16);
  }

  fb.unpack = function (color) {
    if (color.length == 7) {
      return [parseInt('0x' + color.substring(1, 3)) / 255,
        parseInt('0x' + color.substring(3, 5)) / 255,
        parseInt('0x' + color.substring(5, 7)) / 255];
    }
    else if (color.length == 4) {
      return [parseInt('0x' + color.substring(1, 2)) / 15,
        parseInt('0x' + color.substring(2, 3)) / 15,
        parseInt('0x' + color.substring(3, 4)) / 15];
    }
  }

  fb.HSLToRGB = function (hsl) {
    var m1, m2, r, g, b;
    var h = hsl[0], s = hsl[1], l = hsl[2];
    m2 = (l <= 0.5) ? l * (s + 1) : l + s - l*s;
    m1 = l * 2 - m2;
    return [this.hueToRGB(m1, m2, h+0.33333),
        this.hueToRGB(m1, m2, h),
        this.hueToRGB(m1, m2, h-0.33333)];
  }

  fb.hueToRGB = function (m1, m2, h) {
    h = (h < 0) ? h + 1 : ((h > 1) ? h - 1 : h);
    if (h * 6 < 1) return m1 + (m2 - m1) * h * 6;
    if (h * 2 < 1) return m2;
    if (h * 3 < 2) return m1 + (m2 - m1) * (0.66666 - h) * 6;
    return m1;
  }

  fb.RGBToHSL = function (rgb) {
    var min, max, delta, h, s, l;
    var r = rgb[0], g = rgb[1], b = rgb[2];
    min = Math.min(r, Math.min(g, b));
    max = Math.max(r, Math.max(g, b));
    delta = max - min;
    l = (min + max) / 2;
    s = 0;
    if (l > 0 && l < 1) {
      s = delta / (l < 0.5 ? (2 * l) : (2 - 2 * l));
    }
    h = 0;
    if (delta > 0) {
      if (max == r && max != g) h += (g - b) / delta;
      if (max == g && max != b) h += (2 + (b - r) / delta);
      if (max == b && max != r) h += (4 + (r - g) / delta);
      h /= 6;
    }
    return [h, s, l];
  }

  // Install mousedown handler (the others are set on the document on-demand)
  $('*', e).mousedown(fb.mousedown);

    // Init color
  fb.setColor('#000000');

  // Set linked elements/callback
  if (callback) {
    fb.linkTo(callback);
  }
}<commit_msg>Delete farbtastic.js<commit_after><|endoftext|>


<commit_before>// Ionic fittr App, v0.9.20

// angular.module is a global place for creating, registering and retrieving Angular modules
// 'fittr' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
// 'fittr.services' is found in services.js
// 'fittr.controllers' is found in controllers.js
angular.module('fittr', ['ionic', 'fittr.services', 'fittr.controllers', 'ngRoute'])

.config(function($stateProvider, $urlRouterProvider, $routeProvider) {
  // Ionic uses AngularUI Router which uses the concept of states
  // Learn more here: https://github.com/angular-ui/ui-router
  // Set up the various states which the app can be in.
  // Each state's controller can be found in controllers.js

  $stateProvider
    /*
     * Fittr
     */

    // entry
    .state('entry', {
      url: '/entry',
      templateUrl: 'templates/entry.html',
      controller: 'EntryController'
    })

    .state('signup', {
      url: '/signup',
      templateUrl: 'templates/signlogin.html'
      // controller: 'SignupController'
    })

    .state('login', {
      url: '/login',
      templateUrl: 'templates/signlogin.html'
      // controller: 'LoginController'
    })

    // main
    .state('main', {
      url: '/main',
      templateUrl: 'templates/main.html',
      controller: 'MainController'
    })

    /*
     * Pets
     */

    // setup an abstract state for the tabs directive
    .state('tab', {
      url: "/tab",
      abstract: true,
      templateUrl: "templates/tabs.html"
    })

    // the pet tab has its own child nav-view and history
    .state('tab.pet-index', {
      url: '/pets',
      views: {
        'pets-tab': {
          templateUrl: 'templates/pet-index.html',
          controller: 'PetIndexCtrl'
        }
      }
    })

    .state('tab.pet-detail', {
      url: '/pet/:petId',
      views: {
        'pets-tab': {
          templateUrl: 'templates/pet-detail.html',
          controler: 'PetDetailCtrl'
        }
      }
    })

    .state('tab.adopt', {
      url: '/adopt',
      views: {
        'adopt-tab': {
          templateUrl: 'templates/adopt.html'
        }
      }
    })

    .state('tab.about', {
      url: '/about',
      views: {
        'about-tab': {
          templateUrl: 'templates/about.html'
        }
      }
    });

  // if none of the above states are matched, use this as the fallback
  $urlRouterProvider.otherwise('entry');

});

angular.module('fittr.services', []);

<commit_msg>removed duplicated app.js<commit_after><|endoftext|>


<commit_before>(function(){
  var exports = window.Todotxt = {};

  /**
   * Track file and revision # that we have downloaded.
   **/
  var revision = 0;
  var file = exports.file = '';

  /**
   * Track an integer array of the line numbers currently being shown
   * in the editor.
   **/
  var currentFilter = exports.currentFilter = null;

  var updateCallbacks = [];

  var dbExtensions = exports.dbExtensions = ['.txt', '.text', '.ttxt'];

  /**
   * Track whether or not the editor has been changed since the last update.
   **/
  var modified = false;

  // Store the local copy of the editor
  var editor = null;

  $(document).ready(function(){
    // Schedule a periodic check to check Dropbox.
    registerCheck();

    addUpdateHook(function(data, source){
      console.log("Handling update for " + source + " - " + $.param.fragment());
      if (source === $.param.fragment()){
        // We can ignore updates from the current page, since the editor would
        // have already been updated as the user typed.
        return;
      }
      /**
       * Register a periodic check to ensure the version on Dropbox hasn't updated
       * beyond the version that we have. If it has and we've modified, show a
       * persistent error. If it has and we haven't modified, just update to the
       * latest remote version.
       **/
      if (modified){
        // The remote version is more recent.
        $('#persAlerts').attr('class', 'alert alert-danger');
        $('#persAlerts').text('The remote Todo file has been updated. Your local changes cannot be saved. Please refresh the page to view the updates and discard your local changes.');
      } else{
        setText(data.text, -1);
      }
    });

    // Bind for search events.
    $('#search-btn-container').click(function(e){
      var searchVal = $('#search-input').val();
      renderSearch(searchVal);
    });
    $('#search-input').bind("keypress", function(e) {
      var code = e.keyCode || e.which;
      if (code == 13) {
        var searchVal = $('#search-input').val();
        e.preventDefault();
        renderSearch(searchVal);
        return false;
      }
    });

    // Setup our router.
    $(window).bind( 'hashchange', function( event ) {
      var hash_str = event.fragment,
        searchStr = event.getState('search');
      // Deselect any "active" sidebar item.
      $('a', '#sidebar').each(function(i, a){
        $(a).removeClass();
      });

      if (searchStr){
        // Render search
        var results = search(searchStr);
        filterTo(results);
        return
      }

      if (!hash_str){
        hash_str = 'ALL';
      }

      hash_str = hash_str.toUpperCase();

      // On a named list

      // Clear search input.
      $('#search-input').val('');

      // Mark as active
      $('a', '#sidebar').each(function(i, a){
        if ($(a).attr('data-name').toUpperCase() === hash_str){
          $(a).addClass('active');
        }
      });

      if (hash_str.toUpperCase() === "ALL"){
        filterTo();
      } else{
        filterTo(search(hash_str));
      }
      modified = false;

    });
    $(window).trigger( 'hashchange' );
  });

  var getRevision = exports.getRevision = function(){
    return revision;
  }

  /**
   * Add a function callback when the Todolist file is updated.
   **/
  var addUpdateHook = exports.addUpdateHook = function(callback){
    updateCallbacks.push(callback);
  }

  var removeUpdateHook = exports.removeUpdateHook = function(callback){
    updateCallbacks.splice(updateCallbacks.indexOf(callback),1);
  }

  var save = exports.save = function(callback){
    var appliedFilter = currentFilter;
    var appliedText = editor.getSession().getValue();
    var sourceFrag = $.param.fragment();

    $.ajax('/list', {
      type: 'POST',
      data : {
        text: editor.getSession().getValue(),
        revision: revision,
        filter: currentFilter
      }
    })
    .done(function(data){
      if (appliedFilter){
        // Need to merge the changes in to our local copy
        file = mergeEdits(file, appliedFilter, appliedText);
      } else {
        file = appliedText;
      }
      revision = data.revision;
      callback(null, data);

      modified = false;

      fireUpdate({text: file, revision: revision}, sourceFrag);
    })
    .fail(function(xhr, status, err){
      callback(err, null);
    });
  }

  var getList = exports.getList = function(callback, forceRefresh){
    if (arguments.length < 2){
      forceRefresh = false;
    }

    if (!forceRefresh && file){
      return callback(null, {text: file, revision: revision});
    }

    $.ajax('/list')
    .done(function(data){
      file = data.text;
      revision = data.revision;
      callback(null, data);
    })
    .fail(function(xhr, status, err){
      callback(err, null);
    });
  }

  var onDBSuccess = exports.onDBSuccess = function(files){
    // We only get one file
    var link = files[0].link;

    // The dropbox API doesn't really expose what we want, but I don't want to
    // write a custom file chooser. So we're going to get the direct link and then
    // parse out the path to the file. This is absolutely vulnerable to them
    // changing their API, but... here goes!
    var path =
      link.replace(/(http)?(s)?(:)?\/\/[^\/]+\/(\d+\/)?[^\/]+\/[^\/]+\//, '');

    $.ajax('/settings/path', {
      type: 'POST',
      data: {
        path: path
      }
    })
    .done(function(){
      // Great. The server now knows our path, but we're probably on a useless
      // "choose your file" page. Should we just refresh? Sure.
      location.reload();
    })
    .fail(function(){
      alert("Unable to set path.");
    });
  };

  exports.setEditor = function(edtr){
    editor = edtr;
    editor.getSession().on('change', function(e) {
      modified = true;
    });
    return editor;
  }

  var setText = exports.setText = function(text, force){
    if (modified && !force){
      throw new Error("Can't update the file since it's been modified");
    }

    editor.setValue(text, -1);

    modified = false;
  }

  /**
   * Perform a search for the given string using the local file.
   * @param searchVal A string or array of strings representing the pattern for
   *   which we're searching -- can include special characters like @ and + to
   *   search for projects or contexts.
   * @return If searchVals is a string, returns a single array of lineNumbers
   *   which match the pattern. If searchVals is an array, returns an array
   *   of arrays in which the outer index corresponds to the searchVals array,
   *   and the inner indices are the line numbers on which a match was found.
   **/
  var search = exports.search = function(searchVals){
    var singleMode = false;

    // Nest in an array
    if (typeof searchVals !== "object"){
      singleMode = true;
      searchVals = [searchVals];
    }

    searchVals = $.map(searchVals, function(searchVal){
      var trimmed = searchVal.trim();
      if (trimmed.length === 0){
        return null;
      }
      return trimmed.toUpperCase();
    });

    var matches = new Array(searchVals.length);
    for (var i = 0; i < matches.length; i++){
      matches[i] = [];
    }

    var splitLine = file.split(/\r?\n/);
    $.each(splitLine, function(lineNum, line){
      line = line.toUpperCase();
      $.each(searchVals, function(valNum, searchVal){
        if (searchVal && line.indexOf(searchVal) >= 0){
          // 1-Indexed line numbers match the editor.
          matches[valNum].push(lineNum+1);
        }
      });
    });

    if (singleMode){
      matches = matches[0];
    }

    return matches;
  }

  /**
   * Execute a search for the given string and render the results.
   **/
  var renderSearch = exports.renderSearch = function(searchVal){
    var results = search(searchVal);
    $.bbq.pushState({search: searchVal});
  }

  var filterTo = exports.filterTo = function(lineNums){
    if (!editor){
      console.log("WARN: can't really filter until editor is set. Aborting.");
      return;
    }

    currentFilter = lineNums;

    if (!lineNums){
      editor.setValue(file, -1);
      return;
    }

    var str2 = file;

    var filtered = file.split(/\r?\n/);
    filtered = $.grep(filtered, function(el, i){
      return ($.inArray(i+1, lineNums) >= 0);
    });

    var str = filtered.join('\n');
    setText(str);
  }

  /**
   * Register a periodic check to keep our file up-to-date with the one on
   * Dropbox.
   **/
  function registerCheck(){
    window.setInterval(function(){
      if (!revision){
        // There's nothing we can do yet.
        return;
      }
      $.ajax('/revision')
      .done(function(rev){
        if (rev > revision){
          getList(function(err, update){
            if (!err){
              fireUpdate(update, '__external__');
            }
          }, true);
        }
      });
    }, 15000);
  }

  /**
   * Fires an update to call all callback functions.
   * @param update The update object with the text and revision #.
   * @param external String representing the source (page) of the update
   *   or '__external__' if it came from an external source.
   **/
  function fireUpdate(update, source){
    $.each(updateCallbacks, function(i, cb){
      cb(update, source);
    });
  }

})();<commit_msg>Prevent page changes while you have unsaved edits.<commit_after>(function(){
  var exports = window.Todotxt = {};

  /**
   * Track file and revision # that we have downloaded.
   **/
  var revision = 0;
  var file = exports.file = '';

  /**
   * Track an integer array of the line numbers currently being shown
   * in the editor.
   **/
  var currentFilter = exports.currentFilter = null;

  var updateCallbacks = [];

  var dbExtensions = exports.dbExtensions = ['.txt', '.text', '.ttxt'];

  /**
   * Track whether or not the editor has been changed since the last update.
   **/
  var modified = false;

  // Store the local copy of the editor
  var editor = null;

  var ignoreNextHashchange = false;

  $(document).ready(function(){
    // Schedule a periodic check to check Dropbox.
    registerCheck();

    window.onbeforeunload = function(){
      if (modified){
        return 'You have changes that have not yet been saved to Dropbox. If you leave, any unsaved changes will be lost.';
      }
      return;
    }

    addUpdateHook(function(data, external){
      if (!external){
        // We can ignore updates from the current page, since the editor would
        // have already been updated as the user typed.
        return;
      }
      /**
       * Register a periodic check to ensure the version on Dropbox hasn't updated
       * beyond the version that we have. If it has and we've modified, show a
       * persistent error. If it has and we haven't modified, just update to the
       * latest remote version.
       **/
      if (modified){
        // The remote version is more recent.
        $('#persAlerts').attr('class', 'alert alert-danger');
        $('#persAlerts').text('The remote Todo file has been updated. Your local changes cannot be saved. Please refresh the page to view the updates and discard your local changes.');
      } else{
        setText(data.text, -1);
      }
    });

    // Bind for search events.
    $('#search-btn-container').click(function(e){
      var searchVal = $('#search-input').val();
      renderSearch(searchVal);
    });
    $('#search-input').bind("keypress", function(e) {
      var code = e.keyCode || e.which;
      if (code == 13) {
        var searchVal = $('#search-input').val();
        e.preventDefault();
        renderSearch(searchVal);
        return false;
      }
    });

    // Setup our router.
    $(window).bind( 'hashchange', function( event ) {
      if (modified && !ignoreNextHashchange){
        $(document).trigger("add-alerts", [
          {
            'message': "You must save your changes here before you can change pages.",
            'priority': 'warning'
          }
        ]);
        ignoreNextHashchange = true;
        history.back();
        return false;
      }

      if (ignoreNextHashchange){
        // We were instructed to ignore this hash change.
        ignoreNextHashchange = false;
        return;
      }

      var hash_str = event.fragment,
        searchStr = event.getState('search');
      // Deselect any "active" sidebar item.
      $('a', '#sidebar').each(function(i, a){
        $(a).removeClass();
      });

      if (searchStr){
        // Render search
        var results = search(searchStr);
        filterTo(results);
        return
      }

      if (!hash_str){
        hash_str = 'ALL';
      }

      hash_str = hash_str.toUpperCase();

      // On a named list

      // Clear search input.
      $('#search-input').val('');

      // Mark as active
      $('a', '#sidebar').each(function(i, a){
        if ($(a).attr('data-name').toUpperCase() === hash_str){
          $(a).addClass('active');
        }
      });

      if (hash_str.toUpperCase() === "ALL"){
        filterTo();
      } else{
        filterTo(search(hash_str));
      }
      modified = false;

    });
    $(window).trigger( 'hashchange' );
  });

  var getRevision = exports.getRevision = function(){
    return revision;
  }

  /**
   * Add a function callback when the Todolist file is updated.
   **/
  var addUpdateHook = exports.addUpdateHook = function(callback){
    updateCallbacks.push(callback);
  }

  var removeUpdateHook = exports.removeUpdateHook = function(callback){
    updateCallbacks.splice(updateCallbacks.indexOf(callback),1);
  }

  var save = exports.save = function(callback){
    var appliedFilter = currentFilter;
    var appliedText = editor.getSession().getValue();

    $.ajax('/list', {
      type: 'POST',
      data : {
        text: editor.getSession().getValue(),
        revision: revision,
        filter: currentFilter
      }
    })
    .done(function(data){
      if (appliedFilter){
        // Need to merge the changes in to our local copy
        file = mergeEdits(file, appliedFilter, appliedText);
      } else {
        file = appliedText;
      }
      revision = data.revision;
      callback(null, data);

      modified = false;

      fireUpdate({text: file, revision: revision}, false);
    })
    .fail(function(xhr, status, err){
      callback(err, null);
    });
  }

  var getList = exports.getList = function(callback, forceRefresh){
    if (arguments.length < 2){
      forceRefresh = false;
    }

    if (!forceRefresh && file){
      return callback(null, {text: file, revision: revision});
    }

    $.ajax('/list')
    .done(function(data){
      file = data.text;
      revision = data.revision;
      callback(null, data);
    })
    .fail(function(xhr, status, err){
      callback(err, null);
    });
  }

  var onDBSuccess = exports.onDBSuccess = function(files){
    // We only get one file
    var link = files[0].link;

    // The dropbox API doesn't really expose what we want, but I don't want to
    // write a custom file chooser. So we're going to get the direct link and then
    // parse out the path to the file. This is absolutely vulnerable to them
    // changing their API, but... here goes!
    var path =
      link.replace(/(http)?(s)?(:)?\/\/[^\/]+\/(\d+\/)?[^\/]+\/[^\/]+\//, '');

    $.ajax('/settings/path', {
      type: 'POST',
      data: {
        path: path
      }
    })
    .done(function(){
      // Great. The server now knows our path, but we're probably on a useless
      // "choose your file" page. Should we just refresh? Sure.
      location.reload();
    })
    .fail(function(){
      alert("Unable to set path.");
    });
  };

  exports.setEditor = function(edtr){
    editor = edtr;
    editor.getSession().on('change', function(e) {
      modified = true;
    });
    return editor;
  }

  var setText = exports.setText = function(text, force){
    if (modified && !force){
      throw new Error("Can't update the file since it's been modified");
    }

    editor.setValue(text, -1);

    modified = false;
  }

  /**
   * Perform a search for the given string using the local file.
   * @param searchVal A string or array of strings representing the pattern for
   *   which we're searching -- can include special characters like @ and + to
   *   search for projects or contexts.
   * @return If searchVals is a string, returns a single array of lineNumbers
   *   which match the pattern. If searchVals is an array, returns an array
   *   of arrays in which the outer index corresponds to the searchVals array,
   *   and the inner indices are the line numbers on which a match was found.
   **/
  var search = exports.search = function(searchVals){
    var singleMode = false;

    // Nest in an array
    if (typeof searchVals !== "object"){
      singleMode = true;
      searchVals = [searchVals];
    }

    searchVals = $.map(searchVals, function(searchVal){
      var trimmed = searchVal.trim();
      if (trimmed.length === 0){
        return null;
      }
      return trimmed.toUpperCase();
    });

    var matches = new Array(searchVals.length);
    for (var i = 0; i < matches.length; i++){
      matches[i] = [];
    }

    var splitLine = file.split(/\r?\n/);
    $.each(splitLine, function(lineNum, line){
      line = line.toUpperCase();
      $.each(searchVals, function(valNum, searchVal){
        if (searchVal && line.indexOf(searchVal) >= 0){
          // 1-Indexed line numbers match the editor.
          matches[valNum].push(lineNum+1);
        }
      });
    });

    if (singleMode){
      matches = matches[0];
    }

    return matches;
  }

  /**
   * Execute a search for the given string and render the results.
   **/
  var renderSearch = exports.renderSearch = function(searchVal){
    var results = search(searchVal);
    $.bbq.pushState({search: searchVal});
  }

  var filterTo = exports.filterTo = function(lineNums){
    if (!editor){
      console.log("WARN: can't really filter until editor is set. Aborting.");
      return;
    }

    currentFilter = lineNums;

    if (!lineNums){
      editor.setValue(file, -1);
      return;
    }

    var str2 = file;

    var filtered = file.split(/\r?\n/);
    filtered = $.grep(filtered, function(el, i){
      return ($.inArray(i+1, lineNums) >= 0);
    });

    var str = filtered.join('\n');
    setText(str);
  }

  /**
   * Register a periodic check to keep our file up-to-date with the one on
   * Dropbox.
   **/
  function registerCheck(){
    window.setInterval(function(){
      if (!revision){
        // There's nothing we can do yet.
        return;
      }
      $.ajax('/revision')
      .done(function(rev){
        if (rev > revision){
          getList(function(err, update){
            if (!err){
              fireUpdate(update, true);
            }
          }, true);
        }
      });
    }, 15000);
  }

  /**
   * Fires an update to call all callback functions.
   * @param update The update object with the text and revision #.
   * @param external Boolean representing whether the update came from an
   *   external source (true) or this application (false).
   **/
  function fireUpdate(update, external){
    $.each(updateCallbacks, function(i, cb){
      cb(update, external);
    });
  }

})();<|endoftext|>


<commit_before>import Map from '../../../../src/ol/Map.js';
import Control from '../../../../src/ol/control/Control.js';

describe('ol.control.Control', function() {
  let map, control;

  beforeEach(function() {
    map = new Map({
      target: document.createElement('div')
    });
    const element = document.createElement('div');
    control = new Control({element: element});
    control.setMap(map);
  });

  afterEach(function() {
    disposeMap(map);
    map = null;
    control = null;
  });

  describe('dispose', function() {
    it('removes the control element from its parent', function() {
      control.dispose();
      expect(control.element.parentNode).to.be(null);
    });
  });
});

describe('ol.control.Control\'s target', function() {
  describe('target as string or element', function() {
    it('transforms target from string to element', function() {
      const target = document.createElement('div');
      target.id = 'mycontrol';
      document.body.appendChild(target);
      const ctrl = new Control({target: 'mycontrol'});
      expect(ctrl.target_.id).to.equal('mycontrol');
      ctrl.dispose();
      target.parentNode.removeChild(target);
    });
    it('accepts element for target', function() {
      const target = document.createElement('div');
      target.id = 'mycontrol';
      document.body.appendChild(target);
      const ctrl = new Control({target: target});
      expect(ctrl.target_.id).to.equal('mycontrol');
      ctrl.dispose();
      target.parentNode.removeChild(target);
    });
    it('ignores non-existing target id', function() {
      const ctrl = new Control({target: 'doesnotexist'});
      expect(ctrl.target_).to.equal(null);
      ctrl.dispose();
    });
  });
});
<commit_msg>Add regression test for event target on Control<commit_after>import Map from '../../../../src/ol/Map.js';
import Control from '../../../../src/ol/control/Control.js';

describe('ol.control.Control', function() {
  let map, control;

  beforeEach(function() {
    map = new Map({
      target: document.createElement('div')
    });
    const element = document.createElement('div');
    control = new Control({element: element});
    control.setMap(map);
  });

  afterEach(function() {
    disposeMap(map);
    map = null;
    control = null;
  });

  describe('dispose', function() {
    it('removes the control element from its parent', function() {
      control.dispose();
      expect(control.element.parentNode).to.be(null);
    });
  });
});

describe('ol.control.Control\'s target', function() {
  describe('target as string or element', function() {
    it('transforms target from string to element', function() {
      const target = document.createElement('div');
      target.id = 'mycontrol';
      document.body.appendChild(target);
      const ctrl = new Control({target: 'mycontrol'});
      expect(ctrl.target_.id).to.equal('mycontrol');
      ctrl.dispose();
      target.parentNode.removeChild(target);
    });
    it('accepts element for target', function() {
      const target = document.createElement('div');
      target.id = 'mycontrol';
      document.body.appendChild(target);
      const ctrl = new Control({target: target});
      expect(ctrl.target_.id).to.equal('mycontrol');
      ctrl.dispose();
      target.parentNode.removeChild(target);
    });
    it('ignores non-existing target id', function() {
      const ctrl = new Control({target: 'doesnotexist'});
      expect(ctrl.target_).to.equal(null);
      ctrl.dispose();
    });
  });
});

describe('ol.control.Control\'s event target', function() {
  it('is the Control when the Control uses the default target', function() {
    const ctrl = new Control({element: document.createElement('div')});
    ctrl.on('test-event', function(e) {
      expect(e.target).to.be(ctrl);
    });
    ctrl.dispatchEvent('test-event');
    ctrl.dispose();
  });
  it('is the Control when the Control has a custom target', function() {
    const ctrl = new Control({
      element: document.createElement('div'),
      target: document.createElement('div')
    });
    ctrl.on('test-event', function(e) {
      expect(e.target).to.be(ctrl);
    });
    ctrl.dispatchEvent('test-event');
    ctrl.dispose();
  });
});
<|endoftext|>


<commit_before>const Lambda = require('aws-sdk/clients/lambda')
const lambda = new Lambda()

const handleResolveReadModelEvent = async (lambdaEvent, resolve) => {
  switch (lambdaEvent.operation) {
    case 'reset':
    case 'pause':
    case 'resume': {
      const names = lambdaEvent.name
        ? [ lambdaEvent.name ]
        : resolve.readModels.map(readmodel => readmodel.name)
      const { DEPLOYMENT_ID } = process.env
      for (const name of names) {
        await lambda
          .invoke({
            FunctionName: `${DEPLOYMENT_ID}-meta-lock`,
            Payload: JSON.stringify({
              listenerId: name,
              operation: lambdaEvent.operation
            })
          })
          .promise()
        await resolve.executeQuery.drop(name)
      }
      return 'ok'
    }
    case 'list': {
      return resolve.readModels.map(readModel => readModel.name)
    }
    default: {
      return null
    }
  }
}

const handleDeployServiceEvent = async (lambdaEvent, resolve) => {
  switch (lambdaEvent.part) {
    case 'readModel': {
      return await handleResolveReadModelEvent(lambdaEvent, resolve)
    }
    default: {
      return null
    }
  }
}

export default handleDeployServiceEvent
<commit_msg>Feature/invoke lambda reset meta (#1014)<commit_after>const Lambda = require('aws-sdk/clients/lambda')
const lambda = new Lambda()

const handleResolveReadModelEvent = async (lambdaEvent, resolve) => {
  switch (lambdaEvent.operation) {
    case 'reset':
    case 'pause':
    case 'resume': {
      const names = lambdaEvent.name
        ? [ lambdaEvent.name ]
        : resolve.readModels.map(readmodel => readmodel.name)
      const { DEPLOYMENT_ID } = process.env
      for (const name of names) {
        await lambda
          .invoke({
            FunctionName: `${DEPLOYMENT_ID}-meta-lock`,
            Payload: JSON.stringify({
              listenerId: name,
              operation: lambdaEvent.operation
            })
          })
          .promise()

        if (lambdaEvent.operation === 'reset') {
          await resolve.executeQuery.drop(name)
        }
      }
      return 'ok'
    }
    case 'list': {
      return resolve.readModels.map(readModel => readModel.name)
    }
    default: {
      return null
    }
  }
}

const handleDeployServiceEvent = async (lambdaEvent, resolve) => {
  switch (lambdaEvent.part) {
    case 'readModel': {
      return await handleResolveReadModelEvent(lambdaEvent, resolve)
    }
    default: {
      return null
    }
  }
}

export default handleDeployServiceEvent
<|endoftext|>


<commit_before>function Teams() {
    this.teams = [
        {
            id: "TeamRenaissance",
            name: "Renaissance",
            teamLead: "Anton Valadzko",
            qaTeamLead: "Aliaksandra Kutynka",
            developers: [
                "Andrei Osipau2",
                "Dzianis Arlouski",
                "Siarhei Tkachenka",
                "Iryna Kucharenka1",
                "Ivan Izmer",
                "Mark Varabyou",
                "Raman But-Husaim",
                "Siarhei Abrazhevich",

                "Artsiom Rusak",
                "Raman Ivanou",
                "Aliaksandr Koush",
                "Nicolay Kostroma",
                "Valentina Napolnova",

                "Aliaksey Rahatka",
                "Pavel Kastsiuk",
                "Juliana Stolnik"
            ],
            testers: [
                "Pavel Vysotsky",
                "Viktoriya Harbatsenkava",
                "Hanna Prykhodzka",
                "Kseniya Kavalchuk",
                "Yuliya Tukaila",
                "Aliaksandra Kutynka"
            ]
        },
        {
            id: "TeamInspiration",
            name: "Inspiration",
            teamLead: "Sergey Tischenko",
            qaTeamLead: "Denys Pugachov",
            developers: [
                "Borys Roshal",
                "Denys Poliakov",
                "Kostiantyn Lazurenko",
                "Oleksandr Stukalov",
                "Oleksii Bespalko",
                "Yevhenii Havryliuk",
                "Yuriy Shestyora",
                "Ihor Bershov",
                "Vladyslav Pilhui",
                "Oleksandr Zhyltsov",
                "Oleksii Suriadnyi",
                "Roman Golovchenko",
                "Serhiy Haponenko",
                "Yevhenii Lomov"
            ],
            testers: [
                "Mila Botnar",
                "Yuri Timchenko",
                "Anastasia Kotenyova",
                "Pavlo Golovashchenko",
                "Svitlana Peleshenko",
                "Denys Pugachov"
            ]
        },
        {
            id: "TeamNova",
            name: "Nova",
            teamLead: "Heorhi Vilkitski",
            qaTeamLead: "Valiantsina Krautsevich",
            developers: [
                "Andrei Kandybovich",
                "Dzmitry Siamchonak",
                "Mikita Stalpinski",
                "Uladzimir Harabtsou",
                "Aliaksandr Nikulin",
                "Ilya Kazlou1",
                "Katsiaryna Kaliukhovich",
                "Vadzim Vysotski",
                "Aliaksei Labachou",
                "Edhar Liashok",
                "Raman Prakofyeu",
                "Ruslan Khilmanovich",
                "Anton Kratenok",

                "Dzmitry Chapurok",
                "Evgeny Sinitsyn"

            ],
            testers: [
                "Aliaksei Burnosenka",
                "Viktar Mikalayenka",
                "Viktoryia Darashenka",
                "Eugeny Okulik",
                "Yuliya Kalasouskaya",
                "Valiantsina Krautsevich"
            ]
        },
        {
            id: "TeamLiberty",
            name: "Liberty",
            teamLead: "Dzmitry Tabolich",
            qaTeamLead: "Iryna Kutsko",
            developers: [
                "Pavel Naumenka",
                "Sergei Kulick",
                "Volha Shandrokha",
                "Aliaksandr Rusak",
                "Andrei Kasak",
                "Andrei Krasnou",
                "Pavel Krakasevich",
                "Stepan Zelenin",
                "Dzmitry Isachenka",
                "Eugen Surovets",
                "Katsiaryna Tsalabanava",
                "Vitali Podobed",
                "Hleb Krotsik",
                "Uladzimir Vysotski"

            ],
            testers: [
                "Anna Novikova",
                "Anton Rapinchuk",
                "Igor Andros",
                "Maria Sobal",
                "Yuliya Karnatsevich",
                "Iryna Kutsko"
            ]
        },
        {
            id: "TeamViva",
            name: "Viva",
            teamLead: "Valentine Zhuck",
            qaTeamLead: "Katsiaryna Kuchko",
            developers: [
                "Valentine Zhuck",
                "Maryna Furman",
                "Siarhei Zhalezka",
                "Viachaslau Anufryiuk",
                "Yury Yamoryk",
                "Aliaksandr Kladau",
                "Dzmitry Kavaliou",
                "Dzmitry Shynkarou",
                "Maksim Tsikhan",
                "Petr Falitarchyk",
                "Yuri Chupyrkin",
                "Aliaksandr Rykau",
                "Ivan Dziameshka",
                "Siarhei Bahdanovich",

                "Aleh Dukel",
                "Ivan Yanchuk"
            ],
            testers: [
                "Iryna Koush",
                "Maryia Kireyeva",
                "Iryna Shuliak",
                "Liudmila Barshcheuskaya",
                "Iryna Razorionova",
                "Katsiaryna Kuchko"
            ]
        },
        {
            id: "TeamAutomation",
            name: "Automation",
            teamLead: "Aliaksandr Basau",
            developers: [
                "Aliaksandr Basau",
                "Julia Zhavnerchik",
                "Nadzeya Mishurava",
                "Stepan Zelenin",
                "Viachaslau Naimovich",
                "Vitali Sonchyk",
                "Katsiaryna Firsava",
                "Katsiaryna Kulbitskaya",
                "Maryia Kashtanava",
                "Rustam Allanazarau"
            ]
        }
    ]
}

exports.AllTeams = new Teams();
<commit_msg>"Siarhei Maksimau1" added for Nova team devs<commit_after>function Teams() {
    this.teams = [
        {
            id: "TeamRenaissance",
            name: "Renaissance",
            teamLead: "Anton Valadzko",
            qaTeamLead: "Aliaksandra Kutynka",
            developers: [
                "Andrei Osipau2",
                "Dzianis Arlouski",
                "Siarhei Tkachenka",
                "Iryna Kucharenka1",
                "Ivan Izmer",
                "Mark Varabyou",
                "Raman But-Husaim",
                "Siarhei Abrazhevich",

                "Artsiom Rusak",
                "Raman Ivanou",
                "Aliaksandr Koush",
                "Nicolay Kostroma",
                "Valentina Napolnova",

                "Aliaksey Rahatka",
                "Pavel Kastsiuk",
                "Juliana Stolnik"
            ],
            testers: [
                "Pavel Vysotsky",
                "Viktoriya Harbatsenkava",
                "Hanna Prykhodzka",
                "Kseniya Kavalchuk",
                "Yuliya Tukaila",
                "Aliaksandra Kutynka"
            ]
        },
        {
            id: "TeamInspiration",
            name: "Inspiration",
            teamLead: "Sergey Tischenko",
            qaTeamLead: "Denys Pugachov",
            developers: [
                "Borys Roshal",
                "Denys Poliakov",
                "Kostiantyn Lazurenko",
                "Oleksandr Stukalov",
                "Oleksii Bespalko",
                "Yevhenii Havryliuk",
                "Yuriy Shestyora",
                "Ihor Bershov",
                "Vladyslav Pilhui",
                "Oleksandr Zhyltsov",
                "Oleksii Suriadnyi",
                "Roman Golovchenko",
                "Serhiy Haponenko",
                "Yevhenii Lomov"
            ],
            testers: [
                "Mila Botnar",
                "Yuri Timchenko",
                "Anastasia Kotenyova",
                "Pavlo Golovashchenko",
                "Svitlana Peleshenko",
                "Denys Pugachov"
            ]
        },
        {
            id: "TeamNova",
            name: "Nova",
            teamLead: "Heorhi Vilkitski",
            qaTeamLead: "Valiantsina Krautsevich",
            developers: [
                "Andrei Kandybovich",
                "Dzmitry Siamchonak",
                "Mikita Stalpinski",
                "Uladzimir Harabtsou",
                "Aliaksandr Nikulin",
                "Ilya Kazlou1",
                "Katsiaryna Kaliukhovich",
                "Vadzim Vysotski",
                "Aliaksei Labachou",
                "Edhar Liashok",
                "Raman Prakofyeu",
                "Ruslan Khilmanovich",
                "Anton Kratenok",
                "Siarhei Maksimau1",
                "Dzmitry Chapurok",
                "Evgeny Sinitsyn"

            ],
            testers: [
                "Aliaksei Burnosenka",
                "Viktar Mikalayenka",
                "Viktoryia Darashenka",
                "Eugeny Okulik",
                "Yuliya Kalasouskaya",
                "Valiantsina Krautsevich"
            ]
        },
        {
            id: "TeamLiberty",
            name: "Liberty",
            teamLead: "Dzmitry Tabolich",
            qaTeamLead: "Iryna Kutsko",
            developers: [
                "Pavel Naumenka",
                "Sergei Kulick",
                "Volha Shandrokha",
                "Aliaksandr Rusak",
                "Andrei Kasak",
                "Andrei Krasnou",
                "Pavel Krakasevich",
                "Stepan Zelenin",
                "Dzmitry Isachenka",
                "Eugen Surovets",
                "Katsiaryna Tsalabanava",
                "Vitali Podobed",
                "Hleb Krotsik",
                "Uladzimir Vysotski"

            ],
            testers: [
                "Anna Novikova",
                "Anton Rapinchuk",
                "Igor Andros",
                "Maria Sobal",
                "Yuliya Karnatsevich",
                "Iryna Kutsko"
            ]
        },
        {
            id: "TeamViva",
            name: "Viva",
            teamLead: "Valentine Zhuck",
            qaTeamLead: "Katsiaryna Kuchko",
            developers: [
                "Valentine Zhuck",
                "Maryna Furman",
                "Siarhei Zhalezka",
                "Viachaslau Anufryiuk",
                "Yury Yamoryk",
                "Aliaksandr Kladau",
                "Dzmitry Kavaliou",
                "Dzmitry Shynkarou",
                "Maksim Tsikhan",
                "Petr Falitarchyk",
                "Yuri Chupyrkin",
                "Aliaksandr Rykau",
                "Ivan Dziameshka",
                "Siarhei Bahdanovich",

                "Aleh Dukel",
                "Ivan Yanchuk"
            ],
            testers: [
                "Iryna Koush",
                "Maryia Kireyeva",
                "Iryna Shuliak",
                "Liudmila Barshcheuskaya",
                "Iryna Razorionova",
                "Katsiaryna Kuchko"
            ]
        },
        {
            id: "TeamAutomation",
            name: "Automation",
            teamLead: "Aliaksandr Basau",
            developers: [
                "Aliaksandr Basau",
                "Julia Zhavnerchik",
                "Nadzeya Mishurava",
                "Stepan Zelenin",
                "Viachaslau Naimovich",
                "Vitali Sonchyk",
                "Katsiaryna Firsava",
                "Katsiaryna Kulbitskaya",
                "Maryia Kashtanava",
                "Rustam Allanazarau"
            ]
        }
    ]
}

exports.AllTeams = new Teams();
<|endoftext|>


<commit_before>import path from 'path';

import assert from 'yeoman-assert';
import helpers from 'yeoman-test';

describe('Generator', () => {
  beforeAll(() =>
    helpers.run(path.join(__dirname, '../app')).inTmpDir().withPrompts({
      moduleName: 'bunny module',
      description: 'as cute as bunny',
      githubUsername: 'bunny',
      website: 'www.wewww.com',
      name: 'yo',
      email: 'hi@bunny.io',
    })
  );

  it('can be required without throwing', () => {
    const app = require('./'); // eslint-disable-line
    assert(app);
  });

  it('generates files', () => {
    assert.file([
      '.all-contributorsrc',
      '.babelrc',
      '.editorconfig',
      '.eslintignore',
      '.eslintrc.json',
      '.flowconfig',
      '.gitattributes',
      '.gitignore',
      '.npmrc',
      '.travis.yml',
      'changelog.md',
      'contributing.md',
      'license',
      'package-scripts.js',
      'package.json',
      'readme.md',
      'src/index.js',
      'src/index.test.js',
    ]);
    assert.noFile('yo-rc.json');
  });

  describe('templating', () => {
    it('fills package.json with correct informations', () => {
      assert.JSONFileContent('package.json', {
        name: 'bunny-module',
        description: 'as cute as bunny',
        repository: {
          type: 'git',
          url: 'git+https://github.com/bunny/bunny-module.git',
        },
        author: {
          name: 'yo',
          email: 'hi@bunny.io',
          url: 'www.wewww.com',
        },
      });
    });

    describe('readme.md', () => {
      it('fills the title & description', () => {
        assert.fileContent('readme.md', '# bunny-module');
        assert.fileContent('readme.md', '> as cute as bunny');
      });

      describe('badges', () => {
        it('package version', () => {
          assert.fileContent(
            'readme.md',
            '[![npm](https://img.shields.io/npm/v/bunny-module.svg?style=flat-square)](https://www.npmjs.com/package/bunny-module)'
          );
        });

        it('download stats', () => {
          assert.fileContent(
            'readme.md',
            '[![npm](https://img.shields.io/npm/dt/bunny-module.svg?style=flat-square)](https://npm-stat.com/charts.html?package=bunny-module&from=2016-04-01)'
          );
        });

        it('build status', () => {
          assert.fileContent(
            'readme.md',
            '[![Travis branch](https://img.shields.io/travis/bunny-module/rust/master.svg?style=flat-square)](https://travis-ci.org/bunny/bunny-module)'
          );
        });

        it('coverage', () => {
          assert.fileContent(
            'readme.md',
            '[![Codecov branch](https://img.shields.io/codecov/c/github/bunny/bunny-module/master.svg?style=flat-square)](https://codecov.io/github/bunny/bunny-module)'
          );
        });

        it('COC', () => {
          assert.fileContent(
            'readme.md',
            '[![Code of Conduct](https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square)](./other/code_of_conduct.md)'
          );
        });

        it('roadmap', () => {
          assert.fileContent(
            'readme.md',
            '[![Roadmap](https://img.shields.io/badge/%F0%9F%93%94-roadmap-CD9523.svg?style=flat-square)](./other/roadmap.md)'
          );
        });
      });

      it('fills the installation instructions', () => {
        assert.fileContent('readme.md', 'npm install --save bunny-module');
      });

      it('fills the usage instructions', () => {
        assert.fileContent(
          'readme.md',
          'import bunnyModule from \'bunny-module\''
        );
      });

      it('fills the FAQ', () => {
        assert.fileContent('readme.md', '### Why should I use `bunny-module`?');
      });

      it('fills the license', () => {
        assert.fileContent('readme.md', 'MIT © [yo](www.wewww.com)');
      });
    });

    describe('license', () => {
      it('fiils the authors & email', () => {
        assert.fileContent(
          'license',
          'Copyright (c) yo <hi@bunny.io>'
        );
      });
    });
  });
});
<commit_msg>test: add specs for `code-of-conduct.md`<commit_after>import path from 'path';

import assert from 'yeoman-assert';
import helpers from 'yeoman-test';

describe('Generator', () => {
  beforeAll(() =>
    helpers.run(path.join(__dirname, '../app')).inTmpDir().withPrompts({
      moduleName: 'bunny module',
      description: 'as cute as bunny',
      githubUsername: 'bunny',
      website: 'www.wewww.com',
      name: 'yo',
      email: 'hi@bunny.io',
    })
  );

  it('can be required without throwing', () => {
    const app = require('./'); // eslint-disable-line
    assert(app);
  });

  it('generates files', () => {
    assert.file([
      '.all-contributorsrc',
      '.babelrc',
      '.editorconfig',
      '.eslintignore',
      '.eslintrc.json',
      '.flowconfig',
      '.gitattributes',
      '.gitignore',
      '.npmrc',
      '.travis.yml',
      'changelog.md',
      'contributing.md',
      'license',
      'package-scripts.js',
      'package.json',
      'readme.md',
      'src/index.js',
      'src/index.test.js',
    ]);
    assert.noFile('yo-rc.json');
  });

  describe('templating', () => {
    it('fills package.json with correct informations', () => {
      assert.JSONFileContent('package.json', {
        name: 'bunny-module',
        description: 'as cute as bunny',
        repository: {
          type: 'git',
          url: 'git+https://github.com/bunny/bunny-module.git',
        },
        author: {
          name: 'yo',
          email: 'hi@bunny.io',
          url: 'www.wewww.com',
        },
      });
    });

    describe('readme.md', () => {
      it('fills the title & description', () => {
        assert.fileContent('readme.md', '# bunny-module');
        assert.fileContent('readme.md', '> as cute as bunny');
      });

      describe('badges', () => {
        it('package version', () => {
          assert.fileContent(
            'readme.md',
            '[![npm](https://img.shields.io/npm/v/bunny-module.svg?style=flat-square)](https://www.npmjs.com/package/bunny-module)'
          );
        });

        it('download stats', () => {
          assert.fileContent(
            'readme.md',
            '[![npm](https://img.shields.io/npm/dt/bunny-module.svg?style=flat-square)](https://npm-stat.com/charts.html?package=bunny-module&from=2016-04-01)'
          );
        });

        it('build status', () => {
          assert.fileContent(
            'readme.md',
            '[![Travis branch](https://img.shields.io/travis/bunny-module/rust/master.svg?style=flat-square)](https://travis-ci.org/bunny/bunny-module)'
          );
        });

        it('coverage', () => {
          assert.fileContent(
            'readme.md',
            '[![Codecov branch](https://img.shields.io/codecov/c/github/bunny/bunny-module/master.svg?style=flat-square)](https://codecov.io/github/bunny/bunny-module)'
          );
        });

        it('COC', () => {
          assert.fileContent(
            'readme.md',
            '[![Code of Conduct](https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square)](./other/code_of_conduct.md)'
          );
        });

        it('roadmap', () => {
          assert.fileContent(
            'readme.md',
            '[![Roadmap](https://img.shields.io/badge/%F0%9F%93%94-roadmap-CD9523.svg?style=flat-square)](./other/roadmap.md)'
          );
        });
      });

      it('fills the installation instructions', () => {
        assert.fileContent('readme.md', 'npm install --save bunny-module');
      });

      it('fills the usage instructions', () => {
        assert.fileContent(
          'readme.md',
          'import bunnyModule from \'bunny-module\''
        );
      });

      it('fills the FAQ', () => {
        assert.fileContent('readme.md', '### Why should I use `bunny-module`?');
      });

      it('fills the license', () => {
        assert.fileContent('readme.md', 'MIT © [yo](www.wewww.com)');
      });
    });

    describe('code-of-conduct.md', () => {
      it('fiils the authors email', () => {
        assert.fileContent(
          'other/code_of_conduct.md',
          'reported by contacting the project team at hi@bunny.io'
        );
      });
    });

    describe('license', () => {
      it('fiils the authors & email', () => {
        assert.fileContent(
          'license',
          'Copyright (c) yo <hi@bunny.io>'
        );
      });
    });
  });
});
<|endoftext|>


<commit_before>(function (root, factory) {
  if (typeof define === 'function' && define.amd) {
    define(factory);
  } else if (typeof exports === 'object') {
    module.exports = factory;
  } else {
    root.enums = factory(root);
  }
})(this, function (root) {

    'use strict';

    var exports = {};

    function Enum(args){
        if(args.length === 0){
            throw new Error('At least one argument must be supplied');
        }

        var self = this,
                keys = [];

        for(var i = 0, len = args.length; i < len; i++){
            if(typeof args[i] !== 'string') {
                throw new Error('All arguments must be of string type.');
            }
            keys.push(args[i]);
        }

        for(var i = 0, len = keys.length; i < len; i++){
            self[keys[i]] = i;
        }

        self.keys = keys;
        return self;
    }

    exports['create'] = function () {
        return Object.freeze(new Enum(arguments));
    };

    return exports;
});
<commit_msg>Setting the string as value of their own key and removing insertion of repeated keys<commit_after>(function (root, factory) {
  if (typeof define === 'function' && define.amd) {
    define(factory);
  } else if (typeof exports === 'object') {
    module.exports = factory;
  } else {
    root.enums = factory(root);
  }
})(this, function (root) {

    'use strict';

    var exports = {};

    function Enum(args){
        if(args.length === 0){
            throw new Error('At least one argument must be supplied');
        }

        var self = this,
                keys = [];

        for(var i = 0, len = args.length; i < len; i++){
            if(typeof args[i] !== 'string') {
                throw new Error('All arguments must be of string type.');
            }
            if (keys.indexOf(args[i]) < 0){
                keys.push(args[i]);
            }
        }

        for(var i = 0, len = keys.length; i < len; i++){
            self[keys[i]] = keys[i];
        }

        self.keys = keys;
        return self;
    }

    exports['create'] = function () {
        return Object.freeze(new Enum(arguments));
    };

    return exports;
});
<|endoftext|>