<commit_before>var scrollerObj = new Scroller(function(left, top, zoom) {
    // apply coordinates/zooming
}, {
	zooming: true,
	locking: false,
	bouncing: false,
	animating: false,
	minZoom: 1,
	maxZoom: 10
});

var canvas, ctx, mousedown=false, mousemove=false;

function prepareCanvas(){
	canvas=document.getElementById("canvas");
	canvas.onselectstart = function () { return false; }
	canvas.setAttribute('width', canvasSize);
	canvas.setAttribute('height', canvasSize);
	canvas.style.width="800px";
	canvas.style.height="800px";
	ctx=canvas.getContext("2d");

	ctx.lineCap = 'round';

	scrollerObj.setDimensions(800, 800, 800, 800);	//I'm almost certain that I'm doing this the wrong way, but somehow it works flawlessly
	scrollerObj.setPosition($('canvas').position().left, $('canvas').position().top);

	canvas.addEventListener("mousedown", function(e) {
		scrollerObj.doTouchStart([{pageX: e.pageX,pageY: e.pageY}], e.timeStamp);
		mousemove=false;
		mousedown = true;
		redraw();
	}, false);

	canvas.addEventListener("mousemove", function(e) {
		mousemove=true;
		if (!mousedown) {return;}
		scrollerObj.doTouchMove([{pageX: e.pageX,pageY: e.pageY}], e.timeStamp);
		redraw();
	}, false);

	canvas.addEventListener("mouseup", function(e) {
		if(!mousemove) { //it was a click
			doClick(e);
		}
		if (!mousedown) {return;}
		scrollerObj.doTouchEnd(e.timeStamp);
		mousedown = false;
		redraw();
	}, false);

};

function resetZoom(){
	scrollerObj.zoomTo(1);
}

function getMouse(e){
	var mouseX = e.pageX-$('canvas').position().left, mouseY = e.pageY-$('canvas').position().top;
	var data=scrollerObj.getValues();
	mouseX=(data.left+mouseX)*canvasScale/data.zoom, mouseY=(data.top+mouseY)*canvasScale/data.zoom;
	return {x:mouseX, y:mouseY};
}

$('canvas').mousewheel(function(e, delta, deltaX, deltaY){
	if(selectedCircle != -1) return;
	scrollerObj.doMouseZoom(-delta*3, e.timeStamp, e.pageX, e.pageY);
	redraw();
	return false;
})

$(document).on("contextmenu", "canvas", function(e){
   return false;
});

function createFinalImage(){
	dirtyRender=0;
	redraw();
	var imgData=ctx.getImageData(0,0,canvasSize,canvasSize);
	for (var i=0;i<imgData.data.length;i+=4)
		if(imgData.data[i]>64 && imgData.data[i+1]>64 && imgData.data[i+2]>64) imgData.data[i+3]=0;	//converts white to transparency
	ctx.putImageData(imgData,0,0);
	var dataURL = canvas.toDataURL();
	window.open(dataURL);
	dirtyRender=1;
	redraw();
	return;
}<commit_msg>A workaround for mouseMove event triggering together with MouseDown<commit_after>var scrollerObj = new Scroller(function(left, top, zoom) {
    // apply coordinates/zooming
}, {
	zooming: true,
	locking: false,
	bouncing: false,
	animating: false,
	minZoom: 1,
	maxZoom: 10
});

var canvas, ctx, mousedown=false, mousemove=0;

function prepareCanvas(){
	canvas=document.getElementById("canvas");
	canvas.onselectstart = function () { return false; }
	canvas.setAttribute('width', canvasSize);
	canvas.setAttribute('height', canvasSize);
	canvas.style.width="800px";
	canvas.style.height="800px";
	ctx=canvas.getContext("2d");

	ctx.lineCap = 'round';

	scrollerObj.setDimensions(800, 800, 800, 800);	//I'm almost certain that I'm doing this the wrong way, but somehow it works flawlessly
	scrollerObj.setPosition($('canvas').position().left, $('canvas').position().top);

	canvas.addEventListener("mousedown", function(e) {
		scrollerObj.doTouchStart([{pageX: e.pageX,pageY: e.pageY}], e.timeStamp);
		mousemove=0;
		mousedown = true;
		redraw();
	}, false);

	canvas.addEventListener("mousemove", function(e) {
		mousemove+=1;
		if (!mousedown) {return;}
		scrollerObj.doTouchMove([{pageX: e.pageX,pageY: e.pageY}], e.timeStamp);
		redraw();
	}, false);

	canvas.addEventListener("mouseup", function(e) {
		if(mousemove<=1) { //ignore the first mouseMove as sometimes it's triggered together with mouseDown
			doClick(e);
		}
		if (!mousedown) {return;}
		scrollerObj.doTouchEnd(e.timeStamp);
		mousedown = false;
		redraw();
	}, false);

};

function resetZoom(){
	scrollerObj.zoomTo(1);
}

function getMouse(e){
	var mouseX = e.pageX-$('canvas').position().left, mouseY = e.pageY-$('canvas').position().top;
	var data=scrollerObj.getValues();
	mouseX=(data.left+mouseX)*canvasScale/data.zoom, mouseY=(data.top+mouseY)*canvasScale/data.zoom;
	return {x:mouseX, y:mouseY};
}

$('canvas').mousewheel(function(e, delta, deltaX, deltaY){
	if(selectedCircle != -1) return;
	scrollerObj.doMouseZoom(-delta*3, e.timeStamp, e.pageX, e.pageY);
	redraw();
	return false;
})

$(document).on("contextmenu", "canvas", function(e){
   return false;
});

function createFinalImage(){
	dirtyRender=0;
	redraw();
	var imgData=ctx.getImageData(0,0,canvasSize,canvasSize);
	for (var i=0;i<imgData.data.length;i+=4)
		if(imgData.data[i]>64 && imgData.data[i+1]>64 && imgData.data[i+2]>64) imgData.data[i+3]=0;	//converts white to transparency
	ctx.putImageData(imgData,0,0);
	var dataURL = canvas.toDataURL();
	window.open(dataURL);
	dirtyRender=1;
	redraw();
	return;
}<|endoftext|>


<commit_before>"use strict";

const tickFormatter = require("../src/tick-formatter");

describe("tick-formatter", function () {

    it("is a function", () => {
        assert("function" === typeof tickFormatter);
    });

    [{
        label: "0",
        tick: 0,
        ms: 0,
        s: 0,
        m: 0,

    }].forEach(test => {
        let {
            label,
            tick,
            ms,
            s,
            m
        } = test;
        it(`format tick into time details: ${label}`, () => {
            let formatted = tickFormatter(tick);
            assert(ms === formatted.ms);
            assert(s === formatted.s);
            assert(m === formatted.m);
        });
    });

});
<commit_msg>Should process digits<commit_after>"use strict";

const
    tickFormatter = require("../src/tick-formatter"),

    zero = (x, count = 2) => {
        let result = [],
            max = Math.pow(10, count - 1);
        while (max > 1 && x < max) {
            result.push("0");
            max /= 10;
        }
        result.push(x);
        return result.join("");
    }

;

describe("tick-formatter", function () {

    it("is a function", () => {
        assert("function" === typeof tickFormatter);
    });

    [{
        tick: 0,
        ms: 0,
        s: 0,
        m: 0,
        digits: [0, 0, 0, 0, 0, 0, 0]

    }, {
        tick: 347,
        ms: 347,
        s: 0,
        m: 0,
        digits: [0, 0, 0, 0, 3, 4, 7]

    }, {
        tick: 54347,
        ms: 347,
        s: 54,
        m: 0,
        digits: [0, 0, 5, 4, 3, 4, 7]

    }, {
        tick: 154348,
        ms: 348,
        s: 34,
        m: 2,
        digits: [0, 2, 3, 4, 3, 4, 8]

    }].forEach(test => {
        let {
            tick,
            ms,
            s,
            m,
            digits
        } = test;
        it(`format tick into time details: ${tick} = ${zero(m)}:${zero(s)}.${zero(ms,4)}`, () => {
            let formatted = tickFormatter(tick);
            assert(ms === formatted.ms);
            assert(s === formatted.s);
            assert(m === formatted.m);
            // digits.forEach((digit, position) => assert(formatted.digits[position] === digit));
        });
    });

});
<|endoftext|>


<commit_before>'use strict';

const titleContainer = '[class*=PlayerControlsMetadata]';

const plexFilter = MetadataFilter.createFilter({
	album: removeUnknownAlbum,
});

Connector.playerSelector = '[class^=Player-miniPlayerContainer]';

Connector.trackSelector = `${titleContainer} a[class*=MetadataPosterTitle]`;

Connector.albumSelector = `${titleContainer} [class*=MetadataPosterTitle-title] > a:nth-child(3)`;

Connector.artistSelector = `${titleContainer} [class*=MetadataPosterTitle-title] > a:nth-child(1)`;

Connector.timeInfoSelector = `${Connector.playerSelector} [class*=DurationRemaining-container]`;

// @ifndef FIREFOX
// NOTE: Blob URLs used in Plex aren't supported by Firefox 67 and older.
Connector.trackArtSelector = [
	`${Connector.playerSelector} [class^=PosterCardImg-imageContainer] div`,
	'[class^=AudioVideoFullPlayer] [class^=PosterCardImg-imageContainer] div',
];
// @endif

Connector.pauseButtonSelector = [
	`${Connector.playerSelector} [data-qa-id="pauseButton"]`,
	`${Connector.playerSelector} [class^=plex-icon-player-pause]`,
];

// For watch-it-later videos
Connector.artistTrackSelector = `${Connector.playerSelector} [class*=MetadataPosterTitle-title]`;

Connector.applyFilter(MetadataFilter.getYoutubeFilter().extend(plexFilter));

Connector.getTrack = () => {
	if (Connector.getArtist()) {
		return $(Connector.trackSelector).text();
	}
	return null;
};

function removeUnknownAlbum(text) {
	return text.replace('[Unknown Album]', '');
}
<commit_msg>Update plex.js - necessary as selector for Pause Button had changed (#3078)<commit_after>'use strict';

const titleContainer = '[class*=PlayerControlsMetadata]';

const plexFilter = MetadataFilter.createFilter({
	album: removeUnknownAlbum,
});

Connector.playerSelector = '[class^=Player-miniPlayerContainer]';

Connector.trackSelector = `${titleContainer} a[class*=MetadataPosterTitle]`;

Connector.albumSelector = `${titleContainer} [class*=MetadataPosterTitle-title] > a:nth-child(3)`;

Connector.artistSelector = `${titleContainer} [class*=MetadataPosterTitle-title] > a:nth-child(1)`;

Connector.timeInfoSelector = `${Connector.playerSelector} [class*=DurationRemaining-container]`;

// @ifndef FIREFOX
// NOTE: Blob URLs used in Plex aren't supported by Firefox 67 and older.
Connector.trackArtSelector = [
	`${Connector.playerSelector} [class^=PosterCardImg-imageContainer] div`,
	'[class^=AudioVideoFullPlayer] [class^=PosterCardImg-imageContainer] div',
];
// @endif

Connector.pauseButtonSelector = [
	`${Connector.playerSelector} [data-testid="pauseButton"]`,
	`${Connector.playerSelector} [class^=plex-icon-player-pause]`,
];

// For watch-it-later videos
Connector.artistTrackSelector = `${Connector.playerSelector} [class*=MetadataPosterTitle-title]`;

Connector.applyFilter(MetadataFilter.getYoutubeFilter().extend(plexFilter));

Connector.getTrack = () => {
	if (Connector.getArtist()) {
		return $(Connector.trackSelector).text();
	}
	return null;
};

function removeUnknownAlbum(text) {
	return text.replace('[Unknown Album]', '');
}
<|endoftext|>


<commit_before>"use strict";

/*
 * This is a collection of well known SMTP service providers
 */

module.exports = {
    "Gmail":{
        transport: "SMTP",
        host: "smtp.gmail.com",
        secureConnection: true,
        port: 465,
        requiresAuth: true,
        domains: ["gmail.com", "googlemail.com"]
    },
    "Yahoo":{
        transport: "SMTP",
        host: "smtp.mail.yahoo.com",
        secureConnection: true,
        port: 465,
        requiresAuth: true,
        domains: ["yahoo.com"]
    },
    "Hotmail":{
        transport: "SMTP",
        host: "smtp.live.com",
        port: 587,
        requiresAuth: true,
        domains: ["hotmail.com", "outlook.com"],
        tls: {ciphers:'SSLv3'}
    },
    "hot.ee":{
        transport: "SMTP",
        host: "mail.hot.ee",
        requiresAuth: true,
        domains: ["hot.ee"]
    },
    "mail.ee":{
        transport: "SMTP",
        host: "smtp.mail.ee",
        requiresAuth: true,
        domains: ["mail.ee"]
    },
    "SES":{
        transport: "SMTP",
        host: "email-smtp.us-east-1.amazonaws.com",
        secureConnection: true,
        port: 465,
        requiresAuth: true
    },
    "Zoho":{
        transport: "SMTP",
        host: "smtp.zoho.com",
        secureConnection: true,
        port: 465,
        requiresAuth: true,
        authMethod: 'LOGIN'
    },
    "iCloud":{
        transport: "SMTP",
        host:"smtp.mail.me.com",
        port: 587,
        requiresAuth: true,
        domains: ["me.com", "mac.com"]
    },
    "SendGrid":{
        transport: "SMTP",
        host: "smtp.sendgrid.net",
        port: 587,
        requiresAuth: true
    },
    "Mailgun":{
        transport: "SMTP",
        host: "smtp.mailgun.org",
        port: 587,
        requiresAuth: true,
        tls: {ciphers:'SSLv3'}
    },
    "Postmark":{
        transport: "SMTP",
        host: "smtp.postmarkapp.com",
        port: 25,
        requiresAuth: true
    },
    "yandex":{
        transport: "SMTP",
        host: "smtp.yandex.ru",
        port: 465,
        secureConnection: true,
        requiresAuth: true,
        domains: ["yandex.ru"]
    },
    "Mail.Ru":{
        transport: "SMTP",
        host: "smtp.mail.ru",
        port: 465,
        secureConnection: true,
        requiresAuth: true,
        domains: ["mail.ru"]
    },
    "DynectEmail":{
        transport: "SMTP",
        host:"smtp.dynect.net",
        port:25,
        requiresAuth: true
    },
    "Mandrill":{
        transport: "SMTP",
        host: "smtp.mandrillapp.com",
        port: 587,
        requiresAuth: true
    },
    "Mailjet":{
        transport: "SMTP",
        host: "in.mailjet.com",
        port: 587,
        requiresAuth: true
    },
    "QQ":{
        transport: "SMTP",
        host: "smtp.qq.com",
        secureConnection: true,
        port: 465,
        requiresAuth: true,
        domains: ["qq.com"]
    },
    "QQex":{
        transport: "SMTP",
        host: "smtp.exmail.qq.com",
        secureConnection: true,
        port: 465,
        requiresAuth: true,
        domains: ["exmail.qq.com"]
    },
    "Godaddy": {
        transport: "SMTP",
        host: "smtpout.secureserver.net",
        port: 25,
        requiresAuth: true
    },
    "GodaddyEurope": {
        transport: "SMTP",
        host: "smtp.europe.secureserver.net",
        port: 25,
        requiresAuth: true
    },
    "GodaddyAsia": {
        transport: "SMTP",
        host: "smtp.asia.secureserver.net",
        port: 25,
        requiresAuth: true
    }
};
<commit_msg>Update wellknown.js<commit_after>"use strict";

/*
 * This is a collection of well known SMTP service providers
 */

module.exports = {
    "Gmail":{
        transport: "SMTP",
        host: "smtp.gmail.com",
        secureConnection: true,
        port: 465,
        requiresAuth: true,
        domains: ["gmail.com", "googlemail.com"]
    },
    "Yahoo":{
        transport: "SMTP",
        host: "smtp.mail.yahoo.com",
        secureConnection: true,
        port: 465,
        requiresAuth: true,
        domains: ["yahoo.com"]
    },
    "Hotmail":{
        transport: "SMTP",
        host: "smtp.live.com",
        port: 587,
        requiresAuth: true,
        domains: ["hotmail.com", "outlook.com"],
        tls: {ciphers:'SSLv3'}
    },
    "hot.ee":{
        transport: "SMTP",
        host: "mail.hot.ee",
        requiresAuth: true,
        domains: ["hot.ee"]
    },
    "mail.ee":{
        transport: "SMTP",
        host: "smtp.mail.ee",
        requiresAuth: true,
        domains: ["mail.ee"]
    },
    "SES":{
        transport: "SMTP",
        host: "email-smtp.us-east-1.amazonaws.com",
        secureConnection: true,
        port: 465,
        requiresAuth: true
    },
    "Zoho":{
        transport: "SMTP",
        host: "smtp.zoho.com",
        secureConnection: true,
        port: 465,
        requiresAuth: true,
        authMethod: 'LOGIN'
    },
    "iCloud":{
        transport: "SMTP",
        host:"smtp.mail.me.com",
        port: 587,
        requiresAuth: true,
        domains: ["me.com", "mac.com"]
    },
    "SendGrid":{
        transport: "SMTP",
        host: "smtp.sendgrid.net",
        port: 587,
        requiresAuth: true
    },
    "Mailgun":{
        transport: "SMTP",
        host: "smtp.mailgun.org",
        port: 587,
        requiresAuth: true,
        tls: {ciphers:'SSLv3'}
    },
    "Postmark":{
        transport: "SMTP",
        host: "smtp.postmarkapp.com",
        port: 25,
        requiresAuth: true
    },
    "yandex":{
        transport: "SMTP",
        host: "smtp.yandex.ru",
        port: 465,
        secureConnection: true,
        requiresAuth: true,
        domains: ["yandex.ru"]
    },
    "Mail.Ru":{
        transport: "SMTP",
        host: "smtp.mail.ru",
        port: 465,
        secureConnection: true,
        requiresAuth: true,
        domains: ["mail.ru"]
    },
    "DynectEmail":{
        transport: "SMTP",
        host:"smtp.dynect.net",
        port:25,
        requiresAuth: true
    },
    "Mandrill":{
        transport: "SMTP",
        host: "smtp.mandrillapp.com",
        port: 587,
        requiresAuth: true
    },
    "Mailjet":{
        transport: "SMTP",
        host: "in.mailjet.com",
        port: 587,
        requiresAuth: true
    },
    "QQ":{
        transport: "SMTP",
        host: "smtp.qq.com",
        secureConnection: true,
        port: 465,
        requiresAuth: true,
        domains: ["qq.com"]
    },
    "QQex":{
        transport: "SMTP",
        host: "smtp.exmail.qq.com",
        secureConnection: true,
        port: 465,
        requiresAuth: true,
        domains: ["exmail.qq.com"]
    },
    "Godaddy": {
        transport: "SMTP",
        host: "smtpout.secureserver.net",
        port: 25,
        requiresAuth: true
    },
    "GodaddyEurope": {
        transport: "SMTP",
        host: "smtp.europe.secureserver.net",
        port: 25,
        requiresAuth: true
    },
    "GodaddyAsia": {
        transport: "SMTP",
        host: "smtp.asia.secureserver.net",
        port: 25,
        requiresAuth: true
    },
    // https://www.fastmail.fm/help/remote_email_access_server_names_and_ports.html
    'FastMail': {
        transport: 'SMTP',
        host: 'mail.messagingengine.com',
        secureConnection: true,
        port: 465,
        requiresAuth: true,
        // and many more: https://www.fastmail.fm/help/signup_domains.html
        domains: ['fastmail.fm']
    }
};
<|endoftext|>


<commit_before>var utils = module.exports;
var path = require('path');
var c = require('chalk');
var log = console.log;

utils.checkLocalXtc = function checkLocalXtc(env) {
	if (!env.modulePath) {
		log(c.red('No local xtc install found in'), c.magenta(env.cwd));
		log(c.red('Try running: npm install xtc'));
		//process.exit(1);
	}
};

utils.pkgInfo = function pkgInfo(moduleName, cb) {

	var Client = require('npm-pkginfo'),
		client
	;

	// note: the memory store is only for testing / examples
	// in production you should either use the fsStore (see commented lines below)
	// or another custom store
	/*client = new Client({
		cacheStore: new Client.stores.memory()
	});*/

	// Uncomment below to use the fs cache store
	client = new Client({
		cacheDir: path.resolve(__dirname, '../cache')
	});

	// fetch a module from NPM
	client.get(moduleName, function(err, pkg) {
		cb(err, pkg ? Object.keys(pkg.versions) : null);
	});
};<commit_msg>ale utils.checkLocalXtc exit the program if xtc can't be found<commit_after>var utils = module.exports;
var path = require('path');
var c = require('chalk');
var log = console.log;

utils.checkLocalXtc = function checkLocalXtc(env) {
	if (!env.modulePath) {
		log(c.red('No local xtc install found in'), c.magenta(env.cwd));
		process.exit(1);
	}
};

utils.pkgInfo = function pkgInfo(moduleName, cb) {

	var Client = require('npm-pkginfo'),
		client
	;

	// note: the memory store is only for testing / examples
	// in production you should either use the fsStore (see commented lines below)
	// or another custom store
	/*client = new Client({
		cacheStore: new Client.stores.memory()
	});*/

	// Uncomment below to use the fs cache store
	client = new Client({
		cacheDir: path.resolve(__dirname, '../cache')
	});

	// fetch a module from NPM
	client.get(moduleName, function(err, pkg) {
		cb(err, pkg ? Object.keys(pkg.versions) : null);
	});
};<|endoftext|>


<commit_before>module.exports = {
  plugins: {
   'postcss-import': {},
   'postcss-cssnext': {
	   browsers: ['last 2 versions', '> 5%'],
	  }
	}
};
<commit_msg>clean up<commit_after>module.exports = {
  plugins: {
   'postcss-import': {},
   'postcss-cssnext': {
	   browsers: ['last 2 versions', '> 5%'],
	  }
	}
};
<|endoftext|>


<commit_before>/*
 yerbajs - simple javascript data management
  @copyright 2014 Kevin von Flotow <vonflow@gmail.com>
  @license MIT License <http://opensource.org/licenses/MIT>
*/
(function(e){function b(a){this._init(a)}var c=Date.prototype.toISOString?"toISOString":"getTime";b.prototype={_init:function(a){a=a||[];this.indices={_id:{}};for(var d=this.length=this.lastUpdate=0,g=a.length;d<g;d++)this.add(a[d])},_setLastUpdate:function(){this.lastUpdate=(new Date)[c]()},_generateUID:function(){for(var a=e.genUID();this.get(a);a=e.genUID());return a},reIndex:function(){this.indices={_id:{}};this.each(function(a,d){this.indices._id[d._id]=a});return this},each:function(a){for(var d=
0,g=this.length;d<g;++d){var b=a.call(this,d,this[d]);if(!b&&"undefined"!==typeof b)break}return this},get:function(a){return this.indices._id.hasOwnProperty(a)?this[this.indices._id[a]]:!1},find:function(a){if(!a)return!1;var d=void 0,b={},c=function(a){};isFunction(a)?c=a:(d="undefined"!==typeof a.query?a.query:d,b=a.opts||b,c=a.done||c);b.caseSensitive="undefined"!==typeof b.caseSensitive?b.caseSensitive:!0;b.limit="undefined"!==typeof b.limit&&e.isNumber(b.limit)?b.limit|0:0;var h=[];this.each(function(a,
c){var k=0,l=0;if(e.isString(d)||e.isNumber(d))k=1,"undefined"!==typeof c.data&&c.data==d&&(l=1);else for(var f in d)c.hasOwnProperty(f)&&(b.caseSensitive&&c[f]===d[f]||!b.caseSensitive&&c[f].toLowerCase()===d[f].toLowerCase())&&l++,k++;if(l===k&&(h.push(c),0<b.limit&&h.length>=b.limit))return!1});c.call(this,h);return this},shuffle:function(){for(var a=this.length,b,c;0<--a;)b=Math.random()*(a+1)|0,c=this[b],this[b]=this[a],this[a]=c;return this},clone:function(){return this.slice(0)},random:function(){var a=
this.clone().shuffle();return a[Math.random()*a.length|0]},addOne:function(a){a={data:a};a._id=a.data._id||this._generateUID();if(this.indices._id.hasOwnProperty(a._id))this[this.indices._id[a._id]]=a;else{var b=this.length++;this[b]=a;this.indices._id[a._id]=b}this._setLastUpdate();return this},add:function(){for(var a=0,b=arguments.length;a<b;++a)this.addOne(arguments[a]);return this},toArray:function(){var a=[];this.each(function(b,c){a.push(c)});return a},slice:function(a,d){return new b(Array.prototype.slice.call(this,
a,d))},pop:function(){var a=Array.prototype.pop.call(this);this.reIndex();return a},shift:function(){var a=Array.prototype.shift.call(this);this.reIndex();return a},flush:function(){for(var a=0,b=this.length;a<b;++a)delete this[a];return this._init()}};if("undefined"!==typeof module&&module.exports)module.exports=b;else if(window)window.yerba=b;else return b})(function(){function e(){}e.prototype={genUID:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(b){var c=16*
Math.random()|0;return("x"===b?c:c&3|8).toString(16)})},isFunction:function(b){return"[object Function]"===Object.prototype.toString.call(b)},isString:function(b){return"string"===typeof b||b instanceof String},isNumber:function(b){return!isNaN(parseFloat(b))&&isFinite(b)},isObject:function(b){return b===Object(b)&&"[object Array]"!==Object.prototype.toString.call(b)},isArray:Array.isArray||function(b){return"[object Array]"===Object.prototype.toString.call(b)}};return new e}());
<commit_msg>refactoring<commit_after>/*
 yerbajs - simple javascript data management
  @copyright 2014 Kevin von Flotow <vonflow@gmail.com>
  @license MIT License <http://opensource.org/licenses/MIT>
*/
(function(){(function(f,l){function a(b){if(this._init)return this._init(b)}function c(b){b=b||[];this.indices={_id:{}};for(var a=this.length=this.lastUpdate=0,d=b.length;a<d;a++)this.add(b[a])}function e(b){if(!b)return!1;var a=l,d={},c=function(b){};isFunction(b)?c=b:(a="undefined"!==typeof b.query?b.query:a,d=b.opts||d,c=b.done||c);d.caseSensitive="undefined"!==typeof d.caseSensitive?d.caseSensitive:!0;d.limit="undefined"!==typeof d.limit&&f.isNumber(d.limit)?d.limit|0:0;var e=[];this.each(function(b,
c){var g=0,h=0;if(f.isString(a)||f.isNumber(a))g=1,"undefined"!==typeof c.data&&c.data==a&&(h=1);else for(var k in a)c.hasOwnProperty(k)&&(d.caseSensitive&&c[k]===a[k]||!d.caseSensitive&&c[k].toLowerCase()===a[k].toLowerCase())&&h++,g++;if(h===g&&(e.push(c),0<d.limit&&e.length>=d.limit))return!1});c.call(this,e);return this}function g(){for(var b=0,a=arguments.length;b<a;++b)this.addOne(arguments[b]);return this}function h(){var b=Array.prototype.pop.call(this);this._reIndex();return b}function m(){for(var b=
0,a=this.length;b<a;++b)delete this[b];return this._init()}function n(){for(var b=this.length,a,c;0<--b;)a=Math.random()*(b+1)|0,c=this[a],this[a]=this[b],this[b]=c;return this}var p=Date.prototype.toISOString?"toISOString":"getTime";a.prototype={_init:c,brew:c,_setLastUpdate:function(){this.lastUpdate=(new Date)[p]()},_generateUID:function(){for(var b=f.genUID();this.get(b);b=f.genUID());return b},_reIndex:function(){this.indices={_id:{}};this.each(function(b,a){this.indices._id[a._id]=b});return this},
each:function(b){for(var a=0,c=this.length;a<c;++a){var e=b.call(this,a,this[a]);if(!e&&"undefined"!==typeof e)break}return this},get:function(b){return this.indices._id.hasOwnProperty(b)?this[this.indices._id[b]]:!1},find:e,bombilla:e,shuffle:n,stir:n,clone:function(){return this.slice(0)},random:function(){var b=this.clone().shuffle();return b[Math.random()*b.length|0]},addOne:function(b){b={data:b};b._id=b.data._id||this._generateUID();if(this.indices._id.hasOwnProperty(b._id))this[this.indices._id[b._id]]=
b;else{var a=this.length++;this[a]=b;this.indices._id[b._id]=a}this._setLastUpdate();return this},add:g,pour:g,toArray:function(){return f.toArray(this)},slice:function(b,c){return new a(Array.prototype.slice.call(this,b,c))},pop:h,sip:h,shift:function(){var a=Array.prototype.shift.call(this);this._reIndex();return a},flush:m,spill:m,extend:function(){for(var b=0,c=arguments.length;b<c;++b)console.log(a.isYerba(arguments[b])),"yerba"===typeof arguments[b]&&console.log("yerbaaa")}};a.isYerba=function(b){return b instanceof
a};a._$=f;if("undefined"!==typeof module&&module.exports)module.exports=a;else if(window)window.yerba=a;else return a})(function(){function f(){}var l=Object.create||function(){function a(){}return function(c){if(1!=arguments.length)throw Error("Object.create implementation only accepts one parameter.");a.prototype=c;return new a}}();f.prototype={genUID:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var c=16*Math.random()|0;return("x"===a?c:c&3|8).toString(16)})},
isFunction:function(a){return"[object Function]"===Object.prototype.toString.call(a)},isString:function(a){return"string"===typeof a||a instanceof String},isNumber:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},isObject:function(a){return a===Object(a)&&"[object Array]"!==Object.prototype.toString.call(a)},isArray:Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)},toArray:function(a){for(var c=[],e=0,g=a.length;e<g;++e)c.push(a[e]);return c},extend:function(){var a=
arguments;if(0===a.length)return!1;for(var c=0,e=a.length,g=l(a[0]);c<e;c++)for(var f in a[c])g[f]=a[c][f];return g}};return new f}(),void 0)}).call(this);
<|endoftext|>


<commit_before>import { assert } from 'chai';
import sinon from 'sinon';
import Cell from '../../src/Cell';

describe('Cell', () => {
  it('Should properly create cell with default arguments', () => {
    const cell = new Cell();

    assert.instanceOf(cell, Cell);
    assert.equal(cell._char, ' ');
    assert.equal(cell._x, 0);
    assert.equal(cell._y, 0);
    assert.deepEqual(cell._background, {r: -1, g: -1, b: -1});
    assert.deepEqual(cell._foreground, {r: -1, g: -1, b: -1});
    assert.deepEqual(cell._display, {
      bold: false,
      dim: false,
      underlined: false,
      blink: false,
      reverse: false,
      hidden: false
    });
  });

  it('Should properly get/set char', () => {
    const cell = new Cell();

    assert.equal(cell.getChar(), ' ');
    assert.instanceOf(cell.setChar('t'), Cell);
    assert.equal(cell.getChar(), 't');
    assert.instanceOf(cell.setChar('long text'), Cell);
    assert.equal(cell.getChar(), 'l');
  });

  it('Should properly get/set X coordinate', () => {
    const cell = new Cell();

    assert.equal(cell.getX(), 0);
    assert.instanceOf(cell.setX(40), Cell);
    assert.equal(cell.getX(), 40);
    assert.instanceOf(cell.setX(50.99), Cell);
    assert.equal(cell.getX(), 50);
  });

  it('Should properly get/set Y coordinate', () => {
    const cell = new Cell();

    assert.equal(cell.getY(), 0);
    assert.instanceOf(cell.setY(40), Cell);
    assert.equal(cell.getY(), 40);
    assert.instanceOf(cell.setY(50.99), Cell);
    assert.equal(cell.getY(), 50);
  });

  it('Should properly get/set background color', () => {
    const cell = new Cell();

    assert.deepEqual(cell.getBackground(), {r: -1, g: -1, b: -1});
    assert.instanceOf(cell.setBackground({r: 0, g: 100, b: 200}), Cell);
    assert.deepEqual(cell.getBackground(), {r: 0, g: 100, b: 200});
    assert.instanceOf(cell.setBackground(), Cell);
    assert.deepEqual(cell.getBackground(), {r: -1, g: -1, b: -1});
  });

  it('Should properly get/set foreground color', () => {
    const cell = new Cell();

    assert.deepEqual(cell.getForeground(), {r: -1, g: -1, b: -1});
    assert.instanceOf(cell.setForeground({r: 0, g: 100, b: 200}), Cell);
    assert.deepEqual(cell.getForeground(), {r: 0, g: 100, b: 200});
    assert.instanceOf(cell.setForeground(), Cell);
    assert.deepEqual(cell.getForeground(), {r: -1, g: -1, b: -1});
  });

  it('Should properly get/set display modes', () => {
    const cell = new Cell();

    assert.deepEqual(cell.getDisplay(), {
      bold: false,
      dim: false,
      underlined: false,
      blink: false,
      reverse: false,
      hidden: false
    });

    assert.instanceOf(cell.setDisplay({bold: true, underlined: true, dim: false}), Cell);
    assert.deepEqual(cell.getDisplay(), {
      bold: true,
      dim: false,
      underlined: true,
      blink: false,
      reverse: false,
      hidden: false
    });

    assert.instanceOf(cell.setDisplay(), Cell);
    assert.deepEqual(cell.getDisplay(), {
      bold: false,
      dim: false,
      underlined: false,
      blink: false,
      reverse: false,
      hidden: false
    });
  });

  it('Should properly mark cell as modified', () => {
    const cell = new Cell();

    assert.ok(cell.isModified());
    assert.instanceOf(cell.setModified(false), Cell);
    assert.notOk(cell.isModified());
    assert.instanceOf(cell.setModified(), Cell);
    assert.ok(cell.isModified());
  });

  it('Should properly reset the cell contents and display settings', () => {
    const cell = new Cell();
    const mock = sinon.mock(cell);

    mock.expects('setChar').once().returns(cell);
    mock.expects('setBackground').once().returns(cell);
    mock.expects('setForeground').once().returns(cell);
    mock.expects('setDisplay').once().returns(cell);

    assert.instanceOf(cell.reset(), Cell);
    mock.verify();
  });

  it('Should properly convert Cell into ASCII sequence', () => {
    const cell = new Cell();

    assert.equal(cell.toString(), '\u001b[1;1f\u001b[48;2;-1;-1;-1m\u001b[38;2;-1;-1;-1m \u001b[0m');
    assert.instanceOf(cell.setX(20), Cell);
    assert.equal(cell.toString(), '\u001b[1;21f\u001b[48;2;-1;-1;-1m\u001b[38;2;-1;-1;-1m \u001b[0m');
    assert.instanceOf(cell.setY(10), Cell);
    assert.equal(cell.toString(), '\u001b[11;21f\u001b[48;2;-1;-1;-1m\u001b[38;2;-1;-1;-1m \u001b[0m');
    assert.instanceOf(cell.setBackground({r: 0, g: 100, b: 200}), Cell);
    assert.equal(cell.toString(), '\u001b[11;21f\u001b[48;2;0;100;200m\u001b[38;2;-1;-1;-1m \u001b[0m');
    assert.instanceOf(cell.setForeground({r: 200, g: 100, b: 0}), Cell);
    assert.equal(cell.toString(), '\u001b[11;21f\u001b[48;2;0;100;200m\u001b[38;2;200;100;0m \u001b[0m');
    assert.instanceOf(cell.setDisplay({bold: true, underlined: true, dim: false}), Cell);
    assert.equal(cell.toString(), '\u001b[11;21f\u001b[48;2;0;100;200m\u001b[38;2;200;100;0m\u001b[1m\u001b[4m \u001b[0m');
  });

  it('Should properly create Cell instance from static create()', () => {
    const cell = Cell.create(' ', {x: 10, y: 20});

    assert.instanceOf(cell, Cell);
    assert.equal(cell._char, ' ');
    assert.equal(cell._x, 10);
    assert.equal(cell._y, 20);
    assert.deepEqual(cell._background, {r: -1, g: -1, b: -1});
    assert.deepEqual(cell._foreground, {r: -1, g: -1, b: -1});
    assert.deepEqual(cell._display, {
      bold: false,
      dim: false,
      underlined: false,
      blink: false,
      reverse: false,
      hidden: false
    });
  })
});
<commit_msg>test(cell): Fix tests<commit_after>import { assert } from 'chai';
import sinon from 'sinon';
import Cell from '../../src/Cell';

describe('Cell', () => {
  it('Should properly create cell with default arguments', () => {
    const cell = new Cell();

    assert.instanceOf(cell, Cell);
    assert.equal(cell._char, ' ');
    assert.equal(cell._x, 0);
    assert.equal(cell._y, 0);
    assert.deepEqual(cell._background, {r: -1, g: -1, b: -1});
    assert.deepEqual(cell._foreground, {r: -1, g: -1, b: -1});
    assert.deepEqual(cell._display, {
      bold: false,
      dim: false,
      underlined: false,
      blink: false,
      reverse: false,
      hidden: false
    });
  });

  it('Should properly get/set char', () => {
    const cell = new Cell();

    assert.equal(cell.getChar(), ' ');
    assert.instanceOf(cell.setChar('t'), Cell);
    assert.equal(cell.getChar(), 't');
    assert.instanceOf(cell.setChar('long text'), Cell);
    assert.equal(cell.getChar(), 'l');
  });

  it('Should properly get/set X coordinate', () => {
    const cell = new Cell();

    assert.equal(cell.getX(), 0);
    assert.instanceOf(cell.setX(40), Cell);
    assert.equal(cell.getX(), 40);
    assert.instanceOf(cell.setX(50.99), Cell);
    assert.equal(cell.getX(), 50);
  });

  it('Should properly get/set Y coordinate', () => {
    const cell = new Cell();

    assert.equal(cell.getY(), 0);
    assert.instanceOf(cell.setY(40), Cell);
    assert.equal(cell.getY(), 40);
    assert.instanceOf(cell.setY(50.99), Cell);
    assert.equal(cell.getY(), 50);
  });

  it('Should properly get/set background color', () => {
    const cell = new Cell();

    assert.deepEqual(cell.getBackground(), {r: -1, g: -1, b: -1});
    assert.instanceOf(cell.setBackground({r: 0, g: 100, b: 200}), Cell);
    assert.deepEqual(cell.getBackground(), {r: 0, g: 100, b: 200});
    assert.instanceOf(cell.setBackground(), Cell);
    assert.deepEqual(cell.getBackground(), {r: -1, g: -1, b: -1});
  });

  it('Should properly get/set foreground color', () => {
    const cell = new Cell();

    assert.deepEqual(cell.getForeground(), {r: -1, g: -1, b: -1});
    assert.instanceOf(cell.setForeground({r: 0, g: 100, b: 200}), Cell);
    assert.deepEqual(cell.getForeground(), {r: 0, g: 100, b: 200});
    assert.instanceOf(cell.setForeground(), Cell);
    assert.deepEqual(cell.getForeground(), {r: -1, g: -1, b: -1});
  });

  it('Should properly get/set display modes', () => {
    const cell = new Cell();

    assert.deepEqual(cell.getDisplay(), {
      bold: false,
      dim: false,
      underlined: false,
      blink: false,
      reverse: false,
      hidden: false
    });

    assert.instanceOf(cell.setDisplay({bold: true, underlined: true, dim: false}), Cell);
    assert.deepEqual(cell.getDisplay(), {
      bold: true,
      dim: false,
      underlined: true,
      blink: false,
      reverse: false,
      hidden: false
    });

    assert.instanceOf(cell.setDisplay(), Cell);
    assert.deepEqual(cell.getDisplay(), {
      bold: false,
      dim: false,
      underlined: false,
      blink: false,
      reverse: false,
      hidden: false
    });
  });

  it('Should properly mark cell as modified', () => {
    const cell = new Cell();

    assert.notOk(cell.isModified());
    assert.instanceOf(cell.setModified(false), Cell);
    assert.notOk(cell.isModified());
    assert.instanceOf(cell.setModified(), Cell);
    assert.ok(cell.isModified());
  });

  it('Should properly reset the cell contents and display settings', () => {
    const cell = new Cell();
    const mock = sinon.mock(cell);

    mock.expects('setChar').once().returns(cell);
    mock.expects('setBackground').once().returns(cell);
    mock.expects('setForeground').once().returns(cell);
    mock.expects('setDisplay').once().returns(cell);

    assert.instanceOf(cell.reset(), Cell);
    mock.verify();
  });

  it('Should properly convert Cell into ASCII sequence', () => {
    const cell = new Cell();

    assert.equal(cell.toString(), '\u001b[1;1f\u001b[48;2;-1;-1;-1m\u001b[38;2;-1;-1;-1m \u001b[0m');
    assert.instanceOf(cell.setX(20), Cell);
    assert.equal(cell.toString(), '\u001b[1;21f\u001b[48;2;-1;-1;-1m\u001b[38;2;-1;-1;-1m \u001b[0m');
    assert.instanceOf(cell.setY(10), Cell);
    assert.equal(cell.toString(), '\u001b[11;21f\u001b[48;2;-1;-1;-1m\u001b[38;2;-1;-1;-1m \u001b[0m');
    assert.instanceOf(cell.setBackground({r: 0, g: 100, b: 200}), Cell);
    assert.equal(cell.toString(), '\u001b[11;21f\u001b[48;2;0;100;200m\u001b[38;2;-1;-1;-1m \u001b[0m');
    assert.instanceOf(cell.setForeground({r: 200, g: 100, b: 0}), Cell);
    assert.equal(cell.toString(), '\u001b[11;21f\u001b[48;2;0;100;200m\u001b[38;2;200;100;0m \u001b[0m');
    assert.instanceOf(cell.setDisplay({bold: true, underlined: true, dim: false}), Cell);
    assert.equal(cell.toString(), '\u001b[11;21f\u001b[48;2;0;100;200m\u001b[38;2;200;100;0m\u001b[1m\u001b[4m \u001b[0m');
  });

  it('Should properly create Cell instance from static create()', () => {
    const cell = Cell.create(' ', {x: 10, y: 20});

    assert.instanceOf(cell, Cell);
    assert.equal(cell._char, ' ');
    assert.equal(cell._x, 10);
    assert.equal(cell._y, 20);
    assert.deepEqual(cell._background, {r: -1, g: -1, b: -1});
    assert.deepEqual(cell._foreground, {r: -1, g: -1, b: -1});
    assert.deepEqual(cell._display, {
      bold: false,
      dim: false,
      underlined: false,
      blink: false,
      reverse: false,
      hidden: false
    });
  })
});
<|endoftext|>


<commit_before>//  Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog)

var Class = require('../../utils/Class');
var FromPoints = require('../../geom/rectangle/FromPoints');
var Rectangle = require('../../geom/rectangle/Rectangle');
var Vector2 = require('../../math/Vector2');

//  Our Base Curve which all other curves extend

var Curve = new Class({

    initialize:

    /**
     * [description]
     *
     * @class Curve
     * @memberOf Phaser.Curves
     * @constructor
     * @since 3.0.0
     *
     * @param {string} type - [description]
     */
    function Curve (type)
    {
        /**
         * String based identifier
         *
         * @property {string} type
         */
        this.type = type;

        /**
         * [description]
         *
         * @property {integer} defaultDivisions
         * @default 5
         */
        this.defaultDivisions = 5;

        /**
         * [description]
         *
         * @property {integer} arcLengthDivisions
         * @default 100
         */
        this.arcLengthDivisions = 100;

        /**
         * [description]
         *
         * @property {array} cacheArcLengths
         * @default []
         */
        this.cacheArcLengths = [];

        /**
         * [description]
         *
         * @property {boolean} needsUpdate
         * @default true
         */
        this.needsUpdate = true;

        /**
         * [description]
         *
         * @property {boolean} active
         * @default true
         */
        this.active = true;

        /**
         * [description]
         *
         * @property {Phaser.Math.Vector2} _tmpVec2A
         * @private
         */
        this._tmpVec2A = new Vector2();

        /**
         * [description]
         *
         * @property {Phaser.Math.Vector2} _tmpVec2B
         * @private
         */
        this._tmpVec2B = new Vector2();
    },

    /**
     * [description]
     *
     * @method Phaser.Curves.Curve#draw
     * @since 3.0.0
     *
     * @param {Phaser.GameObjects.Graphics} graphics - [description]
     * @param {integer} [pointsTotal=32] - [description]
     *
     * @return {Phaser.GameObjects.Graphics} [description]
     */
    draw: function (graphics, pointsTotal)
    {
        if (pointsTotal === undefined) { pointsTotal = 32; }

        //  So you can chain graphics calls
        return graphics.strokePoints(this.getPoints(pointsTotal));
    },

    /**
     * [description]
     *
     * @method Phaser.Curves.Curve#getBounds
     * @since 3.0.0
     *
     * @param {Phaser.Geom.Rectangle} out - [description]
     * @param {integer} [accuracy=16] - [description]
     *
     * @return {Phaser.Geom.Rectangle} [description]
     */
    getBounds: function (out, accuracy)
    {
        if (out === undefined) { out = new Rectangle(); }
        if (accuracy === undefined) { accuracy = 16; }

        var len = this.getLength();

        if (accuracy > len)
        {
            accuracy = len / 2;
        }

        //  The length of the curve in pixels
        //  So we'll have 1 spaced point per 'accuracy' pixels

        var spaced = Math.max(1, Math.round(len / accuracy));

        return FromPoints(this.getSpacedPoints(spaced), out);
    },

    //  Return an array of points, spaced out X distance pixels apart

    /**
     * [description]
     *
     * @method Phaser.Curves.Curve#getDistancePoints
     * @since 3.0.0
     *
     * @param {integer} distance - [description]
     *
     * @return {Phaser.Geom.Point[]} [description]
     */
    getDistancePoints: function (distance)
    {
        var len = this.getLength();

        var spaced = Math.max(1, len / distance);

        return this.getSpacedPoints(spaced);
    },

    /**
     * [description]
     *
     * @method Phaser.Curves.Curve#getEndPoint
     * @since 3.0.0
     *
     * @param {Phaser.Math.Vector2} out - [description]
     *
     * @return {Phaser.Math.Vector2} [description]
     */
    getEndPoint: function (out)
    {
        if (out === undefined) { out = new Vector2(); }

        return this.getPointAt(1, out);
    },

    // Get total curve arc length

    /**
     * [description]
     *
     * @method Phaser.Curves.Curve#getLength
     * @since 3.0.0
     *
     * @return {number} [description]
     */
    getLength: function ()
    {
        var lengths = this.getLengths();

        return lengths[lengths.length - 1];
    },

    // Get list of cumulative segment lengths

    /**
     * [description]
     *
     * @method Phaser.Curves.Curve#getLengths
     * @since 3.0.0
     *
     * @param {integer} [divisions] - [description]
     *
     * @return {number[]} [description]
     */
    getLengths: function (divisions)
    {
        if (divisions === undefined) { divisions = this.arcLengthDivisions; }

        if ((this.cacheArcLengths.length === divisions + 1) && !this.needsUpdate)
        {
            return this.cacheArcLengths;
        }

        this.needsUpdate = false;

        var cache = [];
        var current;
        var last = this.getPoint(0, this._tmpVec2A);
        var sum = 0;

        cache.push(0);

        for (var p = 1; p <= divisions; p++)
        {
            current = this.getPoint(p / divisions, this._tmpVec2B);

            sum += current.distance(last);

            cache.push(sum);

            last.copy(current);
        }

        this.cacheArcLengths = cache;

        return cache; // { sums: cache, sum:sum }; Sum is in the last element.
    },

    // Get point at relative position in curve according to arc length

    // - u [0 .. 1]

    /**
     * [description]
     *
     * @method Phaser.Curves.Curve#getPointAt
     * @since 3.0.0
     *
     * @param {float} u - [description]
     * @param {Phaser.Math.Vector2} [out] - [description]
     *
     * @return {Phaser.Math.Vector2} [description]
     */
    getPointAt: function (u, out)
    {
        var t = this.getUtoTmapping(u);

        return this.getPoint(t, out);
    },

    // Get sequence of points using getPoint( t )

    /**
     * [description]
     *
     * @method Phaser.Curves.Curve#getPoints
     * @since 3.0.0
     *
     * @param {integer} [divisions] - [description]
     *
     * @return {Phaser.Math.Vector2[]} [description]
     */
    getPoints: function (divisions)
    {
        if (divisions === undefined) { divisions = this.defaultDivisions; }

        var points = [];

        for (var d = 0; d <= divisions; d++)
        {
            points.push(this.getPoint(d / divisions));
        }

        return points;
    },

    /**
     * [description]
     *
     * @method Phaser.Curves.Curve#getRandomPoint
     * @since 3.0.0
     *
     * @param {Phaser.Math.Vector2} [out] - [description]
     *
     * @return {Phaser.Math.Vector2} [description]
     */
    getRandomPoint: function (out)
    {
        if (out === undefined) { out = new Vector2(); }

        return this.getPoint(Math.random(), out);
    },

    // Get sequence of points using getPointAt( u )

    /**
     * [description]
     *
     * @method Phaser.Curves.Curve#getSpacedPoints
     * @since 3.0.0
     *
     * @param {integer} [divisions] - [description]
     *
     * @return {Phaser.Math.Vector2[]} [description]
     */
    getSpacedPoints: function (divisions)
    {
        if (divisions === undefined) { divisions = this.defaultDivisions; }

        var points = [];

        for (var d = 0; d <= divisions; d++)
        {
            var t = this.getUtoTmapping(d / divisions, null, divisions);

            points.push(this.getPoint(t));
        }

        return points;
    },

    /**
     * [description]
     *
     * @method Phaser.Curves.Curve#getStartPoint
     * @since 3.0.0
     *
     * @param {Phaser.Math.Vector2} [out] - [description]
     *
     * @return {Phaser.Math.Vector2} [description]
     */
    getStartPoint: function (out)
    {
        if (out === undefined) { out = new Vector2(); }

        return this.getPointAt(0, out);
    },

    // Returns a unit vector tangent at t
    // In case any sub curve does not implement its tangent derivation,
    // 2 points a small delta apart will be used to find its gradient
    // which seems to give a reasonable approximation

    /**
     * [description]
     *
     * @method Phaser.Curves.Curve#getTangent
     * @since 3.0.0
     *
     * @param {number} t - [description]
     * @param {Phaser.Math.Vector2} [out] - [description]
     *
     * @return {Phaser.Math.Vector2} [description]
     */
    getTangent: function (t, out)
    {
        if (out === undefined) { out = new Vector2(); }

        var delta = 0.0001;
        var t1 = t - delta;
        var t2 = t + delta;

        // Capping in case of danger

        if (t1 < 0)
        {
            t1 = 0;
        }

        if (t2 > 1)
        {
            t2 = 1;
        }

        this.getPoint(t1, this._tmpVec2A);
        this.getPoint(t2, out);

        return out.subtract(this._tmpVec2A).normalize();
    },

    /**
     * [description]
     *
     * @method Phaser.Curves.Curve#getTangentAt
     * @since 3.0.0
     *
     * @param {float} u - [description]
     * @param {Phaser.Math.Vector2} [out] - [description]
     *
     * @return {Phaser.Math.Vector2} [description]
     */
    getTangentAt: function (u, out)
    {
        var t = this.getUtoTmapping(u);

        return this.getTangent(t, out);
    },

    //  Given a distance in pixels, get a t to find p.
    /**
     * [description]
     *
     * @method Phaser.Curves.Curve#getTFromDistance
     * @since 3.0.0
     *
     * @param {integer} distance - [description]
     * @param {integer} [divisions] - [description]
     *
     * @return {float} [description]
     */
    getTFromDistance: function (distance, divisions)
    {
        if (distance <= 0)
        {
            return 0;
        }

        return this.getUtoTmapping(0, distance, divisions);
    },

    // Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equidistant

    /**
     * [description]
     *
     * @method Phaser.Curves.Curve#getUtoTmapping
     * @since 3.0.0
     *
     * @param {float} u - [description]
     * @param {integer} distance - [description]
     * @param {integer} [divisions] - [description]
     *
     * @return {number} [description]
     */
    getUtoTmapping: function (u, distance, divisions)
    {
        var arcLengths = this.getLengths(divisions);

        var i = 0;
        var il = arcLengths.length;

        var targetArcLength; // The targeted u distance value to get

        if (distance)
        {
            //  Cannot overshoot the curve
            targetArcLength = Math.min(distance, arcLengths[il - 1]);
        }
        else
        {
            targetArcLength = u * arcLengths[il - 1];
        }

        // binary search for the index with largest value smaller than target u distance

        var low = 0;
        var high = il - 1;
        var comparison;

        while (low <= high)
        {
            i = Math.floor(low + (high - low) / 2); // less likely to overflow, though probably not issue here, JS doesn't really have integers, all numbers are floats

            comparison = arcLengths[i] - targetArcLength;

            if (comparison < 0)
            {
                low = i + 1;
            }
            else if (comparison > 0)
            {
                high = i - 1;
            }
            else
            {
                high = i;
                break;
            }
        }

        i = high;

        if (arcLengths[i] === targetArcLength)
        {
            return i / (il - 1);
        }

        // we could get finer grain at lengths, or use simple interpolation between two points

        var lengthBefore = arcLengths[i];
        var lengthAfter = arcLengths[i + 1];

        var segmentLength = lengthAfter - lengthBefore;

        // determine where we are between the 'before' and 'after' points

        var segmentFraction = (targetArcLength - lengthBefore) / segmentLength;

        // add that fractional amount to t

        return (i + segmentFraction) / (il - 1);
    },

    /**
     * [description]
     *
     * @method Phaser.Curves.Curve#updateArcLengths
     * @since 3.0.0
     */
    updateArcLengths: function ()
    {
        this.needsUpdate = true;

        this.getLengths();
    }

});

module.exports = Curve;
<commit_msg>Added jsdocs.<commit_after>var Class = require('../../utils/Class');
var FromPoints = require('../../geom/rectangle/FromPoints');
var Rectangle = require('../../geom/rectangle/Rectangle');
var Vector2 = require('../../math/Vector2');

var Curve = new Class({

    initialize:

    /**
     * A Base Curve class, which all other curve types extend.
     *
     * Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog)
     *
     * @class Curve
     * @memberOf Phaser.Curves
     * @constructor
     * @since 3.0.0
     *
     * @param {string} type - [description]
     */
    function Curve (type)
    {
        /**
         * String based identifier for the type of curve.
         *
         * @property {string} type
         * @since 3.0.0
         */
        this.type = type;

        /**
         * The default number of divisions within the curve.
         *
         * @property {integer} defaultDivisions
         * @since 3.0.0
         * @default 5
         */
        this.defaultDivisions = 5;

        /**
         * The quantity of arc length divisions within the curve.
         *
         * @property {integer} arcLengthDivisions
         * @since 3.0.0
         * @default 100
         */
        this.arcLengthDivisions = 100;

        /**
         * An array of cached arc length values.
         *
         * @property {array} cacheArcLengths
         * @since 3.0.0
         * @default []
         */
        this.cacheArcLengths = [];

        /**
         * Does the data of this curve need updating?
         *
         * @property {boolean} needsUpdate
         * @since 3.0.0
         * @default true
         */
        this.needsUpdate = true;

        /**
         * [description]
         *
         * @property {boolean} active
         * @since 3.0.0
         * @default true
         */
        this.active = true;

        /**
         * A temporary calculation Vector.
         *
         * @property {Phaser.Math.Vector2} _tmpVec2A
         * @since 3.0.0
         * @private
         */
        this._tmpVec2A = new Vector2();

        /**
         * A temporary calculation Vector.
         *
         * @property {Phaser.Math.Vector2} _tmpVec2B
         * @since 3.0.0
         * @private
         */
        this._tmpVec2B = new Vector2();
    },

    /**
     * Draws this curve on the given Graphics object.
     *
     * The curve is drawn using `Graphics.strokePoints` so will be drawn at whatever the present Graphics stroke color is.
     * The Graphics object is not cleared before the draw, so the curve will appear on-top of anything else already rendered to it.
     *
     * @method Phaser.Curves.Curve#draw
     * @since 3.0.0
     *
     * @param {Phaser.GameObjects.Graphics} graphics - The Graphics instance onto which this curve will be drawn.
     * @param {integer} [pointsTotal=32] - The resolution of the curve. The higher the value the smoother it will render, at the cost of rendering performance.
     *
     * @return {Phaser.GameObjects.Graphics} The Graphics object to which the curve was drawn.
     */
    draw: function (graphics, pointsTotal)
    {
        if (pointsTotal === undefined) { pointsTotal = 32; }

        //  So you can chain graphics calls
        return graphics.strokePoints(this.getPoints(pointsTotal));
    },

    /**
     * Returns a Rectangle where the position and dimensions match the bounds of this Curve.
     *
     * You can control the accuracy of the bounds. The value given is used to work out how many points
     * to plot across the curve. Higher values are more accurate at the cost of calculation speed.
     *
     * @method Phaser.Curves.Curve#getBounds
     * @since 3.0.0
     *
     * @param {Phaser.Geom.Rectangle} out - The Rectangle to store the bounds in. If falsey a new object will be created.
     * @param {integer} [accuracy=16] - The accuracy of the bounds calculations.
     *
     * @return {Phaser.Geom.Rectangle} A Rectangle containing the bounds values of this Curve.
     */
    getBounds: function (out, accuracy)
    {
        if (!out) { out = new Rectangle(); }
        if (accuracy === undefined) { accuracy = 16; }

        var len = this.getLength();

        if (accuracy > len)
        {
            accuracy = len / 2;
        }

        //  The length of the curve in pixels
        //  So we'll have 1 spaced point per 'accuracy' pixels

        var spaced = Math.max(1, Math.round(len / accuracy));

        return FromPoints(this.getSpacedPoints(spaced), out);
    },

    /**
     * Returns an array of points, spaced out X distance pixels apart.
     * The smaller the distance, the larger the array will be.
     *
     * @method Phaser.Curves.Curve#getDistancePoints
     * @since 3.0.0
     *
     * @param {integer} distance - The distance, in pixels, between each point along the curve.
     *
     * @return {Phaser.Geom.Point[]} An Array of Point objects.
     */
    getDistancePoints: function (distance)
    {
        var len = this.getLength();

        var spaced = Math.max(1, len / distance);

        return this.getSpacedPoints(spaced);
    },

    /**
     * [description]
     *
     * @method Phaser.Curves.Curve#getEndPoint
     * @since 3.0.0
     *
     * @param {Phaser.Math.Vector2} out - [description]
     *
     * @return {Phaser.Math.Vector2} [description]
     */
    getEndPoint: function (out)
    {
        if (out === undefined) { out = new Vector2(); }

        return this.getPointAt(1, out);
    },

    // Get total curve arc length

    /**
     * [description]
     *
     * @method Phaser.Curves.Curve#getLength
     * @since 3.0.0
     *
     * @return {number} [description]
     */
    getLength: function ()
    {
        var lengths = this.getLengths();

        return lengths[lengths.length - 1];
    },

    // Get list of cumulative segment lengths

    /**
     * [description]
     *
     * @method Phaser.Curves.Curve#getLengths
     * @since 3.0.0
     *
     * @param {integer} [divisions] - [description]
     *
     * @return {number[]} [description]
     */
    getLengths: function (divisions)
    {
        if (divisions === undefined) { divisions = this.arcLengthDivisions; }

        if ((this.cacheArcLengths.length === divisions + 1) && !this.needsUpdate)
        {
            return this.cacheArcLengths;
        }

        this.needsUpdate = false;

        var cache = [];
        var current;
        var last = this.getPoint(0, this._tmpVec2A);
        var sum = 0;

        cache.push(0);

        for (var p = 1; p <= divisions; p++)
        {
            current = this.getPoint(p / divisions, this._tmpVec2B);

            sum += current.distance(last);

            cache.push(sum);

            last.copy(current);
        }

        this.cacheArcLengths = cache;

        return cache; // { sums: cache, sum:sum }; Sum is in the last element.
    },

    // Get point at relative position in curve according to arc length

    // - u [0 .. 1]

    /**
     * [description]
     *
     * @method Phaser.Curves.Curve#getPointAt
     * @since 3.0.0
     *
     * @param {float} u - [description]
     * @param {Phaser.Math.Vector2} [out] - [description]
     *
     * @return {Phaser.Math.Vector2} [description]
     */
    getPointAt: function (u, out)
    {
        var t = this.getUtoTmapping(u);

        return this.getPoint(t, out);
    },

    // Get sequence of points using getPoint( t )

    /**
     * [description]
     *
     * @method Phaser.Curves.Curve#getPoints
     * @since 3.0.0
     *
     * @param {integer} [divisions] - [description]
     *
     * @return {Phaser.Math.Vector2[]} [description]
     */
    getPoints: function (divisions)
    {
        if (divisions === undefined) { divisions = this.defaultDivisions; }

        var points = [];

        for (var d = 0; d <= divisions; d++)
        {
            points.push(this.getPoint(d / divisions));
        }

        return points;
    },

    /**
     * [description]
     *
     * @method Phaser.Curves.Curve#getRandomPoint
     * @since 3.0.0
     *
     * @param {Phaser.Math.Vector2} [out] - [description]
     *
     * @return {Phaser.Math.Vector2} [description]
     */
    getRandomPoint: function (out)
    {
        if (out === undefined) { out = new Vector2(); }

        return this.getPoint(Math.random(), out);
    },

    // Get sequence of points using getPointAt( u )

    /**
     * [description]
     *
     * @method Phaser.Curves.Curve#getSpacedPoints
     * @since 3.0.0
     *
     * @param {integer} [divisions] - [description]
     *
     * @return {Phaser.Math.Vector2[]} [description]
     */
    getSpacedPoints: function (divisions)
    {
        if (divisions === undefined) { divisions = this.defaultDivisions; }

        var points = [];

        for (var d = 0; d <= divisions; d++)
        {
            var t = this.getUtoTmapping(d / divisions, null, divisions);

            points.push(this.getPoint(t));
        }

        return points;
    },

    /**
     * [description]
     *
     * @method Phaser.Curves.Curve#getStartPoint
     * @since 3.0.0
     *
     * @param {Phaser.Math.Vector2} [out] - [description]
     *
     * @return {Phaser.Math.Vector2} [description]
     */
    getStartPoint: function (out)
    {
        if (out === undefined) { out = new Vector2(); }

        return this.getPointAt(0, out);
    },

    // Returns a unit vector tangent at t
    // In case any sub curve does not implement its tangent derivation,
    // 2 points a small delta apart will be used to find its gradient
    // which seems to give a reasonable approximation

    /**
     * [description]
     *
     * @method Phaser.Curves.Curve#getTangent
     * @since 3.0.0
     *
     * @param {number} t - [description]
     * @param {Phaser.Math.Vector2} [out] - [description]
     *
     * @return {Phaser.Math.Vector2} [description]
     */
    getTangent: function (t, out)
    {
        if (out === undefined) { out = new Vector2(); }

        var delta = 0.0001;
        var t1 = t - delta;
        var t2 = t + delta;

        // Capping in case of danger

        if (t1 < 0)
        {
            t1 = 0;
        }

        if (t2 > 1)
        {
            t2 = 1;
        }

        this.getPoint(t1, this._tmpVec2A);
        this.getPoint(t2, out);

        return out.subtract(this._tmpVec2A).normalize();
    },

    /**
     * [description]
     *
     * @method Phaser.Curves.Curve#getTangentAt
     * @since 3.0.0
     *
     * @param {float} u - [description]
     * @param {Phaser.Math.Vector2} [out] - [description]
     *
     * @return {Phaser.Math.Vector2} [description]
     */
    getTangentAt: function (u, out)
    {
        var t = this.getUtoTmapping(u);

        return this.getTangent(t, out);
    },

    //  Given a distance in pixels, get a t to find p.
    /**
     * [description]
     *
     * @method Phaser.Curves.Curve#getTFromDistance
     * @since 3.0.0
     *
     * @param {integer} distance - [description]
     * @param {integer} [divisions] - [description]
     *
     * @return {float} [description]
     */
    getTFromDistance: function (distance, divisions)
    {
        if (distance <= 0)
        {
            return 0;
        }

        return this.getUtoTmapping(0, distance, divisions);
    },

    // Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equidistant

    /**
     * [description]
     *
     * @method Phaser.Curves.Curve#getUtoTmapping
     * @since 3.0.0
     *
     * @param {float} u - [description]
     * @param {integer} distance - [description]
     * @param {integer} [divisions] - [description]
     *
     * @return {number} [description]
     */
    getUtoTmapping: function (u, distance, divisions)
    {
        var arcLengths = this.getLengths(divisions);

        var i = 0;
        var il = arcLengths.length;

        var targetArcLength; // The targeted u distance value to get

        if (distance)
        {
            //  Cannot overshoot the curve
            targetArcLength = Math.min(distance, arcLengths[il - 1]);
        }
        else
        {
            targetArcLength = u * arcLengths[il - 1];
        }

        // binary search for the index with largest value smaller than target u distance

        var low = 0;
        var high = il - 1;
        var comparison;

        while (low <= high)
        {
            i = Math.floor(low + (high - low) / 2); // less likely to overflow, though probably not issue here, JS doesn't really have integers, all numbers are floats

            comparison = arcLengths[i] - targetArcLength;

            if (comparison < 0)
            {
                low = i + 1;
            }
            else if (comparison > 0)
            {
                high = i - 1;
            }
            else
            {
                high = i;
                break;
            }
        }

        i = high;

        if (arcLengths[i] === targetArcLength)
        {
            return i / (il - 1);
        }

        // we could get finer grain at lengths, or use simple interpolation between two points

        var lengthBefore = arcLengths[i];
        var lengthAfter = arcLengths[i + 1];

        var segmentLength = lengthAfter - lengthBefore;

        // determine where we are between the 'before' and 'after' points

        var segmentFraction = (targetArcLength - lengthBefore) / segmentLength;

        // add that fractional amount to t

        return (i + segmentFraction) / (il - 1);
    },

    /**
     * [description]
     *
     * @method Phaser.Curves.Curve#updateArcLengths
     * @since 3.0.0
     */
    updateArcLengths: function ()
    {
        this.needsUpdate = true;

        this.getLengths();
    }

});

module.exports = Curve;
<|endoftext|>


<commit_before>'use strict'

require('debug').enable('*')
var debug = require('debug')('timeline')

var d3 = require('d3')
d3.layout.timeline = require('../lib/d3-plugins/timeline')
var $ = require('jquery')

var componentName = 'timeline'

var store = require('./store')
var action = require('./action')

module.exports = function (p) {

  var props = Object.assign({
    margin: { top: 0, right: 0, bottom: 0, left: 0 },
    width: 0,
    height: 0,
    focused: 0
  }, p || {})

  var div
  var tops = []

  // hack
  $(window).off('scroll')
  $(window).on('scroll', debounce(handleScroll))

  function debounce (func) {
    var wait = 10
    var count
    return function () {
      if (count) { clearTimeout(count) }
      count = setTimeout(func, wait)
    }
  }

  function handleScroll () {

    if (tops.length === 0) return
    var i = props.focused
    var scroll = $(window).scrollTop()
    while (i >= tops.length || (i >= 0 && tops[i].top > scroll)) i--
    while (i < 0 || tops[i].top <= scroll) i++
    if (i !== props.focused) {
      action.run('focused', { value: i, date: tops[i].date })
    }
  }

  function eventHTML (d) {
    return '
' + d.date + '

' + ' [' + d.category.join('][') + '] ' + '' + d.title + '

' + d.ref + (d.location ? '(' + d.location.join(',') + ')' : '') + '
'
  }

  function drawTimeline (data) {
    debug('drawTimeline with %o', data)

    var events = div.selectAll('div.event')
      .data(data)
      .classed('focused', function (d, i) { return i === props.focused })
      .html(eventHTML)
    events.enter().append('div')
      .classed('event', true)
      .classed('focused', function (d, i) { return i === props.focused })
      .html(eventHTML)
    events.exit().remove()

    tops = []
    events[0].forEach(function (e, i) {
      tops.push({
        date: new Date(data[i].date),
        top: $(e).offset().top
      })
    })
    if (events[0].length > 0) {
      var lastEvent = $(events[0][events[0].length - 1])
      var timelineHeight = lastEvent.offset().top + lastEvent.outerHeight()
      if (props.height !== timelineHeight) {
        action.run('setHeight', timelineHeight)
      }
    }
  }

  function draw (selection) {
    debug('draw with %o', props)

    div = selection.selectAll('div.' + componentName)
      .data([0])
      .style('margin-top', props.margin.top + 'px')
      .style('margin-right', props.margin.right + 'px')
      .style('margin-bottom', props.margin.bottom + 'px')
      .style('margin-left', props.margin.left + 'px')
      .style('width', props.width + 'px')
    div.enter().append('div')
      .classed(componentName, true)
      .style('margin-top', props.margin.top + 'px')
      .style('margin-right', props.margin.right + 'px')
      .style('margin-bottom', props.margin.bottom + 'px')
      .style('margin-left', props.margin.left + 'px')
      .style('width', props.width + 'px')
    div.exit().remove()

    drawTimeline(store.get('timeline') || [])
  }

  return draw
}
<commit_msg>drop excessive debug enable<commit_after>'use strict'

var debug = require('debug')('timeline')

var d3 = require('d3')
d3.layout.timeline = require('../lib/d3-plugins/timeline')
var $ = require('jquery')

var componentName = 'timeline'

var store = require('./store')
var action = require('./action')

module.exports = function (p) {

  var props = Object.assign({
    margin: { top: 0, right: 0, bottom: 0, left: 0 },
    width: 0,
    height: 0,
    focused: 0
  }, p || {})

  var div
  var tops = []

  // hack
  $(window).off('scroll')
  $(window).on('scroll', debounce(handleScroll))

  function debounce (func) {
    var wait = 10
    var count
    return function () {
      if (count) { clearTimeout(count) }
      count = setTimeout(func, wait)
    }
  }

  function handleScroll () {

    if (tops.length === 0) return
    var i = props.focused
    var scroll = $(window).scrollTop()
    while (i >= tops.length || (i >= 0 && tops[i].top > scroll)) i--
    while (i < 0 || tops[i].top <= scroll) i++
    if (i !== props.focused) {
      action.run('focused', { value: i, date: tops[i].date })
    }
  }

  function eventHTML (d) {
    return '
' + d.date + '

' + ' [' + d.category.join('][') + '] ' + '' + d.title + '

' + '
'
  }

  function drawTimeline (data) {
    debug('drawTimeline with %o', data)

    var events = div.selectAll('div.event')
      .data(data)
      .classed('focused', function (d, i) { return i === props.focused })
      .html(eventHTML)
    events.enter().append('div')
      .classed('event', true)
      .classed('focused', function (d, i) { return i === props.focused })
      .html(eventHTML)
    events.exit().remove()

    tops = []
    events[0].forEach(function (e, i) {
      tops.push({
        date: new Date(data[i].date),
        top: $(e).offset().top
      })
    })
    if (events[0].length > 0) {
      var lastEvent = $(events[0][events[0].length - 1])
      var timelineHeight = lastEvent.offset().top + lastEvent.outerHeight()
      if (props.height !== timelineHeight) {
        action.run('setHeight', timelineHeight)
      }
    }
  }

  function draw (selection) {
    debug('draw with %o', props)

    div = selection.selectAll('div.' + componentName)
      .data([0])
      .style('margin-top', props.margin.top + 'px')
      .style('margin-right', props.margin.right + 'px')
      .style('margin-bottom', props.margin.bottom + 'px')
      .style('margin-left', props.margin.left + 'px')
      .style('width', props.width + 'px')
    div.enter().append('div')
      .classed(componentName, true)
      .style('margin-top', props.margin.top + 'px')
      .style('margin-right', props.margin.right + 'px')
      .style('margin-bottom', props.margin.bottom + 'px')
      .style('margin-left', props.margin.left + 'px')
      .style('width', props.width + 'px')
    div.exit().remove()

    drawTimeline(store.get('timeline') || [])
  }

  return draw
}
<|endoftext|>


<commit_before>import Client from './Client';

const javascriptSdk = {
  Client
};

export default javascriptSdk;
<commit_msg>Case client correctly<commit_after>import Client from './client';

const javascriptSdk = {
  Client
};

export default javascriptSdk;
<|endoftext|>


<commit_before>import React from 'react'
import {
  Provider,
  Banner,
  Heading,
  Lead,
  Container,
  Flex,
  Box,
  Text,
  Subhead,
  Absolute,
  ButtonOutline
} from 'rebass'
import theme, { colors, mx } from '../theme'
import { Head, Link } from 'react-static'
import Features from '../components/Features'
import Stat from '../components/Stat'

const css = `
  body { background-color: #000; }
  #root > div, #features *, #stats span {
    color: ${colors.green[6]} !important;
    font-family: ${theme.monospace} !important;
    letter-spacing: -.02em;
  }
  p, a, #stats span {
    text-shadow: 0 1px 2px ${colors.green[4]};
  }
  #features > div > div {
    background-color: #000;
    border: 1px solid ${colors.green[6]};
    border-radius: 0;
  }
  #features img { display: none !important; }
  #features * {
    font-size: ${theme.fontSizes[2]};
  }
  #stats > div {
    padding-left: .5rem;
    padding-right: .5rem;
  }
  #stats p {
    color: ${colors.green[8]};
    text-shadow: none;
  }
  #stats span { font-weight: 400; }
`

const Header = Flex.extend.attrs({
  is: 'header',
  align: 'center',
  justify: 'center',
  direction: 'column',
  px: [3, 0],
  py: [5, 3]
})`
  background: #000 url('/map-repl.svg') no-repeat;
  background-size: cover;
  background-position: 33% top;
  border-bottom: 1px solid ${colors.green[9]};
  text-align: center;
  ${mx[0]} {
    background-position: center top;
    min-height: 75vh !important;
  }
`
const Section = Box.extend.attrs({ is: 'section', py: 4 })`
  border-bottom: 1px solid ${colors.green[9]};
  text-align: center;
`
const Footer = Box.extend.attrs({
  is: 'footer',
  py: 4,
  f: 2
})`text-align: center;`

const Tagline = Text.extend.attrs({
  f: 3,
  mb: 2
})`
  text-align: center;
  text-transform: uppercase;
`
const Headline = Heading.extend.attrs({
  is: 'h1',
  f: 6,
  mb: 2
})`line-height: 1.125;`
const Subheadline = Heading.extend.attrs({
  f: 5,
  mt: 4,
  px: 3
})``

const CTA = Box.extend.attrs({
  is: 'a',
  color: colors.green[6],
  px: [2, 3, 4],
  py: [2, 3],
  mx: 2,
  f: [3, 4]
})`
  border: 2px solid ${colors.green[6]};
  line-height: 1;
  text-decoration: none;
  text-transform: uppercase;
  cursor: pointer;
`

export default () => (
  <Provider theme={theme}>

      <title>Repl.it – Hack Club</title>


<commit_before>/**
* Licensed to the Symphony Software Foundation (SSF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The SSF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied.  See the License for the
* specific language governing permissions and limitations
* under the License.
**/

// Create our own local service pertaining to the application module
// We have namespaced local services with "hello:"
var helloAppService = SYMPHONY.services.register("hello:app");

SYMPHONY.remote.hello().then(function(data) {

    // Set the theme of the app module
    var themeColor = data.themeV2.name;
    var themeSize = data.themeV2.size;
    // You must add the symphony-external-app class to the body element
    document.body.className = "symphony-external-app " + themeColor + " " + themeSize;

    SYMPHONY.application.connect("hello", ["modules", "applications-nav", "ui", "share"], ["hello:app"]).then(function(response) {

        // The userReferenceId is an anonymized random string that can be used for uniquely identifying users.
        // The userReferenceId persists until the application is uninstalled by the user.
        // If the application is reinstalled, the userReferenceId will change.
        var userId = response.userReferenceId;

        // Subscribe to Symphony's services
        var modulesService = SYMPHONY.services.subscribe("modules");
        var navService = SYMPHONY.services.subscribe("applications-nav");
        var uiService = SYMPHONY.services.subscribe("ui");
        var shareService = SYMPHONY.services.subscribe("share");

        // UI: Listen for theme change events
        uiService.listen("themeChangeV2", function() {
            SYMPHONY.remote.hello().then(function(data) {
                themeColor = data.themeV2.name;
                themeSize = data.themeV2.size;
                document.body.className = "symphony-external-app " + themeColor + " " + themeSize;
            });
        });

        // MODULE: Add a menu item to our module
        modulesService.addMenuItem("hello", "About Hello World App", "hello-menu-item");
        modulesService.setHandler("hello", "hello:app");

        // LEFT NAV: Update the left navigation item's badge count when the "Increment Unread Badge Count" button is clicked using the navService's count method.
        var incrementButton = document.getElementById("increment");
        var count = 0;
        // Bind a click event handler
        incrementButton.addEventListener("click", function(){
            count++;
            navService.count("hello-nav", count);
        });

        // MODULE: Hide the main module when the "Hide Main App Module" button is clicked
        var hideButton = document.getElementById("hide");
        hideButton.addEventListener("click", function() {
            // Note that this will not close any modules opened in context of cashtags or articles since we are specifying the main app module's id
            modulesService.hide("hello");
        });

        // MODULE: Change the title of the main module when the "Change Main App Module Title" button is clicked
        var setTitleButton = document.getElementById("set-title");
        setTitleButton.addEventListener("click", function() {
            // Note that this will not change the title of any modules opened in context of cashtags or articles since we are specifying the main app module's id
            modulesService.setTitle("hello", "New Module Title");
        });

        // LEFT NAV: Remove the left navigation item ("Removable Left Nav Item") when the "Remove Left Nav Item" button is clicked
        var removeLeftNavItemButton = document.getElementById("remove-left-nav-item");
        removeLeftNavItemButton.addEventListener("click", function() {
            // Note that this will not remove all left navigation items created by the application - only the one with the specified id
            // After removing the "Removable Left Nav Item" once, you will need to remove and reinstall the app to bring it back
            navService.remove('hello-nav-remove');
        });

        // LEFT NAV: Rename the left navigation item ("hello-nav") when the "Rename Left Nav Item" button is clicked
        var renameLeftNavItemButton = document.getElementById("rename-left-nav-item");
        renameLeftNavItemButton.addEventListener("click", function() {
            // Note that this will not rename all left navigation items created by the application - only the one with the specified id
            navService.rename('hello-nav', 'New Left Nav Title');
        });

        // UI: Remove the Room UI extension button when the "Unregister Room UI Extension" button is clicked
        var unregisterRoomExtensionButton = document.getElementById("unregister-room-extension");
        unregisterRoomExtensionButton.addEventListener("click", function() {
            // Note that this will not remove all UI extensions
            // This will remove only the extension of a given ID ('hello-room') for a given class ('room')
            uiService.unregisterExtension('room', 'hello-room');
        });

        // SHARE: Trigger Symphony's share modal when the "Share" button is clicked
        var shareButton = document.getElementById("share");
        // Convert the datestring (07 June 2016) to Unix timestamp for the share service
        var articleUnixTimestamp = (new Date(document.getElementById("article-date").innerHTML).getTime())/1000;
        var articleOptions = {
            "title": document.getElementById("article-title").innerHTML,
            "subTitle": document.getElementById("article-subtitle").innerHTML,
            "blurb": document.getElementById("article-blurb").innerHTML,
            "date": articleUnixTimestamp,
            "publisher": document.getElementById("article-publisher").innerHTML,
            "author": document.getElementById("article-author").innerHTML,
            "thumbnail": document.getElementById("article-thumbnail").src,
            // In this case, the shared article has an ID, which is used to deeplink back into our application
            "id": document.getElementById("article-id").innerHTML
        };
        shareButton.addEventListener("click", function(){
            shareService.share(
                "article",
                articleOptions
            );
        });

        var shareButton2 = document.getElementById("share-2");
        var articleUnixTimestamp2 = (new Date(document.getElementById("article-date-2").innerHTML).getTime())/1000;
        var articleOptions2 = {
            "title": document.getElementById("article-title-2").innerHTML,
            "subTitle": document.getElementById("article-subtitle-2").innerHTML,
            "blurb": document.getElementById("article-blurb-2").innerHTML,
            "date": articleUnixTimestamp2,
            "publisher": document.getElementById("article-publisher-2").innerHTML,
            "author": document.getElementById("article-author-2").innerHTML,
            "thumbnail": document.getElementById("article-thumbnail-2").src,
            // In this case, the shared article has an href link, which should be opened in a new browser window
            "href": document.getElementById("article-link-2").href
        };
        shareButton2.addEventListener("click", function(){
            shareService.share(
                "article",
                articleOptions2
            );
        });

        // UI CASHTAG: If the app is opened in the context of a cashtag, show the cashtag in the text box on the app.
        // window.location.search returns the querystring part of a URL. Use substring to omit the leading ?.
        var querystring = window.location.search.substring(1);
        // Use regex to check if the querystring includes "cashtag"
        if (querystring && /cashtag/.test(querystring)) {
            // Split the querystring into a list of pairs
            var urlParams = querystring.split('&');
            for (var i = 0; i < urlParams.length; i++) {
                var pair = urlParams[i].split('=');
                // Check if the key of one of the pairs is cashtag (there should always be such a pair)
                if(pair[0] == 'cashtag') {
                    // Use substring to omit the leading "%24" (url encoding of $)
                    var cashtag = pair[1].substring(3);
                    document.getElementById("cashtag").value = cashtag;
                }
            }
        }
        // SHARE: If the app is opened in the context of an article, show the articleId in the text box on the app.
        // @TODO(anjana): Refactor this redundant code
        else if (querystring && /article/.test(querystring)) {
            var urlParams = querystring.split('&');
            for (var i = 0; i < urlParams.length; i++) {
                var pair = urlParams[i].split('=');
                if(pair[0] == 'article') {
                    var articleId = pair[1];
                    document.getElementById("article").value = articleId;
                }
            }
        }

        // Implement methods on the application module service
        helloAppService.implement({
            // If the menu item is selected, display the About text
            menuSelect: function(itemId) {
                if (itemId == "hello-menu-item") {
                    document.getElementById("about-hello-world-app").className = "";
                }
            }
        });

    }.bind(this))
}.bind(this));
<commit_msg>Update app.js<commit_after>/**
* Licensed to the Symphony Software Foundation (SSF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The SSF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied.  See the License for the
* specific language governing permissions and limitations
* under the License.
**/

// Create our own local service pertaining to the application module
// We have namespaced local services with "1854a949f53b49039b4a1a5038629922:"
var 1854a949f53b49039b4a1a5038629922AppService = SYMPHONY.services.register("1854a949f53b49039b4a1a5038629922:app");

SYMPHONY.remote.1854a949f53b49039b4a1a5038629922().then(function(data) {

    // Set the theme of the app module
    var themeColor = data.themeV2.name;
    var themeSize = data.themeV2.size;
    // You must add the symphony-external-app class to the body element
    document.body.className = "symphony-external-app " + themeColor + " " + themeSize;

    SYMPHONY.application.connect("1854a949f53b49039b4a1a5038629922", ["modules", "applications-nav", "ui", "share"], ["1854a949f53b49039b4a1a5038629922:app"]).then(function(response) {

        // The userReferenceId is an anonymized random string that can be used for uniquely identifying users.
        // The userReferenceId persists until the application is uninstalled by the user.
        // If the application is reinstalled, the userReferenceId will change.
        var userId = response.userReferenceId;

        // Subscribe to Symphony's services
        var modulesService = SYMPHONY.services.subscribe("modules");
        var navService = SYMPHONY.services.subscribe("applications-nav");
        var uiService = SYMPHONY.services.subscribe("ui");
        var shareService = SYMPHONY.services.subscribe("share");

        // UI: Listen for theme change events
        uiService.listen("themeChangeV2", function() {
            SYMPHONY.remote.1854a949f53b49039b4a1a5038629922().then(function(data) {
                themeColor = data.themeV2.name;
                themeSize = data.themeV2.size;
                document.body.className = "symphony-external-app " + themeColor + " " + themeSize;
            });
        });

        // MODULE: Add a menu item to our module
        modulesService.addMenuItem("1854a949f53b49039b4a1a5038629922", "About 1854a949f53b49039b4a1a5038629922 World App", "1854a949f53b49039b4a1a5038629922-menu-item");
        modulesService.setHandler("1854a949f53b49039b4a1a5038629922", "1854a949f53b49039b4a1a5038629922:app");

        // LEFT NAV: Update the left navigation item's badge count when the "Increment Unread Badge Count" button is clicked using the navService's count method.
        var incrementButton = document.getElementById("increment");
        var count = 0;
        // Bind a click event handler
        incrementButton.addEventListener("click", function(){
            count++;
            navService.count("1854a949f53b49039b4a1a5038629922-nav", count);
        });

        // MODULE: Hide the main module when the "Hide Main App Module" button is clicked
        var hideButton = document.getElementById("hide");
        hideButton.addEventListener("click", function() {
            // Note that this will not close any modules opened in context of cashtags or articles since we are specifying the main app module's id
            modulesService.hide("1854a949f53b49039b4a1a5038629922");
        });

        // MODULE: Change the title of the main module when the "Change Main App Module Title" button is clicked
        var setTitleButton = document.getElementById("set-title");
        setTitleButton.addEventListener("click", function() {
            // Note that this will not change the title of any modules opened in context of cashtags or articles since we are specifying the main app module's id
            modulesService.setTitle("1854a949f53b49039b4a1a5038629922", "New Module Title");
        });

        // LEFT NAV: Remove the left navigation item ("Removable Left Nav Item") when the "Remove Left Nav Item" button is clicked
        var removeLeftNavItemButton = document.getElementById("remove-left-nav-item");
        removeLeftNavItemButton.addEventListener("click", function() {
            // Note that this will not remove all left navigation items created by the application - only the one with the specified id
            // After removing the "Removable Left Nav Item" once, you will need to remove and reinstall the app to bring it back
            navService.remove('1854a949f53b49039b4a1a5038629922-nav-remove');
        });

        // LEFT NAV: Rename the left navigation item ("1854a949f53b49039b4a1a5038629922-nav") when the "Rename Left Nav Item" button is clicked
        var renameLeftNavItemButton = document.getElementById("rename-left-nav-item");
        renameLeftNavItemButton.addEventListener("click", function() {
            // Note that this will not rename all left navigation items created by the application - only the one with the specified id
            navService.rename('1854a949f53b49039b4a1a5038629922-nav', 'New Left Nav Title');
        });

        // UI: Remove the Room UI extension button when the "Unregister Room UI Extension" button is clicked
        var unregisterRoomExtensionButton = document.getElementById("unregister-room-extension");
        unregisterRoomExtensionButton.addEventListener("click", function() {
            // Note that this will not remove all UI extensions
            // This will remove only the extension of a given ID ('1854a949f53b49039b4a1a5038629922-room') for a given class ('room')
            uiService.unregisterExtension('room', '1854a949f53b49039b4a1a5038629922-room');
        });

        // SHARE: Trigger Symphony's share modal when the "Share" button is clicked
        var shareButton = document.getElementById("share");
        // Convert the datestring (07 June 2016) to Unix timestamp for the share service
        var articleUnixTimestamp = (new Date(document.getElementById("article-date").innerHTML).getTime())/1000;
        var articleOptions = {
            "title": document.getElementById("article-title").innerHTML,
            "subTitle": document.getElementById("article-subtitle").innerHTML,
            "blurb": document.getElementById("article-blurb").innerHTML,
            "date": articleUnixTimestamp,
            "publisher": document.getElementById("article-publisher").innerHTML,
            "author": document.getElementById("article-author").innerHTML,
            "thumbnail": document.getElementById("article-thumbnail").src,
            // In this case, the shared article has an ID, which is used to deeplink back into our application
            "id": document.getElementById("article-id").innerHTML
        };
        shareButton.addEventListener("click", function(){
            shareService.share(
                "article",
                articleOptions
            );
        });

        var shareButton2 = document.getElementById("share-2");
        var articleUnixTimestamp2 = (new Date(document.getElementById("article-date-2").innerHTML).getTime())/1000;
        var articleOptions2 = {
            "title": document.getElementById("article-title-2").innerHTML,
            "subTitle": document.getElementById("article-subtitle-2").innerHTML,
            "blurb": document.getElementById("article-blurb-2").innerHTML,
            "date": articleUnixTimestamp2,
            "publisher": document.getElementById("article-publisher-2").innerHTML,
            "author": document.getElementById("article-author-2").innerHTML,
            "thumbnail": document.getElementById("article-thumbnail-2").src,
            // In this case, the shared article has an href link, which should be opened in a new browser window
            "href": document.getElementById("article-link-2").href
        };
        shareButton2.addEventListener("click", function(){
            shareService.share(
                "article",
                articleOptions2
            );
        });

        // UI CASHTAG: If the app is opened in the context of a cashtag, show the cashtag in the text box on the app.
        // window.location.search returns the querystring part of a URL. Use substring to omit the leading ?.
        var querystring = window.location.search.substring(1);
        // Use regex to check if the querystring includes "cashtag"
        if (querystring && /cashtag/.test(querystring)) {
            // Split the querystring into a list of pairs
            var urlParams = querystring.split('&');
            for (var i = 0; i < urlParams.length; i++) {
                var pair = urlParams[i].split('=');
                // Check if the key of one of the pairs is cashtag (there should always be such a pair)
                if(pair[0] == 'cashtag') {
                    // Use substring to omit the leading "%24" (url encoding of $)
                    var cashtag = pair[1].substring(3);
                    document.getElementById("cashtag").value = cashtag;
                }
            }
        }
        // SHARE: If the app is opened in the context of an article, show the articleId in the text box on the app.
        // @TODO(anjana): Refactor this redundant code
        else if (querystring && /article/.test(querystring)) {
            var urlParams = querystring.split('&');
            for (var i = 0; i < urlParams.length; i++) {
                var pair = urlParams[i].split('=');
                if(pair[0] == 'article') {
                    var articleId = pair[1];
                    document.getElementById("article").value = articleId;
                }
            }
        }

        // Implement methods on the application module service
        1854a949f53b49039b4a1a5038629922AppService.implement({
            // If the menu item is selected, display the About text
            menuSelect: function(itemId) {
                if (itemId == "1854a949f53b49039b4a1a5038629922-menu-item") {
                    document.getElementById("about-1854a949f53b49039b4a1a5038629922-world-app").className = "";
                }
            }
        });

    }.bind(this))
}.bind(this));
<|endoftext|>


<commit_before>// stub location that mocha uses
global.location = {};

// reset the suites each time mocha is run
var _mochaRun = mocha.run;
mocha.run = function(fn) {
	return _mochaRun.call(this, function() {
		mocha.suite.suites.length = 0;
		if (fn) { fn(); }
	});
};

mocha.reporter = function(r) {
	Mocha.prototype.reporter.call(this, r);
	this._ti_reporter = r;
	return this;
};

mocha.outputFile = function(outputFile) {
	this._ti_output_file = outputFile;
};

mocha.quiet = function(val) {
	this._ti_quiet = val;
};

// Override the console functions with node.js-style formatting. This allows us to use some of mocha's existing
// reporters with only a few modifications, like I do with spec.
var console = {};
var types = ['info','log','error','warn','trace'];

// Use node.js-style util.format() for each console function call
function createConsoleLogger(type) {
	console[type] = function() {
		var util = require('titanium/util'),
			args = Array.prototype.slice.call(arguments, 0),
			rawArgs = args.slice(0),
			isStudio = /\-studio$/.test(mocha._ti_reporter);

		if (!mocha._ti_quiet) {
			if (args.length === 0) {
				if (isStudio) {
					args.push(util.cursor.reset + ' ' + util.cursor.reset);
				} else {
					args.push(util.cursor.resetLine);
				}
			} else {
				var prefix = util.cursor.resetLine;
				if (!isStudio) {
					// Clear the existing line of text using ANSI codes, get rid of those pesky [INFO] prefixes
					args[0] = prefix + (args[0] || '').toString().split(/(?:\r\n|\n|\r)/).join('\n' + prefix);
				}
			}

			// Use the util.js format() port to get node.js-like console functions
			Ti.API.log(type === 'log' ? 'info' : type, util.format.apply(this, args));
		}

		// If the output file exists, write the content to the file as well
		if (mocha._ti_output_file) {
			mocha._ti_output_file.append(util.format.apply(this, rawArgs).replace(/\x1B\[[0-9;]*[a-zA-Z]/g, ''));
		}
	};
}

for (var i = 0; i < types.length; i++) {
	createConsoleLogger(types[i]);
}

// set the ti-spec reporter by default
mocha.setup({
	ui: 'bdd',
	reporter: 'ti-spec'
});
<commit_msg>Pass failures info to `#run` callback<commit_after>// stub location that mocha uses
global.location = {};

// reset the suites each time mocha is run
var _mochaRun = mocha.run;
mocha.run = function(fn) {
	return _mochaRun.call(this, function() {
		mocha.suite.suites.length = 0;
		if (fn) { fn.apply(this, arguments); }
	});
};

mocha.reporter = function(r) {
	Mocha.prototype.reporter.call(this, r);
	this._ti_reporter = r;
	return this;
};

mocha.outputFile = function(outputFile) {
	this._ti_output_file = outputFile;
};

mocha.quiet = function(val) {
	this._ti_quiet = val;
};

// Override the console functions with node.js-style formatting. This allows us to use some of mocha's existing
// reporters with only a few modifications, like I do with spec.
var console = {};
var types = ['info','log','error','warn','trace'];

// Use node.js-style util.format() for each console function call
function createConsoleLogger(type) {
	console[type] = function() {
		var util = require('titanium/util'),
			args = Array.prototype.slice.call(arguments, 0),
			rawArgs = args.slice(0),
			isStudio = /\-studio$/.test(mocha._ti_reporter);

		if (!mocha._ti_quiet) {
			if (args.length === 0) {
				if (isStudio) {
					args.push(util.cursor.reset + ' ' + util.cursor.reset);
				} else {
					args.push(util.cursor.resetLine);
				}
			} else {
				var prefix = util.cursor.resetLine;
				if (!isStudio) {
					// Clear the existing line of text using ANSI codes, get rid of those pesky [INFO] prefixes
					args[0] = prefix + (args[0] || '').toString().split(/(?:\r\n|\n|\r)/).join('\n' + prefix);
				}
			}

			// Use the util.js format() port to get node.js-like console functions
			Ti.API.log(type === 'log' ? 'info' : type, util.format.apply(this, args));
		}

		// If the output file exists, write the content to the file as well
		if (mocha._ti_output_file) {
			mocha._ti_output_file.append(util.format.apply(this, rawArgs).replace(/\x1B\[[0-9;]*[a-zA-Z]/g, ''));
		}
	};
}

for (var i = 0; i < types.length; i++) {
	createConsoleLogger(types[i]);
}

// set the ti-spec reporter by default
mocha.setup({
	ui: 'bdd',
	reporter: 'ti-spec'
});
<|endoftext|>