<commit_before>"use strict";
var expect        = require("chai").expect;
var fixtures      = require("./helpers/fixtures");
var Sinon         = require("sinon");
var _             = require("lodash");

var Response      = require("../lib/Response");
var ContactRecord = require("../lib/ContactRecord");
var util          = require("../lib/util");

describe("The util module", function () {
	describe("extracting a list of contacts from a response", function () {
		var response;
		var parse;
		var contacts;

		before(function () {
			parse = Sinon.stub(ContactRecord, "parse");

			response = {
				code    : "200",
				message : "OK",
				success : true,
				body    :
				[
					"AOR:: +883511000000755@dev.ringto.bwapp-stage.stage.bwsip.io",
					"\tContact:: sip:ringto_user_1495526@187.42.31.10:42817;ob Q=0.5",
					"\t\tExpires:: 2336",
					"\t\tCallid:: FJas.XiUKJXQGWt4nfpISbRFFwCgWwd5",
					"\t\tCseq:: 43646",
					"\t\tUser-agent:: BWSip Framework v1.0",
					"\t\tReceived:: sip:187.42.31.10:42817",
					"\t\tState:: CS_NEW",
					"\t\tFlags:: 0",
					"\t\tCflags:: ",
					"\t\tSocket:: udp:52.4.77.11:9060",
					"\t\tMethods:: 8063",
					"\tContact:: sip:ringto_user_1495526@177.135.168.30:59999;transport=TCP;ob",
					"\t\tExpires:: 94",
					"\t\tCallid:: dVYWN9riDOONNlKZKzanWOKlZjIYziYi",
					"\t\tCseq:: 65094",
					"\t\tUser-agent:: BWSip Framework v1.0",
					"\t\tReceived:: sip:177.135.168.30:59999",
					"\t\tState:: CS_NEW",
					"\t\tFlags:: 0",
					"\t\tCflags:: ",
					"\t\tSocket:: tcp:52.4.77.11:9060",
					"\t\tMethods:: 8063",
					"\t\tSIP_instance:: <urn:uuid:00000000-0000-0000-0000-00008340d0fa>"
				]
			};
			contacts = util.extractContactList(response);
		});
		after(function () {
			parse.restore();
		});

		it("parses each contact of the body as a ContactRecord", function () {
			expect(parse.callCount).to.equal(2);
		});
	});
	describe("integrating with ContactRecord to parse the contacts", function () {
		var resultNew;
		var expectedResult;
		var response;
		before(function () {
			expectedResult = [
				{
					contact    : "sip:ringto_user_1495526@187.42.31.10:42817;ob",
					properties :
					{
						Q            : "0.5",
						Expires      : "2336",
						Callid       : "FJas.XiUKJXQGWt4nfpISbRFFwCgWwd5",
						Cseq         : "43646",
						"User-agent" : "BWSip Framework v1.0",
						Received     : "sip:187.42.31.10:42817",
						State        : "CS_NEW",
						Flags        : "0",
						Cflags       : "",
						Socket       : "udp:52.4.77.11:9060",
						Methods      : "8063"
					}
				},
				{
					contact    : "sip:ringto_user_1495526@177.135.168.30:59999;transport=TCP;ob",
					properties :
					{
						Expires      : "94",
						Callid       : "dVYWN9riDOONNlKZKzanWOKlZjIYziYi",
						Cseq         : "65094",
						"User-agent" : "BWSip Framework v1.0",
						Received     : "sip:177.135.168.30:59999",
						State        : "CS_NEW",
						Flags        : "0",
						Cflags       : "",
						Socket       : "tcp:52.4.77.11:9060",
						Methods      : "8063",
						SIP_instance : "<urn:uuid:00000000-0000-0000-0000-00008340d0fa>"
					}
				}
			];
			response = {
				code    : "200",
				message : "OK",
				success : true,
				body    :
				[
					"AOR:: +883511000000755@dev.ringto.bwapp-stage.stage.bwsip.io",
					"\tContact:: sip:ringto_user_1495526@187.42.31.10:42817;ob Q=0.5",
					"\t\tExpires:: 2336",
					"\t\tCallid:: FJas.XiUKJXQGWt4nfpISbRFFwCgWwd5",
					"\t\tCseq:: 43646",
					"\t\tUser-agent:: BWSip Framework v1.0",
					"\t\tReceived:: sip:187.42.31.10:42817",
					"\t\tState:: CS_NEW",
					"\t\tFlags:: 0",
					"\t\tCflags:: ",
					"\t\tSocket:: udp:52.4.77.11:9060",
					"\t\tMethods:: 8063",
					"\tContact:: sip:ringto_user_1495526@177.135.168.30:59999;transport=TCP;ob",
					"\t\tExpires:: 94",
					"\t\tCallid:: dVYWN9riDOONNlKZKzanWOKlZjIYziYi",
					"\t\tCseq:: 65094",
					"\t\tUser-agent:: BWSip Framework v1.0",
					"\t\tReceived:: sip:177.135.168.30:59999",
					"\t\tState:: CS_NEW",
					"\t\tFlags:: 0",
					"\t\tCflags:: ",
					"\t\tSocket:: tcp:52.4.77.11:9060",
					"\t\tMethods:: 8063",
					"\t\tSIP_instance:: <urn:uuid:00000000-0000-0000-0000-00008340d0fa>"
				]
			};
		});
		it("returns the correct Contact Properties", function () {
			resultNew = util.extractContactList(response);
			expect(resultNew).to.deep.equal(expectedResult);
		});
	});
});
<commit_msg>Fixed test lib.<commit_after>"use strict";
var expect        = require("chai").expect;
var Sinon         = require("sinon");

var ContactRecord = require("../lib/ContactRecord");
var util          = require("../lib/util");

describe("The util module", function () {
	describe("extracting a list of contacts from a response", function () {
		var response;
		var parse;
		var contacts;

		before(function () {
			parse = Sinon.stub(ContactRecord, "parse");

			response = {
				code    : "200",
				message : "OK",
				success : true,
				body    :
				[
					"AOR:: +883511000000755@dev.ringto.bwapp-stage.stage.bwsip.io",
					"\tContact:: sip:ringto_user_1495526@187.42.31.10:42817;ob Q=0.5",
					"\t\tExpires:: 2336",
					"\t\tCallid:: FJas.XiUKJXQGWt4nfpISbRFFwCgWwd5",
					"\t\tCseq:: 43646",
					"\t\tUser-agent:: BWSip Framework v1.0",
					"\t\tReceived:: sip:187.42.31.10:42817",
					"\t\tState:: CS_NEW",
					"\t\tFlags:: 0",
					"\t\tCflags:: ",
					"\t\tSocket:: udp:52.4.77.11:9060",
					"\t\tMethods:: 8063",
					"\tContact:: sip:ringto_user_1495526@177.135.168.30:59999;transport=TCP;ob",
					"\t\tExpires:: 94",
					"\t\tCallid:: dVYWN9riDOONNlKZKzanWOKlZjIYziYi",
					"\t\tCseq:: 65094",
					"\t\tUser-agent:: BWSip Framework v1.0",
					"\t\tReceived:: sip:177.135.168.30:59999",
					"\t\tState:: CS_NEW",
					"\t\tFlags:: 0",
					"\t\tCflags:: ",
					"\t\tSocket:: tcp:52.4.77.11:9060",
					"\t\tMethods:: 8063",
					"\t\tSIP_instance:: <urn:uuid:00000000-0000-0000-0000-00008340d0fa>"
				]
			};
			contacts = util.extractContactList(response);
		});
		after(function () {
			parse.restore();
		});

		it("parses each contact of the body as a ContactRecord", function () {
			expect(parse.callCount).to.equal(2);
		});
	});
	describe("integrating with ContactRecord to parse the contacts", function () {
		var resultNew;
		var expectedResult;
		var response;
		before(function () {
			expectedResult = [
				{
					contact    : "sip:ringto_user_1495526@187.42.31.10:42817;ob",
					properties :
					{
						Q            : "0.5",
						Expires      : "2336",
						Callid       : "FJas.XiUKJXQGWt4nfpISbRFFwCgWwd5",
						Cseq         : "43646",
						"User-agent" : "BWSip Framework v1.0",
						Received     : "sip:187.42.31.10:42817",
						State        : "CS_NEW",
						Flags        : "0",
						Cflags       : "",
						Socket       : "udp:52.4.77.11:9060",
						Methods      : "8063"
					}
				},
				{
					contact    : "sip:ringto_user_1495526@177.135.168.30:59999;transport=TCP;ob",
					properties :
					{
						Expires      : "94",
						Callid       : "dVYWN9riDOONNlKZKzanWOKlZjIYziYi",
						Cseq         : "65094",
						"User-agent" : "BWSip Framework v1.0",
						Received     : "sip:177.135.168.30:59999",
						State        : "CS_NEW",
						Flags        : "0",
						Cflags       : "",
						Socket       : "tcp:52.4.77.11:9060",
						Methods      : "8063",
						SIP_instance : "<urn:uuid:00000000-0000-0000-0000-00008340d0fa>"
					}
				}
			];
			response = {
				code    : "200",
				message : "OK",
				success : true,
				body    :
				[
					"AOR:: +883511000000755@dev.ringto.bwapp-stage.stage.bwsip.io",
					"\tContact:: sip:ringto_user_1495526@187.42.31.10:42817;ob Q=0.5",
					"\t\tExpires:: 2336",
					"\t\tCallid:: FJas.XiUKJXQGWt4nfpISbRFFwCgWwd5",
					"\t\tCseq:: 43646",
					"\t\tUser-agent:: BWSip Framework v1.0",
					"\t\tReceived:: sip:187.42.31.10:42817",
					"\t\tState:: CS_NEW",
					"\t\tFlags:: 0",
					"\t\tCflags:: ",
					"\t\tSocket:: udp:52.4.77.11:9060",
					"\t\tMethods:: 8063",
					"\tContact:: sip:ringto_user_1495526@177.135.168.30:59999;transport=TCP;ob",
					"\t\tExpires:: 94",
					"\t\tCallid:: dVYWN9riDOONNlKZKzanWOKlZjIYziYi",
					"\t\tCseq:: 65094",
					"\t\tUser-agent:: BWSip Framework v1.0",
					"\t\tReceived:: sip:177.135.168.30:59999",
					"\t\tState:: CS_NEW",
					"\t\tFlags:: 0",
					"\t\tCflags:: ",
					"\t\tSocket:: tcp:52.4.77.11:9060",
					"\t\tMethods:: 8063",
					"\t\tSIP_instance:: <urn:uuid:00000000-0000-0000-0000-00008340d0fa>"
				]
			};
		});
		it("returns the correct Contact Properties", function () {
			resultNew = util.extractContactList(response);
			expect(resultNew).to.deep.equal(expectedResult);
		});
	});
});
<|endoftext|>


<commit_before>/*globals describe it beforeEach afterEach */
require("should");
var path = require("path");
var TestHelper = require("./helpers/TestHelper");
var Watchpack = require("../lib/watchpack");

var fixtures = path.join(__dirname, "fixtures");
var testHelper = new TestHelper(fixtures);

describe("Watchpack", function() {
	this.timeout(10000);
	beforeEach(testHelper.before);
	afterEach(testHelper.after);

	it("should watch a single file", function(done) {
		var w = new Watchpack({
			aggregateTimeout: 1000
		});
		var changeEvents = 0;
		w.on("change", function(file) {
			file.should.be.eql(path.join(fixtures, "a"));
			changeEvents++;
		});
		w.on("aggregated", function(changes) {
			changes.should.be.eql([path.join(fixtures, "a")]);
			changeEvents.should.be.eql(1);
			w.close();
			done();
		});
		w.watch([path.join(fixtures, "a")], []);
		testHelper.tick(function() {
			testHelper.file("a");
		});
	});

	it("should watch multiple files", function(done) {
		var w = new Watchpack({
			aggregateTimeout: 1000
		});
		var changeEvents = [];
		w.on("change", function(file) {
			if(changeEvents[changeEvents.length - 1] === file)
				return;
			changeEvents.push(file);
		});
		w.on("aggregated", function(changes) {
			changes.sort().should.be.eql([path.join(fixtures, "a"), path.join(fixtures, "b")]);
			changeEvents.should.be.eql([
				path.join(fixtures, "a"),
				path.join(fixtures, "b"),
				path.join(fixtures, "a"),
				path.join(fixtures, "b"),
				path.join(fixtures, "a")
			]);
			Object.keys(w.getTimes()).sort().should.be.eql([
				path.join(fixtures, "a"),
				path.join(fixtures, "b")
			]);
			w.close();
			done();
		});
		w.watch([path.join(fixtures, "a"), path.join(fixtures, "b")], []);
		testHelper.tick(function() {
			testHelper.file("a");
			testHelper.tick(function() {
				testHelper.file("b");
				testHelper.tick(function() {
					testHelper.file("a");
					testHelper.tick(function() {
						testHelper.file("b");
						testHelper.tick(function() {
							testHelper.file("a");
						});
					});
				});
			});
		});
	});

	it("should watch a directory", function(done) {
		var w = new Watchpack({
			aggregateTimeout: 1000
		});
		var changeEvents = [];
		w.on("change", function(file) {
			if(changeEvents[changeEvents.length - 1] === file)
				return;
			changeEvents.push(file);
		});
		w.on("aggregated", function(changes) {
			changes.should.be.eql([path.join(fixtures, "dir")]);
			changeEvents.should.be.eql([path.join(fixtures, "dir", "a")]);
			w.close();
			done();
		});
		testHelper.dir("dir");
		testHelper.tick(function() {
			w.watch([], [path.join(fixtures, "dir")]);
			testHelper.tick(function() {
				testHelper.file(path.join("dir", "a"));
			});
		});
	});

	it("should watch a directory (delete file)", function(done) {
		var w = new Watchpack({
			aggregateTimeout: 1000
		});
		var changeEvents = [];
		w.on("change", function(file) {
			if(changeEvents[changeEvents.length - 1] === file)
				return;
			changeEvents.push(file);
		});
		w.on("aggregated", function(changes) {
			changes.should.be.eql([path.join(fixtures, "dir")]);
			changeEvents.should.be.eql([path.join(fixtures, "dir", "a")]);
			w.close();
			done();
		});
		testHelper.dir("dir");
		testHelper.file(path.join("dir", "a"));
		testHelper.tick(function() {
			w.watch([], [path.join(fixtures, "dir")]);
			testHelper.tick(function() {
				testHelper.remove(path.join("dir", "a"));
			});
		});
	});

	it("should watch a directory (delete directory)", function(done) {
		var w = new Watchpack({
			aggregateTimeout: 1000
		});
		var changeEvents = [];
		w.on("change", function(file) {
			if(changeEvents[changeEvents.length - 1] === file)
				return;
			changeEvents.push(file);
		});
		w.on("aggregated", function(changes) {
			changes.should.be.eql([path.join(fixtures, "dir")]);
			w.close();
			done();
		});
		testHelper.dir("dir");
		testHelper.dir(path.join("dir", "sub"));
		testHelper.file(path.join("dir", "sub", "a"));
		testHelper.tick(function() {
			w.watch([], [path.join(fixtures, "dir")]);
			testHelper.tick(function() {
				testHelper.remove(path.join("dir", "sub"));
			});
		});
	});

	it("should watch a directory (delete directory2)", function(done) {
		var w = new Watchpack({
			aggregateTimeout: 1000
		});
		var changeEvents = [];
		w.on("change", function(file) {
			if(changeEvents[changeEvents.length - 1] === file)
				return;
			changeEvents.push(file);
		});
		w.on("aggregated", function(changes) {
			changes.should.be.eql([path.join(fixtures, "dir")]);
			changeEvents.should.be.eql([path.join(fixtures, "dir", "sub")]);
			w.close();
			done();
		});
		testHelper.dir("dir");
		testHelper.dir(path.join("dir", "sub"));
		testHelper.tick(function() {
			w.watch([], [path.join(fixtures, "dir")]);
			testHelper.tick(function() {
				testHelper.remove(path.join("dir", "sub"));
			});
		});
	});

	it("should watch already watched directory", function(done) {
		var w = new Watchpack({
			aggregateTimeout: 1000
		});
		var changeEvents = [];
		w.on("change", function(file) {
			if(changeEvents[changeEvents.length - 1] === file)
				return;
			changeEvents.push(file);
		});
		w.on("aggregated", function(changes) {
			changes.should.be.eql([path.join(fixtures, "dir")]);
			changeEvents.should.be.eql([path.join(fixtures, "dir", "a")]);
			w.close();
			done();
		});
		testHelper.dir("dir");
		testHelper.file(path.join("dir", "a"));
		testHelper.tick(function() {
			w.watch([path.join(fixtures, "dir", "a")], []);
			testHelper.tick(function() {
				w.watch([], [path.join(fixtures, "dir")]);
				testHelper.tick(function() {
					testHelper.remove(path.join("dir", "a"));
				});
			});
		});
	});

	it("should watch file in a sub directory", function(done) {
		var w = new Watchpack({
			aggregateTimeout: 1000
		});
		var changeEvents = [];
		w.on("change", function(file) {
			if(changeEvents[changeEvents.length - 1] === file)
				return;
			changeEvents.push(file);
		});
		w.on("aggregated", function(changes) {
			changes.should.be.eql([path.join(fixtures, "dir")]);
			changeEvents.should.be.eql([path.join(fixtures, "dir", "sub", "a")]);
			var times = w.getTimes();
			times[path.join(fixtures, "dir")].should.be.type("number");
			times[path.join(fixtures, "dir")].should.be.eql(times[path.join(fixtures, "dir", "sub", "a")]);
						times[path.join(fixtures, "dir", "sub")].should.be.eql(times[path.join(fixtures, "dir", "sub", "a")]);
			w.close();
			done();
		});
		testHelper.dir("dir");
		testHelper.dir(path.join("dir", "sub"));
		testHelper.tick(function() {
			w.watch([], [path.join(fixtures, "dir")]);
			testHelper.tick(function() {
				testHelper.file(path.join("dir", "sub", "a"));
			});
		});
	});

	it("should watch file in a sub sub directory", function(done) {
		var w = new Watchpack({
			aggregateTimeout: 1000
		});
		var changeEvents = [];
		w.on("change", function(file) {
			if(changeEvents[changeEvents.length - 1] === file)
				return;
			changeEvents.push(file);
		});
		w.on("aggregated", function(changes) {
			changes.should.be.eql([path.join(fixtures, "dir")]);
			changeEvents.should.be.eql([path.join(fixtures, "dir", "sub", "sub", "a")]);
			Object.keys(w.getTimes()).sort().should.be.eql([
				path.join(fixtures, "dir"),
				path.join(fixtures, "dir", "sub"),
				path.join(fixtures, "dir", "sub", "sub"),
				path.join(fixtures, "dir", "sub", "sub", "a")
			]);
			w.close();
			done();
		});
		testHelper.dir("dir");
		testHelper.dir(path.join("dir", "sub"));
		testHelper.dir(path.join("dir", "sub", "sub"));
		testHelper.tick(function() {
			w.watch([], [path.join(fixtures, "dir")]);
			testHelper.tick(function() {
				testHelper.file(path.join("dir", "sub", "sub", "a"));
			});
		});
	});

	it("should detect a single change to future timestamps", function(done) {
		var w = new Watchpack({
			aggregateTimeout: 1000
		});
		var w2 = new Watchpack({
			aggregateTimeout: 1000
		});
		w.on("change", function() {
			throw new Error("should not report change event");
		});
		w.on("aggregated", function() {
			throw new Error("should not report aggregated event");
		});
		testHelper.file("a");
		testHelper.tick(function() {
			w2.watch([path.join(fixtures, "a")], []);
			testHelper.tick(1000, function() { // wait for initial scan
				testHelper.mtime("a", Date.now() + 1000000);
				testHelper.tick(function() {
					w.watch([path.join(fixtures, "a")], []);
					testHelper.tick(function() {
						testHelper.tick(function() {
							w2.close();
							w.close();
							done();
						});
					});
				});
			});
		});
	});

	it("should detect a past change to a file (timestamp)", function(done) {
		var w = new Watchpack({
			aggregateTimeout: 1000
		});
		var changeEvents = 0;
		w.on("change", function(file) {
			file.should.be.eql(path.join(fixtures, "a"));
			changeEvents++;
		});
		w.on("aggregated", function(changes) {
			changes.should.be.eql([path.join(fixtures, "a")]);
			changeEvents.should.be.greaterThan(0);
			w.close();
			done();
		});
		var startTime = Date.now();
		testHelper.tick(function() {
			testHelper.file("a");
			testHelper.tick(function() {
				w.watch([path.join(fixtures, "a")], [], startTime);
			});
		});
	});

	it("should not detect a past change to a file (watched)", function(done) {
		var w2 = new Watchpack();
		var w = new Watchpack();
		w.on("change", function() {
			throw new Error("Should not be detected");
		});
		testHelper.tick(function() {
			testHelper.file("b");
			w2.watch([path.join(fixtures, "b")], []);
			testHelper.tick(1000, function() { // wait for stable state
				testHelper.file("a");
				testHelper.tick(function() {
					var startTime = Date.now();
					testHelper.tick(function() {
						w.watch([path.join(fixtures, "a")], [], startTime);
						testHelper.tick(function() {
							w.close();
							w2.close();
							done();
						});
					});
				});
			});
		});
	});

	it("should detect a past change to a file (watched)", function(done) {
		var w2 = new Watchpack();
		var w = new Watchpack();
		var changeEvents = 0;
		w.on("change", function(file) {
			file.should.be.eql(path.join(fixtures, "a"));
			changeEvents++;
		});
		w.on("aggregated", function(changes) {
			changes.should.be.eql([path.join(fixtures, "a")]);
			changeEvents.should.be.eql(1);
			w.close();
			w2.close();
			done();
		});
		testHelper.tick(function() {
			testHelper.file("b");
			w2.watch([path.join(fixtures, "b")], []);
			testHelper.tick(function() {
				var startTime = Date.now();
				testHelper.tick(function() {
					testHelper.file("a");
					testHelper.tick(function() {
						w.watch([path.join(fixtures, "a")], [], startTime);
					});
				});
			});
		});
	});
});
<commit_msg>added testcase<commit_after>/*globals describe it beforeEach afterEach */
require("should");
var path = require("path");
var TestHelper = require("./helpers/TestHelper");
var Watchpack = require("../lib/watchpack");

var fixtures = path.join(__dirname, "fixtures");
var testHelper = new TestHelper(fixtures);

describe("Watchpack", function() {
	this.timeout(10000);
	beforeEach(testHelper.before);
	afterEach(testHelper.after);

	it("should watch a single file", function(done) {
		var w = new Watchpack({
			aggregateTimeout: 1000
		});
		var changeEvents = 0;
		w.on("change", function(file) {
			file.should.be.eql(path.join(fixtures, "a"));
			changeEvents++;
		});
		w.on("aggregated", function(changes) {
			changes.should.be.eql([path.join(fixtures, "a")]);
			changeEvents.should.be.eql(1);
			w.close();
			done();
		});
		w.watch([path.join(fixtures, "a")], []);
		testHelper.tick(function() {
			testHelper.file("a");
		});
	});

	it("should watch multiple files", function(done) {
		var w = new Watchpack({
			aggregateTimeout: 1000
		});
		var changeEvents = [];
		w.on("change", function(file) {
			if(changeEvents[changeEvents.length - 1] === file)
				return;
			changeEvents.push(file);
		});
		w.on("aggregated", function(changes) {
			changes.sort().should.be.eql([path.join(fixtures, "a"), path.join(fixtures, "b")]);
			changeEvents.should.be.eql([
				path.join(fixtures, "a"),
				path.join(fixtures, "b"),
				path.join(fixtures, "a"),
				path.join(fixtures, "b"),
				path.join(fixtures, "a")
			]);
			Object.keys(w.getTimes()).sort().should.be.eql([
				path.join(fixtures, "a"),
				path.join(fixtures, "b")
			]);
			w.close();
			done();
		});
		w.watch([path.join(fixtures, "a"), path.join(fixtures, "b")], []);
		testHelper.tick(function() {
			testHelper.file("a");
			testHelper.tick(function() {
				testHelper.file("b");
				testHelper.tick(function() {
					testHelper.file("a");
					testHelper.tick(function() {
						testHelper.file("b");
						testHelper.tick(function() {
							testHelper.file("a");
						});
					});
				});
			});
		});
	});

	it("should watch a directory", function(done) {
		var w = new Watchpack({
			aggregateTimeout: 1000
		});
		var changeEvents = [];
		w.on("change", function(file) {
			if(changeEvents[changeEvents.length - 1] === file)
				return;
			changeEvents.push(file);
		});
		w.on("aggregated", function(changes) {
			changes.should.be.eql([path.join(fixtures, "dir")]);
			changeEvents.should.be.eql([path.join(fixtures, "dir", "a")]);
			w.close();
			done();
		});
		testHelper.dir("dir");
		testHelper.tick(function() {
			w.watch([], [path.join(fixtures, "dir")]);
			testHelper.tick(function() {
				testHelper.file(path.join("dir", "a"));
			});
		});
	});

	it("should watch a file than a directory", function(done) {
		var w = new Watchpack({
			aggregateTimeout: 1000
		});
		var changeEvents = [];
		w.on("change", function(file) {
			if(changeEvents[changeEvents.length - 1] === file)
				return;
			changeEvents.push(file);
		});
		w.on("aggregated", function(changes) {
			changes.should.be.eql([path.join(fixtures, "dir")]);
			changeEvents.should.be.eql([path.join(fixtures, "dir", "a")]);
			w.close();
			done();
		});
		testHelper.dir("dir");
		testHelper.file(path.join("dir", "a"));
		testHelper.tick(function() {
			w.watch([path.join(fixtures, "dir", "a")], []);
			testHelper.tick(function() {
				w.watch([path.join(fixtures, "dir")], [path.join(fixtures, "dir")]);
				testHelper.tick(function() {
					testHelper.file(path.join("dir", "a"));
				});
			});
		});
	});

	it("should watch a directory (delete file)", function(done) {
		var w = new Watchpack({
			aggregateTimeout: 1000
		});
		var changeEvents = [];
		w.on("change", function(file) {
			if(changeEvents[changeEvents.length - 1] === file)
				return;
			changeEvents.push(file);
		});
		w.on("aggregated", function(changes) {
			changes.should.be.eql([path.join(fixtures, "dir")]);
			changeEvents.should.be.eql([path.join(fixtures, "dir", "a")]);
			w.close();
			done();
		});
		testHelper.dir("dir");
		testHelper.file(path.join("dir", "a"));
		testHelper.tick(function() {
			w.watch([], [path.join(fixtures, "dir")]);
			testHelper.tick(function() {
				testHelper.remove(path.join("dir", "a"));
			});
		});
	});

	it("should watch a directory (delete directory)", function(done) {
		var w = new Watchpack({
			aggregateTimeout: 1000
		});
		var changeEvents = [];
		w.on("change", function(file) {
			if(changeEvents[changeEvents.length - 1] === file)
				return;
			changeEvents.push(file);
		});
		w.on("aggregated", function(changes) {
			changes.should.be.eql([path.join(fixtures, "dir")]);
			w.close();
			done();
		});
		testHelper.dir("dir");
		testHelper.dir(path.join("dir", "sub"));
		testHelper.file(path.join("dir", "sub", "a"));
		testHelper.tick(function() {
			w.watch([], [path.join(fixtures, "dir")]);
			testHelper.tick(function() {
				testHelper.remove(path.join("dir", "sub"));
			});
		});
	});

	it("should watch a directory (delete directory2)", function(done) {
		var w = new Watchpack({
			aggregateTimeout: 1000
		});
		var changeEvents = [];
		w.on("change", function(file) {
			if(changeEvents[changeEvents.length - 1] === file)
				return;
			changeEvents.push(file);
		});
		w.on("aggregated", function(changes) {
			changes.should.be.eql([path.join(fixtures, "dir")]);
			changeEvents.should.be.eql([path.join(fixtures, "dir", "sub")]);
			w.close();
			done();
		});
		testHelper.dir("dir");
		testHelper.dir(path.join("dir", "sub"));
		testHelper.tick(function() {
			w.watch([], [path.join(fixtures, "dir")]);
			testHelper.tick(function() {
				testHelper.remove(path.join("dir", "sub"));
			});
		});
	});

	it("should watch already watched directory", function(done) {
		var w = new Watchpack({
			aggregateTimeout: 1000
		});
		var changeEvents = [];
		w.on("change", function(file) {
			if(changeEvents[changeEvents.length - 1] === file)
				return;
			changeEvents.push(file);
		});
		w.on("aggregated", function(changes) {
			changes.should.be.eql([path.join(fixtures, "dir")]);
			changeEvents.should.be.eql([path.join(fixtures, "dir", "a")]);
			w.close();
			done();
		});
		testHelper.dir("dir");
		testHelper.file(path.join("dir", "a"));
		testHelper.tick(function() {
			w.watch([path.join(fixtures, "dir", "a")], []);
			testHelper.tick(function() {
				w.watch([], [path.join(fixtures, "dir")]);
				testHelper.tick(function() {
					testHelper.remove(path.join("dir", "a"));
				});
			});
		});
	});

	it("should watch file in a sub directory", function(done) {
		var w = new Watchpack({
			aggregateTimeout: 1000
		});
		var changeEvents = [];
		w.on("change", function(file) {
			if(changeEvents[changeEvents.length - 1] === file)
				return;
			changeEvents.push(file);
		});
		w.on("aggregated", function(changes) {
			changes.should.be.eql([path.join(fixtures, "dir")]);
			changeEvents.should.be.eql([path.join(fixtures, "dir", "sub", "a")]);
			var times = w.getTimes();
			times[path.join(fixtures, "dir")].should.be.type("number");
			times[path.join(fixtures, "dir")].should.be.eql(times[path.join(fixtures, "dir", "sub", "a")]);
						times[path.join(fixtures, "dir", "sub")].should.be.eql(times[path.join(fixtures, "dir", "sub", "a")]);
			w.close();
			done();
		});
		testHelper.dir("dir");
		testHelper.dir(path.join("dir", "sub"));
		testHelper.tick(function() {
			w.watch([], [path.join(fixtures, "dir")]);
			testHelper.tick(function() {
				testHelper.file(path.join("dir", "sub", "a"));
			});
		});
	});

	it("should watch file in a sub sub directory", function(done) {
		var w = new Watchpack({
			aggregateTimeout: 1000
		});
		var changeEvents = [];
		w.on("change", function(file) {
			if(changeEvents[changeEvents.length - 1] === file)
				return;
			changeEvents.push(file);
		});
		w.on("aggregated", function(changes) {
			changes.should.be.eql([path.join(fixtures, "dir")]);
			changeEvents.should.be.eql([path.join(fixtures, "dir", "sub", "sub", "a")]);
			Object.keys(w.getTimes()).sort().should.be.eql([
				path.join(fixtures, "dir"),
				path.join(fixtures, "dir", "sub"),
				path.join(fixtures, "dir", "sub", "sub"),
				path.join(fixtures, "dir", "sub", "sub", "a")
			]);
			w.close();
			done();
		});
		testHelper.dir("dir");
		testHelper.dir(path.join("dir", "sub"));
		testHelper.dir(path.join("dir", "sub", "sub"));
		testHelper.tick(function() {
			w.watch([], [path.join(fixtures, "dir")]);
			testHelper.tick(function() {
				testHelper.file(path.join("dir", "sub", "sub", "a"));
			});
		});
	});

	it("should detect a single change to future timestamps", function(done) {
		var w = new Watchpack({
			aggregateTimeout: 1000
		});
		var w2 = new Watchpack({
			aggregateTimeout: 1000
		});
		w.on("change", function() {
			throw new Error("should not report change event");
		});
		w.on("aggregated", function() {
			throw new Error("should not report aggregated event");
		});
		testHelper.file("a");
		testHelper.tick(function() {
			w2.watch([path.join(fixtures, "a")], []);
			testHelper.tick(1000, function() { // wait for initial scan
				testHelper.mtime("a", Date.now() + 1000000);
				testHelper.tick(function() {
					w.watch([path.join(fixtures, "a")], []);
					testHelper.tick(function() {
						testHelper.tick(function() {
							w2.close();
							w.close();
							done();
						});
					});
				});
			});
		});
	});

	it("should detect a past change to a file (timestamp)", function(done) {
		var w = new Watchpack({
			aggregateTimeout: 1000
		});
		var changeEvents = 0;
		w.on("change", function(file) {
			file.should.be.eql(path.join(fixtures, "a"));
			changeEvents++;
		});
		w.on("aggregated", function(changes) {
			changes.should.be.eql([path.join(fixtures, "a")]);
			changeEvents.should.be.greaterThan(0);
			w.close();
			done();
		});
		var startTime = Date.now();
		testHelper.tick(function() {
			testHelper.file("a");
			testHelper.tick(function() {
				w.watch([path.join(fixtures, "a")], [], startTime);
			});
		});
	});

	it("should not detect a past change to a file (watched)", function(done) {
		var w2 = new Watchpack();
		var w = new Watchpack();
		w.on("change", function() {
			throw new Error("Should not be detected");
		});
		testHelper.tick(function() {
			testHelper.file("b");
			w2.watch([path.join(fixtures, "b")], []);
			testHelper.tick(1000, function() { // wait for stable state
				testHelper.file("a");
				testHelper.tick(function() {
					var startTime = Date.now();
					testHelper.tick(function() {
						w.watch([path.join(fixtures, "a")], [], startTime);
						testHelper.tick(function() {
							w.close();
							w2.close();
							done();
						});
					});
				});
			});
		});
	});

	it("should detect a past change to a file (watched)", function(done) {
		var w2 = new Watchpack();
		var w = new Watchpack();
		var changeEvents = 0;
		w.on("change", function(file) {
			file.should.be.eql(path.join(fixtures, "a"));
			changeEvents++;
		});
		w.on("aggregated", function(changes) {
			changes.should.be.eql([path.join(fixtures, "a")]);
			changeEvents.should.be.eql(1);
			w.close();
			w2.close();
			done();
		});
		testHelper.tick(function() {
			testHelper.file("b");
			w2.watch([path.join(fixtures, "b")], []);
			testHelper.tick(function() {
				var startTime = Date.now();
				testHelper.tick(function() {
					testHelper.file("a");
					testHelper.tick(function() {
						w.watch([path.join(fixtures, "a")], [], startTime);
					});
				});
			});
		});
	});
});
<|endoftext|>


<commit_before>const { runKit } = require('@dr-js/core/library/node/kit.js')
const { runInfoPatchCombo } = require('@dr-js/dev/library/ci.js')

runKit(async (kit) => {
  runInfoPatchCombo(kit)

  kit.padLog('Patch npm cache path') // set cache path to `~/.npm/` for all platform (only win32 for now)
  kit.RUN_SUDO_NPM([ 'config', '--global', 'set', 'cache', kit.fromHome('.npm/') ])

  kit.padLog('Patch install "@dr-js/dev" globally')
  kit.RUN_SUDO_NPM('install --global @dr-js/dev@0.4')

  kit.padLog('Patch install "@min-pack/npm" globally')
  if (process.platform !== 'win32') kit.RUN_SUDO_NPM('install --global @min-pack/npm@0.1')
  else kit.RUN([ 'npx', '-p', 'npm@8', '-c', 'npm i -g @min-pack/npm@0.1' ]) // HACK: bypass npm@6+win32 `npm ERR! Error: EPERM: operation not permitted, rename` error
}, { title: 'ci-patch' })
<commit_msg>FIX: ci: npm@6+win32 bypass<commit_after>const { runKit } = require('@dr-js/core/library/node/kit.js')
const { runInfoPatchCombo } = require('@dr-js/dev/library/ci.js')

runKit(async (kit) => {
  runInfoPatchCombo(kit)

  kit.padLog('Patch npm cache path') // set cache path to `~/.npm/` for all platform (only win32 for now)
  kit.RUN_SUDO_NPM([ 'config', '--global', 'set', 'cache', kit.fromHome('.npm/') ])

  kit.padLog('Patch install "@dr-js/core" & "@dr-js/dev" & "@min-pack/npm" globally')
  if (process.platform === 'win32' && parseInt(process.versions.node) <= 14) { // HACK: bypass npm@6+win32 `npm ERR! Error: EPERM: operation not permitted, rename` error
    // check: https://github.com/actions/setup-node/issues/411, https://github.com/npm/cli/issues/4341, https://github.com/npm/template-oss/pull/36
    require('@dr-js/core/library/node/fs/Directory.js').createDirectorySync(kit.fromOsTemp('patch-npm-install-global/'))
    kit.RUN('curl -sO https://registry.npmjs.org/npm/-/npm-7.24.2.tgz', { cwd: kit.fromOsTemp('patch-npm-install-global/') })
    kit.RUN('tar xf npm-7.24.2.tgz', { cwd: kit.fromOsTemp('patch-npm-install-global/') })
    kit.RUN('node lib/npm.js install --no-fund --no-audit --global @dr-js/core@0.4 @dr-js/dev@0.4 @min-pack/npm@0.1', { cwd: kit.fromOsTemp('patch-npm-install-global/', 'package/') })
  } else kit.RUN_SUDO_NPM('install --no-fund --no-audit --global @dr-js/core@0.4 @dr-js/dev@0.4 @min-pack/npm@0.1')
}, { title: 'ci-patch' })
<|endoftext|>


<commit_before>var config = {
  autoprefixer: [], // array of browser options for autoprefixer
  ignore: [ '/_site', '/.git', '/node_modules' ], // folder patterns to ignore
  extensions: ['*'], // files with these extensions will be parsed and output
  asset_host: '', // define an asset host (such as a CDN) for all compiled assets
  workers: require('os').cpus().length // number of generation workers to spawn and use
};

module.exports = config;
<commit_msg>add markdown to default config<commit_after>module.exports = {
  // array of browser options for autoprefixer
  autoprefixer: [],
  // folder patterns to ignore
  ignore: [ '/_site', '/.git', '/node_modules' ],
  // files with these extensions will be parsed and output
  extensions: ['*'],
  // define an asset host (such as a CDN) for all compiled assets
  asset_host: '',
  // number of generation workers to spawn and use
  workers: require('os').cpus().length,
  // whether to parse <markdown> or <md> elements as markdown.
  // set to the `marked` configuration object.
  // if markdown.highlight is truthy, we'll use highlight.js on code blocks
  markdown: false
};
<|endoftext|>


<commit_before>var superagent = require('superagent');
var expect = require('expect.js');
var generateUUID = require('../lib/mongoose-uuid').generateUUID;

describe('express rest API for devices', function() {
    var ID,
        UUID = generateUUID();

    it('post object', function(done) {
        superagent.post('http://localhost:3000/api/devices')
            .send({
                uuid: UUID,
                _type: 1
            })
            .end(function(e, res) {
                // console.log(res.body)
                // console.log('============')
                expect(e).to.eql(null);
                expect(typeof res.body).to.eql('object');
                expect(res.body._id);
                ID = res.body._id;
                done();
            });
    });

    it('retrieves an object', function(done) {
        superagent.get('http://localhost:3000/api/devices/' + ID)
            .end(function(e, res) {
                // console.log(res.body)
                expect(e).to.eql(null);
                expect(typeof res.body).to.eql('object');
                expect(res.body._id);
                expect(res.body._id).to.eql(ID);
                done();
            });
    });

    it('retrieves a collection', function(done) {
        superagent.get('http://localhost:3000/api/devices')
            .end(function(e, res) {
                // console.log(res.body)
                expect(e).to.eql(null);
                expect(res.body.length).to.be.above(0);
                expect(res.body.map(function(item) {
                    return item._id;
                })).to.contain(ID);
                done();
            });
    });

    it('updates an object', function(done) {
        superagent.put('http://localhost:3000/api/devices/' + ID)
            .send({
                _type: 1
            })
            .end(function(e, res) {
                // console.log(res.body)
                expect(e).to.eql(null);
                expect(typeof res.body).to.eql('number');
                done();
            });
    });

    it('checks an updated object', function(done) {
        superagent.get('http://localhost:3000/api/devices/' + ID)
            .end(function(e, res) {
                // console.log(res.body)
                expect(e).to.eql(null);
                expect(typeof res.body).to.eql('object');
                expect(res.body._id.length);
                expect(res.body._id).to.eql(ID);
                expect(res.body._type).to.eql(1);
                done();
            });
    });

    it('removes an object', function(done) {
        superagent.del('http://localhost:3000/api/devices/' + ID)
            .end(function(e, res) {
                // console.log(res.body)
                expect(e).to.eql(null);
                expect(typeof res.body).to.eql('object');
                done();
            });
    });
});
<commit_msg>TEST: wip...<commit_after>var superagent = require('superagent');
var expect = require('expect.js');
var generateUUID = require('../lib/mongoose-uuid').generateUUID;

describe('express rest API for devices', function() {
    var ID,
        MODEL_NAME = 'configurations',
        UUID = generateUUID();

    it('post object', function(done) {
        superagent.post('http://localhost:3000/api/' + MODEL_NAME)
            .send({
                uuid: UUID,
                _type: 1
            })
            .end(function(e, res) {
                // console.log(res.body)
                // console.log('============')
                expect(e).to.eql(null);
                expect(typeof res.body).to.eql('object');
                expect(res.body._id);
                ID = res.body._id;
                done();
            });
    });

    it('retrieves an object', function(done) {
        superagent.get('http://localhost:3000/api/' + MODEL_NAME +'/' + ID)
            .end(function(e, res) {
                // console.log(res.body)
                expect(e).to.eql(null);
                expect(typeof res.body).to.eql('object');
                expect(res.body._id);
                expect(res.body._id).to.eql(ID);
                done();
            });
    });

    it('retrieves a collection', function(done) {
        superagent.get('http://localhost:3000/api/' + MODEL_NAME)
            .end(function(e, res) {
                // console.log(res.body)
                expect(e).to.eql(null);
                expect(res.body.length).to.be.above(0);
                expect(res.body.map(function(item) {
                    return item._id;
                })).to.contain(ID);
                done();
            });
    });

    it('updates an object', function(done) {
        superagent.put('http://localhost:3000/api/' + MODEL_NAME + '/' + ID)
            .send({
                _type: 1
            })
            .end(function(e, res) {
                // console.log(res.body)
                expect(e).to.eql(null);
                expect(typeof res.body).to.eql('number');
                done();
            });
    });

    it('checks an updated object', function(done) {
        superagent.get('http://localhost:3000/api/' + MODEL_NAME + '/' + ID)
            .end(function(e, res) {
                // console.log(res.body)
                expect(e).to.eql(null);
                expect(typeof res.body).to.eql('object');
                expect(res.body._id.length);
                expect(res.body._id).to.eql(ID);
                expect(res.body._type).to.eql(1);
                done();
            });
    });

    it('removes an object', function(done) {
        superagent.del('http://localhost:3000/api/' + MODEL_NAME + '/' + ID)
            .end(function(e, res) {
                // console.log(res.body)
                expect(e).to.eql(null);
                expect(typeof res.body).to.eql('object');
                done();
            });
    });
});
<|endoftext|>


<commit_before>var myApp = angular.module('myApp', ['ngYoutubeEmbed']);

myApp.controller('myCtrl', ['$scope', function($scope) {
	$scope.videoForm = {};
    $scope.link1 = 'https://www.youtube.com/watch?v=OPmOXJtxxoo';
    $scope.link2 = 'https://www.youtube.com/watch?v=E813VYySueM';
    $scope.link3 = 'https://www.youtube.com/watch?v=vWzeQtiwk9g';
    $scope.link4 = 'https://gaming.youtube.com/watch?v=kNcFa3Xuk5U';
    $scope.link5 = 'https://gaming.youtube.com/watch?v=bstDrow5goo';
}]);<commit_msg>Demo video urls updated<commit_after>var myApp = angular.module('myApp', ['ngYoutubeEmbed']);

myApp.controller('myCtrl', ['$scope', function($scope) {
	$scope.videoForm = {};
    $scope.link1 = 'https://www.youtube.com/watch?v=OPmOXJtxxoo';
    $scope.link2 = 'https://www.youtube.com/watch?v=E813VYySueM';
    $scope.link3 = 'https://www.youtube.com/watch?v=SCVvhUW7cxo';
    $scope.link4 = 'https://gaming.youtube.com/watch?v=kNcFa3Xuk5U';
    $scope.link5 = 'https://gaming.youtube.com/watch?v=1pxAXJNJ-z8';
}]);<|endoftext|>


<commit_before>const express = require('express');
const bodyParser = require('body-parser');
const enforce = require('express-sslify');

const app = express();

app.use(bodyParser.json());

if (process.env.NODE_ENV === 'production') {
	app.use(enforce.HTTPS({trustProtoHeader: true}));
}

app.use('/', require('./routes/index'));
app.use('/stages', require('./routes/stages'));

app.listen(process.env.PORT || 3000);

module.exports = app;
<commit_msg>Record hostname for test<commit_after>const express = require('express');
const bodyParser = require('body-parser');
const enforce = require('express-sslify');

const app = express();

app.use(bodyParser.json());

if (process.env.NODE_ENV === 'production') {
	app.use(enforce.HTTPS({trustProtoHeader: true}));
	app.use((req, res, done) => {
		console.log(req.hostname);
		done();
	});
}

app.use('/', require('./routes/index'));
app.use('/stages', require('./routes/stages'));

app.listen(process.env.PORT || 3000);

module.exports = app;
<|endoftext|>


<commit_before>(function($, window, document, undefined) {

//    $(function() {
//        $("video-link").jqueryVideoLightbox();
//    });

    var pluginName = "jqueryVideoLightbox",
        defaults = {
            id: "y-dQw4w9WgXcQ",
            width: "640px",
            height: "390px",
            autoplay: 0,
            autohide: 2,
            controls: 1,
            iv_load_policy: 1,
            loop: 0,
            modestbranding: 0,
            playlist: "",
            related: 0,
            showinfo: 1,
            shart_time: 0,
            theme: "dark",
            color: "",
            byline: 1,
            portrait: 1,
            effectIn: "fadeIn",
            easeIn: 300,
            easeOut: 0
        };

    function JQVideoLightbox ( element, options ) {
        this.element = element;
        this.settings = $.extend( {}, defaults, options );
        this._defaults = defaults;
        this._name = pluginName;
        this.init();
    }

    JQVideoLightbox.prototype = {
        init: function () {

            $(this.element).on( "click", $.proxy(function(){
                $(this.player ( $(this).element, $(this).settings));
            },this));
        },

        player: function ( element, settings ) {
            var video_autohide, video_autoplay, video_byline, video_color, video_controls, video_height, video_id, video_iv_load_policy, video_loop, video_modestbranding, video_playlist, video_portrait, video_related, video_showinfo, video_start_time, video_theme, video_vendor, video_width, vimeo_player, youtube_player;
            if ($(this.element).find(".video-frame").is(':visible')) {
                $(this.element).find(".video").remove();
                $(this.element).find(".video-frame").hide(((this.settings).easeOut));
                return $(this).destroy;
            } else {
                video_vendor = $(this.element).data("videoId").split("-")[0] || (this.settings).id.split("-")[0];
                video_id = $(this.element).data("videoId").split("-")[1] || (this.settings).id.split("-")[1]; // Youtube: "y-XbTtgr8J8uU" Vimeo: "v-32187194"
                video_width = $(this.element).data("videoWidth") || (this.settings).width; // Y&V: video width in px
                video_height = $(this.element).data("videoHeight") || (this.settings).height; // Y&V: video height in px
                video_autoplay = $(this.element).data("videoAutoplay") || (this.settings).autoplay; // Y&V: start playback immediately (0,1)
                video_autohide = $(this.element).data("videoAutohide") || (this.settings).autohide; // Y: auto hide controls after video load (0,1,2)
                video_controls = $(this.element).data("videoControls") || (this.settings).controls; // Y: display controls (0,1,2)
                video_iv_load_policy = $(this.element).data("videoIvLoadPolicy") || (this.settings).iv_load_policy; // Y: display annotations (1,3)
                video_loop = $(this.element).data("videoLoop") || (this.settings).loop; // Y&V: loop video playback (0,1)
                video_modestbranding = $(this.element).data("videoModestbranding") || (this.settings).modestbranding; // Y: hide large Youtube logo (0,1)
                video_playlist = $(this.element).data("videoPlaylist") || (this.settings).playlist; // Y: comma-separated list of video IDs to play
                video_related = $(this.element).data("videoRelated") || (this.settings).related; // Y: show related videos when playback id finished (0,1)
                video_showinfo = $(this.element).data("videoShowinfo") || (this.settings).showinfo; // Y: display title, uploader (0,1)  V: display title (0,1)
                video_start_time = $(this.element).data("videoStartTime") || (this.settings).start_time; // Y: playback start position in seconds (ex. "132" starts at 2mins, 12secs)
                video_theme = $(this.element).data("videoTheme") || (this.settings).theme; // Y: player theme ("dark","light")
                video_color = $(this.element).data("videoColor") || (this.settings).color; // Y: player controls color ("red","white") V: player controls color (hex code minus the "#", default is "00adef")
                video_byline = $(this.element).data("videoByline") || (this.settings).byline; // V: display byline (0,1)
                video_portrait = $(this.element).data("videoPortrait") || (this.settings).portrait; // V: display user's portrait (0,1)
                youtube_player = $("<embed src=\"https://www.youtube.com/embed/" + video_id + "?autoplay=" + video_autoplay + "&autohide=" + video_autohide + "&controls=" + video_controls + "&iv_load_policy=" + video_iv_load_policy + "&loop=" + video_loop + "&modestbranding=" + video_modestbranding + "&playlist=" + video_playlist + "&rel=" + video_related + "&showinfo=" + video_showinfo + "&start=" + video_start_time + "&theme=" + video_theme + "&color=" + video_color + "\" width=\"" + video_width + "\" height=\"" + video_height + "\" frameborder=\"0\" allowfullscreen></embed>");
                vimeo_player = $("");
                $(this.element).append('
' + '
' + '
' + '
' + '
' + '
');
                $(this.element).find(".video-frame").fadeIn(((this.settings).easeIn));
                if ((video_vendor === "v") || (video_vendor === "V")) {
                    return $(this.element).find(".video").html(vimeo_player);
                } else {
                    return $(this.element).find(".video").html(youtube_player);
                }
            }
        },

        destroy: function () {
            $(this).off();
            $(this).removeData();
        }
    };

    $.fn[ pluginName ] = function ( options ) {
        return this.each(function() {
            if ( !$.data( this, "plugin_" + pluginName ) ) {
                $.data( this, "plugin_" + pluginName, new JQVideoLightbox( this, options ) );
            }
        });
    };

    return this;

})( jQuery, window, document );<commit_msg>removed unnecessary comment<commit_after>(function($, window, document, undefined) {

    var pluginName = "jqueryVideoLightbox",
        defaults = {
            id: "y-dQw4w9WgXcQ",
            width: "640px",
            height: "390px",
            autoplay: 0,
            autohide: 2,
            controls: 1,
            iv_load_policy: 1,
            loop: 0,
            modestbranding: 0,
            playlist: "",
            related: 0,
            showinfo: 1,
            shart_time: 0,
            theme: "dark",
            color: "",
            byline: 1,
            portrait: 1,
            effectIn: "fadeIn",
            easeIn: 300,
            easeOut: 0
        };

    function JQVideoLightbox ( element, options ) {
        this.element = element;
        this.settings = $.extend( {}, defaults, options );
        this._defaults = defaults;
        this._name = pluginName;
        this.init();
    }

    JQVideoLightbox.prototype = {
        init: function () {

            $(this.element).on( "click", $.proxy(function(){
                $(this.player ( $(this).element, $(this).settings));
            },this));
        },

        player: function ( element, settings ) {
            var video_autohide, video_autoplay, video_byline, video_color, video_controls, video_height, video_id, video_iv_load_policy, video_loop, video_modestbranding, video_playlist, video_portrait, video_related, video_showinfo, video_start_time, video_theme, video_vendor, video_width, vimeo_player, youtube_player;
            if ($(this.element).find(".video-frame").is(':visible')) {
                $(this.element).find(".video").remove();
                $(this.element).find(".video-frame").hide(((this.settings).easeOut));
                return $(this).destroy;
            } else {
                video_vendor = $(this.element).data("videoId").split("-")[0] || (this.settings).id.split("-")[0];
                video_id = $(this.element).data("videoId").split("-")[1] || (this.settings).id.split("-")[1]; // Youtube: "y-XbTtgr8J8uU" Vimeo: "v-32187194"
                video_width = $(this.element).data("videoWidth") || (this.settings).width; // Y&V: video width in px
                video_height = $(this.element).data("videoHeight") || (this.settings).height; // Y&V: video height in px
                video_autoplay = $(this.element).data("videoAutoplay") || (this.settings).autoplay; // Y&V: start playback immediately (0,1)
                video_autohide = $(this.element).data("videoAutohide") || (this.settings).autohide; // Y: auto hide controls after video load (0,1,2)
                video_controls = $(this.element).data("videoControls") || (this.settings).controls; // Y: display controls (0,1,2)
                video_iv_load_policy = $(this.element).data("videoIvLoadPolicy") || (this.settings).iv_load_policy; // Y: display annotations (1,3)
                video_loop = $(this.element).data("videoLoop") || (this.settings).loop; // Y&V: loop video playback (0,1)
                video_modestbranding = $(this.element).data("videoModestbranding") || (this.settings).modestbranding; // Y: hide large Youtube logo (0,1)
                video_playlist = $(this.element).data("videoPlaylist") || (this.settings).playlist; // Y: comma-separated list of video IDs to play
                video_related = $(this.element).data("videoRelated") || (this.settings).related; // Y: show related videos when playback id finished (0,1)
                video_showinfo = $(this.element).data("videoShowinfo") || (this.settings).showinfo; // Y: display title, uploader (0,1)  V: display title (0,1)
                video_start_time = $(this.element).data("videoStartTime") || (this.settings).start_time; // Y: playback start position in seconds (ex. "132" starts at 2mins, 12secs)
                video_theme = $(this.element).data("videoTheme") || (this.settings).theme; // Y: player theme ("dark","light")
                video_color = $(this.element).data("videoColor") || (this.settings).color; // Y: player controls color ("red","white") V: player controls color (hex code minus the "#", default is "00adef")
                video_byline = $(this.element).data("videoByline") || (this.settings).byline; // V: display byline (0,1)
                video_portrait = $(this.element).data("videoPortrait") || (this.settings).portrait; // V: display user's portrait (0,1)
                youtube_player = $("<embed src=\"https://www.youtube.com/embed/" + video_id + "?autoplay=" + video_autoplay + "&autohide=" + video_autohide + "&controls=" + video_controls + "&iv_load_policy=" + video_iv_load_policy + "&loop=" + video_loop + "&modestbranding=" + video_modestbranding + "&playlist=" + video_playlist + "&rel=" + video_related + "&showinfo=" + video_showinfo + "&start=" + video_start_time + "&theme=" + video_theme + "&color=" + video_color + "\" width=\"" + video_width + "\" height=\"" + video_height + "\" frameborder=\"0\" allowfullscreen></embed>");
                vimeo_player = $("");
                $(this.element).append('
' + '
' + '
' + '
' + '
' + '
');
                $(this.element).find(".video-frame").fadeIn(((this.settings).easeIn));
                if ((video_vendor === "v") || (video_vendor === "V")) {
                    return $(this.element).find(".video").html(vimeo_player);
                } else {
                    return $(this.element).find(".video").html(youtube_player);
                }
            }
        },

        destroy: function () {
            $(this).off();
            $(this).removeData();
        }
    };

    $.fn[ pluginName ] = function ( options ) {
        return this.each(function() {
            if ( !$.data( this, "plugin_" + pluginName ) ) {
                $.data( this, "plugin_" + pluginName, new JQVideoLightbox( this, options ) );
            }
        });
    };

    return this;

})( jQuery, window, document );
<|endoftext|>


<commit_before>const React = require('react');
const {
  DonutChart,
  Icon,
  Loader,
  Modal,
  RangeSelector,
  Select,
  TypeAhead
} = require('../src/Index');

const styles = {
  block: {
    boxSizing: 'border-box',
    float: 'left',
    width: '20%',
    fontFamily: 'Helvetica, Arial, sans-serif',
    fontSize: '13px',
    color: '#666666',
    textAlign: 'center',
    borderRight: '1px solid #e5e5e5',
    borderBottom: '1px solid #e5e5e5',
    borderLeft: '1px solid #e5e5e5',
    padding: '30px 0',
    marginRight: '-1px'
  },
  type: {
    backgroundColor: '#f5f5f5',
    border: '1px solid #e5e5e5',
    borderRadius: '2px',
    display: 'inline-block',
    margin: '5px 0',
    padding: '3px 5px'
  },
  button: {
    borderRadius: '3px',
    background: '#359BCF',
    padding: '10px 20px',
    display: 'inline-block',
    margin: '0 5px',
    color: '#fff',
    cursor: 'pointer',
    fontSize: '14px',
    WebkitFontSmoothing: 'antialiased'
  }
};

const icons = [
  {
    value: 'accounts',
    displayValue: 'Accounts'
  },
  {
    value: 'add',
    displayValue: 'Add'
  },
  {
    value: 'add-solid',
    displayValue: 'Add Solid'
  },
  {
    value: 'arrow-down',
    displayValue: 'Arrow Down'
  },
  {
    value: 'arrow-left',
    displayValue: 'Arrow Left'
  },
  {
    value: 'arrow-right',
    displayValue: 'Arrow Right'
  },
  {
    value: 'arrow-up',
    displayValue: 'Arrow Up'
  },
  {
    value: 'attention',
    displayValue: 'Attention'
  },
  {
    value: 'auto',
    displayValue: 'Auto'
  },
  {
    value: 'backspace',
    displayValue: 'Backspace'
  },
  {
    value: 'campaigns',
    displayValue: 'Campaigns'
  },
  {
    value: 'caret-down',
    displayValue: 'Caret Down'
  },
  {
    value: 'caret-left',
    displayValue: 'Caret Left'
  },
  {
    value: 'caret-right',
    displayValue: 'Caret Right'
  },
  {
    value: 'caret-up',
    displayValue: 'Caret Up'
  },
  {
    value: 'check',
    displayValue: 'Check'
  },
  {
    value: 'check-solid',
    displayValue: 'Check Solid'
  },
  {
    value: 'checking',
    displayValue: 'Checking'
  },
  {
    value: 'close',
    displayValue: 'Close'
  },
  {
    value: 'close-solid',
    displayValue: 'Close Solid'
  },
  {
    value: 'comparisons',
    displayValue: 'Comparisons'
  },
  {
    value: 'credit-card',
    displayValue: 'Credit Card'
  },
  {
    value: 'delete',
    displayValue: 'Delete'
  },
  {
    value: 'download',
    displayValue: 'Download'
  },
  {
    value: 'edit',
    displayValue: 'Edit'
  },
  {
    value: 'envelope',
    displayValue: 'Envelope'
  },
  {
    value: 'export',
    displayValue: 'Export'
  },
  {
    value: 'folder',
    displayValue: 'Folder'
  },
  {
    value: 'gallery',
    displayValue: 'Gallery'
  },
  {
    value: 'gear',
    displayValue: 'Gear'
  },
  {
    value: 'hamburger',
    displayValue: 'Hamburger'
  },
  {
    value: 'help',
    displayValue: 'Help'
  },
  {
    value: 'home',
    displayValue: 'Home'
  },
  {
    value: 'info',
    displayValue: 'Info'
  },
  {
    value: 'list-view',
    displayValue: 'List View'
  },
  {
    value: 'loans',
    displayValue: 'Loans'
  },
  {
    value: 'md-cash',
    displayValue: 'Cash (MD)'
  },
  {
    value: 'md-check-mark',
    displayValue: 'Check Mark (MD)'
  },
  {
    value: 'md-credit',
    displayValue: 'Creidt (MD)'
  },
  {
    value: 'md-debts',
    displayValue: 'Debts (MD)'
  },
  {
    value: 'md-savings',
    displayValue: 'Savings (MD)'
  },
  {
    value: 'mobile-phone',
    displayValue: 'Mobile Phone'
  },
  {
    value: 'mx',
    displayValue: 'MX'
  },
  {
    value: 'phone',
    displayValue: 'Phone'
  },
  {
    value: 'play',
    displayValue: 'Play'
  },
  {
    value: 'play-solid',
    displayValue: 'Play Solid'
  },
  {
    value: 'savings',
    displayValue: 'Savings'
  },
  {
    value: 'search',
    displayValue: 'Search'
  },
  {
    value: 'segments',
    displayValue: 'Segments'
  },
  {
    value: 'sync',
    displayValue: 'Sync'
  },
  {
    value: 'transactions',
    displayValue: 'Transactions'
  },
  {
    value: 'user',
    displayValue: 'User'
  },
  {
    value: 'view',
    displayValue: 'View'
  },
  {
    value: 'visit',
    displayValue: 'Visit'
  },
  {
    value: 'x-axis',
    displayValue: 'X Axis'
  },
  {
    value: 'y-axis',
    displayValue: 'Y Axis'
  }
];

const Demo = React.createClass({
  getInitialState () {
    return {
      icon: {
        value: 'accounts',
        displayValue: 'Accounts'
      },
      showModal: false,
      showSmallModal: false,
      windowWidth: document.documentElement.clientWidth || document.body.clientWidth
    }
  },

  componentDidMount () {
    window.addEventListener('resize', this._handleWindowResize);
  },

  componentWillUnmount () {
    window.removeEventListener('resize', this._handleWindowResize);
  },

  _handleSelectChange (option) {
    this.setState({
      icon: option
    });
  },

  _handleWindowResize () {
    this.setState({
      windowWidth: document.documentElement.clientWidth || document.body.clientWidth
    });
  },

  render () {
    return (

          Show Default Modal
          Show Small Modal

        <Modal
          isOpen={this.state.showModal}
          isSmall={this.state.showSmallModal}
          onRequestClose={this._handleModalClose}
        >

I am a modal!

        </Modal>

        <DonutChart
          animateOnHover={true}
          chartTotal={300}
          data={[
            {
              name: 'Data Point 1',
              value: 50
            },
            {
              name: 'Data Point 2',
              value: 80
            }
          ]}
          dataPoints={[
            {
              name: 'Data Dot 1',
              value: 200
            }
          ]}
          defaultLabelText='Total Users'
          defaultLabelValue={300}
        />

        <TypeAhead
          items={[
            'JPMorgan Chase',
            'Bank of America',
            'Citigroup',
            'Wells Fargo',
            'The Bank of New York Mellon',
            'U.S. Bancorp',
            'HSBC Bank USA',
            'Capital One',
            'PNC Financial Services',
            'State Street Corporation'
          ]}
          placeholderText='Select a Bank'
        />

        <Select
          isMobile={false}
          onChange={this._handleSelectChange}
          options={icons}
          optionStyle={{
            color: '#333'
          }}
          optionHoverStyle={{
            backgroundColor: '#359BCF',
            color: '#fff'
          }}
          placeholderText='Pick One'
          selected={this.state.icon}
          valid={true}
        />

          <Icon
            type={this.state.icon.value}
            size={150}
            style={{
              color: '#359BCF'
            }}
          />

        <RangeSelector
          defaultLowerValue={18}
          defaultUpperValue={30}
          interval={1}
          presets={[
            {
              lowerValue: 0,
              upperValue: 13,
              label: 'Gen Z'
            },
            {
              lowerValue: 14,
              upperValue: 34,
              label: 'Millenials'
            },
            {
              lowerValue: 10,
              upperValue: 40,
              label: 'Gen Y'
            },
            {
              lowerValue: 36,
              upperValue: 50,
              label: 'Gen X'
            },
            {
              lowerValue: 51,
              upperValue: 72,
              label: 'Baby Boomers'
            },
            {
              lowerValue: 73,
              upperValue: 90,
              label: 'Silent'
            }
          ]}
          range={100}
          selectedColor='#359BCF'
        />

          <Loader isLoading={true} isRelative={true} />

    );
  },

  _handleSelectChange (option) {
    this.setState({
      icon: option
    });
  },

  _handleModalClick () {
    this.setState({
      showModal: true,
      showSmallModal: false
    });
  },

  _handleSmallModalClick () {
    this.setState({
      showModal: true,
      showSmallModal: true
    });
  },

  _handleModalClose () {
    this.setState({
      showModal: false,
      showSmallModal: false
    });
  }
});

React.render(<Demo />, document.getElementById('demo'));<commit_msg>Update demo/app.js to React 0.14<commit_after>const React = require('react');
const ReactDOM = require('react-dom');

const {
  DonutChart,
  Icon,
  Loader,
  Modal,
  RangeSelector,
  Select,
  TypeAhead
} = require('../src/Index');

const styles = {
  block: {
    boxSizing: 'border-box',
    float: 'left',
    width: '20%',
    fontFamily: 'Helvetica, Arial, sans-serif',
    fontSize: '13px',
    color: '#666666',
    textAlign: 'center',
    borderRight: '1px solid #e5e5e5',
    borderBottom: '1px solid #e5e5e5',
    borderLeft: '1px solid #e5e5e5',
    padding: '30px 0',
    marginRight: '-1px'
  },
  type: {
    backgroundColor: '#f5f5f5',
    border: '1px solid #e5e5e5',
    borderRadius: '2px',
    display: 'inline-block',
    margin: '5px 0',
    padding: '3px 5px'
  },
  button: {
    borderRadius: '3px',
    background: '#359BCF',
    padding: '10px 20px',
    display: 'inline-block',
    margin: '0 5px',
    color: '#fff',
    cursor: 'pointer',
    fontSize: '14px',
    WebkitFontSmoothing: 'antialiased'
  }
};

const icons = [
  {
    value: 'accounts',
    displayValue: 'Accounts'
  },
  {
    value: 'add',
    displayValue: 'Add'
  },
  {
    value: 'add-solid',
    displayValue: 'Add Solid'
  },
  {
    value: 'arrow-down',
    displayValue: 'Arrow Down'
  },
  {
    value: 'arrow-left',
    displayValue: 'Arrow Left'
  },
  {
    value: 'arrow-right',
    displayValue: 'Arrow Right'
  },
  {
    value: 'arrow-up',
    displayValue: 'Arrow Up'
  },
  {
    value: 'attention',
    displayValue: 'Attention'
  },
  {
    value: 'auto',
    displayValue: 'Auto'
  },
  {
    value: 'backspace',
    displayValue: 'Backspace'
  },
  {
    value: 'campaigns',
    displayValue: 'Campaigns'
  },
  {
    value: 'caret-down',
    displayValue: 'Caret Down'
  },
  {
    value: 'caret-left',
    displayValue: 'Caret Left'
  },
  {
    value: 'caret-right',
    displayValue: 'Caret Right'
  },
  {
    value: 'caret-up',
    displayValue: 'Caret Up'
  },
  {
    value: 'check',
    displayValue: 'Check'
  },
  {
    value: 'check-solid',
    displayValue: 'Check Solid'
  },
  {
    value: 'checking',
    displayValue: 'Checking'
  },
  {
    value: 'close',
    displayValue: 'Close'
  },
  {
    value: 'close-solid',
    displayValue: 'Close Solid'
  },
  {
    value: 'comparisons',
    displayValue: 'Comparisons'
  },
  {
    value: 'credit-card',
    displayValue: 'Credit Card'
  },
  {
    value: 'delete',
    displayValue: 'Delete'
  },
  {
    value: 'download',
    displayValue: 'Download'
  },
  {
    value: 'edit',
    displayValue: 'Edit'
  },
  {
    value: 'envelope',
    displayValue: 'Envelope'
  },
  {
    value: 'export',
    displayValue: 'Export'
  },
  {
    value: 'folder',
    displayValue: 'Folder'
  },
  {
    value: 'gallery',
    displayValue: 'Gallery'
  },
  {
    value: 'gear',
    displayValue: 'Gear'
  },
  {
    value: 'hamburger',
    displayValue: 'Hamburger'
  },
  {
    value: 'help',
    displayValue: 'Help'
  },
  {
    value: 'home',
    displayValue: 'Home'
  },
  {
    value: 'info',
    displayValue: 'Info'
  },
  {
    value: 'list-view',
    displayValue: 'List View'
  },
  {
    value: 'loans',
    displayValue: 'Loans'
  },
  {
    value: 'md-cash',
    displayValue: 'Cash (MD)'
  },
  {
    value: 'md-check-mark',
    displayValue: 'Check Mark (MD)'
  },
  {
    value: 'md-credit',
    displayValue: 'Creidt (MD)'
  },
  {
    value: 'md-debts',
    displayValue: 'Debts (MD)'
  },
  {
    value: 'md-savings',
    displayValue: 'Savings (MD)'
  },
  {
    value: 'mobile-phone',
    displayValue: 'Mobile Phone'
  },
  {
    value: 'mx',
    displayValue: 'MX'
  },
  {
    value: 'phone',
    displayValue: 'Phone'
  },
  {
    value: 'play',
    displayValue: 'Play'
  },
  {
    value: 'play-solid',
    displayValue: 'Play Solid'
  },
  {
    value: 'savings',
    displayValue: 'Savings'
  },
  {
    value: 'search',
    displayValue: 'Search'
  },
  {
    value: 'segments',
    displayValue: 'Segments'
  },
  {
    value: 'sync',
    displayValue: 'Sync'
  },
  {
    value: 'transactions',
    displayValue: 'Transactions'
  },
  {
    value: 'user',
    displayValue: 'User'
  },
  {
    value: 'view',
    displayValue: 'View'
  },
  {
    value: 'visit',
    displayValue: 'Visit'
  },
  {
    value: 'x-axis',
    displayValue: 'X Axis'
  },
  {
    value: 'y-axis',
    displayValue: 'Y Axis'
  }
];

const Demo = React.createClass({
  getInitialState () {
    return {
      icon: {
        value: 'accounts',
        displayValue: 'Accounts'
      },
      showModal: false,
      showSmallModal: false,
      windowWidth: document.documentElement.clientWidth || document.body.clientWidth
    }
  },

  componentDidMount () {
    window.addEventListener('resize', this._handleWindowResize);
  },

  componentWillUnmount () {
    window.removeEventListener('resize', this._handleWindowResize);
  },

  _handleSelectChange (option) {
    this.setState({
      icon: option
    });
  },

  _handleWindowResize () {
    this.setState({
      windowWidth: document.documentElement.clientWidth || document.body.clientWidth
    });
  },

  render () {
    return (

          Show Default Modal
          Show Small Modal

        <Modal
          isOpen={this.state.showModal}
          isSmall={this.state.showSmallModal}
          onRequestClose={this._handleModalClose}
        >

I am a modal!

        </Modal>

        <DonutChart
          animateOnHover={true}
          chartTotal={300}
          data={[
            {
              name: 'Data Point 1',
              value: 50
            },
            {
              name: 'Data Point 2',
              value: 80
            }
          ]}
          dataPoints={[
            {
              name: 'Data Dot 1',
              value: 200
            }
          ]}
          defaultLabelText='Total Users'
          defaultLabelValue='300'
          style={{ margin: '0 auto' }}
        />

        <TypeAhead
          items={[
            'JPMorgan Chase',
            'Bank of America',
            'Citigroup',
            'Wells Fargo',
            'The Bank of New York Mellon',
            'U.S. Bancorp',
            'HSBC Bank USA',
            'Capital One',
            'PNC Financial Services',
            'State Street Corporation'
          ]}
          placeholderText='Select a Bank'
        />

        <Select
          isMobile={false}
          onChange={this._handleSelectChange}
          options={icons}
          optionStyle={{
            color: '#333'
          }}
          optionHoverStyle={{
            backgroundColor: '#359BCF',
            color: '#fff'
          }}
          placeholderText='Pick One'
          selected={this.state.icon}
          valid={true}
        />

          <Icon
            type={this.state.icon.value}
            size={150}
            style={{
              color: '#359BCF'
            }}
          />

        <RangeSelector
          defaultLowerValue={18}
          defaultUpperValue={30}
          interval={1}
          presets={[
            {
              lowerValue: 0,
              upperValue: 13,
              label: 'Gen Z'
            },
            {
              lowerValue: 14,
              upperValue: 34,
              label: 'Millenials'
            },
            {
              lowerValue: 10,
              upperValue: 40,
              label: 'Gen Y'
            },
            {
              lowerValue: 36,
              upperValue: 50,
              label: 'Gen X'
            },
            {
              lowerValue: 51,
              upperValue: 72,
              label: 'Baby Boomers'
            },
            {
              lowerValue: 73,
              upperValue: 90,
              label: 'Silent'
            }
          ]}
          range={100}
          selectedColor='#359BCF'
        />

          <Loader isLoading={true} isRelative={true} />

    );
  },

  _handleSelectChange (option) {
    this.setState({
      icon: option
    });
  },

  _handleModalClick () {
    this.setState({
      showModal: true,
      showSmallModal: false
    });
  },

  _handleSmallModalClick () {
    this.setState({
      showModal: true,
      showSmallModal: true
    });
  },

  _handleModalClose () {
    this.setState({
      showModal: false,
      showSmallModal: false
    });
  }
});

ReactDOM.render(<Demo />, document.getElementById('demo'));<|endoftext|>


<commit_before>import React from 'react'
import { AsyncStorage } from 'react-native'
import io from 'socket.io-client'

const SERVER_URL = 'http://192.168.31.144'
// const SERVER_URL = 'http://10.89.80.125'
// const SERVER_URL = 'http://10.89.151.157'

export const SOCKET_URL = `${SERVER_URL}:8081`
const API_URL = `${SERVER_URL}:8080`

const jsonHeader = {
  'Accept': 'application/json',
  'Content-Type': 'application/json'
}

// Login
export function loginUser (form) {
  return fetch(`${API_URL}/login`, {
    method: 'POST',
    headers: { ...jsonHeader },
    body: JSON.stringify(form)
  })
    .then(response => response.json())
    .catch(err => console.error(err))
}

export async function logoutUser () {
  let token = await AsyncStorage.getItem('Authorization')
  return fetch(`${API_URL}/login`, {
    method: 'POST',
    headers: { Authorization: token, ...jsonHeader },
  })
    .then(response => response.json())
    .catch(err => console.error(err))
}

export function registerUser (form) {
  return fetch(`${API_URL}/user`, {
    method: 'POST',
    headers: { ...jsonHeader },
    body: JSON.stringify(form)
  })
    .then(response => response.json())
    .catch(err => console.error(err))
}

// Task
export async function fetchTasks (page = 0) {
  let token = await AsyncStorage.getItem('Authorization')
  return fetch(`${API_URL}/task?page=${page}`, {
    headers: { Authorization: token, ...jsonHeader }
  })
    .then(response => response.json())
    .catch(err => console.error(err))
}

export async function fetchTaskByID (taskID) {
  let token = await AsyncStorage.getItem('Authorization')
  return fetch(`${API_URL}/task/${taskID}`, {
    headers: { Authorization: token, ...jsonHeader }
  })
    .then(response => response.json())
    .catch(err => console.error(err))
}

export async function fetchChats () {
  let token = await AsyncStorage.getItem('Authorization')
  let itsc = await AsyncStorage.getItem('itsc')
  return fetch(`${API_URL}/task?rfid=${itsc}`, {
    headers: { Authorization: token, ...jsonHeader }
  })
    .then(response => response.json())
    .catch(err => console.error(err))
}

export async function createTask (task) {
  let token = await AsyncStorage.getItem('Authorization')
  return fetch(`${API_URL}/task`, {
    method: 'POST',
    headers: { Authorization: token, ...jsonHeader },
    body: JSON.stringify(task)
  })
    .then(response => response.json())
    .catch(err => console.error(err))
}

export async function updateTask (task, change) {
  let token = await AsyncStorage.getItem('Authorization')
  return fetch(`${API_URL}/task/${task._id}`, {
    method: 'PUT',
    headers: { Authorization: token, ...jsonHeader },
    body: JSON.stringify(change)
  })
    .then(response => console.log(response))
    .catch(err => console.error(err))
}
<commit_msg>fix logout user (previously copies login)<commit_after>import React from 'react'
import { AsyncStorage } from 'react-native'
import io from 'socket.io-client'

const SERVER_URL = 'http://192.168.31.144'
// const SERVER_URL = 'http://10.89.80.125'
// const SERVER_URL = 'http://10.89.151.157'

export const SOCKET_URL = `${SERVER_URL}:8081`
const API_URL = `${SERVER_URL}:8080`

const jsonHeader = {
  'Accept': 'application/json',
  'Content-Type': 'application/json'
}

// Login
export function loginUser (form) {
  return fetch(`${API_URL}/login`, {
    method: 'POST',
    headers: { ...jsonHeader },
    body: JSON.stringify(form)
  })
    .then(response => response.json())
    .catch(err => console.error(err))
}

export async function logoutUser () {
  return AsyncStorage.removeItem('Authorization')
    .catch(err => console.error(err))
}

export function registerUser (form) {
  return fetch(`${API_URL}/user`, {
    method: 'POST',
    headers: { ...jsonHeader },
    body: JSON.stringify(form)
  })
    .then(response => response.json())
    .catch(err => console.error(err))
}

// Task
export async function fetchTasks ({page, status}) {
  let token = await AsyncStorage.getItem('Authorization')
  console.log()
  return fetch(`${API_URL}/task?` + (page ? `page=${page}&` : '') + (status ? `status=${status}&` : ''), {
    headers: { Authorization: token, ...jsonHeader }
  })
    .then(response => response.json())
    .catch(err => console.error(err))
}

export async function fetchTaskByID (taskID) {
  let token = await AsyncStorage.getItem('Authorization')
  return fetch(`${API_URL}/task/${taskID}`, {
    headers: { Authorization: token, ...jsonHeader }
  })
    .then(response => response.json())
    .catch(err => console.error(err))
}

export async function fetchChats () {
  let token = await AsyncStorage.getItem('Authorization')
  let itsc = await AsyncStorage.getItem('itsc')
  return fetch(`${API_URL}/task?rfid=${itsc}&nstatus=COMPLETED`, {
    headers: { Authorization: token, ...jsonHeader }
  })
    .then(response => response.json())
    .catch(err => console.error(err))
}

export async function createTask (task) {
  let token = await AsyncStorage.getItem('Authorization')
  return fetch(`${API_URL}/task`, {
    method: 'POST',
    headers: { Authorization: token, ...jsonHeader },
    body: JSON.stringify(task)
  })
    .then(response => response.json())
    .catch(err => console.error(err))
}

export async function updateTask (task, change) {
  let token = await AsyncStorage.getItem('Authorization')
  return fetch(`${API_URL}/task/${task._id}`, {
    method: 'PUT',
    headers: { Authorization: token, ...jsonHeader },
    body: JSON.stringify(change)
  })
    .then(response => console.log(response))
    .catch(err => console.error(err))
}
<|endoftext|>


<commit_before>;(function() { 'use strict';

  angular
    .module('demoApp', [
      'ngAnimate',
      'ngRoute',
      'sanji.window'
    ])
    .config(function ($routeProvider) {
      $routeProvider
        .when('/', {
          template: '<sanji-window title="{{item.title}}"' +
                      'content-url="{{item.url}}">' +
            '</sanji-window>',
          controller: function($scope) {
            $scope.item = {
              title: 'Bundle',
              url: 'bundle/main.html'
            };
          }
        })
        .otherwise({
          redirectTo: '/'
        });
    });

}());
<commit_msg>Modify indent<commit_after>;(function() { 'use strict';

  angular
    .module('demoApp', [
      'ngAnimate',
      'ngRoute',
      'sanji.window'
    ])
    .config(function ($routeProvider) {
      $routeProvider
        .when('/', {
          template: '<sanji-window title="{{item.title}}"' +
                      'content-url="{{item.url}}">' +
                    '</sanji-window>',
          controller: function($scope) {
            $scope.item = {
              title: 'Bundle',
              url: 'bundle/main.html'
            };
          }
        })
        .otherwise({
          redirectTo: '/'
        });
    });

}());
<|endoftext|>


<commit_before>var fs = require('fs'),
	sys = require('sys'),
    child_process = require('child_process');

var start = exports.start = function (project, createCallback, exitCallback) {
	var tempFile = __dirname + '/tmp/' + Math.random() + '.js';
	fs.writeFile(tempFile, project.lastHandler.code, function(err) {
		if (err)
		    throw err;
		var aggrOut = '';
		var aggrErr = '';
		var node = child_process.spawn('node', [tempFile]);
		createCallback(node.pid);
		node.stdout.on('data', function (data) {
		    console.log('Stdout data: ' + data);
		    aggrOut += data;
		});
		node.stderr.on('data', function (data) {
		    console.log('Stdout data: ' + data);
		    aggrErr += data;
		});
		node.on('exit', function (code) {
		    clearTimeout(timeoutId);
		    aggrOut += 'Exit code: ' + code;
		    fs.unlink(tempFile, function (err) {
		        if (err)
					console.log("Unable to delete " + tempFile + ".");
				exitCallback(aggrOut, aggrErr);
		    });
		});
		var timeoutCallback = function (child) {
		    if (child) {
		        console.log("Killing process " + child.pid);
		        child.kill('SIGKILL');
		    }
		};
		var timeoutId = setTimeout(timeoutCallback, 60000, node)
		return node.pid;
	});
}

var stop = exports.stop = function (pid) {
	if (pid) {
        console.log("Killing process " + pid);
        try {
		    process.kill(pid, 'SIGKILL');
		}
		catch(err) {
		    console.log(err);
		}
	}
}

<commit_msg>Add a bit more space between the program output and the exit code message.<commit_after>var fs = require('fs'),
	sys = require('sys'),
    child_process = require('child_process');

var start = exports.start = function (project, createCallback, exitCallback) {
	var tempFile = __dirname + '/tmp/' + Math.random() + '.js';
	fs.writeFile(tempFile, project.lastHandler.code, function(err) {
		if (err)
		    throw err;
		var aggrOut = '';
		var aggrErr = '';
		var node = child_process.spawn('node', [tempFile]);
		createCallback(node.pid);
		node.stdout.on('data', function (data) {
		    console.log('Stdout data: ' + data);
		    aggrOut += data;
		});
		node.stderr.on('data', function (data) {
		    console.log('Stdout data: ' + data);
		    aggrErr += data;
		});
		node.on('exit', function (code) {
		    clearTimeout(timeoutId);
		    aggrOut += '\nExit code: ' + code;
		    fs.unlink(tempFile, function (err) {
		        if (err)
					console.log("Unable to delete " + tempFile + ".");
				exitCallback(aggrOut, aggrErr);
		    });
		});
		var timeoutCallback = function (child) {
		    if (child) {
		        console.log("Killing process " + child.pid);
		        child.kill('SIGKILL');
		    }
		};
		var timeoutId = setTimeout(timeoutCallback, 60000, node)
		return node.pid;
	});
}

var stop = exports.stop = function (pid) {
	if (pid) {
        console.log("Killing process " + pid);
        try {
		    process.kill(pid, 'SIGKILL');
		}
		catch(err) {
		    console.log(err);
		}
	}
}

<|endoftext|>


<commit_before>var createRenderer = require("../render/render")
var limiter = require("./limiter");

module.exports = function($window, redraw) {
	return function(root, component) {
		var renderer = createRenderer($window)
		var draw = limiter($window, function draw() {
			renderer.render(root, {tag: component})
		})

		renderer.setEventCallback(draw)

		redraw.run = draw
		draw()
	}
}
<commit_msg>Stricter<commit_after>"use strict"

var createRenderer = require("../render/render")
var limiter = require("./limiter");

module.exports = function($window, redraw) {
	return function(root, component) {
		var renderer = createRenderer($window)
		var draw = limiter($window, function draw() {
			renderer.render(root, {tag: component})
		})

		renderer.setEventCallback(draw)

		redraw.run = draw
		draw()
	}
}
<|endoftext|>


<commit_before>/* global module:false */
module.exports = function(grunt) {
	var port = grunt.option('port') || 8000;
	var base = grunt.option('base') || '.';

	// Project configuration
	grunt.initConfig({
		pkg: grunt.file.readJSON('package.json'),
		meta: {
			banner:
				'/*!\n' +
				' * reveal.js <%= pkg.version %> (<%= grunt.template.today("yyyy-mm-dd, HH:MM") %>)\n' +
				' * http://lab.hakim.se/reveal-js\n' +
				' * MIT licensed\n' +
				' *\n' +
				' * Copyright (C) 2016 Hakim El Hattab, http://hakim.se\n' +
				' */'
		},

		qunit: {
			files: [ 'test/*.html' ]
		},

		uglify: {
			options: {
				banner: '<%= meta.banner %>\n'
			},
			build: {
				src: 'js/reveal.js',
				dest: 'js/reveal.min.js'
			}
		},

		sass: {
			core: {
				files: {
					'css/reveal.css': 'css/reveal.scss',
				}
			},
			themes: {
				files: [
					{
						expand: true,
						cwd: 'css/theme/source',
						src: ['*.scss'],
						dest: 'css/theme',
						ext: '.css'
					}
				]
			}
		},

		autoprefixer: {
			dist: {
				src: 'css/reveal.css'
			}
		},

		cssmin: {
			compress: {
				files: {
					'css/reveal.min.css': [ 'css/reveal.css' ]
				}
			}
		},

		jshint: {
			options: {
				curly: false,
				eqeqeq: true,
				immed: true,
				latedef: true,
				newcap: true,
				noarg: true,
				sub: true,
				undef: true,
				eqnull: true,
				browser: true,
				expr: true,
				globals: {
					head: false,
					module: false,
					console: false,
					unescape: false,
					define: false,
					exports: false
				}
			},
			files: [ 'Gruntfile.js', 'js/reveal.js' ]
		},

		connect: {
			server: {
				options: {
					port: port,
					base: base,
					livereload: true,
					open: true
				}
			}
		},

		zip: {
			'reveal-js-presentation.zip': [
				'index.html',
				'css/**',
				'js/**',
				'lib/**',
				'images/**',
				'plugin/**',
				'**.md'
			]
		},

		watch: {
			js: {
				files: [ 'Gruntfile.js', 'js/reveal.js' ],
				tasks: 'js'
			},
			theme: {
				files: [ 'css/theme/source/*.scss', 'css/theme/template/*.scss' ],
				tasks: 'css-themes'
			},
			css: {
				files: [ 'css/reveal.scss' ],
				tasks: 'css-core'
			},
			html: {
				files: [ '*.html']
			},
			markdown: {
				files: [ '*.md' ]
			},
			options: {
				livereload: true
			}
		}

	});

	// Dependencies
	grunt.loadNpmTasks( 'grunt-contrib-qunit' );
	grunt.loadNpmTasks( 'grunt-contrib-jshint' );
	grunt.loadNpmTasks( 'grunt-contrib-cssmin' );
	grunt.loadNpmTasks( 'grunt-contrib-uglify' );
	grunt.loadNpmTasks( 'grunt-contrib-watch' );
	grunt.loadNpmTasks( 'grunt-sass' );
	grunt.loadNpmTasks( 'grunt-contrib-connect' );
	grunt.loadNpmTasks( 'grunt-autoprefixer' );
	grunt.loadNpmTasks( 'grunt-zip' );

	// Default task
	grunt.registerTask( 'default', [ 'css', 'js' ] );

	// JS task
	grunt.registerTask( 'js', [ 'jshint', 'uglify', 'qunit' ] );

	// Theme CSS
	grunt.registerTask( 'css-themes', [ 'sass:themes' ] );

	// Core framework CSS
	grunt.registerTask( 'css-core', [ 'sass:core', 'autoprefixer', 'cssmin' ] );

	// All CSS
	grunt.registerTask( 'css', [ 'sass', 'autoprefixer', 'cssmin' ] );

	// Package presentation to archive
	grunt.registerTask( 'package', [ 'default', 'zip' ] );

	// Serve presentation locally
	grunt.registerTask( 'serve', [ 'connect', 'watch' ] );

	// Run tests
	grunt.registerTask( 'test', [ 'jshint', 'qunit' ] );

};
<commit_msg>Delete Gruntfile.js<commit_after><|endoftext|>