<commit_before>import React from 'react';

class Footer extends React.Component {

  render(){
    return (

            © Jimini 2016
            Daisy Tsao
            Carl Bernardo
            Shin Adachi
            Charles Meredith

    )
  }
}

export default Footer;
<commit_msg>[pull] styling footer component<commit_after>import React from 'react';
import { Panel } from 'react-bootstrap';

class Footer extends React.Component {

  render(){

    const panelInstance = (
      <Panel>

              © Jimini 2016
              Daisy Tsao
              Carl Bernardo
              Shin Adachi
              Charles Meredith

      </Panel>
    );

    return (

{panelInstance}

    )
  }
}

export default Footer;
<|endoftext|>


<commit_before>function chatBot() {

    this.input;

    this.match = function(regex) {
        return new RegExp(regex).test(this.input);
    }

    this.respondTo = function(input) {

        this.input = input.toLowerCase();

        if(this.match('(hi|hello|hey|hola|howdy)(\\s|!|\\.|$)'))
            return ["um... hi?"];

        if(this.match('what[^ ]* up') || this.match('sup') || this.match('how are you'))
            return ["this github thing is pretty cool, huh?"];

        if(this.match('l(ol)+') || this.match('(ha)+(h|$)') || this.match('lmao'))
            return ["what's so funny?"];

        if(this.match('^no+(\\s|!|\\.|$)'))
            return ["don't be such a negative nancy :("];

        if(this.match('(cya|bye|see ya|ttyl|talk to you later)'))
            return ["alright, see you around", "Good luck with the challenge!"];

        if(this.match('(dumb|stupid|is that all)'))
            return ["hey i'm just a proof of concept", "you can make me smarter if you'd like"];

        if(this.match('(game1|challenge|winter game|game)'))
            return ["Do you like UX? Or...", "Do you like middleware plumbing?"];

        if(this.match('(1|ux|frontend|front-end|client)'))
            return ["Do you like Javascript, IOS or Android?"];

        if(this.match('(javascript|js)'))
            return [
            "In the first game, you have to learn to publish a Static WebApp on your favourite Cloud Provider. (AWS, Bluemix, PWS or Google Cloud)",
            "Later, read some stuff about reactive extensions for your favourite front-end environment."];

        if(this.match('(android|ios|swift|objective c|native)'))
            return [
            "In the first game, you have to learn to publish a Native application on your favourite Cloud Provider. (AWS, Bluemix, PWS or Google Cloud)",
            "Later, read some stuff about reactive extensions for your favourite front-end environment."];

        if(this.match('(2|java|middleware|spring)'))
            return [
            "In the first game, you have to learn to publish a REST API on your favourite Cloud Provider. (AWS, Bluemix, PWS or Google Cloud)",
            "It is possible to get extra points if you add some feature about Spring Cloud Contract."];

        if(this.match('(help)'))
            return ["Create an Issue on Github. My creator will help you."];

        if(this.input == 'noop')
            return;

        return ["" + input + " what?"];
    }

}
<commit_msg>Minor change<commit_after>function chatBot() {

    this.input;

    this.match = function(regex) {
        return new RegExp(regex).test(this.input);
    }

    this.respondTo = function(input) {

        this.input = input.toLowerCase();

        if(this.match('(hi|hello|hey|hola|howdy)(\\s|!|\\.|$)'))
            return ["um... hi?"];

        if(this.match('what[^ ]* up') || this.match('sup') || this.match('how are you'))
            return ["this github thing is pretty cool, huh?"];

        if(this.match('l(ol)+') || this.match('(ha)+(h|$)') || this.match('lmao'))
            return ["what's so funny?"];

        if(this.match('^no+(\\s|!|\\.|$)'))
            return ["don't be such a negative nancy :("];

        if(this.match('(cya|bye|see ya|ttyl|talk to you later)'))
            return ["alright, see you around", "Good luck with the challenge!"];

        if(this.match('(dumb|stupid|is that all)'))
            return ["hey i'm just a proof of concept", "you can make me smarter if you'd like"];

        if(this.match('(game1|challenge|winter game|game)'))
            return ["Do you like UX? Or...", "Do you like middleware plumbing?"];

        if(this.match('(1|ux|frontend|front-end|client)'))
            return ["What is your favourite channel technology? (Javascript, IOS or Android)"];

        if(this.match('(javascript|js)'))
            return [
            "In the first game, you have to learn to publish a Static WebApp on your favourite Cloud Provider. (AWS, Bluemix, PWS or Google Cloud)",
            "Later, read some stuff about reactive extensions for your favourite front-end environment."];

        if(this.match('(android|ios|swift|objective c|native)'))
            return [
            "In the first game, you have to learn to publish a Native application on your favourite Cloud Provider. (AWS, Bluemix, PWS or Google Cloud)",
            "Later, read some stuff about reactive extensions for your favourite front-end environment."];

        if(this.match('(2|java|middleware|spring)'))
            return [
            "In the first game, you have to learn to publish a REST API on your favourite Cloud Provider. (AWS, Bluemix, PWS or Google Cloud)",
            "It is possible to get extra points if you add some feature about Spring Cloud Contract."];

        if(this.match('(help)'))
            return ["Create an Issue on Github. My creator will help you."];

        if(this.input == 'noop')
            return;

        return ["" + input + " what?"];
    }

}
<|endoftext|>


<commit_before>/* eslint-disable no-param-reassign */

describe('the prime numbers canary spec', () => {
  it('shows the infrastructure works', () => {
    true.should.be.true();
  });

  const primeFactorsOf = (number) => {
    const factors = [];
    let divisor = 2;

    for (number > 1; number % divisor === 0; number /= divisor) factors.push(divisor);
    divisor++;
    for (number > 1; number % divisor === 0; number /= divisor) factors.push(divisor);

    if (number > 1) factors.push(number);

    return factors;
  };

  describe('a prime numbers function should', () => {
    it('return none for 1', () => {
      primeFactorsOf(1).should.deepEqual([]);
    });

    it('return 2 for 2', () => {
      primeFactorsOf(2).should.deepEqual([2]);
    });

    it('return 3 for 3', () => {
      primeFactorsOf(3).should.deepEqual([3]);
    });

    it('return 2, 2 for 4', () => {
      primeFactorsOf(4).should.deepEqual([2, 2]);
    });

    it('return 5 for 5', () => {
      primeFactorsOf(5).should.deepEqual([5]);
    });

    it('return 2, 3 for 6', () => {
      primeFactorsOf(6).should.deepEqual([2, 3]);
    });

    it('return 7 for 7', () => {
      primeFactorsOf(7).should.deepEqual([7]);
    });

    it('return 2, 2, 2 for 8', () => {
      primeFactorsOf(8).should.deepEqual([2, 2, 2]);
    });

    it('return 3, 3 for 9', () => {
      primeFactorsOf(9).should.deepEqual([3, 3]);
    });
  });
});
<commit_msg>(2) reduce duplication<commit_after>/* eslint-disable no-param-reassign */

describe('the prime numbers canary spec', () => {
  it('shows the infrastructure works', () => {
    true.should.be.true();
  });

  const primeFactorsOf = (number) => {
    const factors = [];
    let divisor = 2;

    while (number > 1) {
      for (; number % divisor === 0; number /= divisor) factors.push(divisor);
      divisor++;
    }

    if (number > 1) factors.push(number);

    return factors;
  };

  describe('a prime numbers function should', () => {
    it('return none for 1', () => {
      primeFactorsOf(1).should.deepEqual([]);
    });

    it('return 2 for 2', () => {
      primeFactorsOf(2).should.deepEqual([2]);
    });

    it('return 3 for 3', () => {
      primeFactorsOf(3).should.deepEqual([3]);
    });

    it('return 2, 2 for 4', () => {
      primeFactorsOf(4).should.deepEqual([2, 2]);
    });

    it('return 5 for 5', () => {
      primeFactorsOf(5).should.deepEqual([5]);
    });

    it('return 2, 3 for 6', () => {
      primeFactorsOf(6).should.deepEqual([2, 3]);
    });

    it('return 7 for 7', () => {
      primeFactorsOf(7).should.deepEqual([7]);
    });

    it('return 2, 2, 2 for 8', () => {
      primeFactorsOf(8).should.deepEqual([2, 2, 2]);
    });

    it('return 3, 3 for 9', () => {
      primeFactorsOf(9).should.deepEqual([3, 3]);
    });
  });
});
<|endoftext|>


<commit_before>// shapnal
// Shape Contour Signal Graph
// nhmood @ [gooscode labs] - 2013
// HTML5 Canvas + JS

// [todo] - Use more complex method to find center of shape
//		  - Currently just using click but maybe use skeleton method
//		  - http://stackoverflow.com/questions/1203135/what-is-the-fastest-way-to-find-the-center-of-an-irregularly-shaped-polygon
//		  - Or use simple center of 2d mass with uniform density

// cid = canvas id
// cheight = canvas height
// cwidth = canvas width
// lstyle = line style
// lwidth = line width
// ccol = center color
// crad = center radius

function Shape(cid, cheight, cwidth, lstyle, lwidth, ccol, crad)  {
	// Grab canvas by ID, use "shape" as default
	this.cID = typeof(cid) === "undefined" ? "shape" : cid;
	this.canvas = document.getElementById(this.cID);

	// Add event handlersr for mouse actions
	// Use .bind(this) to scope "this" to Shape not canvas
	// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind
	this.canvas.addEventListener("mousedown", this.mouseDown.bind(this));
	this.canvas.addEventListener("mousemove", this.mouseMove.bind(this));
	this.canvas.addEventListener("mouseup"  , this.mouseUp.bind(this));

	// Set size of canvas, use 400x400 as default
	this.canvas.width  = typeof(cwidth)  === "undefined" ? 400 : cwidth;
	this.canvas.height = typeof(cheight) === "undefined" ? 400 : cheight;

	// Get context of canvas for path drawing
	this.ctx = this.canvas.getContext("2d");

	this.ctx.strokeStyle = typeof(lstyle) === "undefined" ? "black" : lstyle;
	this.ctx.lineWidth   = typeof(lwidth) === "undefined" ?    3    : lwidth;

	// Create contour object to hold contour, gets populated from mouse events
	this.contour = new Contour();

	// ==================
	// Internal flags
	// ==================

	// drawEnable - Flag for when mouse movement registers drawing
	// drawComplete - Flag for when drawing is completed
	this.drawEnable = 0;
	this.drawComplete = 0;

	// Center point for shape that line is drawn from
	this.centerX = 0;
	this.centerY = 0;

	this.ccol = typeof(ccol) === "undefined" ? "FF0000" : ccol;
	this.crad = typeof(crad) === "undefined" ?     5    : crad;

	this.counter = 0;

}

Shape.prototype.mouseDown = function(e){
	// If we haven't drawn our shape yet, draw our shape!
	if (!this.drawComplete){
		// Enable drawing for mousemove listener
		this.drawEnable = 1;

		// Add starting points to contour
		this.contour.addPoint(e.offsetX, e.offsetY);
		this.ctx.moveTo(e.offsetX, e.offsetY);
		console.log("mousedowndraw");
	}
	// If shape is drawn and mouse is clicked, register new center point
	else {
		// Set center for this instance
		this.centerX = e.offsetX;
		this.centerY = e.offsetY;

		// Clear canvas, restore original shape, and place new center
		this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
		this.drawContour();

		// Draw center point
		this.ctx.fillStyle = this.ccol;
		this.ctx.fillRect(this.centerX - this.crad/2, this.centerY - this.crad/2, this.crad, this.crad);
	}
};

Shape.prototype.mouseMove = function(e){
	// If drawing is enabled, draw the line\
	if (this.drawEnable){
		console.log("mousemovedraw");
		// Store coords at mouse location
		var x = e.offsetX;
		var y = e.offsetY;

		// Add this point to our contour
		this.contour.addPoint(x, y);

		// Draw the point itself using a path
		// We need this to be done instantaneously for the user
		// So using a path is better than drawing each individual contour point
		// We will draw actual contour points as rectangles after full path is done
		this.ctx.lineTo(x, y);
		this.ctx.stroke();
	}
};

Shape.prototype.mouseUp = function(e){
	if (this.drawEnable){
		// Store coords at mouse location
		var x = e.offsetX;
		var y = e.offsetY;

		// Need a sufficiently sized shape
		// Also prevents accidental clicks
		if (this.contour.points.length > 10){
			// Add this current point to connect last to this
			// Then add initial point again to get contour for closePath
			this.contour.addPoint(x, y);
			this.contour.addPoint(this.contour.startX, this.contour.startY);

			// Finish line contour and save it
			this.ctx.lineTo(this.contour.startX, this.contour.startY);
			this.ctx.stroke();
			this.ctx.closePath();

			// Draw contour using actual rectangles then save context so we can
			// redraw this every frame next time
			this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
			this.drawContour();

			this.drawEnable = 0;
			this.drawComplete = 1;
		}
		// If not big enough, reset canvas, allow drawing, and reset params
		else {
			this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
			this.contour = new Contour();
			this.drawEnable = 0;
			this.drawComplete = 0;
		}
	}
};

Shape.prototype.drawContour = function(e){
	// Check if we have a contour to use
	// Short circuit with || will make sure second statement doesn't cause error
	if (typeof this.contour === 'undefined' || this.contour.points.length == 0){
		console.log("Uh oh, looks like there isn't a contour to draw");
		return;
	}

	// If we have valid contour, draw it
	for (var i = 0; i < this.contour.points.length; i++){
		this.ctx.fillStyle = "#000000";
		// Had to shift both dimensions by 2 pixels to line up with path line???
		this.ctx.fillRect(this.contour.points[i][0]-2, this.contour.points[i][1]-2, this.ctx.lineWidth, this.ctx.lineWidth+1);
	}
}

Shape.prototype.drawCenter = function(e){
	this.ctx.fillStyle = this.ccol;
	this.ctx.fillRect(this.centerX - this.crad/2, this.centerY - this.crad/2, this.crad, this.crad);
}

Shape.prototype.trace = function(e){
	e = e || window.event;
	if (e.keyCode == "37"){
		this.counter++;
		// Restore shape by clearing canvas and restoring
		this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
		this.drawContour();
		this.drawCenter();
		// Draw center point
		this.ctx.beginPath();
		this.ctx.moveTo(this.centerX, this.centerY);
		this.ctx.lineTo(this.contour.points[this.counter % this.contour.points.length][0], this.contour.points[this.counter % this.contour.points.length][1]);
		this.ctx.stroke();
		this.ctx.closePath();

		this.counter++;
	}

};

function Contour(startx, starty) {
	this.startX = typeof(startx) === "undefined" ? 0 : startx;
	this.startY = typeof(starty) === "undefined" ? 0 : starty;
	this.endX = 0;
	this.endY = 0;

	this.points = new Array();
}

Contour.prototype.addPoint = function(x, y){
	// If this is the first point to be added, set as startXY also
	if (this.points.length == 0){
		this.points.push([x, y]);
		this.startX = x;
		this.startY = y;
	}
	else {
		// Get the last points in the array
		// Get interpolated array using x, y values
		// Concatenate to points array
		var prev = this.points[this.points.length - 1];
		var interp = this.pointInterp(prev[0], prev[1], x, y);
		this.points = 	this.points.concat(interp);

	}
};

Contour.prototype.pointInterp = function(startX, startY, endX, endY){
	// To interpolate, draw straight line between given points
	// Use y = mx + b to calculate all points in between

	var interp = new Array();

	// Make sure we don't divide by 0!
	var m = 0;
	if (endX != startX){
		m = (endY - startY) / (endX - startX);
	}

	var b = endY - (m * endX);
	// Interpolate points for axis with smallest difference
	// If xdif is bigger than ydif, traverse x and get all the y points
	if (Math.abs(endX - startX) > Math.abs(endY - startY)){
		// Points need to be generated in the correct direction
		// If x2 is larger, then we are moving right, else left
		var xDir = endX > startX ? 1 : -1;

		// Probably shouldn't use != in for comparison but
		// its the only way to not have separate for statements
		// Add xDir to last point to make inclusive
		var y = 0;
		for (var x = startX; x != (endX + xDir); x += xDir){
			// If slope is inf or 0, then the Y stays the same
			y = startY;
			if (m != 0){
				y = (m * x) + b;
			}

			interp.push([Math.round(x), Math.round(y)]);
		}
	}
	// If xdif is smaller than ydif, traverse y and get all the y points
	else {
		// Points need to be generated in the correct direction
		// If y2 is larger, then we are moving right, else left
		var yDir = endY > startY ? 1 : -1;

		// Probably shouldn't use != in for comparison but
		// its the only way to not have separate for statements
		// Add yDir to last point to make inclusive
		var x = 0;

		for (var y = startY; y != (endY + yDir); y += yDir){

			// If slope is inf or 0, then the X stays the same
			x = startX;
			if (m != 0){
				x = (y - b)/m;
			}
			interp.push([Math.round(x), Math.round(y)]);
		}
	}

	return interp;
}

// Testing
var test2 = new Shape("shape", 400, 400);
console.log(test2);

document.onkeydown = test2.trace.bind(test2);
<commit_msg>Moved tracer out of shape<commit_after>// shapnal
// Shape Contour Signal Graph
// nhmood @ [gooscode labs] - 2013
// HTML5 Canvas + JS

// [todo] - Use more complex method to find center of shape
//		  - Currently just using click but maybe use skeleton method
//		  - http://stackoverflow.com/questions/1203135/what-is-the-fastest-way-to-find-the-center-of-an-irregularly-shaped-polygon
//		  - Or use simple center of 2d mass with uniform density

// cid = canvas id
// cheight = canvas height
// cwidth = canvas width
// lstyle = line style
// lwidth = line width
// ccol = center color
// crad = center radius

function Shape(cid, cheight, cwidth, lstyle, lwidth, ccol, crad)  {
	// Grab canvas by ID, use "shape" as default
	this.cID = typeof(cid) === "undefined" ? "shape" : cid;
	this.canvas = document.getElementById(this.cID);

	// Add event handlersr for mouse actions
	// Use .bind(this) to scope "this" to Shape not canvas
	// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind
	this.canvas.addEventListener("mousedown", this.mouseDown.bind(this));
	this.canvas.addEventListener("mousemove", this.mouseMove.bind(this));
	this.canvas.addEventListener("mouseup"  , this.mouseUp.bind(this));

	// Set size of canvas, use 400x400 as default
	this.canvas.width  = typeof(cwidth)  === "undefined" ? 400 : cwidth;
	this.canvas.height = typeof(cheight) === "undefined" ? 400 : cheight;

	// Get context of canvas for path drawing
	this.ctx = this.canvas.getContext("2d");

	this.ctx.strokeStyle = typeof(lstyle) === "undefined" ? "black" : lstyle;
	this.ctx.lineWidth   = typeof(lwidth) === "undefined" ?    3    : lwidth;

	// Create contour object to hold contour, gets populated from mouse events
	this.contour = new Contour();

	// ==================
	// Internal flags
	// ==================

	// drawEnable - Flag for when mouse movement registers drawing
	// drawComplete - Flag for when drawing is completed
	this.drawEnable = 0;
	this.drawComplete = 0;

	// Center point for shape that line is drawn from
	this.centerValid = 0;
	this.centerX = 0;
	this.centerY = 0;

	this.ccol = typeof(ccol) === "undefined" ? "FF0000" : ccol;
	this.crad = typeof(crad) === "undefined" ?     5    : crad;

	this.counter = 0;

}

Shape.prototype.mouseDown = function(e){
	// If we haven't drawn our shape yet, draw our shape!
	if (!this.drawComplete){
		// Enable drawing for mousemove listener
		this.drawEnable = 1;

		// Add starting points to contour
		this.contour.addPoint(e.offsetX, e.offsetY);
		this.ctx.moveTo(e.offsetX, e.offsetY);
		console.log("mousedowndraw");
	}
	// If shape is drawn and mouse is clicked, register new center point
	else {
		// We now have a valid center point
		this.centerValid = 1;

		// Set center for this instance
		this.centerX = e.offsetX;
		this.centerY = e.offsetY;

		// Clear canvas, restore original shape, and place new center
		this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
		this.drawContour();

		// Draw center point
		this.ctx.fillStyle = this.ccol;
		this.ctx.fillRect(this.centerX - this.crad/2, this.centerY - this.crad/2, this.crad, this.crad);
	}
};

Shape.prototype.mouseMove = function(e){
	// If drawing is enabled, draw the line\
	if (this.drawEnable){
		console.log("mousemovedraw");
		// Store coords at mouse location
		var x = e.offsetX;
		var y = e.offsetY;

		// Add this point to our contour
		this.contour.addPoint(x, y);

		// Draw the point itself using a path
		// We need this to be done instantaneously for the user
		// So using a path is better than drawing each individual contour point
		// We will draw actual contour points as rectangles after full path is done
		this.ctx.lineTo(x, y);
		this.ctx.stroke();
	}
};

Shape.prototype.mouseUp = function(e){
	if (this.drawEnable){
		// Store coords at mouse location
		var x = e.offsetX;
		var y = e.offsetY;

		// Need a sufficiently sized shape
		// Also prevents accidental clicks
		if (this.contour.points.length > 10){
			// Add this current point to connect last to this
			// Then add initial point again to get contour for closePath
			this.contour.addPoint(x, y);
			this.contour.addPoint(this.contour.startX, this.contour.startY);

			// Finish line contour and save it
			this.ctx.lineTo(this.contour.startX, this.contour.startY);
			this.ctx.stroke();
			this.ctx.closePath();

			// Draw contour using actual rectangles then save context so we can
			// redraw this every frame next time
			this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
			this.drawContour();

			this.drawEnable = 0;
			this.drawComplete = 1;
		}
		// If not big enough, reset canvas, allow drawing, and reset params
		else {
			this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
			this.contour = new Contour();
			this.drawEnable = 0;
			this.drawComplete = 0;
		}
	}
};

Shape.prototype.drawContour = function(e){
	this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
	// Check if we have a contour to use
	// Short circuit with || will make sure second statement doesn't cause error
	if (typeof this.contour === 'undefined' || this.contour.points.length == 0){
		console.log("Uh oh, looks like there isn't a contour to draw");
		return;
	}

	// If we have valid contour, draw it
	for (var i = 0; i < this.contour.points.length; i++){
		this.ctx.fillStyle = "#000000";
		// Had to shift both dimensions by 2 pixels to line up with path line???
		this.ctx.fillRect(this.contour.points[i][0]-2, this.contour.points[i][1]-2, this.ctx.lineWidth, this.ctx.lineWidth+1);
	}
}

Shape.prototype.drawCenter = function(e){
	this.ctx.fillStyle = this.ccol;
	this.ctx.fillRect(this.centerX - this.crad/2, this.centerY - this.crad/2, this.crad, this.crad);
}

function Contour(startx, starty) {
	this.startX = typeof(startx) === "undefined" ? 0 : startx;
	this.startY = typeof(starty) === "undefined" ? 0 : starty;
	this.endX = 0;
	this.endY = 0;

	this.points = new Array();
}

Contour.prototype.addPoint = function(x, y){
	// If this is the first point to be added, set as startXY also
	if (this.points.length == 0){
		this.points.push([x, y]);
		this.startX = x;
		this.startY = y;
	}
	else {
		// Get the last points in the array
		// Get interpolated array using x, y values
		// Concatenate to points array
		var prev = this.points[this.points.length - 1];
		var interp = this.pointInterp(prev[0], prev[1], x, y);
		this.points = 	this.points.concat(interp);

	}
};

Contour.prototype.pointInterp = function(startX, startY, endX, endY){
	// To interpolate, draw straight line between given points
	// Use y = mx + b to calculate all points in between

	var interp = new Array();

	// Make sure we don't divide by 0!
	var m = 0;
	if (endX != startX){
		m = (endY - startY) / (endX - startX);
	}

	var b = endY - (m * endX);
	// Interpolate points for axis with smallest difference
	// If xdif is bigger than ydif, traverse x and get all the y points
	if (Math.abs(endX - startX) > Math.abs(endY - startY)){
		// Points need to be generated in the correct direction
		// If x2 is larger, then we are moving right, else left
		var xDir = endX > startX ? 1 : -1;

		// Probably shouldn't use != in for comparison but
		// its the only way to not have separate for statements
		// Add xDir to last point to make inclusive
		var y = 0;
		for (var x = startX; x != (endX + xDir); x += xDir){
			// If slope is inf or 0, then the Y stays the same
			y = startY;
			if (m != 0){
				y = (m * x) + b;
			}

			interp.push([Math.round(x), Math.round(y)]);
		}
	}
	// If xdif is smaller than ydif, traverse y and get all the y points
	else {
		// Points need to be generated in the correct direction
		// If y2 is larger, then we are moving right, else left
		var yDir = endY > startY ? 1 : -1;

		// Probably shouldn't use != in for comparison but
		// its the only way to not have separate for statements
		// Add yDir to last point to make inclusive
		var x = 0;

		for (var y = startY; y != (endY + yDir); y += yDir){

			// If slope is inf or 0, then the X stays the same
			x = startX;
			if (m != 0){
				x = (y - b)/m;
			}
			interp.push([Math.round(x), Math.round(y)]);
		}
	}

	return interp;
}

debugTrace = function(e){
	e = e || window.event;
	if (e.keyCode == "37"){
		this.counter++;
		// Restore shape by clearing canvas and restoring
		this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
		this.drawContour();
		this.drawCenter();
		// Draw center point
		this.ctx.beginPath();
		this.ctx.moveTo(this.centerX, this.centerY);
		this.ctx.lineTo(this.contour.points[this.counter % this.contour.points.length][0], this.contour.points[this.counter % this.contour.points.length][1]);
		this.ctx.stroke();
		this.ctx.closePath();

		this.counter++;
	}

};

// Testing
var shape = new Shape("shape", 400, 400);

// Debug trace
//document.onkeydown = debugTrace.bind(shape);
<|endoftext|>


<commit_before>async function kafka_service(args) {
/*
description("Kafka Service")
base_component_id("kafka_service")
load_once_from_file(true)
only_run_on_server(true)
*/
    var promise = new Promise(async function(returnfn) {
        var kafkaConnection = new Kafka({
            clientId: 'myapp23',
            brokers: ['localhost:9092','localhost:9092']
        })
        console.log(1)
        const producer = kafkaConnection.producer()
        console.log(2)
        const consumer = kafkaConnection.consumer({ groupId: uuidv1() })
        console.log(3)
        await consumer.connect()
        console.log(4)
        await consumer.subscribe({ topic: 'test', fromBeginning: true })
        console.log(5)

        var dd=[]
        console.log(6)
        await consumer.run({
          eachMessage: async ({ topic, partition, message }) => {
              consumer.pause([{ topic }])
            console.log({
              partition,
              offset: message.offset,
              value: message.value.toString(),
          })
            dd.push(message.value.toString())
            console.log(8)
            returnfn(dd)
          }
        })

    })
    var ret = await promise
    return ret
}
<commit_msg>code clean up<commit_after>async function kafka_service(args) {
/*
description("Kafka Service")
base_component_id("kafka_service")
load_once_from_file(true)
only_run_on_server(true)
*/
    var promise = new Promise(async function(returnfn) {
        var kafkaConnection = new Kafka({
            clientId: 'myapp',
            brokers: ['localhost:9092','localhost:9092']
        })
        const producer = kafkaConnection.producer()
        const consumer = kafkaConnection.consumer({ groupId: uuidv1() })
        await consumer.connect()
        await consumer.subscribe({ topic: 'test', fromBeginning: true })

        var dd=[]
        await consumer.run({
          eachMessage: async ({ topic, partition, message }) => {
              consumer.pause([{ topic }])
            console.log({
              partition,
              offset: message.offset,
              value: message.value.toString(),
          })
            dd.push(message.value.toString())
            returnfn(dd)
          }
        })

    })
    var ret = await promise
    return ret
}
<|endoftext|>


<commit_before>define(function (require, exports, module) {
    "use strict";

    Algo.authBitLength = 16;
    Algo.offerBitLength = 128;
    Algo.dhPrivBitLength = 160;
    Tlke.authBitLength = Algo.authBitLength;
    Tlke.offerBitLength = Algo.offerBitLength;
    Tlke.dhPrivBitLength = Algo.dhPrivBitLength;

    var tools = require("../tools");
    var SHA1 = require("../cryptography/sha1-crypto-js");
    var DiffieHellman = require("../cryptography/diffie-hellman-leemon");
    var Hex = require("../multivalue/hex");
    var BitArray = require("../multivalue/bitArray");
    var Bytes = require("../multivalue/bytes");
    var Aes = require("../cryptography/aes-sjcl");

    var eventEmitter = require("../events/eventEmitter");
    var invariant = require("../invariant");
    var Multivalue = require("../multivalue/multivalue");

    var serializable = require("../serialization/serializable");

    var extend = tools.extend;
    var isFunction = tools.isFunction;

    function hash(value) {
        return SHA1(value).as(BitArray).bitSlice(0, 128);
    }

// __________________________________________________________________________ //

    function Algo(random) {
        this.random = random;

        this.state = null;
        this._dhAesKey = null;
        this.dhk = null;
        this.dh = null;
        this.auth = null;
        this.check = null;
        this.authData = null;
    }

    Algo.prototype.init = function () {
        this.state = Algo.STATE_NOT_STARTED;
    }

    Algo.prototype._getRandomBytes = function (bitLength) {
        invariant(isFunction(this.random.bitArray), "random must implement IRandom");
        return this.random.bitArray(bitLength);
    }

    Algo.prototype._encrypt = function (bytes, customKey) {
        var iv = this._getRandomBytes(128);
        var aes = new Aes(customKey || this._dhAesKey);
        var encryptedData = aes.encryptCbc(bytes, iv);
        return iv.as(Bytes).concat(encryptedData);
    }

    Algo.prototype._decrypt = function (bytes, customKey) {
        var dataBitArray = bytes.as(BitArray);
        var iv = dataBitArray.bitSlice(0, 128);
        var encryptedData = dataBitArray.bitSlice(128, dataBitArray.bitLength());
        var aes = new Aes(customKey || this._dhAesKey);
        return aes.decryptCbc(encryptedData, iv);
    }

    // Alice 1.1 (instantiation)
    Algo.prototype._generateOffer = function () {
        this.dh = DiffieHellman.generate(Algo.dhPrivBitLength, this.random);
        var dhAes = this._getRandomBytes(Algo.offerBitLength);
        this._dhAesKey = dhAes;
        var outId = dhAes.bitSlice(0, 16);
        var inId = dhAes.bitSlice(16, 32);
        return {inId: inId, outId: outId};
    }

    // Bob 2.1 (instantiation) offer is from getOffer (via IM)
    Algo.prototype._acceptOffer = function (offer) {
        this.dh = DiffieHellman.generate(Algo.dhPrivBitLength, this.random);
        var dhAes = offer.as(Hex).as(BitArray);
        this._dhAesKey = dhAes;
        var inId = dhAes.bitSlice(0, 16);
        var outId = dhAes.bitSlice(16, 32);
        this.state = Algo.STATE_AWAITING_OFFERDATA;
        return {inId: inId, outId: outId};
    }

    Algo.prototype._getOfferData = function () {
        var dhData = new Hex(this.dh.createKeyExchange());
        return this._encrypt(dhData);
    }

    // Bob 2.2.
    Algo.prototype._acceptOfferData = function (bytes) {
        var dhData;
        try {
            dhData = this._decrypt(bytes);
        } catch (ex) {
            console.warn("Received bad bytes.  " + ex.message);
            return;
        }
        var dhDataHex = dhData.as(Hex).value;
        var dhkHex = this.dh.decryptKeyExchange(dhDataHex);
        this.dhk = new Hex(dhkHex);
        this.state = Tlke.STATE_AWAITING_AUTH;
    }

    Algo.prototype._getOfferResponse = function () {
        var dhData = new Hex(this.dh.createKeyExchange());
        return this._encrypt(dhData);
    }

    // Alice 3.1
    Algo.prototype._acceptOfferResponse = function (data) {
        var dhDataHex;
        try {
            dhDataHex = this._decrypt(data).as(Hex).value;
        } catch (ex) {
            console.warn("Received bad bytes.  " + ex.message);
            return;
        }
        var dhkHex = this.dh.decryptKeyExchange(dhDataHex);
        this.dhk = new Hex(dhkHex);

        this.auth = this._getRandomBytes(Tlke.authBitLength);
        this.check = this._getRandomBytes(128);
        this.state = Tlke.STATE_AWAITING_AUTH_RESPONSE;
    }

    Algo.prototype._getAuthData = function () {
        return this._encrypt(this.check, this._getVerifiedDhk());
    }

    Algo.prototype._getVerifiedDhk = function () {
        var dhk = this.dhk.as(Bytes);
        var auth = this.auth.as(Bytes);
        return hash(dhk.concat(auth));
    }

    // Bob 4.2
    Algo.prototype._acceptAuthData = function (bytes) {
        this.authData = bytes;
        if (this.auth) {
            this._acceptAuthAndData();
        } else {
            this.state = Tlke.STATE_AWAITING_AUTH;
        }
    }

    // Bob 4.1
    Algo.prototype._acceptAuth = function (auth) {
        this.auth = auth;
        if (this.authData) {
            this._acceptAuthAndData();
        } else {
            this.state = Tlke.STATE_AWAITING_AUTHDATA;
        }
    }

    // Bob 4.3 (4.1 + 4.2)
    Algo.prototype._acceptAuthAndData = function () {
        var bytes = this.authData;
        // todo check's checksum and ACHTUNG if not match
        var verified = this._getVerifiedDhk();
        try {
            this.check = this._decrypt(bytes, verified);
        } catch (ex) {
            console.warn("Received bad bytes.  " + ex.message);
            return;
        }
        this.state = Tlke.STATE_CONNECTION_ESTABLISHED;
        return {
            inId: hCheck.bitSlice(0, 16),
            outId: hCheck.bitSlice(16, 32),
            key: hash(this.check.as(Bytes).concat(verified))
        };
    }

    Algo.prototype._getAuthResponse = function () {
        var hCheck = hash(this.check);
        return this._encrypt(hCheck, this._getVerifiedDhk());
    }

    // Alice 5
    Algo.prototype._acceptAuthResponse = function (bytes) {
        var verified = this._getVerifiedDhk(), hCheck;
        try {
            hCheck = this._decrypt(bytes, verified);
        } catch (ex) {
            console.warn("Received bad bytes.  " + ex.message);
            return;
        }
        if (hash(this.check).as(Hex).value !== hCheck.as(Hex).value) {
            this.state = Tlke.STATE_CONNECTION_FAILED;
            return;
        }
        this.state = Algo.STATE_CONNECTION_ESTABLISHED;
        return {
            inId: hCheck.bitSlice(16, 32),
            outId: hCheck.bitSlice(0, 16),
            key: hash(this.check.as(Bytes).concat(verified))
        };
    }

    Algo.STATE_NOT_STARTED = 1;
    Algo.STATE_AWAITING_OFFERDATA = 2;
    Algo.STATE_AWAITING_OFFER_RESPONSE = 3;
    Algo.STATE_AWAITING_AUTH = 4;
    Algo.STATE_AWAITING_AUTHDATA = 5;
    Algo.STATE_AWAITING_AUTH_RESPONSE = 6;
    Algo.STATE_CONNECTION_ESTABLISHED = 7;
    Algo.STATE_CONNECTION_SYNCED = 8;
    Algo.STATE_CONNECTION_FAILED = -1;

// __________________________________________________________________________ //

    // tl channel that is used during key exchange (while channel is being set up)
    function Tlke(factory) {
        invariant(factory, "Can be constructed only with factory");
        invariant(isFunction(factory.createRandom), "factory must have createRandom() method");

        this._defineEvent("changed");
        this._defineEvent("offer");
        this._defineEvent("auth");
        this._defineEvent("addr");
        this._defineEvent("packet");
        this._defineEvent("keyReady");

        // use the rng without serialization (assume singleton)
        this.random = factory.createRandom();

        this._algo = new Algo(this.random);
    }

    extend(Tlke.prototype, eventEmitter, serializable, {
        getState: function () {
            return this._algo.state;
        },
        init: function () {
            this._algo.init();
        },
        generate: function () {
            this.checkEventHandlers();
            invariant(this.getState() === Algo.STATE_NOT_STARTED,
                "Can't generate offer being in a state %s", this.state);
            this._generateOffer();
        },
        enterOffer: function (offer) {
            this.checkEventHandlers();
            invariant(offer instanceof Multivalue, "offer must be multivalue");
            invariant(this.getState() === Tlke.STATE_NOT_STARTED,
                "Can't accept offer being in a state %s", this.state);
            invariant(offer, "Received an empty offer");
            this._acceptOffer(offer);
        },
        enterAuth: function (auth) {
            invariant(auth instanceof Multivalue, "offer must be multivalue");
            invariant(auth, "Received an empty auth");
            this._acceptAuth(auth);
        },

        processPacket: function (bytes) {
            invariant(bytes instanceof Multivalue, "bytes must be multivalue");
            switch (this.getState()) {
            case Algo.STATE_AWAITING_OFFER_RESPONSE:
                this._acceptOfferResponse(bytes);
                break;
            case Algo.STATE_AWAITING_AUTH_RESPONSE:
                this._acceptAuthResponse(bytes);
                break;
            case Algo.STATE_AWAITING_OFFERDATA:
                this._acceptOfferData(bytes);
                break;
            case Algo.STATE_AWAITING_AUTH:
            case Algo.STATE_AWAITING_AUTHDATA:
                this._acceptAuthData(bytes);
                break;
            default:
                console.warn("packet ignored: not the right state");
                break;
            }
            this._onChanged();
        },

        // Alice 1.1 (instantiation)
        _generateOffer: function () {
            var ids = this._algo._generateOffer();
            // emit this event before any "packet" event call to configure the appropriate transport behavior
            this.fire("addr", ids);
            this.fire("offer", this._algo._dhAesKey);
            this._algo.state = Algo.STATE_AWAITING_OFFER_RESPONSE;
            this.fire("packet", this._algo._getOfferData());
            this._onChanged();
        },

        // Bob 2.1 (instantiation) offer is from getOffer (via IM)
        _acceptOffer: function (offer) {
            var ids = this._algo._acceptOffer(offer);
            this.fire("addr", ids);
            this._onChanged();
        },

        // Bob 2.2.
        _acceptOfferData: function (bytes) {
            this._algo._acceptOfferData(bytes);
            this.fire("packet", this._algo._getOfferResponse());
            this.fire("auth", null);
        },

        // Alice 3.1
        _acceptOfferResponse: function (data) {
            this._algo._acceptOfferResponse(data);
            this.fire("packet", this._algo._getAuthData());
            this.fire("auth", this.auth);
        },

        // Bob 4.2
        _acceptAuthData: function (bytes) {
            this._algo._acceptAuthData();
        },

        // Bob 4.1
        _acceptAuth: function (auth) {
            this._algo._acceptAuth();
            this._onChanged();
        },

        // Bob 4.3 (4.1 + 4.2)
        _acceptAuthAndData: function () {
            var keyReady = this._algo._acceptAuthAndData();
            this.fire("packet", this._getAuthResponse());
            this.fire("keyReady", idsKey);
            this._onChanged();
        },

        // Alice 5
        _acceptAuthResponse: function (bytes) {
            var keyReady = this._algo._acceptAuthResponse();
            this.fire("keyReady", keyReady);
        },

        _onChanged: function () {
            this.fire("changed", this);
        },

        deserialize: function (packet, context) {
            var dto = packet.getData();
            this._algo.state = dto.state;
            this._algo._dhAesKey = dto.dhAesKey ? Hex.deserialize(dto.dhAesKey) : null;
            this._algo.dhk = dto.dhk ? Hex.deserialize(dto.dhk) : null;
            this._algo.dh = dto.dh ? DiffieHellman.deserialize(dto.dh) : null;
            this._algo.auth = dto.auth ? Hex.deserialize(dto.auth) : null;
            this._algo.check = dto.check ? Hex.deserialize(dto.check) : null;
            this._algo.authData = dto.authData ? Hex.deserialize(dto.authData) : null;
        },

        serialize: function (packet, context) {
            packet.setData({
                state: this._algo.state,
                dhAesKey: this._algo._dhAesKey ? this._algo._dhAesKey.as(Hex).serialize() : null,
                dhk: this._algo.dhk ? this._algo.dhk.as(Hex).serialize() : null,
                dh: this._algo.dh ? this._algo.dh.serialize() : null,
                auth: this._algo.auth ? this._algo.auth.as(Hex).serialize() : null,
                check: this._algo.check ? this._algo.check.as(Hex).serialize() : null,
                authData: this._algo.authData ? this._algo.authData.as(Hex).serialize() : null
            });
            return packet;
        }

    });

    // A. NOT_STARTED
    //    generate() -> packet + offer
    //    AWAITING_OFFER_RESPONSE
    //    _acceptOfferResponse() -> packet + auth
    //    AWAITING_AUTH_RESPONSE
    //    _acceptAuthResponse() -> keyReady | authError

    // B. NOT_STARTED
    //    acceptOffer(offer) -> packet
    //    AWAITING_OFFERDATA
    //    _acceptOfferData
    //    STATE_AWAITING_AUTHDATA   |
    //    _acceptAuthData           |--> packet + keyReady
    //    STATE_AWAITING_AUTH       |
    //    acceptAuth(auth)          |

    Tlke.STATE_NOT_STARTED = Algo.STATE_NOT_STARTED;
    Tlke.STATE_AWAITING_OFFERDATA = Algo.STATE_AWAITING_OFFERDATA;
    Tlke.STATE_AWAITING_OFFER_RESPONSE = Algo.STATE_AWAITING_OFFER_RESPONSE;
    Tlke.STATE_AWAITING_AUTH = Algo.STATE_AWAITING_AUTH;
    Tlke.STATE_AWAITING_AUTHDATA = Algo.STATE_AWAITING_AUTHDATA;
    Tlke.STATE_AWAITING_AUTH_RESPONSE = Algo.STATE_AWAITING_AUTH_RESPONSE;
    Tlke.STATE_CONNECTION_ESTABLISHED = Algo.STATE_CONNECTION_ESTABLISHED;
    Tlke.STATE_CONNECTION_SYNCED = Algo.STATE_CONNECTION_SYNCED;
    Tlke.STATE_CONNECTION_FAILED = Algo.STATE_CONNECTION_FAILED;

    module.exports = Tlke;
});<commit_msg>removed redundant consts<commit_after>define(function (require, exports, module) {
    "use strict";

    Algo.authBitLength = 16;
    Algo.offerBitLength = 128;
    Algo.dhPrivBitLength = 160;

    var tools = require("../tools");
    var SHA1 = require("../cryptography/sha1-crypto-js");
    var DiffieHellman = require("../cryptography/diffie-hellman-leemon");
    var Hex = require("../multivalue/hex");
    var BitArray = require("../multivalue/bitArray");
    var Bytes = require("../multivalue/bytes");
    var Aes = require("../cryptography/aes-sjcl");

    var eventEmitter = require("../events/eventEmitter");
    var invariant = require("../invariant");
    var Multivalue = require("../multivalue/multivalue");

    var serializable = require("../serialization/serializable");

    var extend = tools.extend;
    var isFunction = tools.isFunction;

    function hash(value) {
        return SHA1(value).as(BitArray).bitSlice(0, 128);
    }

// __________________________________________________________________________ //

    function Algo(random) {
        this.random = random;

        this.state = null;
        this._dhAesKey = null;
        this.dhk = null;
        this.dh = null;
        this.auth = null;
        this.check = null;
        this.authData = null;
    }

    Algo.prototype.init = function () {
        this.state = Algo.STATE_NOT_STARTED;
    }

    Algo.prototype._getRandomBytes = function (bitLength) {
        invariant(isFunction(this.random.bitArray), "random must implement IRandom");
        return this.random.bitArray(bitLength);
    }

    Algo.prototype._encrypt = function (bytes, customKey) {
        var iv = this._getRandomBytes(128);
        var aes = new Aes(customKey || this._dhAesKey);
        var encryptedData = aes.encryptCbc(bytes, iv);
        return iv.as(Bytes).concat(encryptedData);
    }

    Algo.prototype._decrypt = function (bytes, customKey) {
        var dataBitArray = bytes.as(BitArray);
        var iv = dataBitArray.bitSlice(0, 128);
        var encryptedData = dataBitArray.bitSlice(128, dataBitArray.bitLength());
        var aes = new Aes(customKey || this._dhAesKey);
        return aes.decryptCbc(encryptedData, iv);
    }

    // Alice 1.1 (instantiation)
    Algo.prototype._generateOffer = function () {
        this.dh = DiffieHellman.generate(Algo.dhPrivBitLength, this.random);
        var dhAes = this._getRandomBytes(Algo.offerBitLength);
        this._dhAesKey = dhAes;
        var outId = dhAes.bitSlice(0, 16);
        var inId = dhAes.bitSlice(16, 32);
        return {inId: inId, outId: outId};
    }

    // Bob 2.1 (instantiation) offer is from getOffer (via IM)
    Algo.prototype._acceptOffer = function (offer) {
        this.dh = DiffieHellman.generate(Algo.dhPrivBitLength, this.random);
        var dhAes = offer.as(Hex).as(BitArray);
        this._dhAesKey = dhAes;
        var inId = dhAes.bitSlice(0, 16);
        var outId = dhAes.bitSlice(16, 32);
        this.state = Algo.STATE_AWAITING_OFFERDATA;
        return {inId: inId, outId: outId};
    }

    Algo.prototype._getOfferData = function () {
        var dhData = new Hex(this.dh.createKeyExchange());
        return this._encrypt(dhData);
    }

    // Bob 2.2.
    Algo.prototype._acceptOfferData = function (bytes) {
        var dhData;
        try {
            dhData = this._decrypt(bytes);
        } catch (ex) {
            console.warn("Received bad bytes.  " + ex.message);
            return;
        }
        var dhDataHex = dhData.as(Hex).value;
        var dhkHex = this.dh.decryptKeyExchange(dhDataHex);
        this.dhk = new Hex(dhkHex);
        this.state = Tlke.STATE_AWAITING_AUTH;
    }

    Algo.prototype._getOfferResponse = function () {
        var dhData = new Hex(this.dh.createKeyExchange());
        return this._encrypt(dhData);
    }

    // Alice 3.1
    Algo.prototype._acceptOfferResponse = function (data) {
        var dhDataHex;
        try {
            dhDataHex = this._decrypt(data).as(Hex).value;
        } catch (ex) {
            console.warn("Received bad bytes.  " + ex.message);
            return;
        }
        var dhkHex = this.dh.decryptKeyExchange(dhDataHex);
        this.dhk = new Hex(dhkHex);

        this.auth = this._getRandomBytes(Tlke.authBitLength);
        this.check = this._getRandomBytes(128);
        this.state = Tlke.STATE_AWAITING_AUTH_RESPONSE;
    }

    Algo.prototype._getAuthData = function () {
        return this._encrypt(this.check, this._getVerifiedDhk());
    }

    Algo.prototype._getVerifiedDhk = function () {
        var dhk = this.dhk.as(Bytes);
        var auth = this.auth.as(Bytes);
        return hash(dhk.concat(auth));
    }

    // Bob 4.2
    Algo.prototype._acceptAuthData = function (bytes) {
        this.authData = bytes;
        if (this.auth) {
            this._acceptAuthAndData();
        } else {
            this.state = Tlke.STATE_AWAITING_AUTH;
        }
    }

    // Bob 4.1
    Algo.prototype._acceptAuth = function (auth) {
        this.auth = auth;
        if (this.authData) {
            this._acceptAuthAndData();
        } else {
            this.state = Tlke.STATE_AWAITING_AUTHDATA;
        }
    }

    // Bob 4.3 (4.1 + 4.2)
    Algo.prototype._acceptAuthAndData = function () {
        var bytes = this.authData;
        // todo check's checksum and ACHTUNG if not match
        var verified = this._getVerifiedDhk();
        try {
            this.check = this._decrypt(bytes, verified);
        } catch (ex) {
            console.warn("Received bad bytes.  " + ex.message);
            return;
        }
        this.state = Tlke.STATE_CONNECTION_ESTABLISHED;
        return {
            inId: hCheck.bitSlice(0, 16),
            outId: hCheck.bitSlice(16, 32),
            key: hash(this.check.as(Bytes).concat(verified))
        };
    }

    Algo.prototype._getAuthResponse = function () {
        var hCheck = hash(this.check);
        return this._encrypt(hCheck, this._getVerifiedDhk());
    }

    // Alice 5
    Algo.prototype._acceptAuthResponse = function (bytes) {
        var verified = this._getVerifiedDhk(), hCheck;
        try {
            hCheck = this._decrypt(bytes, verified);
        } catch (ex) {
            console.warn("Received bad bytes.  " + ex.message);
            return;
        }
        if (hash(this.check).as(Hex).value !== hCheck.as(Hex).value) {
            this.state = Tlke.STATE_CONNECTION_FAILED;
            return;
        }
        this.state = Algo.STATE_CONNECTION_ESTABLISHED;
        return {
            inId: hCheck.bitSlice(16, 32),
            outId: hCheck.bitSlice(0, 16),
            key: hash(this.check.as(Bytes).concat(verified))
        };
    }

    Algo.STATE_NOT_STARTED = 1;
    Algo.STATE_AWAITING_OFFERDATA = 2;
    Algo.STATE_AWAITING_OFFER_RESPONSE = 3;
    Algo.STATE_AWAITING_AUTH = 4;
    Algo.STATE_AWAITING_AUTHDATA = 5;
    Algo.STATE_AWAITING_AUTH_RESPONSE = 6;
    Algo.STATE_CONNECTION_ESTABLISHED = 7;
    Algo.STATE_CONNECTION_SYNCED = 8;
    Algo.STATE_CONNECTION_FAILED = -1;

// __________________________________________________________________________ //

    // tl channel that is used during key exchange (while channel is being set up)
    function Tlke(factory) {
        invariant(factory, "Can be constructed only with factory");
        invariant(isFunction(factory.createRandom), "factory must have createRandom() method");

        this._defineEvent("changed");
        this._defineEvent("offer");
        this._defineEvent("auth");
        this._defineEvent("addr");
        this._defineEvent("packet");
        this._defineEvent("keyReady");

        // use the rng without serialization (assume singleton)
        this.random = factory.createRandom();

        this._algo = new Algo(this.random);
    }

    extend(Tlke.prototype, eventEmitter, serializable, {
        getState: function () {
            return this._algo.state;
        },
        init: function () {
            this._algo.init();
        },
        generate: function () {
            this.checkEventHandlers();
            invariant(this.getState() === Algo.STATE_NOT_STARTED,
                "Can't generate offer being in a state %s", this.state);
            this._generateOffer();
        },
        enterOffer: function (offer) {
            this.checkEventHandlers();
            invariant(offer instanceof Multivalue, "offer must be multivalue");
            invariant(this.getState() === Tlke.STATE_NOT_STARTED,
                "Can't accept offer being in a state %s", this.state);
            invariant(offer, "Received an empty offer");
            this._acceptOffer(offer);
        },
        enterAuth: function (auth) {
            invariant(auth instanceof Multivalue, "offer must be multivalue");
            invariant(auth, "Received an empty auth");
            this._acceptAuth(auth);
        },

        processPacket: function (bytes) {
            invariant(bytes instanceof Multivalue, "bytes must be multivalue");
            switch (this.getState()) {
            case Algo.STATE_AWAITING_OFFER_RESPONSE:
                this._acceptOfferResponse(bytes);
                break;
            case Algo.STATE_AWAITING_AUTH_RESPONSE:
                this._acceptAuthResponse(bytes);
                break;
            case Algo.STATE_AWAITING_OFFERDATA:
                this._acceptOfferData(bytes);
                break;
            case Algo.STATE_AWAITING_AUTH:
            case Algo.STATE_AWAITING_AUTHDATA:
                this._acceptAuthData(bytes);
                break;
            default:
                console.warn("packet ignored: not the right state");
                break;
            }
            this._onChanged();
        },

        // Alice 1.1 (instantiation)
        _generateOffer: function () {
            var ids = this._algo._generateOffer();
            // emit this event before any "packet" event call to configure the appropriate transport behavior
            this.fire("addr", ids);
            this.fire("offer", this._algo._dhAesKey);
            this._algo.state = Algo.STATE_AWAITING_OFFER_RESPONSE;
            this.fire("packet", this._algo._getOfferData());
            this._onChanged();
        },

        // Bob 2.1 (instantiation) offer is from getOffer (via IM)
        _acceptOffer: function (offer) {
            var ids = this._algo._acceptOffer(offer);
            this.fire("addr", ids);
            this._onChanged();
        },

        // Bob 2.2.
        _acceptOfferData: function (bytes) {
            this._algo._acceptOfferData(bytes);
            this.fire("packet", this._algo._getOfferResponse());
            this.fire("auth", null);
        },

        // Alice 3.1
        _acceptOfferResponse: function (data) {
            this._algo._acceptOfferResponse(data);
            this.fire("packet", this._algo._getAuthData());
            this.fire("auth", this.auth);
        },

        // Bob 4.2
        _acceptAuthData: function (bytes) {
            this._algo._acceptAuthData();
        },

        // Bob 4.1
        _acceptAuth: function (auth) {
            this._algo._acceptAuth();
            this._onChanged();
        },

        // Bob 4.3 (4.1 + 4.2)
        _acceptAuthAndData: function () {
            var keyReady = this._algo._acceptAuthAndData();
            this.fire("packet", this._getAuthResponse());
            this.fire("keyReady", idsKey);
            this._onChanged();
        },

        // Alice 5
        _acceptAuthResponse: function (bytes) {
            var keyReady = this._algo._acceptAuthResponse();
            this.fire("keyReady", keyReady);
        },

        _onChanged: function () {
            this.fire("changed", this);
        },

        deserialize: function (packet, context) {
            var dto = packet.getData();
            this._algo.state = dto.state;
            this._algo._dhAesKey = dto.dhAesKey ? Hex.deserialize(dto.dhAesKey) : null;
            this._algo.dhk = dto.dhk ? Hex.deserialize(dto.dhk) : null;
            this._algo.dh = dto.dh ? DiffieHellman.deserialize(dto.dh) : null;
            this._algo.auth = dto.auth ? Hex.deserialize(dto.auth) : null;
            this._algo.check = dto.check ? Hex.deserialize(dto.check) : null;
            this._algo.authData = dto.authData ? Hex.deserialize(dto.authData) : null;
        },

        serialize: function (packet, context) {
            packet.setData({
                state: this._algo.state,
                dhAesKey: this._algo._dhAesKey ? this._algo._dhAesKey.as(Hex).serialize() : null,
                dhk: this._algo.dhk ? this._algo.dhk.as(Hex).serialize() : null,
                dh: this._algo.dh ? this._algo.dh.serialize() : null,
                auth: this._algo.auth ? this._algo.auth.as(Hex).serialize() : null,
                check: this._algo.check ? this._algo.check.as(Hex).serialize() : null,
                authData: this._algo.authData ? this._algo.authData.as(Hex).serialize() : null
            });
            return packet;
        }

    });

    // A. NOT_STARTED
    //    generate() -> packet + offer
    //    AWAITING_OFFER_RESPONSE
    //    _acceptOfferResponse() -> packet + auth
    //    AWAITING_AUTH_RESPONSE
    //    _acceptAuthResponse() -> keyReady | authError

    // B. NOT_STARTED
    //    acceptOffer(offer) -> packet
    //    AWAITING_OFFERDATA
    //    _acceptOfferData
    //    STATE_AWAITING_AUTHDATA   |
    //    _acceptAuthData           |--> packet + keyReady
    //    STATE_AWAITING_AUTH       |
    //    acceptAuth(auth)          |

    Tlke.STATE_NOT_STARTED = Algo.STATE_NOT_STARTED;
    Tlke.STATE_AWAITING_OFFERDATA = Algo.STATE_AWAITING_OFFERDATA;
    Tlke.STATE_AWAITING_OFFER_RESPONSE = Algo.STATE_AWAITING_OFFER_RESPONSE;
    Tlke.STATE_AWAITING_AUTH = Algo.STATE_AWAITING_AUTH;
    Tlke.STATE_AWAITING_AUTHDATA = Algo.STATE_AWAITING_AUTHDATA;
    Tlke.STATE_AWAITING_AUTH_RESPONSE = Algo.STATE_AWAITING_AUTH_RESPONSE;
    Tlke.STATE_CONNECTION_ESTABLISHED = Algo.STATE_CONNECTION_ESTABLISHED;
    Tlke.STATE_CONNECTION_SYNCED = Algo.STATE_CONNECTION_SYNCED;
    Tlke.STATE_CONNECTION_FAILED = Algo.STATE_CONNECTION_FAILED;

    module.exports = Tlke;
});<|endoftext|>


<commit_before>/* global by, element */

'use strict';

var authentication = require('../authentication/authentication');
var common = require('../common/common');
var topologyEditorCommon = require('../topology/topology_editor_common');
var topologyTemplates = require('../topology/topology_templates_common');
var applications = require('../applications/applications');

describe('Applications management :', function() {
  /* Before each spec in the tests suite */
  beforeEach(function() {
    common.before();
    authentication.login('applicationManager');
  });

  /* After each spec in the tests suite(s) */
  afterEach(function() {
    // Logout action
    common.after();
  });

  it('should be able to go to application search page at ' + common.appSearchUrl + ' and create new application', function() {
    console.log('################# should be able to go to application search page at ' + common.appSearchUrl + ' and create new application');
    applications.createApplication('Alien', 'Great Application');
    // Go to the app details page
    expect(browser.element(by.binding('application.name')).getText()).toEqual('Alien');
    expect(browser.element(by.binding('application.description')).getText()).toEqual('Great Application');
  });

  it('should create first a topology template with 3 node templates (COMPUTE, JAVA, TOMCATRPM) and an application based on this template', function() {
    console.log('################# should create first a topology template with 3 node templates (COMPUTE, JAVA, TOMCATRPM) and an application based on this template');
    // Login as architect to create a topology template
    authentication.reLogin('architect');

    // create a topology template with one Compute, 1 Java and 1 Tomcat RPM
    topologyTemplates.createTopologyTemplateWithNodesAndRelationships(topologyEditorCommon.topologyTemplates.template4);

    // create a new application with this template as model
    authentication.reLogin('applicationManager');
    // template at index 2 is the first and only one created (index 1 equals is the default, no template)
    applications.createApplication('JavaTomcatWarApplication', 'Simple application with one compute, one template and all that around java...', 2);

    // check the created topology application (count nodes, count relationship..)
    applications.goToApplicationDetailPage('JavaTomcatWarApplication', true);

    // check relationship count
    // check relationship count
    element(by.id('rect_JavaRPM')).click();
    browser.waitForAngular();
    var relationships = element.all(by.repeater('(relationshipName,relationshipDefinition) in selectedNodeTemplate.relationships'));
    expect(relationships.count()).toBe(2);
    element(by.id('rect_Compute_2')).click();
    browser.waitForAngular();
    relationships = element.all(by.repeater('(relationshipName,relationshipDefinition) in selectedNodeTemplate.relationships'));
    expect(relationships.count()).toBe(0);
    element(by.id('rect_Compute')).click();
    browser.waitForAngular();
    relationships = element.all(by.repeater('(relationshipName,relationshipDefinition) in selectedNodeTemplate.relationships'));
    expect(relationships.count()).toBe(0);
  });

  it('should be able to delete an application from the search list and the application\'s detail page', function() {
    console.log('################# should be able to delete an application from the search list and the application\'s detail page');
    applications.createApplication('Alien_1', 'Great Application 1');
    applications.createApplication('Alien_2', 'Great Application 2');
    applications.createApplication('Alien_3', 'Great Application 3');
    applications.goToApplicationListPage('main', 'applications');
    // delete application from the search list
    common.deleteWithConfirm('delete-app_Alien_1', true);
    expect(appElement.isPresent()).toBe(false);

    // cancel a delete action
    common.deleteWithConfirm('delete-app_Alien_3', false);
    expect(appElement.isPresent()).toBe(true);

    // delete application from it detail page
    appElement = element(by.id('app_Alien_2'));
    applications.goToApplicationDetailPage('Alien_2');
    common.deleteWithConfirm('btn-delete-app', true);
    expect(appElement.isPresent()).toBe(false);

  });

  it('should be able to edit an application', function() {
    console.log('################# should be able to rename an application');
    // Create an application
    applications.createApplication('MyNewApplication1', 'A brand new application...');
    applications.createApplication('MyNewApplication2', 'A rband new application...');
    applications.goToApplicationDetailPage('MyNewApplication1');

    // Rename the application with a non existing name
    common.sendValueToXEditable('app-name', 'NewNameForMyApp', false);
    expect(element(by.binding('application.name')).getText()).toEqual('NewNameForMyApp');
    common.expectNoErrors();

    // Change the application's description
    common.sendValueToXEditable('app-desc', 'Some Description', false, 'textarea');
    expect(element(by.binding('application.description')).getText()).toEqual('Some Description');
    common.expectNoErrors();

    // Rename with an existing application name
    common.sendValueToXEditable('app-name', 'MyNewApplication2', false);
    common.abortXEditable('app-name');
    common.expectTitleMessage('409'); // server 'AlreadyExist' exception error code
    common.dismissAlert();
  });

});
<commit_msg>Correct UI test (app details do not turn anymore on mouse over)<commit_after>/* global by, element */

'use strict';

var authentication = require('../authentication/authentication');
var common = require('../common/common');
var topologyEditorCommon = require('../topology/topology_editor_common');
var topologyTemplates = require('../topology/topology_templates_common');
var applications = require('../applications/applications');

describe('Applications management :', function() {
  /* Before each spec in the tests suite */
  beforeEach(function() {
    common.before();
    authentication.login('applicationManager');
  });

  /* After each spec in the tests suite(s) */
  afterEach(function() {
    // Logout action
    common.after();
  });

  it('should be able to go to application search page at ' + common.appSearchUrl + ' and create new application', function() {
    console.log('################# should be able to go to application search page at ' + common.appSearchUrl + ' and create new application');
    applications.createApplication('Alien', 'Great Application');
    // Go to the app details page
    expect(browser.element(by.binding('application.name')).getText()).toEqual('Alien');
    expect(browser.element(by.binding('application.description')).getText()).toEqual('Great Application');
  });

  it('should create first a topology template with 3 node templates (COMPUTE, JAVA, TOMCATRPM) and an application based on this template', function() {
    console.log('################# should create first a topology template with 3 node templates (COMPUTE, JAVA, TOMCATRPM) and an application based on this template');
    // Login as architect to create a topology template
    authentication.reLogin('architect');

    // create a topology template with one Compute, 1 Java and 1 Tomcat RPM
    topologyTemplates.createTopologyTemplateWithNodesAndRelationships(topologyEditorCommon.topologyTemplates.template4);

    // create a new application with this template as model
    authentication.reLogin('applicationManager');
    // template at index 2 is the first and only one created (index 1 equals is the default, no template)
    applications.createApplication('JavaTomcatWarApplication', 'Simple application with one compute, one template and all that around java...', 2);

    // check the created topology application (count nodes, count relationship..)
    applications.goToApplicationDetailPage('JavaTomcatWarApplication', true);

    // check relationship count
    // check relationship count
    element(by.id('rect_JavaRPM')).click();
    browser.waitForAngular();
    var relationships = element.all(by.repeater('(relationshipName,relationshipDefinition) in selectedNodeTemplate.relationships'));
    expect(relationships.count()).toBe(2);
    element(by.id('rect_Compute_2')).click();
    browser.waitForAngular();
    relationships = element.all(by.repeater('(relationshipName,relationshipDefinition) in selectedNodeTemplate.relationships'));
    expect(relationships.count()).toBe(0);
    element(by.id('rect_Compute')).click();
    browser.waitForAngular();
    relationships = element.all(by.repeater('(relationshipName,relationshipDefinition) in selectedNodeTemplate.relationships'));
    expect(relationships.count()).toBe(0);
  });

  it('should be able to delete an application from the search list and the application\'s detail page', function() {
    console.log('################# should be able to delete an application from the search list and the application\'s detail page');
    applications.createApplication('Alien_1', 'Great Application 1');
    applications.createApplication('Alien_2', 'Great Application 2');
    applications.createApplication('Alien_3', 'Great Application 3');
    applications.goToApplicationListPage('main', 'applications');
    // delete application from the search list
    common.deleteWithConfirm('delete-app_Alien_1', true);
    expect(element(by.id('app_Alien_1')).isPresent()).toBe(false);

    // cancel a delete action
    common.deleteWithConfirm('delete-app_Alien_3', false);
    expect(element(by.id('app_Alien_3')).isPresent()).toBe(true);

    // delete application from it detail page
    applications.goToApplicationDetailPage('Alien_2');
    common.deleteWithConfirm('btn-delete-app', true);
    expect(element(by.id('app_Alien_2')).isPresent()).toBe(false);
  });

  it('should be able to edit an application', function() {
    console.log('################# should be able to rename an application');
    // Create an application
    applications.createApplication('MyNewApplication1', 'A brand new application...');
    applications.createApplication('MyNewApplication2', 'A rband new application...');
    applications.goToApplicationDetailPage('MyNewApplication1');

    // Rename the application with a non existing name
    common.sendValueToXEditable('app-name', 'NewNameForMyApp', false);
    expect(element(by.binding('application.name')).getText()).toEqual('NewNameForMyApp');
    common.expectNoErrors();

    // Change the application's description
    common.sendValueToXEditable('app-desc', 'Some Description', false, 'textarea');
    expect(element(by.binding('application.description')).getText()).toEqual('Some Description');
    common.expectNoErrors();

    // Rename with an existing application name
    common.sendValueToXEditable('app-name', 'MyNewApplication2', false);
    common.abortXEditable('app-name');
    common.expectTitleMessage('409'); // server 'AlreadyExist' exception error code
    common.dismissAlert();
  });

});
<|endoftext|>


<commit_before>"use strict";
// DO NOT EDIT THIS FILE, EDIT THE GRUNT TASK NGCONSTANT SETTINGS INSTEAD WHICH GENERATES THIS FILE
angular.module('publisherApp')

.constant('ENV', 'dev')

.constant('VERSION', '2.0.2-SNAPSHOT')

;<commit_msg>release: set version ngconstant<commit_after>"use strict";
// DO NOT EDIT THIS FILE, EDIT THE GRUNT TASK NGCONSTANT SETTINGS INSTEAD WHICH GENERATES THIS FILE
angular.module('publisherApp')

.constant('ENV', 'dev')

.constant('VERSION', '2.0.2')

;<|endoftext|>


<commit_before>const React = require('react');
const { Link } = require('react-router');

const { Select } = require('mx-react-components');

const Components = React.createClass({
  contextTypes: {
    router: React.PropTypes.object.isRequired
  },

  _handleChange (selected) {
    this.context.router.push('/components/' + selected.value);
  },

  render () {
    return (

            <Select
              onChange={this._handleChange}
              options={[
                {
                  value: 'button',
                  displayValue: 'Button'
                },
                {
                  value: 'button-group',
                  displayValue: 'Button Group'
                },
                {
                  value: 'date-picker',
                  displayValue: 'Date Picker'
                },
                {
                  value: 'date-picker-full-screen',
                  displayValue: 'Date Picker Full Screen'
                },
                {
                  value: 'date-range-picker',
                  displayValue: 'Date Range Picker'
                },
                {
                  value: 'date-time-picker',
                  displayValue: 'Date Time Picker'
                },
                {
                  value: 'display-input',
                  displayValue: 'Display Input'
                },
                {
                  value: 'drawer',
                  displayValue: 'Drawer'
                },
                {
                  value: 'donut',
                  displayValue: 'Donut'
                },
                {
                  value: 'file-upload',
                  displayValue: 'File Upload'
                },
                {
                  value: 'gauge',
                  displayValue: 'Gauge'
                },
                {
                  value: 'icon',
                  displayValue: 'Icon'
                },
                {
                  value: 'loader',
                  displayValue: 'Loader'
                },
                {
                  value: 'menu',
                  displayValue: 'Menu'
                },
                {
                  value: 'modal',
                  displayValue: 'Modal'
                },
                {
                  value: 'notify-on-scroll-threshold',
                  displayValue: 'Notify On Scroll Threshold'
                },
                {
                  value: 'page-indicator',
                  displayValue: 'Page Indicator'
                },
                {
                  value: 'pagination-buttons',
                  displayValue: 'Pagination Buttons'
                },
                {
                  value: 'progress-bar',
                  displayValue: 'Progress Bar'
                },
                {
                  value: 'radio-button',
                  displayValue: 'Radio Button'
                },
                {
                  value: 'raja-icon',
                  displayValue: 'Raja Icon'
                },
                {
                  value: 'range-selector',
                  displayValue: 'Range Selector'
                },
                {
                  value: 'row-column',
                  displayValue: 'Grid Row & Column'
                },
                {
                  value: 'select',
                  displayValue: 'Select'
                },
                {
                  value: 'simple-slider',
                  displayValue: 'Simple Slider'
                },
                {
                  value: 'select-full-screen',
                  displayValue: 'Select Full Screen'
                },
                {
                  value: 'spin',
                  displayValue: 'Spin'
                },
                {
                  value: 'styles',
                  displayValue: 'Styles'
                },
                {
                  value: 'time-based-line-chart',
                  displayValue: 'Time Based Line Chart'
                },
                {
                  value: 'textarea',
                  displayValue: 'TextArea'
                },
                {
                  value: 'tabs',
                  displayValue: 'Tabs'
                },
                {
                  value: 'toggle-switch',
                  displayValue: 'Toggle Switch'
                },
                {
                  value: 'type-ahead',
                  displayValue: 'Type Ahead'
                }
              ]}
              selected={null}
              valid={true}
            />

General

            <Link to='/components/icon'>Icon</Link>
            <Link to='/components/raja-icon'>Raja Icon</Link>
            <Link to='/components/loader'>Loader</Link>
            <Link to='/components/menu'>Menu</Link>
            <Link to='/components/message-box'>MessageBox</Link>
            <Link to='/components/modal'>Modal</Link>
            <Link to='/components/notify-on-scroll-threshold'>Notify On Scroll Threshold</Link>
            <Link to='/components/page-indicator'>Page Indicator</Link>
            <Link to='/components/pagination-buttons'>Pagination Buttons</Link>
            <Link to='/components/progress-bar'>Progress Bar</Link>
            <Link to='/components/spin'>Spin</Link>

Form

            <Link to='/components/button'>Button</Link>
            <Link to='/components/button-group'>Button Group</Link>
            <Link to='/components/date-picker'>Date Picker</Link>
            <Link to='/components/date-picker-full-screen'>Date Picker Full Screen</Link>
            <Link to='/components/date-range-picker'>Date Range Picker</Link>
            <Link to='/components/date-time-picker'>Date Time Picker</Link>
            <Link to='/components/display-input'>Display Input</Link>
            <Link to='/components/drawer'>Drawer</Link>
            <Link to='/components/file-upload'>File Upload</Link>
            <Link to='/components/radio-button'>Radio Button</Link>
            <Link to='/components/range-selector'>Range Selector</Link>
            <Link to='/components/search-input'>Search Input</Link>
            <Link to='/components/select'>Select</Link>
            <Link to='/components/select-full-screen'>Select Full Screen</Link>
            <Link to='/components/simple-input'>Simple Input</Link>
            <Link to='/components/simple-select'>Simple Select</Link>
            <Link to='/components/simple-slider'>Simple Slider</Link>
            <Link to='/components/textarea'>TextArea</Link>
            <Link to='/components/tabs'>Tabs</Link>
            <Link to='/components/toggle-switch'>Toggle Switch</Link>
            <Link to='/components/type-ahead'>Type Ahead</Link>

Charts (D3)

            <Link to='/components/bar'>Bar</Link>
            <Link to='/components/donut'>Donut</Link>
            <Link to='/components/gauge'>Gauge</Link>
            <Link to='/components/time-based-line-chart'>Time Based Line Chart</Link>

Responsive Grid

            <Link to='/components/row-column'>Row & Column</Link>

Helpers

            <Link to='/components/styles'>Styles</Link>

          {this.props.children}

    );
  }
});

module.exports = Components;
<commit_msg>container fluid for testing component resize<commit_after>const React = require('react');
const { Link } = require('react-router');

const { Select } = require('mx-react-components');

const Components = React.createClass({
  contextTypes: {
    router: React.PropTypes.object.isRequired
  },

  _handleChange (selected) {
    this.context.router.push('/components/' + selected.value);
  },

  render () {
    return (

            <Select
              onChange={this._handleChange}
              options={[
                {
                  value: 'button',
                  displayValue: 'Button'
                },
                {
                  value: 'button-group',
                  displayValue: 'Button Group'
                },
                {
                  value: 'date-picker',
                  displayValue: 'Date Picker'
                },
                {
                  value: 'date-picker-full-screen',
                  displayValue: 'Date Picker Full Screen'
                },
                {
                  value: 'date-range-picker',
                  displayValue: 'Date Range Picker'
                },
                {
                  value: 'date-time-picker',
                  displayValue: 'Date Time Picker'
                },
                {
                  value: 'display-input',
                  displayValue: 'Display Input'
                },
                {
                  value: 'drawer',
                  displayValue: 'Drawer'
                },
                {
                  value: 'donut',
                  displayValue: 'Donut'
                },
                {
                  value: 'file-upload',
                  displayValue: 'File Upload'
                },
                {
                  value: 'gauge',
                  displayValue: 'Gauge'
                },
                {
                  value: 'icon',
                  displayValue: 'Icon'
                },
                {
                  value: 'loader',
                  displayValue: 'Loader'
                },
                {
                  value: 'menu',
                  displayValue: 'Menu'
                },
                {
                  value: 'modal',
                  displayValue: 'Modal'
                },
                {
                  value: 'notify-on-scroll-threshold',
                  displayValue: 'Notify On Scroll Threshold'
                },
                {
                  value: 'page-indicator',
                  displayValue: 'Page Indicator'
                },
                {
                  value: 'pagination-buttons',
                  displayValue: 'Pagination Buttons'
                },
                {
                  value: 'progress-bar',
                  displayValue: 'Progress Bar'
                },
                {
                  value: 'radio-button',
                  displayValue: 'Radio Button'
                },
                {
                  value: 'raja-icon',
                  displayValue: 'Raja Icon'
                },
                {
                  value: 'range-selector',
                  displayValue: 'Range Selector'
                },
                {
                  value: 'row-column',
                  displayValue: 'Grid Row & Column'
                },
                {
                  value: 'select',
                  displayValue: 'Select'
                },
                {
                  value: 'simple-slider',
                  displayValue: 'Simple Slider'
                },
                {
                  value: 'select-full-screen',
                  displayValue: 'Select Full Screen'
                },
                {
                  value: 'spin',
                  displayValue: 'Spin'
                },
                {
                  value: 'styles',
                  displayValue: 'Styles'
                },
                {
                  value: 'time-based-line-chart',
                  displayValue: 'Time Based Line Chart'
                },
                {
                  value: 'textarea',
                  displayValue: 'TextArea'
                },
                {
                  value: 'tabs',
                  displayValue: 'Tabs'
                },
                {
                  value: 'toggle-switch',
                  displayValue: 'Toggle Switch'
                },
                {
                  value: 'type-ahead',
                  displayValue: 'Type Ahead'
                }
              ]}
              selected={null}
              valid={true}
            />

General

            <Link to='/components/icon'>Icon</Link>
            <Link to='/components/raja-icon'>Raja Icon</Link>
            <Link to='/components/loader'>Loader</Link>
            <Link to='/components/menu'>Menu</Link>
            <Link to='/components/message-box'>MessageBox</Link>
            <Link to='/components/modal'>Modal</Link>
            <Link to='/components/notify-on-scroll-threshold'>Notify On Scroll Threshold</Link>
            <Link to='/components/page-indicator'>Page Indicator</Link>
            <Link to='/components/pagination-buttons'>Pagination Buttons</Link>
            <Link to='/components/progress-bar'>Progress Bar</Link>
            <Link to='/components/spin'>Spin</Link>

Form

            <Link to='/components/button'>Button</Link>
            <Link to='/components/button-group'>Button Group</Link>
            <Link to='/components/date-picker'>Date Picker</Link>
            <Link to='/components/date-picker-full-screen'>Date Picker Full Screen</Link>
            <Link to='/components/date-range-picker'>Date Range Picker</Link>
            <Link to='/components/date-time-picker'>Date Time Picker</Link>
            <Link to='/components/display-input'>Display Input</Link>
            <Link to='/components/drawer'>Drawer</Link>
            <Link to='/components/file-upload'>File Upload</Link>
            <Link to='/components/radio-button'>Radio Button</Link>
            <Link to='/components/range-selector'>Range Selector</Link>
            <Link to='/components/search-input'>Search Input</Link>
            <Link to='/components/select'>Select</Link>
            <Link to='/components/select-full-screen'>Select Full Screen</Link>
            <Link to='/components/simple-input'>Simple Input</Link>
            <Link to='/components/simple-select'>Simple Select</Link>
            <Link to='/components/simple-slider'>Simple Slider</Link>
            <Link to='/components/textarea'>TextArea</Link>
            <Link to='/components/tabs'>Tabs</Link>
            <Link to='/components/toggle-switch'>Toggle Switch</Link>
            <Link to='/components/type-ahead'>Type Ahead</Link>

Charts (D3)

            <Link to='/components/bar'>Bar</Link>
            <Link to='/components/donut'>Donut</Link>
            <Link to='/components/gauge'>Gauge</Link>
            <Link to='/components/time-based-line-chart'>Time Based Line Chart</Link>

Responsive Grid

            <Link to='/components/row-column'>Row & Column</Link>

Helpers

            <Link to='/components/styles'>Styles</Link>

          {this.props.children}

    );
  }
});

module.exports = Components;
<|endoftext|>


<commit_before>var Post = require('./post.model');

/**
* Adds new comment to the post
*/
exports.create = function (req, res, next) {
  var postId = req.params.id;
  var comment = req.body.comment;
  comment.date = Date.now();

  Post.findById(req.params.id, function(error, post){
    if(err) { return handleError(res, err); }
    post.comments.push(comment);
    post.save();
  });
};
<commit_msg>quick fix<commit_after>var Post = require('../post.model');

/**
* Adds new comment to the post
*/
exports.create = function (req, res, next) {
  var postId = req.params.id;
  var comment = req.body.comment;
  comment.date = Date.now();

  Post.findById(req.params.id, function(error, post){
    if(err) { return handleError(res, err); }
    post.comments.push(comment);
    post.save();
  });
};
<|endoftext|>


<commit_before>define(function(require, exports, module) {
    var Marionette = require('marionette'),
        $ = require ('jquery'),
        UserView = require('userView'),
        emptyUserView = require('emptyUserView'),
        MainUserListView = require('hbs!user-list/view/templates/main-user-list-view');

    module.exports = Marionette.CompositeView.extend({
        template: MainUserListView,
        childView: UserView,
        childViewContainer: '#userList',
        childEvents:{
            'user:removed': 'userClickedM'
        },

        events: {
            'change #filter-name' :'changed',
            'click .js-add-new-user': 'addNewUser'

        },

        getEmptyView: function() {
            return emptyUserView;
        },

        userClickedM: function (view, model) {
            var confirm_result = confirm('Are you sure you want to remove ' + model.get('firstName')+ ' ' + model.get('lastName') + ' from the system?');

            if (confirm_result === true) {
                model.destroy();
            }
        },

        changed: function(evt) {
            this.trigger('filter:users:name:applied', evt.currentTarget.value);
        },

        addNewUser: function(){
            this.collection.unshift({'image_path': 'images/male.jpg', 'addPass':'true'});
            this.trigger('filter:users:name:applied', '');
           // $('#filter-name').val('');*/
        }

    });

});<commit_msg>fix bag with userList filter<commit_after>define(function(require, exports, module) {
    var Marionette = require('marionette'),
        $ = require ('jquery'),
        UserView = require('userView'),
        emptyUserView = require('emptyUserView'),
        MainUserListView = require('hbs!user-list/view/templates/main-user-list-view');

    module.exports = Marionette.CompositeView.extend({
        template: MainUserListView,
        childView: UserView,
        childViewContainer: '#userList',
        childEvents:{
            'user:removed': 'userClickedM'
        },

        events: {
            'change #filter-name' :'changed',
            'click .js-add-new-user': 'addNewUser'

        },

        getEmptyView: function() {
            return emptyUserView;
        },

        userClickedM: function (view, model) {
            var confirm_result = confirm('Are you sure you want to remove ' + model.get('firstName')+ ' ' + model.get('lastName') + ' from the system?');

            if (confirm_result === true) {
                model.destroy();
            }
        },

        changed: function(evt) {
            this.trigger('filter:users:name:applied', evt.currentTarget.value);
        },

        addNewUser: function(){
            this.collection.unshift({'image_path': 'images/male.jpg', 'addPass':'true', 'lastName':''});
            this.trigger('filter:users:name:applied', '');
            $('#filter-name').val('');
        }

    });

});<|endoftext|>


<commit_before>define([
      'knockout'
    , './models/message'
], function (ko, MessageModel) {
    util = {}
    util.ajax_fail = function(messages_ob) {
        return function (jqXHR, textStatus, errorThrown) {
            var message = (jqXHR.responseJSON || {})['message'] || textStatus
            messages_ob([
                new MessageModel({'message': message, 'category': 'danger'})
            ])
        }
    }
    util.param = function(value, def, obsType) {
        return typeof(value) === 'function' ? value : util._paramObs(value, def, obsType)
    }
    util.paramArray = function(value, def) {
        return util.param(value, def, ko.observableArray)
    }
    util._paramObs = function(value, def, obsType) {
        obsType = typeof(obsType) === 'undefined' ? ko.observable : obsType
        return obsType(
            typeof(value) !== 'undefined' ? value : util._paramDef(def)
        )
    }
    util._paramDef = function(def) {
        return typeof(def) === 'function' ? def() : def
    }
    return util
})
<commit_msg>Handle multi field errors in FE<commit_after>define([
      'knockout'
    , './models/message'
], function (ko, MessageModel) {
    util = {}
    util.ajax_fail = function(messages_ob) {
        return function (jqXHR, textStatus, errorThrown) {
            var message = (jqXHR.responseJSON || {})['message'] || textStatus
            if(typeof(message) === 'object') {
                // TODO use fields to add messages next to inputs
                messages_ob($.map(message, function(message){
                    return new MessageModel(
                        {'message': message, 'category': 'danger'}
                    )
                }))
            } else {
                messages_ob([new MessageModel(
                    {'message': message, 'category': 'danger'}
                )])
            }
        }
    }
    util.param = function(value, def, obsType) {
        return typeof(value) === 'function' ? value : util._paramObs(value, def, obsType)
    }
    util.paramArray = function(value, def) {
        return util.param(value, def, ko.observableArray)
    }
    util._paramObs = function(value, def, obsType) {
        obsType = typeof(obsType) === 'undefined' ? ko.observable : obsType
        return obsType(
            typeof(value) !== 'undefined' ? value : util._paramDef(def)
        )
    }
    util._paramDef = function(def) {
        return typeof(def) === 'function' ? def() : def
    }
    return util
})
<|endoftext|>