<commit_before>// Config
var deleteKey = 44;
var multipleKeys = [
	{ 'code': 97, 'characters': [ 'a', 'á' ] },
	{ 'code': 101, 'characters': [ 'e', 'é' ] },
	{ 'code': 105, 'characters': [ 'i', 'í' ] },
	{ 'code': 111, 'characters': [ 'o', 'ó' ] },
	{ 'code': 117, 'characters': [ 'u', 'ú' ] }
];
var timeToMultiple = 1000;

// Audio
var enterAudio;
var keyAudio;

// Functions
function resetAudio ()
{
	try
	{
		enterAudio.pause ();
		keyAudio.pause ();
	}
	catch (v)
	{
		console.log (v);
	}
	enterAudio = new Audio('audio/enter.wav');
	keyAudio = new Audio('audio/key.wav');

}
function showKey (selector, delay)
{
	// Hide all others
	$('.keys').not (selector)
		.finish ()
		.hide ();

	if ($(selector).is(':visible'))
		$(selector)
			.finish()
			.show();
	else
		$(selector).show ('fade');

	$(selector)
		.delay (delay)
		.hide ('fade');
}
function showPressed (s)
{
	$('#pressed')
		.text (s);
	showKey ('#pressed', 400);
}
function showPressedSpecial (name)
{
	showKey (name, 400);
}
function showPressedMultiple (item, charIndex, first)
{
	// First?
	if (first)
	{
		// Clear and add keys
		$('#multiple > .container')
			.empty();
		$.each (item.characters, function (i, item)
		{
			$('#multiple > .container').append ($('<div>').text (item));
		});
	}

	// Highlight selected
	$('#multiple > .container > div')
		.removeClass ('selected')
		.eq (charIndex).addClass ('selected');

	// Animate progress
	$('#multiple > .progressContainer > div')
		.finish ()
		.css ('width', '0%')
		.animate ({ 'width': '100%'}, timeToMultiple);

	showKey ('#multiple', timeToMultiple);
}
function addChar (s)
{
	$('#textbox span').append (s);
	showPressed (s);
}
function deleteChar ()
{
	var $span = $('#textbox span');
	var currentText = $span.text();
	var newText = currentText.substr (0, currentText.length - 1);
	$span.text (newText);
}
function getLastChar ()
{
	return $('#textbox span').text ().slice(-1);
}

$(function ()
{
	// Variables
	var last = 0;
	var lastChar = null;
	var multipleIndex = 0;
	var $span = $('#textbox span');
	$('.keys').hide();

	// Event
	$(document).keypress (function (event)
	{
		// Stop sounds
		resetAudio ();

		// Enter
		if (event.charCode == 13)
		{
			showPressedSpecial (".specialKey.enter");
			$span.empty();
			enterAudio.play();
			return;
		}

		keyAudio.play();

		// Delete
		if (event.charCode == deleteKey)
		{
			showPressedSpecial (".specialKey.backspace");
			deleteChar();
			return;
		}

		// Multiple
		var now = (new Date()).getTime();
		var found = Enumerable.From (multipleKeys)
			.Where (function (x) { return x.code == event.charCode; })
			.FirstOrDefault();
		if (found !== undefined)
		{
			var isFirst = (lastChar != event.charCode || now - last > timeToMultiple);
			if (isFirst)
				multipleIndex = 0;
			else
				deleteChar();
			var indexToShow = multipleIndex++ % found.characters.length;
			console.log (found, indexToShow, isFirst);
			$('#textbox span').append (found.characters [indexToShow]);
			showPressedMultiple (found, indexToShow, isFirst);
			last = now;
			lastChar = event.charCode;
			return;
		}

		// Normal key
		last = now;
		lastChar = event.charCode;
		multipleIndex = 0;
		console.log(event.charCode);
		var s = String.fromCharCode (event.charCode);
		addChar (s);
		event.stopPropagation();
	});
});<commit_msg>Playing multiple audios at the same time<commit_after>// Config
var deleteKey = 44;
var multipleKeys = [
	{ 'code': 97, 'characters': [ 'a', 'á' ] },
	{ 'code': 101, 'characters': [ 'e', 'é' ] },
	{ 'code': 105, 'characters': [ 'i', 'í' ] },
	{ 'code': 111, 'characters': [ 'o', 'ó' ] },
	{ 'code': 117, 'characters': [ 'u', 'ú' ] }
];
var timeToMultiple = 1000;

// Functions
function play (url)
{
	new Audio (url).play ();
}
function playEnter ()
{
	play ('audio/enter.wav');
}

function playKey ()
{
	play ('audio/key.wav');
}
function showKey (selector, delay)
{
	// Hide all others
	$('.keys').not (selector)
		.finish ()
		.hide ();

	if ($(selector).is(':visible'))
		$(selector)
			.finish()
			.show();
	else
		$(selector).show ('fade');

	$(selector)
		.delay (delay)
		.hide ('fade');
}
function showPressed (s)
{
	$('#pressed')
		.text (s);
	showKey ('#pressed', 400);
}
function showPressedSpecial (name)
{
	showKey (name, 400);
}
function showPressedMultiple (item, charIndex, first)
{
	// First?
	if (first)
	{
		// Clear and add keys
		$('#multiple > .container')
			.empty();
		$.each (item.characters, function (i, item)
		{
			$('#multiple > .container').append ($('<div>').text (item));
		});
	}

	// Highlight selected
	$('#multiple > .container > div')
		.removeClass ('selected')
		.eq (charIndex).addClass ('selected');

	// Animate progress
	$('#multiple > .progressContainer > div')
		.finish ()
		.css ('width', '0%')
		.animate ({ 'width': '100%'}, timeToMultiple);

	showKey ('#multiple', timeToMultiple);
}
function addChar (s)
{
	$('#textbox span').append (s);
	showPressed (s);
}
function deleteChar ()
{
	var $span = $('#textbox span');
	var currentText = $span.text();
	var newText = currentText.substr (0, currentText.length - 1);
	$span.text (newText);
}
function getLastChar ()
{
	return $('#textbox span').text ().slice(-1);
}

$(function ()
{
	// Variables
	var last = 0;
	var lastChar = null;
	var multipleIndex = 0;
	var $span = $('#textbox span');
	$('.keys').hide();

	// Event
	$(document).keypress (function (event)
	{
		// Enter
		if (event.charCode == 13)
		{
			showPressedSpecial (".specialKey.enter");
			$span.empty();
			playEnter ();
			return;
		}

		playKey ();

		// Delete
		if (event.charCode == deleteKey)
		{
			showPressedSpecial (".specialKey.backspace");
			deleteChar();
			return;
		}

		// Multiple
		var now = (new Date()).getTime();
		var found = Enumerable.From (multipleKeys)
			.Where (function (x) { return x.code == event.charCode; })
			.FirstOrDefault();
		if (found !== undefined)
		{
			var isFirst = (lastChar != event.charCode || now - last > timeToMultiple);
			if (isFirst)
				multipleIndex = 0;
			else
				deleteChar();
			var indexToShow = multipleIndex++ % found.characters.length;
			console.log (found, indexToShow, isFirst);
			$('#textbox span').append (found.characters [indexToShow]);
			showPressedMultiple (found, indexToShow, isFirst);
			last = now;
			lastChar = event.charCode;
			return;
		}

		// Normal key
		last = now;
		lastChar = event.charCode;
		multipleIndex = 0;
		console.log(event.charCode);
		var s = String.fromCharCode (event.charCode);
		addChar (s);
		event.stopPropagation();
	});
});<|endoftext|>


<commit_before>function setup() {
	var canvas = document.createElement("canvas"),
		ctx = canvas.getContext("2d"),
		width = canvas.width = window.innerWidth,
		height = canvas.height = window.innerHeight;

	var mouseParticle = particle.create(0, 0, 0, 0);
		mouseParticle.mass = 1000;

	var middle = particle.create(width / 2, height / 2, 0, 0);
		middle.mass = 300;

	var orbits = [],
		text = ["ABOUT", "CONTACT", "PROJECTS", "CALANDER"];

	var about = particle.create(middle.x + middle.mass / 2, middle.y, 1, Math.PI / 2),
		contact = particle.create(middle.x - middle.mass / 2, middle.y, 1, -Math.PI / 2),
		projects = particle.create(middle.x, middle.y - middle.mass, 1, 0),
		newsletter = particle.create(middle.x, middle.y + middle.mass, 1, -Math.PI);

		orbits.push(about);
		orbits.push(contact);
		orbits.push(projects);
		orbits.push(newsletter);

	for(var f = 0; f < orbits.length; f++) {
		orbits[f].addGravitation(middle);
		orbits[f].mass = 20;
		orbits[f].radius = 50;
	}

	var blobs = [],
		totalPoints = [];

		document.body.appendChild(canvas);

		ctx.fillStyle = "rgba(0, 0, 0, 0.5)";
		ctx.strokeStyle = "rgba(0, 0, 0, 0.2)";

	var blob = function(x, y, vect) {
		this.points = [];
		this.pointRadius = 1;
		this.force = vect;
		this.radius = 30;
		var dir = (Math.random() < 0.5) ? Math.PI * Math.random() : -Math.PI * Math.random();
		this.particle = particle.create(x, y, 2, dir, 0.98);
		//this.particle.addGravitation(middle);
		this.particle.mass = 200 * Math.random() + 100;

		this.elasticity = 0.05;

		this.numPoints = 16;

		for(var i = 0; i < this.numPoints; i++) {
			var p1 = particle.create( this.particle.x + Math.cos(Math.PI * 2 / this.numPoints * i), this.particle.y + Math.sin(Math.PI * 2 / this.numPoints * i), 0, 0, 0.80);
			this.points.push(p1);
			totalPoints.push(p1);
		}

		for(var i = 0; i < this.points.length; i++) {
			this.points[i].addSpring(this.particle, this.elasticity, this.radius);
		}

		for(var i = 1; i < this.points.length; i++) {
			this.points[i].addSpring(this.points[i-1], this.elasticity, this.radius / 2 * Math.random());
			this.points[i-1].addSpring(this.points[i], this.elasticity, this.radius / 2 * Math.random());
		}

		for(var i = this.points.length - 1; i >= this.points.length / 2; i--) {
			var index = i - this.points.length / 2;
			this.points[i].addSpring(this.points[index], this.elasticity, this.radius * 2);
			this.points[index].addSpring(this.points[i], this.elasticity, this.radius * 2);
		}

		this.points[this.points.length - 1].addSpring(this.points[0], this.elasticity, this.radius / 2);

		this.draw = function() {
			if(this.particle.x + this.radius >= width) {
				var h = this.particle.getHeading();
				this.particle.x = width - this.radius;
				var lx = this.force.getX(),
					ly = this.force.getY();
					this.particle.setSpeed(this.particle.getSpeed() * 0.4);
				this.force = vector.create(-1 * lx, ly);
			}
			if(this.particle.x - this.radius <= 0) {
				var h = this.particle.getHeading();
				this.particle.x = 0 + this.radius;
				var lx = this.force.getX(),
					ly = this.force.getY();
					this.particle.setSpeed(this.particle.getSpeed() * 0.4);
				this.force = vector.create(-1 * lx, ly);
			}
			if(this.particle.y + this.radius >= height) {
				var h = this.particle.getHeading();
				this.particle.y = height - this.radius;
				var lx = this.force.getX(),
					ly = this.force.getY();
					this.particle.setSpeed(this.particle.getSpeed() * 0.4);
				this.force = vector.create(lx, -1 * ly);
			}
			if(this.particle.y - this.radius <= 0) {
				var h = this.particle.getHeading();
				this.particle.y = 0 + this.radius;
				var lx = this.force.getX(),
					ly = this.force.getY();
				this.particle.setSpeed(this.particle.getSpeed() * 0.4);
				this.force = vector.create(lx, -1 * ly);
			}

			for(var w = 0; w < blobs.length; w++) {
				if(blobs[w] != this) {
					this.particle.gravitateTo(blobs[w].particle);
				}
			}

			this.particle.gravitateTo(mouseParticle);

			//this.particle.accelerate(this.force.getX(), this.force.getY());
			this.particle.update();
			/*for(var i = 0; i < this.points.length; i++) {
				this.points[i].accelerate(this.force.getX(), this.force.getY());
			}*/
			var rval = Math.floor(255 - (this.particle.mass / 300 * 255));
			ctx.fillStyle = "rgba(" + rval + ", 0, 0, 1)";
			ctx.strokeStyle = "rgba(" + rval + ", 0, 0, 1)";
			for(var i = 0; i < this.points.length; i++) {
				this.points[i].update();
				ctx.beginPath();
				ctx.arc(this.points[i].x, this.points[i].y, this.pointRadius, 0, Math.PI * 2);
				ctx.fill();

					for(var k = 0; k < this.points[i].springs.length; k++) {
						ctx.moveTo(this.points[i].x, this.points[i].y);
						ctx.lineTo(this.points[i].springs[k].point.x, this.points[i].springs[k].point.y);
						ctx.stroke();
					}

				ctx.closePath();
			}

			/*ctx.beginPath();
			ctx.arc(this.particle.x, this.particle.y, this.radius, 0, Math.PI * 2);
			ctx.fillStyle = "red";
			ctx.arc(this.particle.x, this.particle.y, 20, 0, Math.PI * 2);
			ctx.fill();
			ctx.fillStyle = "rgba(0, 0, 0, 0.2)";
			ctx.closePath();*/
		};
	};

	for(var t = 0; t < 10; t++) {
		var m1 = (Math.random() < 0.5) ? Math.random() * -0.01 : Math.random() * 0.01,
	   	 	m2 = (Math.random() < 0.5) ? Math.random() * -0.01 : Math.random() * 0.01;
		var blob1 = new blob(Math.random() * width / 2 + width / 4, Math.random() * height / 2 + height / 4, vector.create(m1, m2));
		//var blob1 = new blob(Math.random() * width / 2 + width / 4, Math.random() * height / 2 + height / 4, vector.create(0, 0));
		blobs.push(blob1);
	}

	canvas.addEventListener("mousedown", function(event) {
		var chosen;
		for(var i = 0; i < orbits.length; i++) {
			if(utils.distanceTo(event.x, event.y, orbits[i].x, orbits[i].y) <= orbits[i].radius) {
				//alert("okay")
				chosen = orbits[i];
				location.href = 'Information/info.html';
			}
		}
	});

	canvas.addEventListener("mousemove", function(event) {
		mouseParticle.x = event.x;
		mouseParticle.y = event.y;
	});

	update();

	function update() {
		ctx.clearRect(0, 0, width, height);
		//ctx.fillStyle = "black";
		for(var t = 0; t < blobs.length; t++) {
			//ctx.fillStyle = utils.randomColor();
			blobs[t].draw();
		}

		/*ctx.fillStyle = "rgba(255, 255, 255, 0.9)";
		ctx.fillRect(0, 0, width, height);*/

		/*ctx.beginPath();
		ctx.fillStyle = "white";
		ctx.arc(middle.x, middle.y, 200, 0, Math.PI * 2);
		ctx.fill();
		ctx.closePath();*/

		/*ctx.beginPath();
		ctx.fillStyle = "orange";
		ctx.arc(middle.x, middle.y, 75, 0, Math.PI * 2);
		ctx.fill();
		ctx.closePath();*/

		ctx.font = "100px Times";
		ctx.fillStyle = "black";
		ctx.fillText("Westview", width / 2 - 200, height / 2 - 100);
		ctx.fillText("Software Developers", width / 2 - 430, height / 2);
		ctx.fillText("Association", width / 2 - 275, height / 2 + 100);

		ctx.fillStyle = "rgba(255, 255, 255, 0.3)";
		ctx.fillRect(0, 0, width, height);

		ctx.font = "15px Times";

		for(var v = 0; v < orbits.length; v++) {
			var pt = orbits[v];
				pt.update();
			ctx.beginPath();
			ctx.fillStyle = "black";
			ctx.arc(pt.x, pt.y, pt.radius, 0, Math.PI * 2);
			ctx.fill();
			ctx.closePath();
			ctx.fillStyle = "white";
			ctx.fillText(text[v], pt.x - text[v].length * 5, pt.y + 5);
		}

		requestAnimationFrame(update);
	}
}

setup();<commit_msg>index2<commit_after>function setup() {
	var canvas = document.createElement("canvas"),
		ctx = canvas.getContext("2d"),
		width = canvas.width = window.innerWidth,
		height = canvas.height = window.innerHeight;

	var mouseParticle = particle.create(0, 0, 0, 0);
		mouseParticle.mass = 1000;

	var middle = particle.create(width / 2, height / 2, 0, 0);
		middle.mass = 300;

	var orbits = [],
		text = ["ABOUT", "CONTACT", "PROJECTS", "CALANDER"];

	var about = particle.create(middle.x + middle.mass / 2, middle.y, 1, Math.PI / 2),
		contact = particle.create(middle.x - middle.mass / 2, middle.y, 1, -Math.PI / 2),
		projects = particle.create(middle.x, middle.y - middle.mass, 1, 0),
		newsletter = particle.create(middle.x, middle.y + middle.mass, 1, -Math.PI);

		orbits.push(about);
		orbits.push(contact);
		orbits.push(projects);
		orbits.push(newsletter);

	for(var f = 0; f < orbits.length; f++) {
		orbits[f].addGravitation(middle);
		orbits[f].mass = 20;
		orbits[f].radius = 50;
	}

	var blobs = [],
		totalPoints = [];

		document.body.appendChild(canvas);

		ctx.fillStyle = "rgba(0, 0, 0, 0.5)";
		ctx.strokeStyle = "rgba(0, 0, 0, 0.2)";

	var blob = function(x, y, vect) {
		this.points = [];
		this.pointRadius = 1;
		this.force = vect;
		this.radius = 30;
		var dir = (Math.random() < 0.5) ? Math.PI * Math.random() : -Math.PI * Math.random();
		this.particle = particle.create(x, y, 2, dir, 0.98);
		//this.particle.addGravitation(middle);
		this.particle.mass = 200 * Math.random() + 100;

		this.elasticity = 0.05;

		this.numPoints = 16;

		for(var i = 0; i < this.numPoints; i++) {
			var p1 = particle.create( this.particle.x + Math.cos(Math.PI * 2 / this.numPoints * i), this.particle.y + Math.sin(Math.PI * 2 / this.numPoints * i), 0, 0, 0.80);
			this.points.push(p1);
			totalPoints.push(p1);
		}

		for(var i = 0; i < this.points.length; i++) {
			this.points[i].addSpring(this.particle, this.elasticity, this.radius);
		}

		for(var i = 1; i < this.points.length; i++) {
			this.points[i].addSpring(this.points[i-1], this.elasticity, this.radius / 2 * Math.random());
			this.points[i-1].addSpring(this.points[i], this.elasticity, this.radius / 2 * Math.random());
		}

		for(var i = this.points.length - 1; i >= this.points.length / 2; i--) {
			var index = i - this.points.length / 2;
			this.points[i].addSpring(this.points[index], this.elasticity, this.radius * 2);
			this.points[index].addSpring(this.points[i], this.elasticity, this.radius * 2);
		}

		this.points[this.points.length - 1].addSpring(this.points[0], this.elasticity, this.radius / 2);

		this.draw = function() {
			if(this.particle.x + this.radius >= width) {
				var h = this.particle.getHeading();
				this.particle.x = width - this.radius;
				var lx = this.force.getX(),
					ly = this.force.getY();
					this.particle.setSpeed(this.particle.getSpeed() * 0.4);
				this.force = vector.create(-1 * lx, ly);
			}
			if(this.particle.x - this.radius <= 0) {
				var h = this.particle.getHeading();
				this.particle.x = 0 + this.radius;
				var lx = this.force.getX(),
					ly = this.force.getY();
					this.particle.setSpeed(this.particle.getSpeed() * 0.4);
				this.force = vector.create(-1 * lx, ly);
			}
			if(this.particle.y + this.radius >= height) {
				var h = this.particle.getHeading();
				this.particle.y = height - this.radius;
				var lx = this.force.getX(),
					ly = this.force.getY();
					this.particle.setSpeed(this.particle.getSpeed() * 0.4);
				this.force = vector.create(lx, -1 * ly);
			}
			if(this.particle.y - this.radius <= 0) {
				var h = this.particle.getHeading();
				this.particle.y = 0 + this.radius;
				var lx = this.force.getX(),
					ly = this.force.getY();
				this.particle.setSpeed(this.particle.getSpeed() * 0.4);
				this.force = vector.create(lx, -1 * ly);
			}

			for(var w = 0; w < blobs.length; w++) {
				if(blobs[w] != this) {
					this.particle.gravitateTo(blobs[w].particle);
				}
			}

			this.particle.gravitateTo(mouseParticle);

			//this.particle.accelerate(this.force.getX(), this.force.getY());
			this.particle.update();
			/*for(var i = 0; i < this.points.length; i++) {
				this.points[i].accelerate(this.force.getX(), this.force.getY());
			}*/
			var rval = Math.floor(255 - (this.particle.mass / 300 * 255));
			ctx.fillStyle = "rgba(" + rval + ", 0, 0, 1)";
			ctx.strokeStyle = "rgba(" + rval + ", 0, 0, 1)";
			for(var i = 0; i < this.points.length; i++) {
				this.points[i].update();
				ctx.beginPath();
				ctx.arc(this.points[i].x, this.points[i].y, this.pointRadius, 0, Math.PI * 2);
				ctx.fill();

					for(var k = 0; k < this.points[i].springs.length; k++) {
						ctx.moveTo(this.points[i].x, this.points[i].y);
						ctx.lineTo(this.points[i].springs[k].point.x, this.points[i].springs[k].point.y);
						ctx.stroke();
					}

				ctx.closePath();
			}

			/*ctx.beginPath();
			ctx.arc(this.particle.x, this.particle.y, this.radius, 0, Math.PI * 2);
			ctx.fillStyle = "red";
			ctx.arc(this.particle.x, this.particle.y, 20, 0, Math.PI * 2);
			ctx.fill();
			ctx.fillStyle = "rgba(0, 0, 0, 0.2)";
			ctx.closePath();*/
		};
	};

	for(var t = 0; t < 10; t++) {
		var m1 = (Math.random() < 0.5) ? Math.random() * -0.01 : Math.random() * 0.01,
	   	 	m2 = (Math.random() < 0.5) ? Math.random() * -0.01 : Math.random() * 0.01;
		var blob1 = new blob(Math.random() * width / 2 + width / 4, Math.random() * height / 2 + height / 4, vector.create(m1, m2));
		//var blob1 = new blob(Math.random() * width / 2 + width / 4, Math.random() * height / 2 + height / 4, vector.create(0, 0));
		blobs.push(blob1);
	}

	canvas.addEventListener("mousedown", function(event) {
		var chosen;
		for(var i = 0; i < orbits.length; i++) {
			if(utils.distanceTo(event.x, event.y, orbits[i].x, orbits[i].y) <= orbits[i].radius) {
				//alert("okay")
				chosen = orbits[i];
				location.href = 'https://wvsoda.github.io/Infomation/';
			}
		}
	});

	canvas.addEventListener("mousemove", function(event) {
		mouseParticle.x = event.x;
		mouseParticle.y = event.y;
	});

	update();

	function update() {
		ctx.clearRect(0, 0, width, height);
		//ctx.fillStyle = "black";
		for(var t = 0; t < blobs.length; t++) {
			//ctx.fillStyle = utils.randomColor();
			blobs[t].draw();
		}

		/*ctx.fillStyle = "rgba(255, 255, 255, 0.9)";
		ctx.fillRect(0, 0, width, height);*/

		/*ctx.beginPath();
		ctx.fillStyle = "white";
		ctx.arc(middle.x, middle.y, 200, 0, Math.PI * 2);
		ctx.fill();
		ctx.closePath();*/

		/*ctx.beginPath();
		ctx.fillStyle = "orange";
		ctx.arc(middle.x, middle.y, 75, 0, Math.PI * 2);
		ctx.fill();
		ctx.closePath();*/

		ctx.font = "100px Times";
		ctx.fillStyle = "black";
		ctx.fillText("Westview", width / 2 - 200, height / 2 - 100);
		ctx.fillText("Software Developers", width / 2 - 430, height / 2);
		ctx.fillText("Association", width / 2 - 275, height / 2 + 100);

		ctx.fillStyle = "rgba(255, 255, 255, 0.3)";
		ctx.fillRect(0, 0, width, height);

		ctx.font = "15px Times";

		for(var v = 0; v < orbits.length; v++) {
			var pt = orbits[v];
				pt.update();
			ctx.beginPath();
			ctx.fillStyle = "black";
			ctx.arc(pt.x, pt.y, pt.radius, 0, Math.PI * 2);
			ctx.fill();
			ctx.closePath();
			ctx.fillStyle = "white";
			ctx.fillText(text[v], pt.x - text[v].length * 5, pt.y + 5);
		}

		requestAnimationFrame(update);
	}
}

setup();<|endoftext|>


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

var lat,
    lon,
    city,
    firefoxTimeLimit;
    // geo_options = {
    //   maximumAge: 300000,
    //   timeout: 7000,
    //   enableHighAccuracy: true
    // };

// This timeout solves the error of Firefox not calling the callback function when the user denies access to navigator.geolocation

var firefoxTimeLimit=setTimeout(getLocationByApi, 5000);

getLocation();

$("#temp").click(function(){
  var t = $(".temp").html();

  if (localStorage["userDegrees"] === "F"){
     localStorage["userDegrees"]="C";
     $(".temp").html(Math.round((t-32)/1.8)); // conversion F to C
     $(".tempIcon").html(" ");
  } else{
    localStorage["userDegrees"]="F";
    $(".temp").html(Math.round(t*1.8+32)); // conversion C to F
    $(".tempIcon").html(" ");
  }
})

function getLocation(){
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position) {
      clearTimeout(firefoxTimeLimit);
      lat=position.coords.latitude;
      lon=position.coords.longitude;
      getWeather(lat,lon);
  //   },getLocationByApi,geo_options);
    },getLocationByApi);
  }else{
    getLocationByApi();
  }
}

function getLocationByApi(){
  clearTimeout(firefoxTimeLimit);
    //using ip-api.com (at least in Spain, returns city)
    $.get("http://ip-api.com/json", function (location){

    lat=location.lat;
    lon=location.lon;
    if (location.city !== undefined){
      city=location.city;
    }
    getWeather(lat, lon);

    },"jsonp"); //end $.get
}

function getWeather(lat, lon){
  //using openweathermap.org
  var url= "http://api.openweathermap.org/data/2.5/weather?lat="+lat+"&lon="+lon+"&units=metric&appid=23488743c00ea56f5e6b5c302fa3cdc7";
  $.get(url, function(weather){

     console.log(weather);

     var userDegrees = localStorage["userDegrees"] || "C";

     if (weather.name !== undefined){
       $(".city").html(weather.name);
     } else if (city !==undefined){
       $(".city").html(city);
     }else {
       $(".city").html("Latitude: "+lat+" Longitude: "+ lon);
     }

     var actualTemperature=Math.round(weather.main.temp);

     if (actualTemperature>25){
       var red=Math.round((actualTemperature-25)*5.7+50);
       if (red > 255) red=255;
        $("#temp").css("background", "rgba("+red+",0,0,0.5)");
        $("#container").css("background-image", "url('https://dl.dropboxusercontent.com/u/49268757/1024_hot.jpg')");
     }else if (actualTemperature<10){
       var blue=Math.round((40+actualTemperature)*2+50);
        $("#temp").css("background", "rgba(0,0,"+blue+",0.5)");
        $("#container").css("background-image", "url('https://dl.dropboxusercontent.com/u/49268757/1024_cold.jpg')");
     }else{
       var green=Math.round((actualTemperature-10)*13.333+50);
       console.log(green);
        $("#temp").css("background", "rgba(0,"+green+",0,0.5)");
        $("#container").css("background-image", 'url("https://dl.dropboxusercontent.com/u/49268757/1024_normal.jpg")');
     }

     if (userDegrees==="C"){
       $(".temp").html(actualTemperature);
       $(".tempIcon").html(" ");
     }else{
       $(".temp").html(Math.round(weather.main.temp*1.8+32));
       $(".tempIcon").html(" ");
     }

     if (weather.weather[0].icon !== undefined){
       $(".weatherIcon").html("");
     }

     $(".weather").html(weather.weather[0].description);
     $(".humidity").html(weather.main.humidity);
     if (weather.wind.speed !== undefined){
       $(".wind").html(weather.wind.speed);
     } else{
       $(".wind").html(weather.wind.speed+" Unknown");
     }
     $(".windDirection").html(windDirection(weather.wind.deg));

  }, "jsonp");
};

function windDirection(deg) {
    var rose = ['N', 'NNE', 'NE', 'ENE', 'E', 'ESE','SE', 'SSE', 'S', 'SSW','SW', 'WSW', 'W', 'WNW', 'NW', 'NNW'];
    if (deg !== undefined){
      var direction = Math.floor(deg/22.5);
      return rose[direction];
    }else return " ";
}

}); //end document

/*
current weather:

"http://api.openweathermap.org/data/2.5/weather?lat=40.9688&lon=-5.6639&units=metric"

returns:

{"coord":{"lon":-5.65,"lat":40.97},
 "weather":[{"id":800,
              "main":"Clear",
              "description":"Sky is Clear",
              "icon":"01n"}],
 "base":"stations",
 "main":{"temp":21.51,"pressure":1019,"humidity":68,"temp_min":19,"temp_max":22.78},
 "visibility":10000,
 "wind":{"speed":0.5},
 "clouds":{"all":0},
 "dt":1440535612,
 "sys":{"type":1,
        "id":5498,"message":0.0083,"country":"ES",
        "sunrise":1440481368,"sunset":1440529532},
        "id":3111108,"name":"Salamanca","cod":200}

*/

/*
// api ipinfo.io

  $.get("http://ipinfo.io", function(response) {
    //doesn't return city for my location in Spain, nor the correct lat, lon
  $('.uno').html("ip: "+response.ip +
                 "
city: "+ response.city +
                 "
loc: "+ response.loc+
                 "
Country: "+response.country+
                 "
Region: "+response.region);
  }, "jsonp");
*/
<commit_msg>Patch. When temp=0 openweather do not provide temp<commit_after>$(document).ready(function () {

var lat,
    lon,
    city,
    firefoxTimeLimit;
    // geo_options = {
    //   maximumAge: 300000,
    //   timeout: 7000,
    //   enableHighAccuracy: true
    // };

// This timeout solves the error of Firefox not calling the callback function when the user denies access to navigator.geolocation

var firefoxTimeLimit=setTimeout(getLocationByApi, 5000);

getLocation();

$("#temp").click(function(){
  var t = $(".temp").html();

  if (localStorage["userDegrees"] === "F"){
     localStorage["userDegrees"]="C";
     $(".temp").html(Math.round((t-32)/1.8)); // conversion F to C
     $(".tempIcon").html(" ");
  } else{
    localStorage["userDegrees"]="F";
    $(".temp").html(Math.round(t*1.8+32)); // conversion C to F
    $(".tempIcon").html(" ");
  }
})

function getLocation(){
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position) {
      clearTimeout(firefoxTimeLimit);
      lat=position.coords.latitude;
      lon=position.coords.longitude;
      getWeather(lat,lon);
  //   },getLocationByApi,geo_options);
    },getLocationByApi);
  }else{
    getLocationByApi();
  }
}

function getLocationByApi(){
  clearTimeout(firefoxTimeLimit);
    //using ip-api.com (at least in Spain, returns city)
    $.get("http://ip-api.com/json", function (location){

      lat=location.lat;
      lon=location.lon;
      if (location.city !== undefined){
        city=location.city;
      }
      getWeather(lat, lon);

    },"jsonp");
}

function getWeather(lat, lon){
  //using openweathermap.org
  var url= "http://api.openweathermap.org/data/2.5/weather?lat="+lat+"&lon="+lon+"&units=metric&appid=23488743c00ea56f5e6b5c302fa3cdc7";

  $.get(url, function(weather){

     console.log(weather);

     var userDegrees = localStorage["userDegrees"] || "C";

     if (weather.name !== undefined){
       $(".city").html(weather.name);
     } else if (city !==undefined){
       $(".city").html(city);
     }else {
       $(".city").html("Latitude: "+lat+" Longitude: "+ lon);
     }

     var actualTemperature=Math.round(weather.main.temp||0);
     if (actualTemperature>25){
       var red=Math.round((actualTemperature-25)*5.7+50);
       if (red > 255) red=255;
        $("#temp").css("background", "rgba("+red+",0,0,0.5)");
        $("#container").css("background-image", "url('https://dl.dropboxusercontent.com/u/49268757/1024_hot.jpg')");
     }else if (actualTemperature<10){
       var blue=Math.round((40+actualTemperature)*2+50);
        $("#temp").css("background", "rgba(0,0,"+blue+",0.5)");
        $("#container").css("background-image", "url('https://dl.dropboxusercontent.com/u/49268757/1024_cold.jpg')");
     }else{
       var green=Math.round((actualTemperature-10)*13.333+50);
      //  console.log(green);
        $("#temp").css("background", "rgba(0,"+green+",0,0.5)");
        $("#container").css("background-image", 'url("https://dl.dropboxusercontent.com/u/49268757/1024_normal.jpg")');
     }

     if (userDegrees==="C"){
       $(".temp").text(actualTemperature);
       $(".tempIcon").html(" ");
     }else{
       $(".temp").text(Math.round((weather.main.temp||0)*1.8+32));
       $(".tempIcon").html(" ");
     }

     if (weather.weather[0].icon !== undefined){
       $(".weatherIcon").html("");
     }

     $(".weather").html(weather.weather[0].description);
     $(".humidity").html(weather.main.humidity);
     if (weather.wind.speed !== undefined){
       $(".wind").html(weather.wind.speed);
     } else{
       $(".wind").html(weather.wind.speed+" Unknown");
     }
     $(".windDirection").html(windDirection(weather.wind.deg));

  }, "jsonp");
};

function windDirection(deg) {
    var rose = ['N', 'NNE', 'NE', 'ENE', 'E', 'ESE','SE', 'SSE', 'S', 'SSW','SW', 'WSW', 'W', 'WNW', 'NW', 'NNW'];
    if (deg !== undefined){
      var direction = Math.floor(deg/22.5);
      return rose[direction];
    }else return " ";
}

}); //end document

/*
current weather:

"http://api.openweathermap.org/data/2.5/weather?lat=40.9688&lon=-5.6639&units=metric"

returns:

{"coord":{"lon":-5.65,"lat":40.97},
 "weather":[{"id":800,
              "main":"Clear",
              "description":"Sky is Clear",
              "icon":"01n"}],
 "base":"stations",
 "main":{"temp":21.51,"pressure":1019,"humidity":68,"temp_min":19,"temp_max":22.78},
 "visibility":10000,
 "wind":{"speed":0.5},
 "clouds":{"all":0},
 "dt":1440535612,
 "sys":{"type":1,
        "id":5498,"message":0.0083,"country":"ES",
        "sunrise":1440481368,"sunset":1440529532},
        "id":3111108,"name":"Salamanca","cod":200}

*/

/*
// api ipinfo.io

  $.get("http://ipinfo.io", function(response) {
    //doesn't return city for my location in Spain, nor the correct lat, lon
  $('.uno').html("ip: "+response.ip +
                 "
city: "+ response.city +
                 "
loc: "+ response.loc+
                 "
Country: "+response.country+
                 "
Region: "+response.region);
  }, "jsonp");
*/
<|endoftext|>


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

__axiomRequire__('shell/chrome/background');
<commit_msg>Create a fake window to load polymer.<commit_after>// Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

chrome.app.runtime.onLaunched.addListener(function() {
  chrome.app.window.create('html/main_window.html', {
    'bounds': {
      'width': 2,
      'height': 2
    }
  });
});
<|endoftext|>


<commit_before>/* exported items */

// item definitions - tr specific
var items = {
	engineer: {
		avManaTurret: 71564,
		flakArmor: [
			8121,
			8122,
			8123,
			8124,
			8125
		],
		nanoArmorKit: [
			125,
			1256,
			1257,
			1258,
			1259,
			6011
		]
	},
	heavyAssault: {
		flakArmor: [
			7693,
			7694,
			7695,
			7696,
			7697
		]
	},
	infiltrator: {
		flakArmor: [
			8116,
			8117,
			8118,
			8119,
			8120
		]
	},
	lightAssault: {
		flakArmor: [
			7659,
			7660,
			7661,
			7662,
			7663
		]
	},
	medic: {
		medicalApplicator: [
			94,
			1608,
			1609,
			1610,
			1611,
			1612
		],
		flakArmor: [
			8126,
			8127,
			8128,
			8129,
			8130
		]
	},
	consumable: {
		claymore: 429,
		c4: 432,
		tankMine: 650,
		reviveGrenade: 884,
		concussionGrenade: 1096,
		flashGrenade: 7755,
		empGrenade: 50051
	},
	lightning: {
		skyguard: 3108,
		fireSuppression: [
			3113,
			3114,
			3115,
			3116
		],
		mineGuard: [
			3139,
			3140,
			3141,
			3142
		]
	},
	prowler: {
		walker: 4003,
		p2120he: 4009,
		ranger: 4010,
		halberd: 4015,
		vulcan: 4029,
		anchoredMode: [
			4030,
			4031,
			4032,
			4033
		],
		mineGuard: [
			4050,
			4051,
			4052,
			4053
		]
	},
	sunderer: {
		ams: 2996,
		frontBulldog: 2834,
		rearBulldog: 2837,
		frontFury: 2874,
		rearFury: 2877,
		frontWalker: 3082,
		rearWalker: 3085,
		frontRanger: 3088,
		rearRanger: 3091,
		ammoDispenser: [
			2830,
			2961,
			2962,
			2963
		],
		mineGuard: [
			2845,
			3017,
			3018,
			3019
		],
		proximityRepair: [
			2964,
			2965,
			2966,
			2967,
			2968,
			2969
		]
	},
	weapon: {
		trac5s: {
			id: 7192,
			grenadeLauncher: 9322,
			smokeLauncher: 9329,
			hsnv: 9323,
			suppressor: 9330
		},
		m77: 25000,
		tsar: 25001,
		ksr: 25002,
		sr7: 25003,
		rams: 25004,
		smg46: 28000,
		pdw16: 28001,
		t2: 34002,
		skep: 34003
	}
};
<commit_msg>Added decimator item definition.<commit_after>/* exported items */

// item definitions - tr specific
var items = {
	engineer: {
		avManaTurret: 71564,
		flakArmor: [
			8121,
			8122,
			8123,
			8124,
			8125
		],
		nanoArmorKit: [
			125,
			1256,
			1257,
			1258,
			1259,
			6011
		]
	},
	heavyAssault: {
		flakArmor: [
			7693,
			7694,
			7695,
			7696,
			7697
		]
	},
	infiltrator: {
		flakArmor: [
			8116,
			8117,
			8118,
			8119,
			8120
		]
	},
	lightAssault: {
		flakArmor: [
			7659,
			7660,
			7661,
			7662,
			7663
		]
	},
	medic: {
		medicalApplicator: [
			94,
			1608,
			1609,
			1610,
			1611,
			1612
		],
		flakArmor: [
			8126,
			8127,
			8128,
			8129,
			8130
		]
	},
	consumable: {
		claymore: 429,
		c4: 432,
		tankMine: 650,
		reviveGrenade: 884,
		concussionGrenade: 1096,
		flashGrenade: 7755,
		empGrenade: 50051
	},
	lightning: {
		skyguard: 3108,
		fireSuppression: [
			3113,
			3114,
			3115,
			3116
		],
		mineGuard: [
			3139,
			3140,
			3141,
			3142
		]
	},
	prowler: {
		walker: 4003,
		p2120he: 4009,
		ranger: 4010,
		halberd: 4015,
		vulcan: 4029,
		anchoredMode: [
			4030,
			4031,
			4032,
			4033
		],
		mineGuard: [
			4050,
			4051,
			4052,
			4053
		]
	},
	sunderer: {
		ams: 2996,
		frontBulldog: 2834,
		rearBulldog: 2837,
		frontFury: 2874,
		rearFury: 2877,
		frontWalker: 3082,
		rearWalker: 3085,
		frontRanger: 3088,
		rearRanger: 3091,
		ammoDispenser: [
			2830,
			2961,
			2962,
			2963
		],
		mineGuard: [
			2845,
			3017,
			3018,
			3019
		],
		proximityRepair: [
			2964,
			2965,
			2966,
			2967,
			2968,
			2969
		]
	},
	weapon: {
		trac5s: {
			id: 7192,
			grenadeLauncher: 9322,
			smokeLauncher: 9329,
			hsnv: 9323,
			suppressor: 9330
		},
		m77: 25000,
		tsar: 25001,
		ksr: 25002,
		sr7: 25003,
		rams: 25004,
		smg46: 28000,
		pdw16: 28001,
		t2: 34002,
		decimator: 50560,
		skep: 34003
	}
};
<|endoftext|>


<commit_before>import React, { Component } from 'react';
import Relay from 'react-relay';
import XRegExp from 'xregexp';
import RaisedButton from 'material-ui/RaisedButton';
import TextField from 'material-ui/TextField';
import { Card, CardActions, CardHeader, CardText } from 'material-ui/Card';
import styled from 'styled-components';
import {
  FormattedMessage,
  defineMessages,
  injectIntl,
  intlShape,
} from 'react-intl';
import config from 'config'; // eslint-disable-line require-path-exists/exists
import PageTitle from '../PageTitle';
import CreateTeamMutation from '../../relay/mutations/CreateTeamMutation';
import Message from '../Message';
import CheckContext from '../../CheckContext';
import {
  ContentColumn,
  caption,
  subheading2,
  checkBlue,
  black38,
} from '../../styles/js/shared';

const TeamUrlRow = styled.div`
  align-items: flex-end;
  display: flex;
  font-size: 12px;
  margin-top: 24px;
  label {
    font: ${caption};
    color: ${checkBlue};
  }
`;

const TeamUrlColumn = styled.div`
  display: flex;
  flex-direction: column;
  padding-bottom: 9px;
`;

const TeamUrlDomain = styled.span`
  font: ${subheading2};
  color: ${black38};
`;

const messages = defineMessages({
  slugChecking: {
    id: 'createTeam.slugChecking',
    defaultMessage: 'Checking availability...',
  },
  slugAvailable: {
    id: 'createTeam.slugAvailable',
    defaultMessage: 'Available!',
  },
  slugUnavailable: {
    id: 'createTeam.slugUnavailable',
    defaultMessage: 'That URL is unavailable.',
  },
  createTeamError: {
    id: 'createTeam.createTeamError',
    defaultMessage: 'Sorry, could not create the team',
  },
  title: {
    id: 'createTeam.title',
    defaultMessage: 'Create a Team',
  },
  teamNameHint: {
    id: 'createTeam.teamNameHint',
    defaultMessage: 'Team Name',
  },
  teamSlugHint: {
    id: 'createTeam.teamSlugHint',
    defaultMessage: 'team-slug',
  },
});

class CreateTeam extends Component {
  constructor(props) {
    super(props);
    this.state = {
      displayNameLabelClass: this.displayNameLabelClass(),
      slugClass: this.slugClass(),
      slugLabelClass: this.slugLabelClass(),
      slugMessage: '',
      buttonIsDisabled: true,
      displayName: '',
      slugName: '',
    };
  }

  componentDidMount() {
    this.teamNameInput.focus();
  }

  getContext() {
    return new CheckContext(this);
  }

  displayNameLabelClass(suffix) {
    const defaultClass = 'create-team__team-display-name-label';
    return suffix
      ? [defaultClass, defaultClass + suffix].join(' ')
      : defaultClass;
  }

  slugClass(suffix) {
    const defaultClass = 'create-team__team-slug';
    return suffix
      ? [defaultClass, defaultClass + suffix].join(' ')
      : defaultClass;
  }

  slugLabelClass(suffix) {
    const defaultClass = 'create-team__team-slug-label';
    return suffix
      ? [defaultClass, defaultClass + suffix].join(' ')
      : defaultClass;
  }

  handleDisplayNameChange(e) {
    const isTextEntered = e.target.value && e.target.value.length > 0;
    const newClass = isTextEntered
      ? this.displayNameLabelClass('--text-entered')
      : this.displayNameLabelClass();
    this.setState({
      displayNameLabelClass: newClass,
      displayName: e.target.value,
    });
  }

  handleDisplayNameBlur(e) {
    function slugify(text) {
      const regex = XRegExp('[^\\p{L}\\p{N}]+', 'g');
      return XRegExp.replace(text.toString().toLowerCase().trim(), regex, '-');
    }

    const slugSuggestion = slugify(e.target.value);

    if (!this.state.slugName && slugSuggestion.length) {
      this.setState({ slugName: slugSuggestion });
    }
  }

  handleSlugChange(e) {
    const slug = e.target.value;

    this.setState({
      slugName: slug,
    });
  }

  handleSubmit(e) {
    e.preventDefault();

    const context = this.getContext();

    const onFailure = (transaction) => {
      const error = transaction.getError();
      let message = this.props.intl.formatMessage(messages.createTeamError);
      try {
        const json = JSON.parse(error.source);
        if (json.error) {
          message = json.error;
        }
      } catch (e) {
        // Do nothing.
      }
      this.setState({ message });
    };

    const onSuccess = (response) => {
      this.setState({ message: null });
      const team = response.createTeam.team;
      const teams = JSON.parse(context.currentUser.teams);
      teams[team.slug] = { status: 'member' };
      context.currentUser.teams = JSON.stringify(teams);

      const path = `/${team.slug}`;
      context.history.push(path);
    };

    Relay.Store.commitUpdate(
      new CreateTeamMutation({
        name: this.state.displayName,
        slug: this.state.slugName,
        description: '',
        user: context.currentUser,
      }),
      { onSuccess, onFailure },
    );
  }

  render() {
    return (
      <PageTitle
        prefix={this.props.intl.formatMessage(messages.title)}
        skipTeam
      >

          <ContentColumn narrow>
            <Message message={this.state.message} />
            <Card>
              <CardHeader
                titleStyle={{ fontSize: '20px', lineHeight: '32px' }}
                title={
                  <FormattedMessage
                    id="createTeam.mainHeading"
                    defaultMessage="Create a Team"
                  />
                }
                subtitle={
                  <FormattedMessage
                    id="createTeam.blurb"
                    defaultMessage="Create a team for your organization, or just for yourself:"
                  />
                }
              />
              <form className="create-team__form">
                <CardText>

                    <TextField
                      value={this.state.displayName}
                      type="text"
                      name="teamDisplayName"
                      id="team-name-container"
                      className="create-team__team-display-name-input"
                      onChange={this.handleDisplayNameChange.bind(this)}
                      onBlur={this.handleDisplayNameBlur.bind(this)}
                      autoComplete="off"
                      ref={input => (this.teamNameInput = input)}
                      floatingLabelText={
                        <FormattedMessage
                          id="createTeam.displayName"
                          defaultMessage="Team Name"
                        />
                      }
                      fullWidth
                    />

                  <TeamUrlRow>
                    <TeamUrlColumn>

                        <FormattedMessage
                          id="createTeam.url"
                          defaultMessage="Team URL"
                        />

                      <TeamUrlDomain>
                        {config.selfHost}/
                      </TeamUrlDomain>
                    </TeamUrlColumn>
                    <TextField
                      value={this.state.slugName}
                      type="text"
                      name="teamSlug"
                      id="team-slug-container"
                      className="create-team__team-slug-input"
                      onChange={this.handleSlugChange.bind(this)}
                      hintText={this.props.intl.formatMessage(
                        messages.teamSlugHint,
                      )}
                      autoComplete="off"
                      fullWidth
                    />
                  </TeamUrlRow>
                </CardText>
                <CardActions>
                  <RaisedButton
                    type="submit"
                    className="create-team__submit-button"
                    label={
                      <FormattedMessage
                        id="createTeam.submitButton"
                        defaultMessage="Create"
                      />
                    }
                    primary
                    onClick={this.handleSubmit.bind(this)}
                  />
                </CardActions>
              </form>
            </Card>
          </ContentColumn>

      </PageTitle>
    );
  }
}

CreateTeam.propTypes = {
  intl: intlShape.isRequired,
};

CreateTeam.contextTypes = {
  store: React.PropTypes.object,
};

export default injectIntl(CreateTeam);
<commit_msg>Fix test #4996<commit_after>import React, { Component } from 'react';
import Relay from 'react-relay';
import XRegExp from 'xregexp';
import RaisedButton from 'material-ui/RaisedButton';
import TextField from 'material-ui/TextField';
import { Card, CardActions, CardHeader, CardText } from 'material-ui/Card';
import styled from 'styled-components';
import {
  FormattedMessage,
  defineMessages,
  injectIntl,
  intlShape,
} from 'react-intl';
import config from 'config'; // eslint-disable-line require-path-exists/exists
import PageTitle from '../PageTitle';
import CreateTeamMutation from '../../relay/mutations/CreateTeamMutation';
import Message from '../Message';
import CheckContext from '../../CheckContext';
import {
  ContentColumn,
  caption,
  subheading2,
  checkBlue,
  black38,
} from '../../styles/js/shared';

const TeamUrlRow = styled.div`
  align-items: flex-end;
  display: flex;
  font-size: 12px;
  margin-top: 24px;
  label {
    font: ${caption};
    color: ${checkBlue};
  }
`;

const TeamUrlColumn = styled.div`
  display: flex;
  flex-direction: column;
  padding-bottom: 9px;
`;

const TeamUrlDomain = styled.span`
  font: ${subheading2};
  color: ${black38};
`;

const messages = defineMessages({
  slugChecking: {
    id: 'createTeam.slugChecking',
    defaultMessage: 'Checking availability...',
  },
  slugAvailable: {
    id: 'createTeam.slugAvailable',
    defaultMessage: 'Available!',
  },
  slugUnavailable: {
    id: 'createTeam.slugUnavailable',
    defaultMessage: 'That URL is unavailable.',
  },
  createTeamError: {
    id: 'createTeam.createTeamError',
    defaultMessage: 'Sorry, could not create the team',
  },
  title: {
    id: 'createTeam.title',
    defaultMessage: 'Create a Team',
  },
  teamNameHint: {
    id: 'createTeam.teamNameHint',
    defaultMessage: 'Team Name',
  },
  teamSlugHint: {
    id: 'createTeam.teamSlugHint',
    defaultMessage: 'team-slug',
  },
});

class CreateTeam extends Component {
  constructor(props) {
    super(props);
    this.state = {
      displayNameLabelClass: this.displayNameLabelClass(),
      slugClass: this.slugClass(),
      slugLabelClass: this.slugLabelClass(),
      slugMessage: '',
      buttonIsDisabled: true,
      displayName: '',
      slugName: '',
    };
  }

  componentDidMount() {
    this.teamNameInput.focus();
  }

  getContext() {
    return new CheckContext(this).getContextStore();
  }

  displayNameLabelClass(suffix) {
    const defaultClass = 'create-team__team-display-name-label';
    return suffix
      ? [defaultClass, defaultClass + suffix].join(' ')
      : defaultClass;
  }

  slugClass(suffix) {
    const defaultClass = 'create-team__team-slug';
    return suffix
      ? [defaultClass, defaultClass + suffix].join(' ')
      : defaultClass;
  }

  slugLabelClass(suffix) {
    const defaultClass = 'create-team__team-slug-label';
    return suffix
      ? [defaultClass, defaultClass + suffix].join(' ')
      : defaultClass;
  }

  handleDisplayNameChange(e) {
    const isTextEntered = e.target.value && e.target.value.length > 0;
    const newClass = isTextEntered
      ? this.displayNameLabelClass('--text-entered')
      : this.displayNameLabelClass();
    this.setState({
      displayNameLabelClass: newClass,
      displayName: e.target.value,
    });
  }

  handleDisplayNameBlur(e) {
    function slugify(text) {
      const regex = XRegExp('[^\\p{L}\\p{N}]+', 'g');
      return XRegExp.replace(text.toString().toLowerCase().trim(), regex, '-');
    }

    const slugSuggestion = slugify(e.target.value);

    if (!this.state.slugName && slugSuggestion.length) {
      this.setState({ slugName: slugSuggestion });
    }
  }

  handleSlugChange(e) {
    const slug = e.target.value;

    this.setState({
      slugName: slug,
    });
  }

  handleSubmit(e) {
    e.preventDefault();

    const context = this.getContext();

    const onFailure = (transaction) => {
      const error = transaction.getError();
      let message = this.props.intl.formatMessage(messages.createTeamError);
      try {
        const json = JSON.parse(error.source);
        if (json.error) {
          message = json.error;
        }
      } catch (e) {
        // Do nothing.
      }
      this.setState({ message });
    };

    const onSuccess = (response) => {
      this.setState({ message: null });
      const team = response.createTeam.team;
      const teams = JSON.parse(context.currentUser.teams);
      teams[team.slug] = { status: 'member' };
      context.currentUser.teams = JSON.stringify(teams);

      const path = `/${team.slug}`;
      context.history.push(path);
    };

    Relay.Store.commitUpdate(
      new CreateTeamMutation({
        name: this.state.displayName,
        slug: this.state.slugName,
        description: '',
        user: context.currentUser,
      }),
      { onSuccess, onFailure },
    );
  }

  render() {
    return (
      <PageTitle
        prefix={this.props.intl.formatMessage(messages.title)}
        skipTeam
      >

          <ContentColumn narrow>
            <Message message={this.state.message} />
            <Card>
              <CardHeader
                titleStyle={{ fontSize: '20px', lineHeight: '32px' }}
                title={
                  <FormattedMessage
                    id="createTeam.mainHeading"
                    defaultMessage="Create a Team"
                  />
                }
                subtitle={
                  <FormattedMessage
                    id="createTeam.blurb"
                    defaultMessage="Create a team for your organization, or just for yourself:"
                  />
                }
              />
              <form className="create-team__form">
                <CardText>

                    <TextField
                      value={this.state.displayName}
                      type="text"
                      name="teamDisplayName"
                      id="team-name-container"
                      className="create-team__team-display-name-input"
                      onChange={this.handleDisplayNameChange.bind(this)}
                      onBlur={this.handleDisplayNameBlur.bind(this)}
                      autoComplete="off"
                      ref={input => (this.teamNameInput = input)}
                      floatingLabelText={
                        <FormattedMessage
                          id="createTeam.displayName"
                          defaultMessage="Team Name"
                        />
                      }
                      fullWidth
                    />

                  <TeamUrlRow>
                    <TeamUrlColumn>

                        <FormattedMessage
                          id="createTeam.url"
                          defaultMessage="Team URL"
                        />

                      <TeamUrlDomain>
                        {config.selfHost}/
                      </TeamUrlDomain>
                    </TeamUrlColumn>
                    <TextField
                      value={this.state.slugName}
                      type="text"
                      name="teamSlug"
                      id="team-slug-container"
                      className="create-team__team-slug-input"
                      onChange={this.handleSlugChange.bind(this)}
                      hintText={this.props.intl.formatMessage(
                        messages.teamSlugHint,
                      )}
                      autoComplete="off"
                      fullWidth
                    />
                  </TeamUrlRow>
                </CardText>
                <CardActions>
                  <RaisedButton
                    type="submit"
                    className="create-team__submit-button"
                    label={
                      <FormattedMessage
                        id="createTeam.submitButton"
                        defaultMessage="Create"
                      />
                    }
                    primary
                    onClick={this.handleSubmit.bind(this)}
                  />
                </CardActions>
              </form>
            </Card>
          </ContentColumn>

      </PageTitle>
    );
  }
}

CreateTeam.propTypes = {
  intl: intlShape.isRequired,
};

CreateTeam.contextTypes = {
  store: React.PropTypes.object,
};

export default injectIntl(CreateTeam);
<|endoftext|>


<commit_before>
  var levelData = { //the layout for the level. the 1: and 2: are the levels and the number in the brackets corrispond with the alien 1 and 2. It is the orientation of each level.
     1:  [[0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,3,3,0,0,0,0],
          [0,0,0,0,0,2,2,0,0,0,0],
          [0,0,0,0,0,1,1,0,0,0,0]],
     2:  [[0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,2,2,2,2,2,2,2,2,0],
          [0,0,2,2,2,2,2,2,2,2,0],
          [0,0,1,1,1,1,1,1,1,1,0],
          [0,0,1,1,1,1,1,1,1,1,0],
          [0,0,1,1,1,1,1,1,1,1,0],
          [0,0,1,1,1,1,1,1,1,1,0]] };

  var spriteData = {//the sy/sx stands for where to find the aliens in the source file. i.e the png file. and the frames are how many there is of the alien 1 or 2 in the png file.
      // the writing in black is the class for the sprite, the text in " '' " is the name for each sprite.
    'alien1': { sx: 0,  sy: 0,  w: 37, h: 19, cls: Alien, frames: 2 },
    'alien2': { sx: 0,  sy: 20, w: 37, h: 19, cls: Alien, frames: 2 },
      'alien3': { sx: 0,  sy: 100, w: 37, h: 18, cls: Alien, frames: 2 },

    'player': { sx: 0,  sy: 39, w: 26, h: 17, cls: Player },
    'missile': { sx: 0,  sy: 86, w: 37,  h: 14, cls: Missile },

  }

  function startGame() {//starting the game.
    var screen = new GameScreen("Cake Invaders","press space to start",//the title and sub text on the start of the game.
                                 function() {
                                     Game.loadBoard(new GameBoard(1));
                                 });
    Game.loadBoard(screen);
    Game.loop();
  }

  function endGame() {//the writing for if you lose the game
    var screen = new GameScreen("Game Over","(press space to restart)",//the text that appears for when you lose.
                                 function() {
                                     Game.loadBoard(new GameBoard(1));
                                 });
    Game.loadBoard(screen);
  }

  function winGame() {//the writing for if you win the game
    var screen = new GameScreen("You Win!!","(press space to restart)",//text that appears when you have won the game.
                                 function() {
                                     Game.loadBoard(new GameBoard(1));
                                 });
    Game.loadBoard(screen);
  }

  $(function() {//it imports the audio for when you fire or something dies.
    GameAudio.load({ 'fire' : 'media/laser.ogg', 'die' : 'media/explosion.ogg' },//.ogg is the audio file used to the specific 'fire' or 'die' reasons.
                   function() {
                       Game.initialize("#gameboard", levelData, spriteData,
                                      { "start": startGame,
                                        "die"  : endGame,
                                        "win"  : winGame });
                   });
   });

<commit_msg>Added another level to the game<commit_after>
  var levelData = { //the layout for the level. the 1: and 2: are the levels and the number in the brackets corrispond with the alien 1 and 2. It is the orientation of each level.
     1:  [[0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,3,3,0,0,0,0],
          [0,0,0,0,0,2,2,0,0,0,0],
          [0,0,0,0,0,1,1,0,0,0,0]],
     2:  [[0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,2,2,2,2,2,2,2,2,0],
          [0,0,2,2,2,2,2,2,2,2,0],
          [0,0,1,1,1,1,1,1,1,1,0],
          [0,0,1,1,1,1,1,1,1,1,0],
          [0,0,1,1,1,1,1,1,1,1,0],
          [0,0,0,0,0,0,0,0,0,0,0]],
     3:  [[0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,3,3,3,3,3,3,3,3,0],
          [0,0,2,2,2,2,2,2,2,2,0],
          [0,0,2,2,2,2,2,2,2,2,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,1,1,1,1,1,1,1,1,0],
          [0,0,1,1,1,1,1,1,1,1,0]] };

  var spriteData = {//the sy/sx stands for where to find the aliens in the source file. i.e the png file. and the frames are how many there is of the alien 1 or 2 in the png file.
      // the writing in black is the class for the sprite, the text in " '' " is the name for each sprite.
    'alien1': { sx: 0,  sy: 0,  w: 37, h: 19, cls: Alien, frames: 2 },
    'alien2': { sx: 0,  sy: 20, w: 37, h: 19, cls: Alien, frames: 2 },
      'alien3': { sx: 0,  sy: 100, w: 37, h: 18, cls: Alien, frames: 2 },

    'player': { sx: 0,  sy: 39, w: 26, h: 17, cls: Player },
    'missile': { sx: 0,  sy: 86, w: 37,  h: 14, cls: Missile },

  }

  function startGame() {//starting the game.
    var screen = new GameScreen("Cake Invaders","press space to start",//the title and sub text on the start of the game.
                                 function() {
                                     Game.loadBoard(new GameBoard(1));
                                 });
    Game.loadBoard(screen);
    Game.loop();
  }

  function endGame() {//the writing for if you lose the game
    var screen = new GameScreen("Game Over","(press space to restart)",//the text that appears for when you lose.
                                 function() {
                                     Game.loadBoard(new GameBoard(1));
                                 });
    Game.loadBoard(screen);
  }

  function winGame() {//the writing for if you win the game
    var screen = new GameScreen("You Win!!","(press space to restart)",//text that appears when you have won the game.
                                 function() {
                                     Game.loadBoard(new GameBoard(1));
                                 });
    Game.loadBoard(screen);
  }

  $(function() {//it imports the audio for when you fire or something dies.
    GameAudio.load({ 'fire' : 'media/laser.ogg', 'die' : 'media/explosion.ogg' },//.ogg is the audio file used to the specific 'fire' or 'die' reasons.
                   function() {
                       Game.initialize("#gameboard", levelData, spriteData,
                                      { "start": startGame,
                                        "die"  : endGame,
                                        "win"  : winGame });
                   });
   });

<|endoftext|>


<commit_before>'use strict';
const Base = require('yeoman-generator').Base;
const patchPackageJSON = require('../../utils').patchPackageJSON;
const path = require('path');
const glob = require('glob').sync;
const extend = require('lodash').extend;
const Separator = require('inquirer').Separator;

const registry = require('../../knownPhoveaPlugins.json');
const knownPlugins = [].concat(registry.plugins,  null, registry.splugins);
const knownPluginNames = [].concat(
  registry.plugins.map((d) => d.name),
  new Separator(),
  registry.splugins.map((d) => d.name));

function byName(name) {
  return knownPlugins[knownPluginNames.indexOf(name)];
}

class Generator extends Base {

  constructor(args, options) {
    super(args, options);

    this.option('venv', {
      alias: 'v'
    });
  }

  initializing() {
    this.props = this.fs.readJSON(this.destinationPath('.yo-rc-ueber.json'), { modules: [] });
  }

  prompting() {
    const isInstalled = glob('*/package.json', { cwd: this.destinationPath() }).map(path.dirname);
    return this.prompt({
      type: 'list',
      name: 'virtualEnvironment',
      message: 'Virtual Environment',
      store: true,
      choices: ['none', 'vagrant', 'conda', 'virtualenv'],
      default: 'vagrant',
      when: !this.options.venv
    },{
      type: 'checkbox',
      name: 'modules',
      message: 'Additional Plugins',
      choices: knownPluginNames.filter((d) => isInstalled.indexOf(d) < 0),
      default: this.props.modules,
    }).then((props) => {
      this.props.modules = props.modules;
      this.venv = props.virtualEnvironment || this.options.venv;
    });
  }

  default() {
    if (this.venv !== 'none') {
      this.composeWith(`phovea:ueber-${this.venv}`, {
        options: this.options
      }, {
        local: require.resolve(`../ueber-${this.venv}`)
      });
    }
  }

  _generatePackage(additionalPlugins) {
    const files = glob('*/phovea.js', { // web plugin
      cwd: this.destinationPath()
    });
    const plugins = files.map(path.dirname);

    // generate dependencies
    var dependencies = {};
    var devDependencies = {};
    var scripts = {};
    plugins.forEach((p) => {
      const pkg = this.fs.readJSON(this.destinationPath(p + '/package.json'));
      extend(dependencies, pkg.dependencies);
      extend(devDependencies, pkg.devDependencies);

      // no pre post test tasks
      Object.keys(pkg.scripts).filter((s) => !/^(pre|post).*/g.test(s)).forEach((s) => {
        // generate scoped tasks
        scripts[`${s}:${p}`] = `cd ${p} && npm run ${s}`;
      });
    });

    //add additional to install plugins
    additionalPlugins.forEach((p) => {
      const known = byName(p);
      if (known && known.dependencies) {
       extend(dependencies, known.dependencies);
      }
    });

    // remove all plugins that are locally installed
    plugins.forEach((p) => {
      const known = byName(p);
      if (known && known.dependencies) {
        Object.keys(known.dependencies).forEach((pi) => {
          delete dependencies[pi];
        });
      } else {
        delete dependencies[p];
      }
    });

    return { plugins, dependencies, devDependencies, scripts };
  }

  _generateServerDependencies(additionalPlugins) {
    const files = glob('*/requirements.txt', { // server plugin
      cwd: this.destinationPath()
    });
    const plugins = files.map(path.dirname);

    var requirements = new Set();
    var devRequirements = new Set();
    var debianPackages = new Set();
    var redhatPackages = new Set();

    plugins.forEach((p) => {
      // generate dependencies
      const addAll = (name, set) => {
        const r = this.fs.read(this.destinationPath(`${p}/${name}`));
        r.split('\n').forEach((ri) => {
          set.add(ri.trim());
        });
      };
      addAll('requirements.txt', requirements);
      addAll('requirements_dev.txt', devRequirements);
      addAll('debian_packages.txt', debianPackages);
      addAll('redhat_packages.txt', redhatPackages);
    });

    //add additional to install plugins
    additionalPlugins.forEach((p) => {
      const known = byName(p);
      if (known && known.requirements) {
        Object.keys(known.requirements).forEach((r) => requirements.add(r+known.requirements[ri]));
      }
      if (known && known.debianPackages) {
        Object.keys(known.debianPackages).forEach((r) => debianPackages.add(r+known.debianPackages[ri]));
      }
      if (known && known.debianPackages) {
        Object.keys(known.debianPackages).forEach((r) => redhatPackages.add(r+known.debianPackages[ri]));
      }
    });

    // remove all plugins that are locally installed
    plugins.forEach((p) => {
      const known = byName(p);
      if (known && known.requirements) {
        Object.keys(known.requirements).forEach((pi) => {
          requirements.delete(pi + known.requirements[pi]);
        });
      } else {
        requirements.delete(p);
      }
    });

    return {
      requirements: [...requirements.values()],
      devRequirements: [...devRequirements.values()],
      debianPackages: [...debianPackages.values()],
      redhatPackages: [...redhatPackages.values()]
    };
  }

  writing() {
    this.fs.extendJSON(this.destinationPath('.yo-rc-ueber.json'), { modules: this.props.modules });

    const config = {};
    const {plugins, dependencies, devDependencies, scripts} = this._generatePackage(this.props.modules);
    const includeDot = {
      globOptions: {
        dot: true
      }
    };

    config.modules = this.props.modules.concat(plugins);

    this.fs.copy(this.templatePath('plain/**/*'), this.destinationPath(), includeDot);
    this.fs.copyTpl(this.templatePath('processed/**/*'), this.destinationPath(), config, includeDot);

    patchPackageJSON.call(this, config, [], { devDependencies, dependencies, scripts});

    const sdeps = this._generateServerDependencies(this.props.modules);
    this.fs.write(this.destinationPath('requirements.txt'), sdeps.requirements.join('\n'));
    this.fs.write(this.destinationPath('requirements_dev.txt'), sdeps.devRequirements.join('\n'));
    this.fs.write(this.destinationPath('debian_packages.txt'), sdeps.debianPackages.join('\n'));
    this.fs.write(this.destinationPath('redhat_packages.txt'), sdeps.redhatPackages.join('\n'));
  }
}

module.exports = Generator;
<commit_msg>overwrite not patch package.json in ueber<commit_after>'use strict';
const Base = require('yeoman-generator').Base;
const patchPackageJSON = require('../../utils').patchPackageJSON;
const path = require('path');
const glob = require('glob').sync;
const extend = require('lodash').extend;
const Separator = require('inquirer').Separator;

const registry = require('../../knownPhoveaPlugins.json');
const knownPlugins = [].concat(registry.plugins,  null, registry.splugins);
const knownPluginNames = [].concat(
  registry.plugins.map((d) => d.name),
  new Separator(),
  registry.splugins.map((d) => d.name));

function byName(name) {
  return knownPlugins[knownPluginNames.indexOf(name)];
}

class Generator extends Base {

  constructor(args, options) {
    super(args, options);

    this.option('venv', {
      alias: 'v'
    });
  }

  initializing() {
    this.props = this.fs.readJSON(this.destinationPath('.yo-rc-ueber.json'), { modules: [] });
  }

  prompting() {
    const isInstalled = glob('*/package.json', { cwd: this.destinationPath() }).map(path.dirname);
    return this.prompt([{
      type: 'list',
      name: 'virtualEnvironment',
      message: 'Virtual Environment',
      store: true,
      choices: ['none', 'vagrant', 'conda', 'virtualenv'],
      default: 'vagrant',
      when: !this.options.venv
    },{
      type: 'checkbox',
      name: 'modules',
      message: 'Additional Plugins',
      choices: knownPluginNames.filter((d) => isInstalled.indexOf(d) < 0),
      default: this.props.modules,
    }]).then((props) => {
      this.props.modules = props.modules;
      this.venv = props.virtualEnvironment || this.options.venv;
    });
  }

  default() {
    if (this.venv !== 'none') {
      this.composeWith(`phovea:ueber-${this.venv}`, {
        options: this.options
      }, {
        local: require.resolve(`../ueber-${this.venv}`)
      });
    }
  }

  _generatePackage(additionalPlugins) {
    const files = glob('*/phovea.js', { // web plugin
      cwd: this.destinationPath()
    });
    const plugins = files.map(path.dirname);

    // generate dependencies
    var dependencies = {};
    var devDependencies = {};
    var scripts = {};
    plugins.forEach((p) => {
      const pkg = this.fs.readJSON(this.destinationPath(p + '/package.json'));
      extend(dependencies, pkg.dependencies);
      extend(devDependencies, pkg.devDependencies);

      // no pre post test tasks
      Object.keys(pkg.scripts).filter((s) => !/^(pre|post).*/g.test(s)).forEach((s) => {
        // generate scoped tasks
        scripts[`${s}:${p}`] = `cd ${p} && npm run ${s}`;
      });
    });

    //add additional to install plugins
    additionalPlugins.forEach((p) => {
      const known = byName(p);
      if (known && known.dependencies) {
       extend(dependencies, known.dependencies);
      }
    });

    // remove all plugins that are locally installed
    plugins.forEach((p) => {
      const known = byName(p);
      if (known && known.dependencies) {
        Object.keys(known.dependencies).forEach((pi) => {
          delete dependencies[pi];
        });
      } else {
        delete dependencies[p];
      }
    });

    return { plugins, dependencies, devDependencies, scripts };
  }

  _generateServerDependencies(additionalPlugins) {
    const files = glob('*/requirements.txt', { // server plugin
      cwd: this.destinationPath()
    });
    const plugins = files.map(path.dirname);

    var requirements = new Set();
    var devRequirements = new Set();
    var debianPackages = new Set();
    var redhatPackages = new Set();

    plugins.forEach((p) => {
      // generate dependencies
      const addAll = (name, set) => {
        const r = this.fs.read(this.destinationPath(`${p}/${name}`));
        r.split('\n').forEach((ri) => {
          set.add(ri.trim());
        });
      };
      addAll('requirements.txt', requirements);
      addAll('requirements_dev.txt', devRequirements);
      addAll('debian_packages.txt', debianPackages);
      addAll('redhat_packages.txt', redhatPackages);
    });

    //add additional to install plugins
    additionalPlugins.forEach((p) => {
      const known = byName(p);
      if (known && known.requirements) {
        Object.keys(known.requirements).forEach((r) => requirements.add(r+known.requirements[ri]));
      }
      if (known && known.debianPackages) {
        Object.keys(known.debianPackages).forEach((r) => debianPackages.add(r+known.debianPackages[ri]));
      }
      if (known && known.debianPackages) {
        Object.keys(known.debianPackages).forEach((r) => redhatPackages.add(r+known.debianPackages[ri]));
      }
    });

    // remove all plugins that are locally installed
    plugins.forEach((p) => {
      const known = byName(p);
      if (known && known.requirements) {
        Object.keys(known.requirements).forEach((pi) => {
          requirements.delete(pi + known.requirements[pi]);
        });
      } else {
        requirements.delete(p);
      }
    });

    return {
      requirements: [...requirements.values()],
      devRequirements: [...devRequirements.values()],
      debianPackages: [...debianPackages.values()],
      redhatPackages: [...redhatPackages.values()]
    };
  }

  writing() {
    this.fs.extendJSON(this.destinationPath('.yo-rc-ueber.json'), { modules: this.props.modules });

    const config = {};
    const {plugins, dependencies, devDependencies, scripts} = this._generatePackage(this.props.modules);
    const includeDot = {
      globOptions: {
        dot: true
      }
    };

    config.modules = this.props.modules.concat(plugins);

    this.fs.copy(this.templatePath('plain/**/*'), this.destinationPath(), includeDot);
    this.fs.copyTpl(this.templatePath('processed/**/*'), this.destinationPath(), config, includeDot);

    this.fs.copy(this.templatePath('package.tmpl.json'), this.destinationPath('package.json'));
    this.fs.extendJSON(this.destinationPath('package.json'), {devDependencies, dependencies, scripts});

    const sdeps = this._generateServerDependencies(this.props.modules);
    this.fs.write(this.destinationPath('requirements.txt'), sdeps.requirements.join('\n'));
    this.fs.write(this.destinationPath('requirements_dev.txt'), sdeps.devRequirements.join('\n'));
    this.fs.write(this.destinationPath('debian_packages.txt'), sdeps.debianPackages.join('\n'));
    this.fs.write(this.destinationPath('redhat_packages.txt'), sdeps.redhatPackages.join('\n'));
  }
}

module.exports = Generator;
<|endoftext|>


<commit_before>// Positons of aliens in each level
  var levelData = {
     1:  [[0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,3,3,3,3,0,0,0],
          [0,0,0,0,2,2,2,2,0,0,0],
          [0,0,0,0,1,1,1,1,0,0,0]],
      2:  [[0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,3,3,3,3,3,3,0,0],
          [0,0,0,3,3,3,3,3,3,0,0],
          [0,0,0,2,2,2,2,2,2,0,0],
          [0,0,0,2,2,2,2,2,2,0,0],
          [0,0,0,1,1,1,1,1,1,0,0],
          [0,0,0,1,1,1,1,1,1,0,0]],
      3:  [[0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,3,3,3,3,3,3,3,3,3,0],
          [0,3,3,3,3,3,3,3,3,3,0],
          [0,2,2,2,2,2,2,2,2,2,0],
          [0,2,2,2,2,2,2,2,2,2,0],
          [0,1,1,1,1,1,1,1,1,1,0],
          [0,1,1,1,1,1,1,1,1,1,0]],
      4:  [[0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [3,3,3,3,3,3,3,3,3,3,3],
          [2,2,2,2,2,2,2,2,2,2,2],
          [1,1,1,1,1,1,1,1,1,1,1],
          [0,3,3,3,3,3,3,3,3,3,0],
          [0,2,2,2,2,2,2,2,2,2,0],
          [0,1,1,1,1,1,1,1,1,1,0],
          [0,3,3,3,3,3,3,3,3,3,0],
          [0,2,2,2,2,2,2,2,2,2,0],
          [0,1,1,1,1,1,1,1,1,1,0]] };

// Positions of graphics on the sprite card

  var spriteData = {
    'alien1': { sx: 0,  sy: 0,  w: 23, h: 23, cls: Alien },
    'alien2': { sx: 24,  sy: 0, w: 23, h: 23, cls: Alien },
    'alien3': { sx: 48,  sy: 0, w: 23, h: 23, cls: Alien },
    'player': { sx: 0,  sy: 24, w: 22, h: 22, cls: Player },
    'missile': { sx: 2,  sy: 48, w: 5,  h: 5, cls: Missile }
  }

// Start game callback screen - what appears on the start screen - links to engine .js
  function startGame() {
    var screen = new GameScreen("Clown Invaders","Please press space to begin",
                                 function() {
                                     Game.loadBoard(new GameBoard(1));
                                 });
    Game.loadBoard(screen);
    Game.loop();
  }

// End game callback screen - same as above but when the user dies
  function endGame() {
    var screen = new GameScreen("Game Over","Dare to try again? Press space!",
                                 function() {
                                     Game.loadBoard(new GameBoard(1));
                                 });
    Game.loadBoard(screen);
  }

// Win screen - what appears when the user wins
  function winGame() {
    var screen = new GameScreen("You Win!","Want another go? Press space!",
                                 function() {
                                     Game.loadBoard(new GameBoard(1));
                                 });
    Game.loadBoard(screen);
  }

// Attaches audio to functions
  $(function() {
    GameAudio.load({ 'fire' : 'media/laser.ogg', 'die' : 'media/explosion.ogg' },
                   function() {

// Initializes code through all documents
Game.initialize("#gameboard", levelData, spriteData,
                                      { "start": startGame,
                                        "die"  : endGame,
                                        "win"  : winGame });
                   });
   });

<commit_msg>Changes to text on win/start and lose screens<commit_after>// Positons of aliens in each level
  var levelData = {
     1:  [[0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,3,3,3,3,0,0,0],
          [0,0,0,0,2,2,2,2,0,0,0],
          [0,0,0,0,1,1,1,1,0,0,0]],
      2:  [[0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,3,3,3,3,3,3,0,0],
          [0,0,0,3,3,3,3,3,3,0,0],
          [0,0,0,2,2,2,2,2,2,0,0],
          [0,0,0,2,2,2,2,2,2,0,0],
          [0,0,0,1,1,1,1,1,1,0,0],
          [0,0,0,1,1,1,1,1,1,0,0]],
      3:  [[0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [0,3,3,3,3,3,3,3,3,3,0],
          [0,3,3,3,3,3,3,3,3,3,0],
          [0,2,2,2,2,2,2,2,2,2,0],
          [0,2,2,2,2,2,2,2,2,2,0],
          [0,1,1,1,1,1,1,1,1,1,0],
          [0,1,1,1,1,1,1,1,1,1,0]],
      4:  [[0,0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0,0],
          [3,3,3,3,3,3,3,3,3,3,3],
          [2,2,2,2,2,2,2,2,2,2,2],
          [1,1,1,1,1,1,1,1,1,1,1],
          [0,3,3,3,3,3,3,3,3,3,0],
          [0,2,2,2,2,2,2,2,2,2,0],
          [0,1,1,1,1,1,1,1,1,1,0],
          [0,3,3,3,3,3,3,3,3,3,0],
          [0,2,2,2,2,2,2,2,2,2,0],
          [0,1,1,1,1,1,1,1,1,1,0]] };

// Positions of graphics on the sprite card

  var spriteData = {
    'alien1': { sx: 0,  sy: 0,  w: 23, h: 23, cls: Alien },
    'alien2': { sx: 24,  sy: 0, w: 23, h: 23, cls: Alien },
    'alien3': { sx: 48,  sy: 0, w: 23, h: 23, cls: Alien },
    'player': { sx: 0,  sy: 24, w: 22, h: 22, cls: Player },
    'missile': { sx: 2,  sy: 48, w: 5,  h: 5, cls: Missile }
  }

// Start game callback screen - what appears on the start screen - links to engine .js
  function startGame() {
    var screen = new GameScreen("Clown Invaders","Hit Space to Begin Challenge",
                                 function() {
                                     Game.loadBoard(new GameBoard(1));
                                 });
    Game.loadBoard(screen);
    Game.loop();
  }

// End game callback screen - same as above but when the user dies
  function endGame() {
    var screen = new GameScreen("Game Over, You Lost","Press space to try again!",
                                 function() {
                                     Game.loadBoard(new GameBoard(1));
                                 });
    Game.loadBoard(screen);
  }

// Win screen - what appears when the user wins
  function winGame() {
    var screen = new GameScreen("You Have Completed The Challenge!","Bet You Can't Do It Again! Press space!",
                                 function() {
                                     Game.loadBoard(new GameBoard(1));
                                 });
    Game.loadBoard(screen);
  }

// Attaches audio to functions
  $(function() {
    GameAudio.load({ 'fire' : 'media/laser.ogg', 'die' : 'media/explosion.ogg' },
                   function() {

// Initializes code through all documents
Game.initialize("#gameboard", levelData, spriteData,
                                      { "start": startGame,
                                        "die"  : endGame,
                                        "win"  : winGame });
                   });
   });

<|endoftext|>