<commit_before>angular.module('jam.song', [])

.controller('SongController', ['$scope', '$location', '$route', 'Songs', 'Users', function ($scope, loc, $route, Songs, Users) {
  $scope.song = {};
  $scope.audio = Songs.getPlayer();
  $scope.commentTime = null;
  $scope.pinningComment = false;
  $scope.user = {};
  $scope.comments = [];
  $scope.selectedComment = [{}];
  $scope.currentSongIsPlaying;

  var pageWidth = document.getElementsByClassName('page-content')[0].offsetWidth;
  var waveHeight = 100;
  var waveWidth = pageWidth * 0.9;
  var waveRadius = 2;
  var pinWidth = 12;
  var pinHeight = 20;
  var barPadding = 1;
  var initialDelay = 2000;

  $scope.width = waveWidth + 'px';

  // mock data
  var frequencyData = [1, 10, 30, 30, 40, 60, 70, 40, 50, 75, 80, 75, 70, 65, 60, 40, 30, 20, 20, 15, 10, 15, 30,
    30, 40, 60, 70, 40, 60, 70, 40, 50, 75, 80, 75, 70, 65, 60, 40, 30, 20, 20, 15, 10, 10, 30, 30, 40, 60, 70, 40,
    50, 75, 80, 75, 70, 65, 60, 40, 60, 70, 40, 50, 75, 80, 75, 70, 60, 50, 40, 30, 20, 20, 10, 10, 5, 5, 5, 5,
    10, 15, 20, 10, 15, 20, 35, 45, 60, 70, 65, 60, 65, 55, 45, 40, 30, 25, 20, 20, 25, 20, 15, 25, 30 ,35, 45, 60,
    70, 65, 60, 65, 55, 45, 40, 30, 25, 20, 20, 25, 20, 15, 10, 15, 20, 35, 45, 60, 70, 65, 60, 65, 55, 45, 40, 30,
    25, 20, 20, 25, 20, 15, 25, 30, 25, 30, 45, 50, 60, 65, 65, 60, 40, 50, 45, 40, 40, 35, 30, 35, 35, 30, 30, 20, 25, 20, 15, 10, 5, 5, 2, 0];

  // Obtain song information and display comments
  Users.getUserData()
  .then(function (user) {
    $scope.user = user;
  })
  .then(function() {
    return Songs.getSong(loc.path().split('/')[2]);
  })
  .then(function (song) {
    $scope.song = song;
  })
  .then(function () {
    return Songs.getComments($scope.song.id);
  })
  .then(function (comments) {
    $scope.comments = comments;
    renderComments(comments);
    $scope.currentSongIsPlaying = $scope.song.address === $scope.audio.src;
    initialRender();
  });

  var createSvg = function (parent, height, width) {
    return d3.select(parent).append('svg').attr('height', height).attr('width', width);
  };

  // D3
  var svg = createSvg('.waveform-container', waveHeight, waveWidth);

  var selectedComment = d3.select('body').selectAll('.selected-comment');
  var comment = d3.select('body').selectAll('.comment-icon');

  var commentPins = d3.select('body').selectAll('.pin-container')
                      .style('height', pinHeight + 'px')
                      .style('width', waveWidth + 'px');

  var initialRender = function() {
    svg.attr('class', 'visualizer')
      .selectAll('rect')
      .data(frequencyData)
      .enter()
      .append('rect')
      .attr('rx', waveRadius + 'px')
      .attr('ry', waveRadius + 'px')
      .attr('x', function (d, i) {
        return i * (waveWidth / frequencyData.length);
      })
      .attr('y', waveHeight)
      .attr('height', 0)
      .transition()
      .delay(function(d, i) {
        return initialDelay * i / frequencyData.length;
      })
      .attr('width', waveWidth / frequencyData.length - barPadding)
      .attr('y', function(d) {
        return waveHeight - d;
      })
      .attr('height', function(d) {
        return d;
      });

    d3.select('body').selectAll('.comment-pin-container')
      .style('height', pinHeight * 2 + 'px')
      .style('width', waveWidth + 'px');

    d3.select('body').selectAll('.selected-comment-container')
      .style('height', pinHeight + 'px')
      .style('width', waveWidth + 'px');

    _.delay(setInterval, initialDelay, renderFlow, 300);
  };

  $scope.addComment = function (comment) {
    var time = Math.floor($scope.commentTime * $scope.song.duration);
    Songs.addComment({note: comment, time: time, userId: $scope.user.id}, $scope.song.id)
    .then(function (comment) {
      $scope.comments.push(comment);
      renderComments($scope.comments);
      $scope.pinningComment = false;
      $scope.comment = '';
    });
  };

  $scope.commentSelected = function () {
    return !!Object.keys($scope.selectedComment[0]).length;
  };

  $scope.pinComment = function () {
    $scope.commentTime = $scope.audio.currentTime / $scope.song.duration;
    $scope.pinningComment = true;
  };

  var renderComments = function() {
    commentPins.selectAll('div')
      .data($scope.comments)
      .enter()
      .append('div')
      .style('left', function (d) {
        var left = Math.floor(d.time / $scope.song.duration * waveWidth) - pinWidth / 2;
        return left + 'px';
      })
      .attr('class', 'pin')
      .on('mouseover', function(d, i) {
        $scope.setSelectedComment(d);
      });
  };

  var renderSelectedComment = function() {
    var left = Math.floor($scope.selectedComment[0].time / $scope.song.duration * waveWidth);
    var onLeft = left < waveWidth / 2;
    selectedComment.data($scope.selectedComment)
      .style('left', function() {
        if (onLeft) {
          return left + 'px';
        } else {
          return left - waveWidth / 2 + 'px';
        }
      })
      .classed('left', onLeft)
      .classed('right', !onLeft)
      .style('width', waveWidth / 2 + 'px')
      .text(function (d) {
        return d.note;
      });
  };

  var renderFlow = function () {
    svg.selectAll('rect')
      .data(frequencyData)
      .transition()
      .duration(600)
      .attr('fill', function(d, i) {
        if ((i / frequencyData.length) < ($scope.audio.currentTime / $scope.song.duration) && $scope.currentSongIsPlaying) {
          return 'rgb(0, 0, ' + 220 + ')';
        } else {
          return 'rgb(0, 0, ' + 100 + ')';
        }
      });
  };

  $scope.setSelectedComment = function(comment) {
    $scope.selectedComment = [comment];
    renderSelectedComment();
  };

  $scope.setPlayTime = function (e) {
    if ($scope.currentSongIsPlaying) {
      var visualizer = document.getElementsByClassName('visualizer')[0];
      var rect = visualizer.getBoundingClientRect();

      var x = e.clientX - rect.left;
      $scope.audio.currentTime = $scope.song.duration * x / waveWidth;
    }
  };

  $scope.togglePlay = function () {
    if ($scope.currentSongIsPlaying) {
      if ($scope.audio.paused) {
        $scope.audio.play();
      } else {
        $scope.audio.pause();
      }
    } else {
      $scope.audio.src = $scope.song.compressedAddress ||
        $scope.song.address;
      $scope.currentSongIsPlaying = $scope.song.address === $scope.audio.src;
      $scope.audio.play();
    }
  };

}]);
<commit_msg>(fix) Remove currently displayed comment when leaving new comment<commit_after>angular.module('jam.song', [])

.controller('SongController', ['$scope', '$location', '$route', 'Songs', 'Users', function ($scope, loc, $route, Songs, Users) {
  $scope.song = {};
  $scope.audio = Songs.getPlayer();
  $scope.commentTime = null;
  $scope.pinningComment = false;
  $scope.user = {};
  $scope.comments = [];
  $scope.selectedComment = [{}];
  $scope.currentSongIsPlaying;

  var pageWidth = document.getElementsByClassName('page-content')[0].offsetWidth;
  var waveHeight = 100;
  var waveWidth = pageWidth * 0.9;
  var waveRadius = 2;
  var pinWidth = 12;
  var pinHeight = 20;
  var barPadding = 1;
  var initialDelay = 2000;

  $scope.width = waveWidth + 'px';

  // mock data
  var frequencyData = [1, 10, 30, 30, 40, 60, 70, 40, 50, 75, 80, 75, 70, 65, 60, 40, 30, 20, 20, 15, 10, 15, 30,
    30, 40, 60, 70, 40, 60, 70, 40, 50, 75, 80, 75, 70, 65, 60, 40, 30, 20, 20, 15, 10, 10, 30, 30, 40, 60, 70, 40,
    50, 75, 80, 75, 70, 65, 60, 40, 60, 70, 40, 50, 75, 80, 75, 70, 60, 50, 40, 30, 20, 20, 10, 10, 5, 5, 5, 5,
    10, 15, 20, 10, 15, 20, 35, 45, 60, 70, 65, 60, 65, 55, 45, 40, 30, 25, 20, 20, 25, 20, 15, 25, 30 ,35, 45, 60,
    70, 65, 60, 65, 55, 45, 40, 30, 25, 20, 20, 25, 20, 15, 10, 15, 20, 35, 45, 60, 70, 65, 60, 65, 55, 45, 40, 30,
    25, 20, 20, 25, 20, 15, 25, 30, 25, 30, 45, 50, 60, 65, 65, 60, 40, 50, 45, 40, 40, 35, 30, 35, 35, 30, 30, 20, 25, 20, 15, 10, 5, 5, 2, 0];

  // Obtain song information and display comments
  Users.getUserData()
  .then(function (user) {
    $scope.user = user;
  })
  .then(function() {
    return Songs.getSong(loc.path().split('/')[2]);
  })
  .then(function (song) {
    $scope.song = song;
  })
  .then(function () {
    return Songs.getComments($scope.song.id);
  })
  .then(function (comments) {
    $scope.comments = comments;
    renderComments(comments);
    $scope.currentSongIsPlaying = $scope.song.address === $scope.audio.src;
    initialRender();
  });

  var createSvg = function (parent, height, width) {
    return d3.select(parent).append('svg').attr('height', height).attr('width', width);
  };

  // D3
  var svg = createSvg('.waveform-container', waveHeight, waveWidth);

  var selectedComment = d3.select('body').selectAll('.selected-comment');
  var comment = d3.select('body').selectAll('.comment-icon');

  var commentPins = d3.select('body').selectAll('.pin-container')
                      .style('height', pinHeight + 'px')
                      .style('width', waveWidth + 'px');

  var initialRender = function() {
    svg.attr('class', 'visualizer')
      .selectAll('rect')
      .data(frequencyData)
      .enter()
      .append('rect')
      .attr('rx', waveRadius + 'px')
      .attr('ry', waveRadius + 'px')
      .attr('x', function (d, i) {
        return i * (waveWidth / frequencyData.length);
      })
      .attr('y', waveHeight)
      .attr('height', 0)
      .transition()
      .delay(function(d, i) {
        return initialDelay * i / frequencyData.length;
      })
      .attr('width', waveWidth / frequencyData.length - barPadding)
      .attr('y', function(d) {
        return waveHeight - d;
      })
      .attr('height', function(d) {
        return d;
      });

    d3.select('body').selectAll('.comment-pin-container')
      .style('height', pinHeight * 2 + 'px')
      .style('width', waveWidth + 'px');

    d3.select('body').selectAll('.selected-comment-container')
      .style('height', pinHeight + 'px')
      .style('width', waveWidth + 'px');

    _.delay(setInterval, initialDelay, renderFlow, 300);
  };

  $scope.addComment = function (comment) {
    var time = Math.floor($scope.commentTime * $scope.song.duration);
    Songs.addComment({note: comment, time: time, userId: $scope.user.id}, $scope.song.id)
    .then(function (comment) {
      $scope.comments.push(comment);
      renderComments($scope.comments);
      $scope.pinningComment = false;
      $scope.comment = '';
    });
  };

  $scope.commentSelected = function () {
    return !!Object.keys($scope.selectedComment[0]).length;
  };

  $scope.pinComment = function () {
    $scope.commentTime = $scope.audio.currentTime / $scope.song.duration;
    $scope.pinningComment = true;
    $scope.selectedComment = [{}];
  };

  var renderComments = function() {
    commentPins.selectAll('div')
      .data($scope.comments)
      .enter()
      .append('div')
      .style('left', function (d) {
        var left = Math.floor(d.time / $scope.song.duration * waveWidth) - pinWidth / 2;
        return left + 'px';
      })
      .attr('class', 'pin')
      .on('mouseover', function(d, i) {
        $scope.setSelectedComment(d);
      });
  };

  var renderSelectedComment = function() {
    var left = Math.floor($scope.selectedComment[0].time / $scope.song.duration * waveWidth);
    var onLeft = left < waveWidth / 2;
    selectedComment.data($scope.selectedComment)
      .style('left', function() {
        if (onLeft) {
          return left + 'px';
        } else {
          return left - waveWidth / 2 + 'px';
        }
      })
      .classed('left', onLeft)
      .classed('right', !onLeft)
      .style('width', waveWidth / 2 + 'px')
      .text(function (d) {
        return d.note;
      });
  };

  var renderFlow = function () {
    svg.selectAll('rect')
      .data(frequencyData)
      .transition()
      .duration(600)
      .attr('fill', function(d, i) {
        if ((i / frequencyData.length) < ($scope.audio.currentTime / $scope.song.duration) && $scope.currentSongIsPlaying) {
          return 'rgb(0, 0, ' + 220 + ')';
        } else {
          return 'rgb(0, 0, ' + 100 + ')';
        }
      });
  };

  $scope.setSelectedComment = function(comment) {
    $scope.selectedComment = [comment];
    renderSelectedComment();
  };

  $scope.setPlayTime = function (e) {
    if ($scope.currentSongIsPlaying) {
      var visualizer = document.getElementsByClassName('visualizer')[0];
      var rect = visualizer.getBoundingClientRect();

      var x = e.clientX - rect.left;
      $scope.audio.currentTime = $scope.song.duration * x / waveWidth;
    }
  };

  $scope.togglePlay = function () {
    if ($scope.currentSongIsPlaying) {
      if ($scope.audio.paused) {
        $scope.audio.play();
      } else {
        $scope.audio.pause();
      }
    } else {
      $scope.audio.src = $scope.song.compressedAddress ||
        $scope.song.address;
      $scope.currentSongIsPlaying = $scope.song.address === $scope.audio.src;
      $scope.audio.play();
    }
  };

}]);
<|endoftext|>


<commit_before>Template.turn.turn = function(){
    return Turns.findOne();
};
Template.turn.turnIs = function (move) {
	var turn = Turns.findOne();
	return turn ? turn.turn === move : "";
};

Template.listRows.rows = function(){
//  return [1,2,3];
	var a = [];
	for(var i=0; i<ROW_COUNT; i++)
		a.push(i);
	return a;
};

var row = 0;
Template.listCells.cells = function(){
//    console.log("listCells", row, this);
    return Cells.find({ row: row++ }, {sort: {column: 1}});
};

Template.game.events({
  "click td.movement.available" : function(e){
	// 'this' is the clicked cell object
//    console.log("CLICK cell", this._id, this);
    var cell, $cell,
    	row = this.row;
    // Drop cell marker as deep as possible
    while( row < (ROW_COUNT - 1) && !getMoveAt(row + 1, this.column)){
    	row += 1;
    }
//    console.log("CLICK cell dropped", row, this.column);
    cell = getCellAt(row, this.column);

    // Mark <td> as unavailable
    $cell = $("div.container tr.row:nth-of-type(" + (row+1) + ")")
    	.find("td:nth-of-type(" + (this.column+1) + ")");
    $cell.removeClass("available");
//    console.log("CLICK cell dropped", cell, $cell);

    turn = Turns.findOne();

    // TODO: row and columns can be omitted?
    Cells.update(cell._id, { row: cell.row, column: cell.column, move: turn.turn });
//    Cells.update(cell._id, { move: turn.turn });
//    setMoveAt(this._id, { row: this.row, column: this.column, move: turn.turn });
    changeTurn(turn);

    winner = findWinner();
    gameHasWinner(winner);
  }
});

Template.resetCells.events({
  'click button': function(){
    console.log("CLICK reset", this._id, this);
    resetCells();
    resetTurn();
  }
});

var changeTurn = function(turn){
  if (turn.turn == "x") {
    Turns.update(turn._id, { turn: 'o' } );
  } else {
    Turns.update(turn._id, { turn: 'x' } );
  }
};

var gameHasWinner = function(winner){
  if (winner.length > 0) {
	console.log("winner", winner);
    $(".available").removeClass("available");
    $.each(winner, function(index, cell){
      Cells.update(cell._id, { row: cell.row, column: cell.column, move: cell.move, winner: true })
    });
  };
}

<commit_msg>Fixed click events for iPad<commit_after>Template.turn.turn = function(){
    return Turns.findOne();
};
Template.turn.turnIs = function (move) {
	var turn = Turns.findOne();
	return turn ? turn.turn === move : "";
};

Template.listRows.rows = function(){
//  return [1,2,3];
	var a = [];
	for(var i=0; i<ROW_COUNT; i++)
		a.push(i);
	return a;
};

var row = 0;
Template.listCells.cells = function(){
//    console.log("listCells", row, this);
    return Cells.find({ row: row++ }, {sort: {column: 1}});
};

Template.game.events({
  "click td.movement.available, touchstart td.movement.available" : function(e){
	// 'this' is the clicked cell object
//    console.log("CLICK cell", this._id, this);
    var cell, $cell,
    	row = this.row;
    // Drop cell marker as deep as possible
    while( row < (ROW_COUNT - 1) && !getMoveAt(row + 1, this.column)){
    	row += 1;
    }
//    console.log("CLICK cell dropped", row, this.column);
    cell = getCellAt(row, this.column);

    // Mark <td> as unavailable
    $cell = $("div.container tr.row:nth-of-type(" + (row+1) + ")")
    	.find("td:nth-of-type(" + (this.column+1) + ")");
    $cell.removeClass("available");
//    console.log("CLICK cell dropped", cell, $cell);

    turn = Turns.findOne();

    // TODO: row and columns can be omitted?
    Cells.update(cell._id, { row: cell.row, column: cell.column, move: turn.turn });
//    Cells.update(cell._id, { move: turn.turn });
//    setMoveAt(this._id, { row: this.row, column: this.column, move: turn.turn });
    changeTurn(turn);

    winner = findWinner();
    gameHasWinner(winner);
  }
});

Template.resetCells.events({
  'click button': function(){
    console.log("CLICK reset", this._id, this);
    resetCells();
    resetTurn();
  }
});

var changeTurn = function(turn){
  if (turn.turn == "x") {
    Turns.update(turn._id, { turn: 'o' } );
  } else {
    Turns.update(turn._id, { turn: 'x' } );
  }
};

var gameHasWinner = function(winner){
  if (winner.length > 0) {
	console.log("winner", winner);
    $(".available").removeClass("available");
    $.each(winner, function(index, cell){
      Cells.update(cell._id, { row: cell.row, column: cell.column, move: cell.move, winner: true })
    });
  };
}

<|endoftext|>


<commit_before>define(function(require) {
	window.onerror = function (msg, url, lineno) {
		fatalError({
			message: msg,
			filename: url,
			lineno: lineno,
		});
	};

	function fatalError(err) {
		var container = document.getElementById('container');
		container.classList.add('error');

		var elm = splash.querySelector('.contents');
		html = [
			"
Fatal Error!
",
			"
",
				err.filename || err.fileName,
				" (",
					err.lineno || err.lineNumber,
				"):",
			"
",
			"
",
				err.message,
			"
",
			"
Press F5 to attempt a rejoin
",
		].join("\n");
		elm.innerHTML = html;

		exitPointerLock();
		fatalError.fatalErrorTriggered = true;
		function exitPointerLock() {
			(document.exitPointerLock ||
			document.mozExitPointerLock ||
			document.webkitExitPointerLock).call(document);
		}
	}

	fatalError.fatalErrorTriggered = false;

	return fatalError;
});<commit_msg>Unneeded stuff.<commit_after>define(function(require) {
	function fatalError(err) {
		var container = document.getElementById('container');
		container.classList.add('error');

		var elm = splash.querySelector('.contents');
		html = [
			"
Fatal Error!
",
			"
",
				err.filename || err.fileName,
				" (",
					err.lineno || err.lineNumber,
				"):",
			"
",
			"
",
				err.message,
			"
",
			"
Press F5 to attempt a rejoin
",
		].join("\n");
		elm.innerHTML = html;

		exitPointerLock();
		fatalError.fatalErrorTriggered = true;
		function exitPointerLock() {
			(document.exitPointerLock ||
			document.mozExitPointerLock ||
			document.webkitExitPointerLock).call(document);
		}
	}

	fatalError.fatalErrorTriggered = false;

	return fatalError;
});<|endoftext|>


<commit_before>// vim: set ts=2 et:

/*
 * Encapsulates all the logic to handle the video calls.
 * Interface is as follows:
 *
 * var vc = videoChat(jquery_local_video_el, jquery_div_remote videos);
 * vc.make_calls([ "peer1", "peer2"]);
 * vc.end_calls();
 *
 * el_local_video: video element (jquery) where to drop the local video stream
 * el_remote_videos: element container (jquery) where to add the remote video streams
 *
 * If APP exists, this logic will be available in APP.videoChat
 * otherwise just as global variable videoChat
 */
(function() {

var vc = function(el_local_video, el_remote_videos) {

  navigator.getUserMedia = navigator.getUserMedia ||
                           navigator.webkitGetUserMedia ||
                           navigator.mozGetUserMedia;

  var iface = {}, // interface
      existingCall = {},
      localStream,
      class_remote_video_el = "their-video",
      seed_remote_video_id = "r_video_stream_",
      pid_seed = "drd_",
      pid = pid_seed + Math.floor(Math.random() * 10000),
      peer = new Peer(pid, { key: 'lwjd5qra8257b9', debug: 3});

  peer.on('open', function() {
    console.log("Your peerjs ID: " + peer.id);
  });

  // Receiving a call
  peer.on('call', function(call){
    // Answer the call automatically (instead of prompting user) for demo purposes
    call.answer(localStream);
    incoming(call);
  });

  peer.on('error', function(err){
    console.log(err.message);
  });

  // Get local stream
  navigator.getUserMedia({audio: true, video: true}, function(stream){
    el_local_video.prop('src', URL.createObjectURL(stream));
    localStream = stream;
  }, function(){ console.log("Error getting UserMedia."); });

  // Take care of remote streams for call
  function incoming(call) {
    if (call.peer in existingCall) {
      existingCall[call.peer].close();
    }

    // Wait for stream on the call, then set peer video display
    call.on('stream', function(stream){
      var video_el = $('<video>');
      video_el.prop('autoplay', true);
      video_el.prop('id', seed_remote_video_id + call.peer);
      video_el.prop('src', URL.createObjectURL(stream));
      video_el.prop('class', 'their-video');
      el_remote_videos.append(video_el);
    });

    existingCall[call.peer] = call;
    console.log("Received call for peer: " + call.peer);
  }

  // Interface
  iface.make_calls = function(listIds) {
    listIds.forEach(function(r_pid, i, a) {
      var call = peer.call(r_pid, localStream);
      incoming(call);
    });
  }

  iface.end_calls = function() {
    Object.keys(existingCall).forEach(function(k, i, a) {
      existingCall[k].close();
      $('#' + seed_remote_video_id + k).remove();
    });
  }

  return iface;
}

if (window['APP'] != undefined) APP.videoChat = vc;
else videoChat = vc;

})();
<commit_msg>Do not start anything until the user tells you so (start())<commit_after>// vim: set ts=2 et:

/*
 * Encapsulates all the logic to handle the video calls.
 * Interface is as follows:
 *
 * var vc = videoChat(jquery_local_video_el, jquery_div_remote_videos)
 * vc.start(call_back_on_open);
 * vc.make_calls([ "peer1", "peer2"]);
 * vc.end_calls();
 *
 * el_local_video: video element (jquery) where to drop the local video stream
 * el_remote_videos: element container (jquery) where to add the remote video streams
 *
 * If APP exists, this logic will be available in APP.videoChat
 * otherwise just as global variable videoChat
 */
(function() {

var vc = function(el_local_video, el_remote_videos) {

  navigator.getUserMedia = navigator.getUserMedia ||
                           navigator.webkitGetUserMedia ||
                           navigator.mozGetUserMedia;

  var _testing_mode = true,
      iface = {}, // interface
      existingCall = {},
      localStream,
      class_remote_video_el = "their-video",
      seed_remote_video_id = "r_video_stream_",
      pid_seed = "drd_",
      pid = pid_seed + Math.floor(Math.random() * 10000),
      peerjs_cfg = {host: 'localhost', port: 9000},
      peer;

  // Open peerjs connection to the server and setup handlers for incoming calls
  // Get local media also.
  function start(cb_on_open) {
    if (_testing_mode)
      peer = new Peer(pid, { key: 'lwjd5qra8257b9', debug: 3});
    else
      peer = new Peer(pid, peerjs_cfg);

    peer.on('open', function() {
      console.log("Your peerjs ID: " + peer.id);
      cb_on_open(peer);
    });

    // Receiving a call
    peer.on('call', function(call){
      // Answer the call automatically (instead of prompting user) for demo purposes
      call.answer(localStream);
      incoming(call);
    });

    peer.on('error', function(err){
      console.log(err.message);
    });

    navigator.getUserMedia({audio: true, video: true}, function(stream){
      el_local_video.prop('src', URL.createObjectURL(stream));
      localStream = stream;
    }, function(){ console.log("Error getting UserMedia."); });
  }

  // Take care of remote streams for call
  function incoming(call) {
    if (call.peer in existingCall) {
      existingCall[call.peer].close();
    }

    // Wait for stream on the call, then set peer video display
    call.on('stream', function(stream){
      var video_el = $('<video>');
      video_el.prop('autoplay', true);
      video_el.prop('id', seed_remote_video_id + call.peer);
      video_el.prop('src', URL.createObjectURL(stream));
      video_el.prop('class', 'their-video');
      el_remote_videos.append(video_el);
    });

    existingCall[call.peer] = call;
    console.log("Received call for peer: " + call.peer);
  }

  // Interface
  iface.start = start;

  iface.make_calls = function(listIds) {
    listIds.forEach(function(r_pid, i, a) {
      var call = peer.call(r_pid, localStream);
      incoming(call);
    });
  }

  iface.end_calls = function() {
    Object.keys(existingCall).forEach(function(k, i, a) {
      existingCall[k].close();
      $('#' + seed_remote_video_id + k).remove();
    });
  }

  return iface;
}

if (window['APP'] != undefined) APP.videoChat = vc;
else videoChat = vc;

})();
<|endoftext|>


<commit_before>var CENTER = [43.771473, 11.253766];
var BOUNDARY = [
    [43.763007, 11.267304],[43.77225, 11.29374],[43.78755, 11.25015],
    [43.77846, 11.23801],[43.76484, 11.24234], [43.763007, 11.267304]
];

///////////////////// INSERIMENTO DELLA MAPPA /////////////////////
var map = L.map('map')

// http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames
var tiles = L.tileLayer(
    'http://otile4.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png',
    // 'http://{s}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png',
    {
        attribution: 'Map data © OpenStreetMap contributors',
        maxZoom: 30,
        reuseTiles: true
    }
)
tiles.addTo(map);

$(document).on('pageshow', '#home', function() {
    /**
     * this is needed due to a known bug which causes the map to disappear
     */
    tiles.redraw();
});

/////////////////////////// DA LONTANO ///////////////////////////
var introduction = "area degli scavi archeologici di firenze"

var big_line = L.polyline(
    BOUNDARY,
    {color: 'red'}
).bindPopup(introduction);

var cluster = L.polygon(
    BOUNDARY,
    {color: 'red'}
).bindPopup(introduction);
cluster.on("click", function() {
    map.setView(CENTER, 16);
});
cluster.on('mouseover', function (e) {
    this.openPopup();
});
cluster.on('mouseout', function (e) {
    this.closePopup();
});

var RedIcon = L.Icon.Default.extend(
    {
        options: {iconUrl: 'images/marker_icon_red.png'}
    }
);
var redIcon = new RedIcon();
var far_marker = L.marker(
    CENTER,
    {icon: redIcon}
).bindPopup(introduction);
far_marker.on("click",  function() {
    map.setView(CENTER, 16);
});
far_marker.on('mouseover', function (e) {
    this.openPopup();
});
far_marker.on('mouseout', function (e) {
    this.closePopup();
});

function onZoomend() {
    var zoom_now = map.getZoom();
    console.log("zoom: ", zoom_now);

    if(zoom_now >= 17) {
        map.removeLayer(big_line);
        map.removeLayer(far_marker);
        map.removeLayer(cluster);
    }
    else if((zoom_now < 17) && (zoom_now >= 14)) {
        big_line.addTo(map);
        map.removeLayer(far_marker);
        map.removeLayer(cluster);
    }
    else if((zoom_now < 13) && (zoom_now >= 10)) {
        map.removeLayer(big_line);
        map.removeLayer(far_marker);
        cluster.addTo(map);
    }
    else if(zoom_now < 10) {
        map.removeLayer(big_line);
        far_marker.addTo(map);
        map.removeLayer(cluster);
    }
};
map.on('zoomend', onZoomend);

///////////////////// LOCALIZZAZIONE INIZIALE /////////////////////
map.locate({setView: true, maxZoom: 16});

function onLocationFound(e) {
    var my_position = L.marker(e.latlng)
    // var my_position = L.marker([46.019853,5.74585]);     testing
    my_position.bindPopup("sei qui");
    my_position.addTo(map);
    var to_be_shown = new L.featureGroup([my_position, far_marker, cluster, big_line]);
    map.fitBounds(to_be_shown.getBounds());
    console.log(e);
}
map.on('locationfound', onLocationFound);

function onLocationError(e) {
    map.setView(CENTER, 18);
    console.log(e.message);
}
map.on('locationerror', onLocationError);

//////////// INSERIMENTO LAYER WMS SCAVI ARCHEOLOGICI ////////////
var layer_interventi = L.tileLayer.wms(
    'http://www.opengeo.eu:8080/geoserver/wms?', {
        layers: 'topp:interventi',
        format: 'image/png',
        transparent: true,
        attribution: "",
        maxZoom: '25',
        minZoom: '7'
    }
);
//////////// INSERIMENTO LAYER WMS SCAVI ARCHEOLOGICI ////////////
var layer_ritrovamenti_linee = L.tileLayer.wms(
    'http://www.opengeo.eu:8080/geoserver/wms?', {
        layers: 'topp:view_ritro_line',
        format: 'image/png',
        transparent: true,
        attribution: "",
        maxZoom: '25',
        minZoom: '19'
    }
);
//////////// INSERIMENTO LAYER WMS SCAVI ARCHEOLOGICI ////////////
var layer_ritrovamenti_punti = L.tileLayer.wms(
    'http://www.opengeo.eu:8080/geoserver/wms?', {
        layers: 'topp:view_ritro_punti',
        format: 'image/png',
        transparent: true,
        attribution: "",
        maxZoom: '25',
        minZoom: '19'
    }
);

layer_interventi.addTo(map);
layer_ritrovamenti_linee.addTo(map);
layer_ritrovamenti_punti.addTo(map);

/////// GESTIONE POPUP INFORMAZIONI TRAMITE CLICK SU MAPPA ///////
map.addEventListener('click', onMapClick);
popup = new L.Popup({ width: 50 });

function onMapClick(e) {
    // coordinate server ( long, lat ) coordinate standard ( lat, long)
    var bbox = map.getBounds()._southWest.lat + ","
            + map.getBounds()._southWest.lng + ","
            + map.getBounds()._northEast.lat + ","
            + map.getBounds()._northEast.lng;

    var width = map.getSize().x;
    var height = map.getSize().y;
    var x = map.layerPointToContainerPoint(e.layerPoint).x;
    var y = map.layerPointToContainerPoint(e.layerPoint).y;
    wms_proxy(bbox, width, height, x, y, e);
};
<commit_msg>style<commit_after>var CENTER = [43.771473, 11.253766];
var BOUNDARY = [
    [43.763007, 11.267304],[43.77225, 11.29374],[43.78755, 11.25015],
    [43.77846, 11.23801],[43.76484, 11.24234], [43.763007, 11.267304]
];

///////////////////// INSERIMENTO DELLA MAPPA /////////////////////
var map = L.map('map')

// http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames
var tiles = L.tileLayer(
    'http://otile4.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png',
    // 'http://{s}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png',
    {
        attribution: 'Map data © OpenStreetMap contributors',
        maxZoom: 30,
        reuseTiles: true
    }
)
tiles.addTo(map);

$(document).on('pageshow', '#home', function() {
    /**
     * this is needed due to a known bug which causes the map to disappear
     */
    tiles.redraw();
});

/////////////////////////// DA LONTANO ///////////////////////////
var introduction = "area degli scavi archeologici di firenze"

var big_line = L.polyline(
    BOUNDARY,
    {color: 'red'}
).bindPopup(introduction);

var cluster = L.polygon(
    BOUNDARY,
    {color: 'red'}
).bindPopup(introduction);
cluster.on("click", function() {
    map.setView(CENTER, 16);
});
cluster.on('mouseover', function (e) {
    this.openPopup();
});
cluster.on('mouseout', function (e) {
    this.closePopup();
});

var RedIcon = L.Icon.Default.extend(
    {
        options: {iconUrl: 'images/marker_icon_red.png'}
    }
);
var redIcon = new RedIcon();
var far_marker = L.marker(
    CENTER,
    {icon: redIcon}
).bindPopup(introduction);
far_marker.on("click", function() {
    map.setView(CENTER, 16);
});
far_marker.on('mouseover', function (e) {
    this.openPopup();
});
far_marker.on('mouseout', function (e) {
    this.closePopup();
});

function onZoomend() {
    var zoom_now = map.getZoom();
    console.log("zoom: ", zoom_now);

    if(zoom_now >= 17) {
        map.removeLayer(big_line);
        map.removeLayer(far_marker);
        map.removeLayer(cluster);
    }
    else if((zoom_now < 17) && (zoom_now >= 14)) {
        big_line.addTo(map);
        map.removeLayer(far_marker);
        map.removeLayer(cluster);
    }
    else if((zoom_now < 13) && (zoom_now >= 10)) {
        map.removeLayer(big_line);
        map.removeLayer(far_marker);
        cluster.addTo(map);
    }
    else if(zoom_now < 10) {
        map.removeLayer(big_line);
        far_marker.addTo(map);
        map.removeLayer(cluster);
    }
};
map.on('zoomend', onZoomend);

///////////////////// LOCALIZZAZIONE INIZIALE /////////////////////
map.locate({setView: true, maxZoom: 16});

function onLocationFound(e) {
    var my_position = L.marker(e.latlng)
    // var my_position = L.marker([46.019853,5.74585]);     testing
    my_position.bindPopup("sei qui");
    my_position.addTo(map);
    var to_be_shown = new L.featureGroup([my_position, far_marker, cluster, big_line]);
    map.fitBounds(to_be_shown.getBounds());
    console.log(e);
}
map.on('locationfound', onLocationFound);

function onLocationError(e) {
    map.setView(CENTER, 18);
    console.log(e.message);
}
map.on('locationerror', onLocationError);

//////////// INSERIMENTO LAYER WMS SCAVI ARCHEOLOGICI ////////////
var layer_interventi = L.tileLayer.wms(
    'http://www.opengeo.eu:8080/geoserver/wms?',
    {
        layers: 'topp:interventi',
        format: 'image/png',
        transparent: true,
        attribution: "",
        maxZoom: '25',
        minZoom: '7'
    }
);
//////////// INSERIMENTO LAYER WMS SCAVI ARCHEOLOGICI ////////////
var layer_ritrovamenti_linee = L.tileLayer.wms(
    'http://www.opengeo.eu:8080/geoserver/wms?',
    {
        layers: 'topp:view_ritro_line',
        format: 'image/png',
        transparent: true,
        attribution: "",
        maxZoom: '25',
        minZoom: '19'
    }
);
//////////// INSERIMENTO LAYER WMS SCAVI ARCHEOLOGICI ////////////
var layer_ritrovamenti_punti = L.tileLayer.wms(
    'http://www.opengeo.eu:8080/geoserver/wms?',
    {
        layers: 'topp:view_ritro_punti',
        format: 'image/png',
        transparent: true,
        attribution: "",
        maxZoom: '25',
        minZoom: '19'
    }
);

layer_interventi.addTo(map);
layer_ritrovamenti_linee.addTo(map);
layer_ritrovamenti_punti.addTo(map);

/////// GESTIONE POPUP INFORMAZIONI TRAMITE CLICK SU MAPPA ///////
map.addEventListener('click', onMapClick);
popup = new L.Popup({ width: 50 });

function onMapClick(e) {
    // coordinate server ( long, lat ) coordinate standard ( lat, long)
    var bbox = map.getBounds()._southWest.lat + ","
            + map.getBounds()._southWest.lng + ","
            + map.getBounds()._northEast.lat + ","
            + map.getBounds()._northEast.lng;

    var width = map.getSize().x;
    var height = map.getSize().y;
    var x = map.layerPointToContainerPoint(e.layerPoint).x;
    var y = map.layerPointToContainerPoint(e.layerPoint).y;
    wms_proxy(bbox, width, height, x, y, e);
};
<|endoftext|>


<commit_before>(function() {
	'use strict'
	let consoleStyles = {
		'font-size'        : '14px',
		'padding'          : '2px 5px',
		'color'            : '#499e4b',
		//'background-color' : '#282828'
	},
	floatPrecision = 0        //Количество точек после запятой для дробных чисел. 0 — вывод строкой

	/* Сохраняем нативную функцию */
	console.log_ = console.log

	/* Переопределяем функцию */
	console.log = function(...params) {
		let styles    = [],    //Стили для вывода
		    logParams = []    //Параметры для console.log

		params.forEach(param => {
			let type = 's'
			switch (typeof(param))
			{
				case 'object':
					type = 'o'
					break
				case 'number':
					type = 'd'
					if (param % 1 != 0)
					{
						type = (floatPrecision == 0) ? 's' : `.${floatPrecision}f`
					}
					break
			}
			let constyle = []
			Object.getOwnPropertyNames(consoleStyles).forEach(styleName =>
				constyle.push(styleName + ':' + consoleStyles[styleName])
			)

			if (type != 'o' && styles.length && styles[styles.length - 1] != '%c%o')
				styles.push(`%${type}`)
			else
			{
				styles.push(`%c%${type}`)
				logParams.push(constyle.join(';'))
			}
			logParams.push(param)
		})

		console.log_(styles.join(' '), ...logParams)
	}
})()<commit_msg>Можно обойтись дефолтным значением<commit_after>(function() {
	'use strict'
	let consoleStyles = {
		'font-size'        : '14px',
		'padding'          : '2px 5px',
		'color'            : '#499e4b',
		//'background-color' : '#282828'
	},
	floatPrecision = 0        //Количество точек после запятой для дробных чисел. 0 — вывод строкой

	/* Сохраняем нативную функцию */
	console.log_ = console.log

	/* Переопределяем функцию */
	console.log = function(...params) {
		let styles    = [],    //Стили для вывода
		    logParams = []    //Параметры для console.log

		params.forEach(param => {
			let type = 's'
			switch (typeof(param))
			{
				case 'object':
					type = 'o'
					break
				case 'number':
					type = 'd'
					if (param % 1 != 0 && floatPrecision != 0)
						type = `.${floatPrecision}f`
					break
			}
			let constyle = []
			Object.getOwnPropertyNames(consoleStyles).forEach(styleName =>
				constyle.push(styleName + ':' + consoleStyles[styleName])
			)

			if (type != 'o' && styles.length && styles[styles.length - 1] != '%c%o')
				styles.push(`%${type}`)
			else
			{
				styles.push(`%c%${type}`)
				logParams.push(constyle.join(';'))
			}
			logParams.push(param)
		})

		console.log_(styles.join(' '), ...logParams)
	}
})()<|endoftext|>


<commit_before>var _ = require('lodash')
var animate = require('animateplus')
var EventEmitter = require('events').EventEmitter

module.exports = function(container) {
  var wrapper = document.createElement('div')
  wrapper.style.width = '35%'
  wrapper.style.height = '100%'
  wrapper.style.left = 0
  wrapper.style.right = 0
  wrapper.style.margin = '0 auto'
  wrapper.style.position = 'absolute'
  container.appendChild(wrapper)

  var size = wrapper.clientWidth / 2

  var events = new EventEmitter()

  var points = _.range(7).map(function (i) {
    var dx = 0.9 * size * Math.cos(i * 2 * Math.PI / 6 + Math.PI / 6) + size
    var dy = 0.9 * size * Math.sin(i * 2 * Math.PI / 6 + Math.PI / 6) + size
    return [dx, dy]
  })

  var pointsflat = _.range(7).map(function (i) {
    var dx = 0.9 * size * Math.cos(i * 2 * Math.PI / 6) + size
    var dy = 0.9 * size * Math.sin(i * 2 * Math.PI / 6) + size
    return [dx, dy]
  })

  var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg')
  svg.setAttribute('width', size * 2)
  svg.setAttribute('height', size * 2.1)
  svg.style.position = 'relative'
  svg.style.display = 'block'
  svg.style.top = '50%'
  svg.style.transform = 'translateY(-50%)'
  wrapper.appendChild(svg)

  var hex = document.createElementNS('http://www.w3.org/2000/svg', 'polygon')
  hex.setAttribute("points", points.join(' '))
  hex.style.fill = 'none'
  hex.style.stroke = 'rgb(150,150,150)'
  hex.style.strokeWidth = '5'
  hex.style.strokeLinejoin = 'round'
  hex.style.transformOrigin = 'center'
  svg.appendChild(hex)

  var levels = document.createElementNS('http://www.w3.org/2000/svg', 'text')
  levels.setAttribute("fill", 'rgb(200,200,200)')
  levels.setAttribute("font-size", size / 7.5)
  levels.setAttribute("text-anchor", 'middle')
  levels.setAttribute('transform', 'translate(' + pointsflat[5][0] + ',' + pointsflat[5][1] + ')rotate(30)')
  levels.style.position = 'absolute'
  levels.style.transformOrigin = 'center'
  levels.style.cursor = 'pointer'
  levels.innerHTML = 'LEVELS'
  svg.appendChild(levels)

  var settings = document.createElementNS('http://www.w3.org/2000/svg', 'text')
  settings.setAttribute("fill", 'rgb(200,200,200)')
  settings.setAttribute("font-size", size / 7.5)
  settings.setAttribute("text-anchor", 'middle')
  settings.setAttribute("dominant-baseline", 'hanging')
  settings.setAttribute('transform', 'translate(' + pointsflat[1][0] + ',' + pointsflat[1][1] + ')rotate(-30)')
  settings.style.position = 'absolute'
  settings.style.cursor = 'pointer'
  settings.innerHTML = 'SETTINGS'
  svg.appendChild(settings)

  var about = document.createElementNS('http://www.w3.org/2000/svg', 'text')
  about.setAttribute("fill", 'rgb(200,200,200)')
  about.setAttribute("font-size", size / 7.5)
  about.setAttribute("text-anchor", 'middle')
  about.setAttribute('transform', 'translate(' + pointsflat[3][0] + ',' + pointsflat[3][1] + ')rotate(-90)')
  about.innerHTML = 'ABOUT'
  about.style.cursor = 'pointer'
  svg.appendChild(about)

  levels.onclick = function(event) {
    events.emit('click', 'levels')
  }

  settings.onclick = function(event) {
    events.emit('click', 'settings')
  }

  about.onclick = function(event) {
    events.emit('click', 'about')
  }

  wrapper.style.display = 'none'

  return {
    hide: function() {
      animate({
        el: hex,
        opacity: [1, 0],
        duration: 200,
        easing: 'easeInQuad'
      })
      animate({
        el: levels,
        opacity: [1, 0],
        duration: 300,
        easing: 'easeInQuad'
      })
      animate({
        el: about,
        opacity: [1, 0],
        duration: 300,
        easing: 'easeInQuad'
      })
      animate({
        el: settings,
        opacity: [1, 0],
        duration: 300,
        easing: 'easeInQuad',
        complete: function() {
          wrapper.style.display = 'none'
        }
      })
    },

    show: function() {
      wrapper.style.display = 'block'
      animate({
        el: hex,
        opacity: [0, 1],
        duration: 200,
        easing: 'easeInQuad'
      })
      animate({
        el: levels,
        opacity: [0, 1],
        duration: 300,
        easing: 'easeInQuad'
      })
      animate({
        el: about,
        opacity: [0, 1],
        duration: 400,
        easing: 'easeInQuad'
      })
      animate({
        el: settings,
        opacity: [0, 1],
        duration: 500,
        easing: 'easeInQuad'
      })
    },

    events: events
  }

}<commit_msg>Another firefox fix<commit_after>var _ = require('lodash')
var animate = require('animateplus')
var EventEmitter = require('events').EventEmitter

module.exports = function(container) {
  var wrapper = document.createElement('div')
  wrapper.style.width = '35%'
  wrapper.style.height = '100%'
  wrapper.style.left = 0
  wrapper.style.right = 0
  wrapper.style.margin = '0 auto'
  wrapper.style.position = 'absolute'
  container.appendChild(wrapper)

  var size = wrapper.clientWidth / 2

  var events = new EventEmitter()

  var points = _.range(7).map(function (i) {
    var dx = 0.9 * size * Math.cos(i * 2 * Math.PI / 6 + Math.PI / 6) + size
    var dy = 0.9 * size * Math.sin(i * 2 * Math.PI / 6 + Math.PI / 6) + size
    return [dx, dy]
  })

  var pointsflat = _.range(7).map(function (i) {
    var dx = 0.9 * size * Math.cos(i * 2 * Math.PI / 6) + size
    var dy = 0.9 * size * Math.sin(i * 2 * Math.PI / 6) + size
    return [dx, dy]
  })

  var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg')
  svg.setAttribute('width', size * 2)
  svg.setAttribute('height', size * 2.1)
  svg.style.position = 'relative'
  svg.style.display = 'block'
  svg.style.top = '50%'
  svg.style.transform = 'translateY(-50%)'
  wrapper.appendChild(svg)

  var hex = document.createElementNS('http://www.w3.org/2000/svg', 'polygon')
  hex.setAttribute("points", points.join(' '))
  hex.style.fill = 'none'
  hex.style.stroke = 'rgb(150,150,150)'
  hex.style.strokeWidth = '5'
  hex.style.strokeLinejoin = 'round'
  hex.style.transformOrigin = 'center'
  svg.appendChild(hex)

  var levels = document.createElementNS('http://www.w3.org/2000/svg', 'text')
  levels.setAttribute("fill", 'rgb(200,200,200)')
  levels.setAttribute("font-size", size / 7.5)
  levels.setAttribute("text-anchor", 'middle')
  levels.setAttribute('transform', 'translate(' + pointsflat[5][0] + ',' + pointsflat[5][1] + ')rotate(30)')
  levels.style.position = 'absolute'
  levels.style.cursor = 'pointer'
  levels.innerHTML = 'LEVELS'
  svg.appendChild(levels)

  var settings = document.createElementNS('http://www.w3.org/2000/svg', 'text')
  settings.setAttribute("fill", 'rgb(200,200,200)')
  settings.setAttribute("font-size", size / 7.5)
  settings.setAttribute("text-anchor", 'middle')
  settings.setAttribute("dominant-baseline", 'hanging')
  settings.setAttribute('transform', 'translate(' + pointsflat[1][0] + ',' + pointsflat[1][1] + ')rotate(-30)')
  settings.style.position = 'absolute'
  settings.style.cursor = 'pointer'
  settings.innerHTML = 'SETTINGS'
  svg.appendChild(settings)

  var about = document.createElementNS('http://www.w3.org/2000/svg', 'text')
  about.setAttribute("fill", 'rgb(200,200,200)')
  about.setAttribute("font-size", size / 7.5)
  about.setAttribute("text-anchor", 'middle')
  about.setAttribute('transform', 'translate(' + pointsflat[3][0] + ',' + pointsflat[3][1] + ')rotate(-90)')
  about.innerHTML = 'ABOUT'
  about.style.cursor = 'pointer'
  svg.appendChild(about)

  levels.onclick = function(event) {
    events.emit('click', 'levels')
  }

  settings.onclick = function(event) {
    events.emit('click', 'settings')
  }

  about.onclick = function(event) {
    events.emit('click', 'about')
  }

  wrapper.style.display = 'none'

  return {
    hide: function() {
      animate({
        el: hex,
        opacity: [1, 0],
        duration: 200,
        easing: 'easeInQuad'
      })
      animate({
        el: levels,
        opacity: [1, 0],
        duration: 300,
        easing: 'easeInQuad'
      })
      animate({
        el: about,
        opacity: [1, 0],
        duration: 300,
        easing: 'easeInQuad'
      })
      animate({
        el: settings,
        opacity: [1, 0],
        duration: 300,
        easing: 'easeInQuad',
        complete: function() {
          wrapper.style.display = 'none'
        }
      })
    },

    show: function() {
      wrapper.style.display = 'block'
      animate({
        el: hex,
        opacity: [0, 1],
        duration: 200,
        easing: 'easeInQuad'
      })
      animate({
        el: levels,
        opacity: [0, 1],
        duration: 300,
        easing: 'easeInQuad'
      })
      animate({
        el: about,
        opacity: [0, 1],
        duration: 400,
        easing: 'easeInQuad'
      })
      animate({
        el: settings,
        opacity: [0, 1],
        duration: 500,
        easing: 'easeInQuad'
      })
    },

    events: events
  }

}<|endoftext|>


<commit_before>'use strict';

const getChannelURL = require('ember-source-channel-url');
const { embroiderSafe, embroiderOptimized } = require('@embroider/test-setup');

module.exports = async function () {
  return {
    useYarn: true,
    scenarios: [
      {
        name: 'ember-lts-3.24',
        npm: {
          devDependencies: {
            'ember-source': '~3.24.3'
          }
        }
      },
      {
        name: 'ember-lts-3.28',
        npm: {
          devDependencies: {
            'ember-source': '~3.28.0'
          }
        }
      },
      {
        name: 'ember-release',
        npm: {
          devDependencies: {
            'ember-source': await getChannelURL('release')
          }
        }
      },
      {
        name: 'ember-beta',
        npm: {
          devDependencies: {
            'ember-source': await getChannelURL('beta')
          }
        }
      },
      {
        name: 'ember-canary',
        npm: {
          devDependencies: {
            'ember-source': await getChannelURL('canary')
          }
        }
      },
      {
        name: 'ember-default-with-jquery',
        env: {
          EMBER_OPTIONAL_FEATURES: JSON.stringify({
            'jquery-integration': true
          })
        },
        npm: {
          devDependencies: {
            '@ember/jquery': '^1.1.0'
          }
        }
      },
      {
        name: 'ember-classic',
        env: {
          EMBER_OPTIONAL_FEATURES: JSON.stringify({
            'application-template-wrapper': true,
            'default-async-observers': false,
            'template-only-glimmer-components': false
          })
        },
        npm: {
          devDependencies: {
            'ember-source': '~3.28.0'
          },
          ember: {
            edition: 'classic'
          }
        }
      },
      embroiderSafe(),
      embroiderOptimized()
    ]
  };
};
<commit_msg>Update ember-try.js<commit_after>'use strict';

const getChannelURL = require('ember-source-channel-url');
const { embroiderSafe, embroiderOptimized } = require('@embroider/test-setup');

module.exports = async function () {
  return {
    useYarn: true,
    scenarios: [
      {
        name: 'ember-lts-3.24',
        npm: {
          devDependencies: {
            'ember-source': '~3.24.3'
          }
        }
      },
      {
        name: 'ember-lts-3.28',
        npm: {
          devDependencies: {
            'ember-source': '~3.28.0'
          }
        }
      },
      {
        name: 'ember-release',
        npm: {
          devDependencies: {
            'ember-source': await getChannelURL('release')
          }
        }
      },
      {
        name: 'ember-beta',
        npm: {
          devDependencies: {
            'ember-source': await getChannelURL('beta')
          }
        }
      },
      {
        name: 'ember-canary',
        npm: {
          devDependencies: {
            'ember-source': await getChannelURL('canary')
          }
        }
      },
      {
        name: 'ember-default-with-jquery',
        env: {
          EMBER_OPTIONAL_FEATURES: JSON.stringify({
            'jquery-integration': true
          })
        },
        npm: {
          devDependencies: {
            '@ember/jquery': '^1.1.0',
            'ember-source': '~3.28.0'
          }
        }
      },
      {
        name: 'ember-classic',
        env: {
          EMBER_OPTIONAL_FEATURES: JSON.stringify({
            'application-template-wrapper': true,
            'default-async-observers': false,
            'template-only-glimmer-components': false
          })
        },
        npm: {
          devDependencies: {
            'ember-source': '~3.28.0'
          },
          ember: {
            edition: 'classic'
          }
        }
      },
      embroiderSafe(),
      embroiderOptimized()
    ]
  };
};
<|endoftext|>


<commit_before>/* eslint-env node */
module.exports = {
  scenarios: [
    {
      name: 'ember-lts-2.4',
      bower: {
        dependencies: {
          'ember': 'components/ember#lts-2-4'
        },
        resolutions: {
          'ember': 'lts-2-4'
        }
      },
      npm: {
        devDependencies: {
          'ember-source': null
        }
      }
    },
    {
      name: 'ember-lts-2.8',
      bower: {
        dependencies: {
          'ember': 'components/ember#lts-2-8'
        },
        resolutions: {
          'ember': 'lts-2-8'
        }
      },
      npm: {
        devDependencies: {
          'ember-source': null
        }
      }
    },
    {
      name: 'ember-lts-2.12',
      npm: {
        devDependencies: {
          'ember-source': '~2.12.0'
        }
      }
    },
    {
      name: 'ember-release',
      bower: {
        dependencies: {
          'ember': 'components/ember#release'
        },
        resolutions: {
          'ember': 'release'
        }
      },
      npm: {
        devDependencies: {
          'ember-source': null
        }
      }
    },
    {
      name: 'ember-beta',
      bower: {
        dependencies: {
          'ember': 'components/ember#beta'
        },
        resolutions: {
          'ember': 'beta'
        }
      },
      npm: {
        devDependencies: {
          'ember-source': null
        }
      }
    },
    {
      name: 'ember-canary',
      bower: {
        dependencies: {
          'ember': 'components/ember#canary'
        },
        resolutions: {
          'ember': 'canary'
        }
      },
      npm: {
        devDependencies: {
          'ember-source': null
        }
      }
    },
    {
      name: 'ember-default',
      npm: {
        devDependencies: {}
      }
    }
  ]
};
<commit_msg>Fix ember try bug.<commit_after>/* eslint-env node */
module.exports = {
  useYarn: true, //https://github.com/ember-cli/ember-try/issues/148
  scenarios: [
    {
      name: 'ember-lts-2.4',
      bower: {
        dependencies: {
          'ember': 'components/ember#lts-2-4'
        },
        resolutions: {
          'ember': 'lts-2-4'
        }
      },
      npm: {
        devDependencies: {
          'ember-source': null
        }
      }
    },
    {
      name: 'ember-lts-2.8',
      bower: {
        dependencies: {
          'ember': 'components/ember#lts-2-8'
        },
        resolutions: {
          'ember': 'lts-2-8'
        }
      },
      npm: {
        devDependencies: {
          'ember-source': null
        }
      }
    },
    {
      name: 'ember-lts-2.12',
      npm: {
        devDependencies: {
          'ember-source': '~2.12.0'
        }
      }
    },
    {
      name: 'ember-release',
      bower: {
        dependencies: {
          'ember': 'components/ember#release'
        },
        resolutions: {
          'ember': 'release'
        }
      },
      npm: {
        devDependencies: {
          'ember-source': null
        }
      }
    },
    {
      name: 'ember-beta',
      bower: {
        dependencies: {
          'ember': 'components/ember#beta'
        },
        resolutions: {
          'ember': 'beta'
        }
      },
      npm: {
        devDependencies: {
          'ember-source': null
        }
      }
    },
    {
      name: 'ember-canary',
      bower: {
        dependencies: {
          'ember': 'components/ember#canary'
        },
        resolutions: {
          'ember': 'canary'
        }
      },
      npm: {
        devDependencies: {
          'ember-source': null
        }
      }
    },
    {
      name: 'ember-default',
      npm: {
        devDependencies: {}
      }
    }
  ]
};
<|endoftext|>


<commit_before>/*jshint node:true*/
module.exports = {
  scenarios: [
    {
      name: 'default',
      bower: {
        dependencies: { }
      }
    },
    {
      name: 'ember-1.13',
      bower: {
        dependencies: {
          'ember': '~1.13.0'
        },
        resolutions: {
          'ember': '~1.13.0'
        }
      }
    },
    {
      name: 'ember-release',
      bower: {
        dependencies: {
          'ember': 'components/ember#release'
        },
        resolutions: {
          'ember': 'release'
        }
      }
    },
    {
      name: 'ember-beta',
      bower: {
        dependencies: {
          'ember': 'components/ember#beta'
        },
        resolutions: {
          'ember': 'beta'
        }
      }
    },
    {
      name: 'ember-canary',
      bower: {
        dependencies: {
          'ember': 'components/ember#canary'
        },
        resolutions: {
          'ember': 'canary'
        }
      }
    }
  ]
};
<commit_msg>ember-try config<commit_after>/*jshint node:true*/
module.exports = {
  useVersionCompatibility: true,
  scenarios: [
    {
      name: 'default',
      bower: {
        dependencies: { }
      }
    },
    {
      name: 'ember-release',
      bower: {
        dependencies: {
          'ember': 'components/ember#release'
        },
        resolutions: {
          'ember': 'release'
        }
      }
    },
    {
      name: 'ember-beta',
      bower: {
        dependencies: {
          'ember': 'components/ember#beta'
        },
        resolutions: {
          'ember': 'beta'
        }
      }
    },
    {
      name: 'ember-canary',
      bower: {
        dependencies: {
          'ember': 'components/ember#canary'
        },
        resolutions: {
          'ember': 'canary'
        }
      }
    }
  ]
};
<|endoftext|>


<commit_before>'use strict';

const getChannelURL = require('ember-source-channel-url');

module.exports = async function () {
  return {
    useYarn: true,
    scenarios: [
      {
        name: 'ember-lts-3.16',
        npm: {
          devDependencies: {
            'ember-source': '~3.16.0',
          },
        },
      },
      {
        name: 'ember-lts-3.20',
        npm: {
          devDependencies: {
            'ember-source': '~3.20.5',
          },
        },
      },
      {
        name: 'ember-release',
        npm: {
          devDependencies: {
            'ember-source': await getChannelURL('release'),
          },
        },
      },
      {
        name: 'ember-beta',
        npm: {
          devDependencies: {
            'ember-source': await getChannelURL('beta'),
          },
        },
      },
      {
        name: 'ember-canary',
        npm: {
          devDependencies: {
            'ember-source': await getChannelURL('canary'),
          },
        },
      },
      {
        name: 'ember-default-with-jquery',
        env: {
          EMBER_OPTIONAL_FEATURES: JSON.stringify({
            'jquery-integration': true,
          }),
        },
        npm: {
          devDependencies: {
            '@ember/jquery': '^1.1.0',
          },
        },
      },
      {
        name: 'ember-classic',
        env: {
          EMBER_OPTIONAL_FEATURES: JSON.stringify({
            'application-template-wrapper': true,
            'default-async-observers': false,
            'template-only-glimmer-components': false,
          }),
        },
        npm: {
          ember: {
            edition: 'classic',
          },
        },
      },
      {
        name: 'fastboot-addon-tests',
        command: 'npm run test:fastboot',
      },
    ],
  };
};
<commit_msg>Fix seg faults in CI<commit_after>'use strict';

const getChannelURL = require('ember-source-channel-url');

module.exports = async function () {
  return {
    // Somehow there are segmentation faults *after* the scenario has run, presumingly from `sharp`, when installing dependencies with yarn
    // useYarn: true,
    scenarios: [
      {
        name: 'ember-lts-3.16',
        npm: {
          devDependencies: {
            'ember-source': '~3.16.0',
          },
        },
      },
      {
        name: 'ember-lts-3.20',
        npm: {
          devDependencies: {
            'ember-source': '~3.20.5',
          },
        },
      },
      {
        name: 'ember-release',
        npm: {
          devDependencies: {
            'ember-source': await getChannelURL('release'),
          },
        },
      },
      {
        name: 'ember-beta',
        npm: {
          devDependencies: {
            'ember-source': await getChannelURL('beta'),
          },
        },
      },
      {
        name: 'ember-canary',
        npm: {
          devDependencies: {
            'ember-source': await getChannelURL('canary'),
          },
        },
      },
      {
        name: 'ember-default-with-jquery',
        env: {
          EMBER_OPTIONAL_FEATURES: JSON.stringify({
            'jquery-integration': true,
          }),
        },
        npm: {
          devDependencies: {
            '@ember/jquery': '^1.1.0',
          },
        },
      },
      {
        name: 'ember-classic',
        env: {
          EMBER_OPTIONAL_FEATURES: JSON.stringify({
            'application-template-wrapper': true,
            'default-async-observers': false,
            'template-only-glimmer-components': false,
          }),
        },
        npm: {
          ember: {
            edition: 'classic',
          },
        },
      },
      {
        name: 'fastboot-addon-tests',
        command: 'npm run test:fastboot',
      },
    ],
  };
};
<|endoftext|>


<commit_before>/*jshint node:true*/

module.exports = {
  useVersionCompatibility: true,
  scenarios: [{
    name: 'default',
    bower: {
      dependencies: {}
    }
  }, {
    name: 'ember-lts-2.4',
    bower: {
      dependencies: {
        'ember': 'components/ember#lts-2-4'
      },
      resolutions: {
        'ember': 'lts-2-4'
      }
    }
  }, {
    name: 'ember-release',
    bower: {
      dependencies: {
        'ember': 'components/ember#release'
      },
      resolutions: {
        'ember': 'release'
      }
    }
  }, {
    name: 'ember-beta',
    allowedToFail: true,
    bower: {
      dependencies: {
        'ember': 'components/ember#beta'
      },
      resolutions: {
        'ember': 'beta'
      }
    }
  }, {
    name: 'ember-canary',
    allowedToFail: true,
    bower: {
      dependencies: {
        'ember': 'components/ember#canary'
      },
      resolutions: {
        'ember': 'canary'
      }
    }
  }]
};
<commit_msg>Allow 2.6 and 2.7 failures<commit_after>/*jshint node:true*/

module.exports = {
  useVersionCompatibility: true,
  scenarios: [{
    name: 'default',
    bower: {
      dependencies: {}
    }
  }, {
    name: 'ember-lts-2.4',
    bower: {
      dependencies: {
        'ember': 'components/ember#lts-2-4'
      },
      resolutions: {
        'ember': 'lts-2-4'
      }
    }
  }, {
  }, {
    name: 'ember-2.6.2',
    allowedToFail: true
  }, {
  }, {
    name: 'ember-2.7.3',
    allowedToFail: true
  }, {
    name: 'ember-release',
    bower: {
      dependencies: {
        'ember': 'components/ember#release'
      },
      resolutions: {
        'ember': 'release'
      }
    }
  }, {
    name: 'ember-beta',
    allowedToFail: true,
    bower: {
      dependencies: {
        'ember': 'components/ember#beta'
      },
      resolutions: {
        'ember': 'beta'
      }
    }
  }, {
    name: 'ember-canary',
    allowedToFail: true,
    bower: {
      dependencies: {
        'ember': 'components/ember#canary'
      },
      resolutions: {
        'ember': 'canary'
      }
    }
  }]
};
<|endoftext|>


<commit_before>'use strict';

// eslint-disable-next-line node/no-unpublished-require
const getChannelURL = require('ember-source-channel-url');

module.exports = function () {
  return Promise.all([
    getChannelURL('release'),
    getChannelURL('beta'),
    getChannelURL('canary'),
  ]).then((urls) => {
    return {
      useYarn: true,
      scenarios: [
        {
          name: 'default',
          bower: {},
          npm: {
            devDependencies: {
              'ember-data': 'latest',
              '@ember-data/store': null,
              '@ember-data/debug': null,
              '@ember-data/model': null,
              '@ember-data/serializer': null,
              '@ember-data/adapter': null,
              '@ember-data/record-data': null,
              'ember-inflector': null,
            },
          },
        },
        {
          name: 'ember-lts-n-1',
          npm: {
            devDependencies: {
              'ember-source': '~3.12.0',
              'ember-data': '~3.16.0',
              '@ember-data/store': null,
              '@ember-data/debug': null,
              '@ember-data/model': null,
              '@ember-data/serializer': null,
              '@ember-data/adapter': null,
              '@ember-data/record-data': null,
              'ember-inflector': null,
            },
          },
        },
        {
          name: 'ember-lts',
          npm: {
            devDependencies: {
              'ember-source': '~3.16.0',
              'ember-data': '~3.16.0',
              '@ember-data/store': null,
              '@ember-data/debug': null,
              '@ember-data/model': null,
              '@ember-data/serializer': null,
              '@ember-data/adapter': null,
              '@ember-data/record-data': null,
              'ember-inflector': null,
            },
          },
        },
        {
          name: 'ember-data-packages-latest',
          npm: {
            devDependencies: {
              'ember-source': 'latest',
              'ember-data': null,
              '@ember-data/store': 'latest',
              '@ember-data/debug': null, // available in 3.15
              '@ember-data/model': 'latest', // not yet droppable (Errors)
              '@ember-data/serializer': null,
              '@ember-data/adapter': null,
              '@ember-data/record-data': null,
              'ember-inflector': '^3.0.1',
            },
          },
        },
        {
          name: 'ember-data-packages-beta',
          npm: {
            devDependencies: {
              'ember-source': 'latest',
              'ember-data': null,
              '@ember-data/store': 'beta',
              '@ember-data/debug': 'beta',
              '@ember-data/model': 'beta', // not yet droppable (Errors)
              '@ember-data/serializer': null,
              '@ember-data/adapter': null,
              '@ember-data/record-data': null,
              'ember-inflector': '^3.0.1',
            },
          },
        },
        {
          name: 'ember-data-packages-canary',
          npm: {
            devDependencies: {
              'ember-source': 'latest',
              'ember-data': null,
              '@ember-data/store': 'canary',
              '@ember-data/debug': 'canary',
              '@ember-data/model': 'canary', // not yet droppable (Errors)
              '@ember-data/serializer': null,
              '@ember-data/adapter': null,
              '@ember-data/record-data': null,
              'ember-inflector': '^3.0.1',
            },
          },
        },
        {
          name: 'release-n-1',
          npm: {
            devDependencies: {
              'ember-source': '~3.17.0',
              'ember-data': '~3.17.0',
              '@ember-data/store': null,
              '@ember-data/debug': null,
              '@ember-data/model': null,
              '@ember-data/serializer': null,
              '@ember-data/adapter': null,
              '@ember-data/record-data': null,
              'ember-inflector': null,
            },
          },
        },
        {
          name: 'release-channel',
          npm: {
            devDependencies: {
              'ember-source': urls[0],
              'ember-data': 'latest',
              '@ember-data/store': null,
              '@ember-data/debug': null,
              '@ember-data/model': null,
              '@ember-data/serializer': null,
              '@ember-data/adapter': null,
              '@ember-data/record-data': null,
              'ember-inflector': null,
            },
          },
        },
        {
          name: 'beta-channel',
          npm: {
            devDependencies: {
              'ember-source': urls[1],
              'ember-data': 'beta',
              '@ember-data/store': null,
              '@ember-data/debug': null,
              '@ember-data/model': null,
              '@ember-data/serializer': null,
              '@ember-data/adapter': null,
              '@ember-data/record-data': null,
              'ember-inflector': null,
            },
          },
        },
        {
          name: 'canary-channel',
          npm: {
            devDependencies: {
              'ember-source': urls[2],
              'ember-data': 'canary',
              '@ember-data/store': null,
              '@ember-data/debug': null,
              '@ember-data/model': null,
              '@ember-data/serializer': null,
              '@ember-data/adapter': null,
              '@ember-data/record-data': null,
              'ember-inflector': null,
            },
          },
        },
      ],
    };
  });
};
<commit_msg>Upgrade ember-lts versions to actual latest and latest-1<commit_after>'use strict';

// eslint-disable-next-line node/no-unpublished-require
const getChannelURL = require('ember-source-channel-url');

module.exports = function () {
  return Promise.all([
    getChannelURL('release'),
    getChannelURL('beta'),
    getChannelURL('canary'),
  ]).then((urls) => {
    return {
      useYarn: true,
      scenarios: [
        {
          name: 'default',
          bower: {},
          npm: {
            devDependencies: {
              'ember-data': 'latest',
              '@ember-data/store': null,
              '@ember-data/debug': null,
              '@ember-data/model': null,
              '@ember-data/serializer': null,
              '@ember-data/adapter': null,
              '@ember-data/record-data': null,
              'ember-inflector': null,
            },
          },
        },
        {
          name: 'ember-lts-n-1',
          npm: {
            devDependencies: {
              'ember-source': '~3.20.0',
              'ember-data': '~3.20.0',
              '@ember-data/store': null,
              '@ember-data/debug': null,
              '@ember-data/model': null,
              '@ember-data/serializer': null,
              '@ember-data/adapter': null,
              '@ember-data/record-data': null,
              'ember-inflector': null,
            },
          },
        },
        {
          name: 'ember-lts',
          npm: {
            devDependencies: {
              'ember-source': '~3.24.0',
              'ember-data': '~3.24.0',
              '@ember-data/store': null,
              '@ember-data/debug': null,
              '@ember-data/model': null,
              '@ember-data/serializer': null,
              '@ember-data/adapter': null,
              '@ember-data/record-data': null,
              'ember-inflector': null,
            },
          },
        },
        {
          name: 'ember-data-packages-latest',
          npm: {
            devDependencies: {
              'ember-source': 'latest',
              'ember-data': null,
              '@ember-data/store': 'latest',
              '@ember-data/debug': null, // available in 3.15
              '@ember-data/model': 'latest', // not yet droppable (Errors)
              '@ember-data/serializer': null,
              '@ember-data/adapter': null,
              '@ember-data/record-data': null,
              'ember-inflector': '^3.0.1',
            },
          },
        },
        {
          name: 'ember-data-packages-beta',
          npm: {
            devDependencies: {
              'ember-source': 'latest',
              'ember-data': null,
              '@ember-data/store': 'beta',
              '@ember-data/debug': 'beta',
              '@ember-data/model': 'beta', // not yet droppable (Errors)
              '@ember-data/serializer': null,
              '@ember-data/adapter': null,
              '@ember-data/record-data': null,
              'ember-inflector': '^3.0.1',
            },
          },
        },
        {
          name: 'ember-data-packages-canary',
          npm: {
            devDependencies: {
              'ember-source': 'latest',
              'ember-data': null,
              '@ember-data/store': 'canary',
              '@ember-data/debug': 'canary',
              '@ember-data/model': 'canary', // not yet droppable (Errors)
              '@ember-data/serializer': null,
              '@ember-data/adapter': null,
              '@ember-data/record-data': null,
              'ember-inflector': '^3.0.1',
            },
          },
        },
        {
          name: 'release-n-1',
          npm: {
            devDependencies: {
              'ember-source': '~3.17.0',
              'ember-data': '~3.17.0',
              '@ember-data/store': null,
              '@ember-data/debug': null,
              '@ember-data/model': null,
              '@ember-data/serializer': null,
              '@ember-data/adapter': null,
              '@ember-data/record-data': null,
              'ember-inflector': null,
            },
          },
        },
        {
          name: 'release-channel',
          npm: {
            devDependencies: {
              'ember-source': urls[0],
              'ember-data': 'latest',
              '@ember-data/store': null,
              '@ember-data/debug': null,
              '@ember-data/model': null,
              '@ember-data/serializer': null,
              '@ember-data/adapter': null,
              '@ember-data/record-data': null,
              'ember-inflector': null,
            },
          },
        },
        {
          name: 'beta-channel',
          npm: {
            devDependencies: {
              'ember-source': urls[1],
              'ember-data': 'beta',
              '@ember-data/store': null,
              '@ember-data/debug': null,
              '@ember-data/model': null,
              '@ember-data/serializer': null,
              '@ember-data/adapter': null,
              '@ember-data/record-data': null,
              'ember-inflector': null,
            },
          },
        },
        {
          name: 'canary-channel',
          npm: {
            devDependencies: {
              'ember-source': urls[2],
              'ember-data': 'canary',
              '@ember-data/store': null,
              '@ember-data/debug': null,
              '@ember-data/model': null,
              '@ember-data/serializer': null,
              '@ember-data/adapter': null,
              '@ember-data/record-data': null,
              'ember-inflector': null,
            },
          },
        },
      ],
    };
  });
};
<|endoftext|>


<commit_before>'use strict';

var gulp = require('gulp');
var xtend = require('xtend');
var config = require('../../config');

gulp.task('test', ['test:setup'], function(callback) {
  var karma = require('karma');
  var options = xtend(require(config.paths.karma), {
    singleRun: !config.watch,
    webpackServer: {
      quiet: config.watch
    }
  });

  karma.server.start(options);
});

gulp.task('test:watch', ['watch:setup', 'test']);

gulp.task('test:setup', function() {
  config.test = true;
});
<commit_msg>Refine webpack server in test task<commit_after>'use strict';

var gulp = require('gulp');
var xtend = require('xtend');
var config = require('../../config');

gulp.task('test', ['test:setup'], function(callback) {
  var karma = require('karma');
  var options = xtend({
    webpackServer: {}
  }, require(config.paths.karma), {
    singleRun: !config.watch
  });

  options.webpackServer.quiet = config.watch;
  karma.server.start(options);
});

gulp.task('test:watch', ['watch:setup', 'test']);

gulp.task('test:setup', function() {
  config.test = true;
});
<|endoftext|>


<commit_before>/* eslint-disable prefer-arrow-callback, func-names, class-methods-use-this */
import loader from 'graphql-tag/loader';

export default class GraphQLCompiler {
  processFilesForTarget(files) {
    // Fake webpack context
    // @see https://github.com/apollographql/graphql-tag/blob/57a258713acecde5ebef0c5771a975d6446703c7/loader.js#L43
    const context = {
      cacheable() {},
    };

    files
      .forEach((file) => {
        const path = `${file.getPathInPackage()}.js`;
        const content = file.getContentsAsString().trim();

        try {
          const data = loader.call(context, content);

          file.addJavaScript({
            data,
            path,
          });
        } catch (e) {
          if (e.locations) {
            file.error({
              message: e.message,
              line: e.locations[0].line,
              column: e.locations[0].column,
            });
            return null;
          }
          throw e;
        }
      });
  }
}
<commit_msg>ESlint fix<commit_after>/* eslint-disable prefer-arrow-callback, func-names, class-methods-use-this */
import loader from 'graphql-tag/loader';

export default class GraphQLCompiler {
  processFilesForTarget(files) {
    // Fake webpack context
    // @see https://github.com/apollographql/graphql-tag/blob/57a258713acecde5ebef0c5771a975d6446703c7/loader.js#L43
    const context = {
      cacheable() {},
    };

    files
      .forEach((file) => {
        const path = `${file.getPathInPackage()}.js`;
        const content = file.getContentsAsString().trim();

        try {
          const data = loader.call(context, content);

          file.addJavaScript({
            data,
            path,
          });
        } catch (e) {
          if (e.locations) {
            file.error({
              message: e.message,
              line: e.locations[0].line,
              column: e.locations[0].column,
            });
          } else {
            throw e;
          }
        }
      });
  }
}
<|endoftext|>


<commit_before>var http = require('http');
var blake = require('/home/ubuntu/blake/lib/blake.js');
var gits = require('/home/ubuntu/blake/node_modules/gits/main.js');

var server;

server = http.createServer(function (request, response) {
	if (request.method !== 'POST') {
		response.end();
		return;
	}

	// Continue if request comes from github

	var data, payload;

	data = '';

	request.on('data', function (chunk) {
		data += chunk;
	});

	request.on('end', function () {
		if (!data) {
			return;
		}

		var value;

		value = data.split('payload=')[1];

		if (!value) {
			return;
		}

		payload = JSON.parse(unescape(value) || null);

		if (!payload) {
			return;
		}

		console.log(payload);

		// Analyze payload, bake granuarly.

		gits.git('/home/ubuntu/michaelnisi', ['pull'], function () {
			blake.main(['/home/ubuntu/michaelnisi',
					    '/var/www/michaelnisi']);
		});
	});

	response.writeHead(200);
	response.end();
});

server.listen(3000, '127.0.0.1');
<commit_msg>Add conf<commit_after>var http = require('http');
var blake = require('/home/ubuntu/blake/lib/blake.js');
var gits = require('/home/ubuntu/node_modules/gits/main.js');

var server;

server = http.createServer(function (request, response) {
	if (request.method !== 'POST') {
		response.end();
		return;
	}

	// Continue if request comes from github

	var data, payload;

	data = '';

	request.on('data', function (chunk) {
		data += chunk;
	});

	request.on('end', function () {
		if (!data) {
			return;
		}

		var value;

		value = data.split('payload=')[1];

		if (!value) {
			return;
		}

		payload = JSON.parse(unescape(value) || null);

		if (!payload) {
			return;
		}

		console.log(payload);

		// Analyze payload, bake granuarly.

		gits.git('/home/ubuntu/michaelnisi', ['pull'], function () {
			blake.main(['/home/ubuntu/michaelnisi',
					    '/var/www/michaelnisi']);
		});
	});

	response.writeHead(200);
	response.end();
});

server.listen(3000, '127.0.0.1');
<|endoftext|>