<commit_before>/// <reference path="../../../../ext/ext-core-debug.js"/>
/// <reference path="../../../../Simplate.js"/>
/// <reference path="../../../../sdata/SDataSingleResourceRequest.js"/>
/// <reference path="../../../../sdata/SDataService.js"/>
/// <reference path="../../../../platform/View.js"/>
/// <reference path="../../../../platform/Detail.js"/>
/// <reference path="../../Format.js"/>

Ext.namespace("Mobile.SalesLogix.Account");

Mobile.SalesLogix.Account.Detail = Ext.extend(Sage.Platform.Mobile.Detail, {
    titleText: 'Account',
    accountText: 'account',
    phoneText: 'phone',
    addressText: 'address',
    webText: 'web',
    typeText: 'type',
    subTypeText: 'subtype',
    acctMgrText: 'acct mgr',
    notesText: 'notes',
    ownerText: 'owner',
    statusText: 'status',
    createUserText: 'create user',
    createDateText: 'create date',
    relatedItemsText: 'Related Items',
    relatedContactsText: 'Contacts',
    relatedOpportunitiesText: 'Opportunities',
    relatedTicketsText: 'Tickets',
    relatedActivitiesText: 'Activities',
    relatedNotesText: 'Notes',
    importSourceText: 'lead source',
    constructor: function(o) {
        Mobile.SalesLogix.Account.Detail.superclass.constructor.call(this);

        Ext.apply(this, o, {
            id: 'account_detail',
            title: this.titleText,
            editor: 'account_edit',
            resourceKind: 'accounts'
        });

        this.layout = [
            {name: 'AccountName', label: this.accountText},
            {name: 'WebAddress', label: this.webText, renderer: Mobile.SalesLogix.Format.link},
            {name: 'MainPhone', label: this.phoneText, renderer: Mobile.SalesLogix.Format.phone},
            {name: 'Address', label: this.addressText, renderer: Mobile.SalesLogix.Format.address},
            {name: 'Fax', label: this.faxText, renderer: Mobile.SalesLogix.Format.phone},
            {name: 'Type', label: this.typeText},
            {name: 'SubType', label: this.subTypeText},
            {name: 'Status', label: this.statusText},
            {name: 'Industry', label: this.industryText, type: 'text'},
            {name: 'BusinessDescription', label: this.businessDescriptionText, type: 'text'},
            {name: 'AccountManager.UserInfo', label: this.acctMgrText, tpl: Mobile.SalesLogix.Template.nameLF},
            {name: 'Notes', label: this.notesText},
            {name: 'Owner.OwnerDescription', label: this.ownerText},
            {name: 'Status', label: this.statusText},
            {name: 'LeadSource', label: this.importSourceText},
            {options: {title: this.relatedItemsText, list: true}, as: [
                {
                    view: 'activity_related',
                    where: this.formatRelatedQuery.createDelegate(this, ['AccountId eq "{0}"'], true),
                    label: this.relatedActivitiesText,
                    icon: 'content/images/Task_List_3D_24x24.gif'
                },
                {
                    view: 'note_related',
                    where: this.formatRelatedQuery.createDelegate(this, ['AccountId eq "{0}" and Type eq "atNote"'], true),
                    label: this.relatedNotesText,
                    icon: 'content/images/note_24x24.gif'
                },
                {
                    view: 'contact_related',
                    where: this.formatRelatedQuery.createDelegate(this, ['Account.id eq "{0}"'], true),
                    label: this.relatedContactsText,
                    icon: 'content/images/Contacts_24x24.gif'
                },
                {
                    view: 'opportunity_related',
                    where: this.formatRelatedQuery.createDelegate(this, ['Account.id eq "{0}"'], true),
                    label: this.relatedOpportunitiesText,
                    icon: 'content/images/Opportunity_List_24x24.gif'
                },
                {
                    view: 'ticket_related',
                    where: this.formatRelatedQuery.createDelegate(this, ['Account.id eq "{0}"'], true),
                    label: this.relatedTicketsText,
                    icon: 'content/images/Ticket_List_3D_32x32.gif'
                }
            ]}
        ];
    },
    init: function() {
        Mobile.SalesLogix.Account.Detail.superclass.init.call(this);
    },
    createRequest: function() {
        var request = Mobile.SalesLogix.Account.Detail.superclass.createRequest.call(this);

        request
            .setQueryArgs({
                'include': 'Address,AccountManager,AccountManager/UserInfo,Owner,LeadSource',
                'select': [
                    'AccountName',
                    'Description',
                    'MainPhone',
                    'Address/*',
                    'WebAddress',
                    'AccountManager/UserInfo/FirstName',
                    'AccountManager/UserInfo/LastName',
                    'Notes',
                    'Owner/OwnerDescription',
                    'ImportSource',
                    'Status',
                    'AccountName',
                    'WebAddress',
                    'MainPhone',
                    'FullAddress',
                    'Description',
                    'IsPrimary',
                    'IsMailing',
                    'Address1',
                    'Address2',
                    'Address3',
                    'City',
                    'State',
                    'PostalCode',
                    'Country',
                    'Fax',
                    'Type',
                    'SubType',
                    'Status',
                    'Industry',
                    'BusinessDescription',
                    'CreateDate',
                    'CreateUser',
                    'GlobalSyncID',
                    'LeadSource/Description'
                ].join(',')
            });

        return request;
    }
});
<commit_msg>[#5063695] Fixing Lead source on Account Details screen, which displayed as [Object object]<commit_after>/// <reference path="../../../../ext/ext-core-debug.js"/>
/// <reference path="../../../../Simplate.js"/>
/// <reference path="../../../../sdata/SDataSingleResourceRequest.js"/>
/// <reference path="../../../../sdata/SDataService.js"/>
/// <reference path="../../../../platform/View.js"/>
/// <reference path="../../../../platform/Detail.js"/>
/// <reference path="../../Format.js"/>

Ext.namespace("Mobile.SalesLogix.Account");

Mobile.SalesLogix.Account.Detail = Ext.extend(Sage.Platform.Mobile.Detail, {
    titleText: 'Account',
    accountText: 'account',
    phoneText: 'phone',
    addressText: 'address',
    webText: 'web',
    typeText: 'type',
    subTypeText: 'subtype',
    acctMgrText: 'acct mgr',
    notesText: 'notes',
    ownerText: 'owner',
    statusText: 'status',
    createUserText: 'create user',
    createDateText: 'create date',
    relatedItemsText: 'Related Items',
    relatedContactsText: 'Contacts',
    relatedOpportunitiesText: 'Opportunities',
    relatedTicketsText: 'Tickets',
    relatedActivitiesText: 'Activities',
    relatedNotesText: 'Notes',
    importSourceText: 'lead source',
    faxText: 'fax',
    industryText: 'industry',
    constructor: function(o) {
        Mobile.SalesLogix.Account.Detail.superclass.constructor.call(this);

        Ext.apply(this, o, {
            id: 'account_detail',
            title: this.titleText,
            editor: 'account_edit',
            resourceKind: 'accounts'
        });

        this.layout = [
            {name: 'AccountName', label: this.accountText},
            {name: 'WebAddress', label: this.webText, renderer: Mobile.SalesLogix.Format.link},
            {name: 'MainPhone', label: this.phoneText, renderer: Mobile.SalesLogix.Format.phone},
            {name: 'Address', label: this.addressText, renderer: Mobile.SalesLogix.Format.address},
            {name: 'Fax', label: this.faxText, renderer: Mobile.SalesLogix.Format.phone},
            {name: 'Type', label: this.typeText},
            {name: 'SubType', label: this.subTypeText},
            {name: 'Status', label: this.statusText},
            {name: 'Industry', label: this.industryText, type: 'text'},
            {name: 'BusinessDescription', label: this.businessDescriptionText, type: 'text'},
            {name: 'AccountManager.UserInfo', label: this.acctMgrText, tpl: Mobile.SalesLogix.Template.nameLF},
            {name: 'Notes', label: this.notesText},
            {name: 'Owner.OwnerDescription', label: this.ownerText},
            {name: 'Status', label: this.statusText},
            {name: 'LeadSource.Description', label: this.importSourceText},
            {options: {title: this.relatedItemsText, list: true}, as: [
                {
                    view: 'activity_related',
                    where: this.formatRelatedQuery.createDelegate(this, ['AccountId eq "{0}"'], true),
                    label: this.relatedActivitiesText,
                    icon: 'content/images/Task_List_3D_24x24.gif'
                },
                {
                    view: 'note_related',
                    where: this.formatRelatedQuery.createDelegate(this, ['AccountId eq "{0}" and Type eq "atNote"'], true),
                    label: this.relatedNotesText,
                    icon: 'content/images/note_24x24.gif'
                },
                {
                    view: 'contact_related',
                    where: this.formatRelatedQuery.createDelegate(this, ['Account.id eq "{0}"'], true),
                    label: this.relatedContactsText,
                    icon: 'content/images/Contacts_24x24.gif'
                },
                {
                    view: 'opportunity_related',
                    where: this.formatRelatedQuery.createDelegate(this, ['Account.id eq "{0}"'], true),
                    label: this.relatedOpportunitiesText,
                    icon: 'content/images/Opportunity_List_24x24.gif'
                },
                {
                    view: 'ticket_related',
                    where: this.formatRelatedQuery.createDelegate(this, ['Account.id eq "{0}"'], true),
                    label: this.relatedTicketsText,
                    icon: 'content/images/Ticket_List_3D_32x32.gif'
                }
            ]}
        ];
    },
    init: function() {
        Mobile.SalesLogix.Account.Detail.superclass.init.call(this);
    },
    createRequest: function() {
        var request = Mobile.SalesLogix.Account.Detail.superclass.createRequest.call(this);

        request
            .setQueryArgs({
                'include': 'Address,AccountManager,AccountManager/UserInfo,Owner,LeadSource',
                'select': [
                    'AccountName',
                    'Description',
                    'MainPhone',
                    'Address/*',
                    'WebAddress',
                    'AccountManager/UserInfo/FirstName',
                    'AccountManager/UserInfo/LastName',
                    'Notes',
                    'Owner/OwnerDescription',
                    'ImportSource',
                    'Status',
                    'AccountName',
                    'WebAddress',
                    'MainPhone',
                    'FullAddress',
                    'Description',
                    'IsPrimary',
                    'IsMailing',
                    'Address1',
                    'Address2',
                    'Address3',
                    'City',
                    'State',
                    'PostalCode',
                    'Country',
                    'Fax',
                    'Type',
                    'SubType',
                    'Status',
                    'Industry',
                    'BusinessDescription',
                    'CreateDate',
                    'CreateUser',
                    'GlobalSyncID',
                    'LeadSource/Description'
                ].join(',')
            });

        return request;
    }
});
<|endoftext|>


<commit_before>import math.geom.Vec2D as Vec2D;

import ui.View as View;
import ui.ImageView as ImageView;
import ui.TextView as TextView;
import ui.ScoreView as ScoreView;
import ui.ViewPool as Viewpool;
import animate;

exports = Class(ImageView, function (supr) {
	var invert = function(direction) {
		var ret,
			pos = {
				left: 'right',
				right: 'left'
			};

		if (direction !== '') {
			ret = pos[direction];
		}
		return ret;
	};

	this.init = function (opts) {
		supr(this, 'init', [opts]);

		this._adventureMapView = opts.adventureMapView;
		this._ongoing = false;

		this._tileX = 0;
		this._tileY = 0;
		this.initial = [0, 0];

		this._editMode = opts.editMode;

		/*this._doodadView = new ImageView({
			superview: this
		});*/
		this._itemView = new ImageView({
			superview: this,
			zIndex: 1
		});

		this._idText = new ScoreView({
			superview: this._itemView,
			visible: false,
			blockEvents: true,
		});

		this._characterSettings = null;
		this._locSet = false;

		this._itemCtors = opts.nodeSettings.itemCtors;
		this._hideViews = {};

		this._tileSettings = opts.tileSettings;
		/*this._doodads = opts.tileSettings.doodads;*/
		this._nodes = opts.nodeSettings.nodes;

		this.canHandleEvents(false);
	};

	this.update = function (grid, tileX, tileY) {
		var itemView, tag;

		this._tileX = tileX;
		this._tileY = tileY;

		var tile = grid[tileY][tileX];
		if (tile && tile.node) {
			var node = this._nodes[tile.node - 1];
			var style = this._itemView.style;
			var x = this._tileSettings.tileWidth * tile.x;
			var y = this._tileSettings.tileHeight * tile.y;

			this.updateOpts({
				width: node.width,
				height: node.height
			});
			if(!this._locSet)
			{
				this.initial = [this.style.x, this.style.y];
				style.x = x - node.width * 0.5;
				style.y = y - node.height * 0.5;
				this.style.x = this.style.x + style.x;
				this.style.y = this.style.y + style.y;
				style.x = 0;
				style.y = 0;
				style.width = node.width;
				style.height = node.height;
				this._locSet = true;
			}

			style.visible = true;
			this._itemView.setImage(node.image);

			var itemViews = tile.itemViews;
			if (!itemViews) {
				itemViews = {};
				tile.itemViews = itemViews;
			}

			var hideViews = {};
			for (tag in itemViews) {
				itemView = itemViews[tag];
				if (itemView.style.visible) {
					hideViews[tag] = itemView;
				}
			}

			for (tag in tile.tags) {
				hideViews[tag] = null;
				if (this._itemCtors[tag]) {
					if (tag === "Friends") {
						itemView = tile.itemViews[tag];
						if (!itemView) {
							var position = tile.friends.position || invert(tile.position) || 'right',
								friends = tile.friends || {},
								tileSettings = this._tileSettings,
								left = (position === 'left'),
								right = (position === 'right'),
								top = (position === 'top'),
								bottom = (position === 'bottom'),
								deltaX = (left ? -1 : (right ? 1 : 0)),
								deltaY = (top ? -1 : (bottom ? 1 : 0)),
								// with and height of the container
								friendsWidth =  (left || right ? friends.width : friends.height),
								friendsHeight = (left || right ? friends.height : friends.width),
								// position of the container if it is after the milestone icon
								// if position is right, then x position should come after the node, on left it should be 0, before the node
								// otherwise (top and bottom) it should take x value from tile settings.
								friendsRight = (right && isNaN(parseFloat(friends.x)) && node ? node.width : (left ? 0 : tileSettings.friendsX)),
								// if position is bottom, then y position should come after the node, on top it should be 0, before the node
								// otherwise (left and right) it should take y value from tile settings.
								friendsBottom = (bottom && isNaN(parseFloat(friends.y)) && node ? node.height : (top ? 0 : tileSettings.friendsY)),
								// position of the container if it is before the milestone icon
								friendsLeft = (left ? friendsWidth : 0),
								friendsTop = (top ? friendsHeight : 0),
								// x and y value for inner views
								x = (deltaX === -1 ? friendsWidth - tileSettings.friendWidth : 0),
								y = (deltaY === -1 ? friendsHeight - tileSettings.friendHeight : 0);

							itemView = itemViews[tag] = this._itemCtors[tag].obtainView({
								superview: this.getSuperview(),
								ms: tile.id,
								x: this.style.x + friends.x * tileSettings.tileWidth - friendsLeft + friendsRight,
								y: this.style.y + friends.y * tileSettings.tileHeight - friendsTop + friendsBottom
							});
						}
					} else if (this._itemCtors[tag] instanceof Viewpool) {
							itemView = itemViews[tag] = this._itemCtors[tag].obtainView({
								superview: this.getSuperview(),
								tag: tag,
								zIndex: 999999999,
								tile: tile,
								x: this.style.x,
								y: this.style.y
							});
					} else {
						itemView = this._adventureMapView._nodeItems[tag];
						if (!itemView) {
							itemView = new this._itemCtors[tag]({
								superview: this.getSuperview(),
								adventureMapView: this._adventureMapView,
								zIndex: 999999999,
								tag: tag,
								tile: tile
							});
							this._adventureMapView._nodeItems[tag] = itemView;
						} else {
							itemView.updateOpts({
								superview: this.getSuperview(),
								tile: tile
							});
							itemView.removeAllListeners('InputSelect');
						}
						itemView.show();
						itemView.on('InputSelect', bind(this, 'onSelectTag', tag, tile, itemView));

						itemViews[tag] = itemView;
						if (!('centerTag' in this._tileSettings) || this._tileSettings.centerTag) {
							itemView.style.x = this.style.x + (this.style.width * 0.15);
							itemView.style.y = this.style.y - (itemView.style.height * 0.3 + this.style.height);
						} else {
							itemView.style.x = this.style.x + (this.style.width * 0.15);
							itemView.style.y = this.style.y - (itemView.style.height * 0.3 + this.style.height);
						}
						itemView.update && itemView.update(tile);
					}
				}
			}

			for (var tag in hideViews) {
				if (hideViews[tag]) {
					if (hideViews[tag]._obtainedFromPool) {
						this._itemCtors[tag].releaseView(itemViews[tag]);
					} else {
						itemViews[tag].removeFromSuperview();
					}
					delete itemViews[tag];
				}
			}

			if (tile.id && node.characterSettings && tile.tags) {
				this._idText.updateOpts({
					x: node.characterSettings.x || 0,
					y: node.characterSettings.y || 0,
					width: node.width,
					height: node.characterSettings.height || node.height,
					visible: true
				});
				this._idText.setCharacterData(node.characterSettings.data);
				this._idText.setText(tile.id);
				if (node.characterSettings !== this._characterSettings) {
					this._characterSettings = node.characterSettings.data;
				}
				this._idText._container.style.x = -10;
				this._idText._container.style.y = (node.height - node.characterSettings.height) * 0.5-30;
			} else {
				this._idText.hide();
			}

			this._itemView.removeAllListeners('InputSelect');
			this._itemView.on('InputSelect', bind(this, 'onSelectNode', tile));
		} else {
			this._itemView.style.visible = false;
		}

		/*if (tile && tile.doodad) {
			var doodad = this._doodads[tile.doodad - 1];
			if (doodad) {
				var style = this._doodadView.style;

				this._doodadView.setImage(doodad.image);
				style.x = tile.doodadX * this._tileSettings.tileWidth - doodad.width * 0.5;
				style.y = tile.doodadY * this._tileSettings.tileHeight - doodad.height * 0.5;
				style.width = doodad.width;
				style.height = doodad.height;
				style.visible = true;
			} else {
				this._doodadView.style.visible = false;
			}
		} else {
			this._doodadView.style.visible = false;
		}*/

		this.style.visible = tile.node;
	};

	this.onSelectTag = function (tag, tile, itemView) {
		this._adventureMapView.emit('ClickTag', tag, tile, itemView);
	};

	this.onSelectNode = function (tile) {
		this._adventureMapView.emit('ClickNode', tile);
	};

	this.refreshLoc = function() {
		this.style.x = this.initial[0];
		this.style.y = this.initial[1];
		this._locSet = false;
	};

	this.onReleaseNode = function (grid, x, y) {
		var tile = grid[y][x];
		this._idText.hide();
		this.refreshLoc();
		this._itemView.removeAllListeners('InputSelect');

		for (tag in tile.tags) {
			if (tile.itemViews[tag] && tile.itemViews[tag]._obtainedFromPool) {
				this._itemCtors[tag].releaseView(tile.itemViews[tag])
			}
			delete tile.itemViews[tag];
		}
	}
});
<commit_msg>added small optimization<commit_after>import math.geom.Vec2D as Vec2D;

import ui.View as View;
import ui.ImageView as ImageView;
import ui.TextView as TextView;
import ui.ScoreView as ScoreView;
import ui.ViewPool as Viewpool;
import animate;

exports = Class(ImageView, function (supr) {
	var invert = function(direction) {
		var ret,
			pos = {
				left: 'right',
				right: 'left'
			};

		if (direction !== '') {
			ret = pos[direction];
		}
		return ret;
	};

	this.init = function (opts) {
		supr(this, 'init', [opts]);

		this._adventureMapView = opts.adventureMapView;
		this._ongoing = false;

		this._tileX = 0;
		this._tileY = 0;
		this.initial = [0, 0];

		this._editMode = opts.editMode;

		/*this._doodadView = new ImageView({
			superview: this
		});*/
		this._itemView = new ImageView({
			superview: this,
			zIndex: 1
		});

		this._idText = new ScoreView({
			superview: this._itemView,
			visible: false,
			blockEvents: true,
		});

		this._characterSettings = null;
		this._locSet = false;

		this._itemCtors = opts.nodeSettings.itemCtors;
		this._hideViews = {};

		this._tileSettings = opts.tileSettings;
		/*this._doodads = opts.tileSettings.doodads;*/
		this._nodes = opts.nodeSettings.nodes;

		this.canHandleEvents(false);
	};

	this.update = function (grid, tileX, tileY) {
		var itemView, tag;

		this._tileX = tileX;
		this._tileY = tileY;

		var tile = grid[tileY][tileX];
		if (tile && tile.node) {
			var node = this._nodes[tile.node - 1];
			var style = this._itemView.style;
			var x = this._tileSettings.tileWidth * tile.x;
			var y = this._tileSettings.tileHeight * tile.y;

			this.updateOpts({
				width: node.width,
				height: node.height
			});
			if(!this._locSet)
			{
				this.initial = [this.style.x, this.style.y];
				style.x = x - node.width * 0.5;
				style.y = y - node.height * 0.5;
				this.style.x = this.style.x + style.x;
				this.style.y = this.style.y + style.y;
				style.x = 0;
				style.y = 0;
				style.width = node.width;
				style.height = node.height;
				this._locSet = true;
			}

			style.visible = true;
			this._itemView.setImage(node.image);

			var itemViews = tile.itemViews;
			if (!itemViews) {
				itemViews = {};
				tile.itemViews = itemViews;
			}

			var hideViews = {};
			for (tag in itemViews) {
				itemView = itemViews[tag];
				if (itemView.style.visible) {
					hideViews[tag] = itemView;
				}
			}

			for (tag in tile.tags) {
				hideViews[tag] = null;
				if (this._itemCtors[tag]) {
					if (tag === "Friends") {
						itemView = tile.itemViews[tag];
						if (!itemView) {
							var position = tile.friends.position || invert(tile.position) || 'right',
								friends = tile.friends,
								tileSettings = this._tileSettings,
								left = (position === 'left'),
								right = (position === 'right'),
								top = (position === 'top'),
								bottom = (position === 'bottom'),
								deltaX = (left ? -1 : (right ? 1 : 0)),
								deltaY = (top ? -1 : (bottom ? 1 : 0)),
								// with and height of the container
								friendsWidth =  (left || right ? friends.width : friends.height),
								friendsHeight = (left || right ? friends.height : friends.width),
								// position of the container if it is after the milestone icon
								// if position is right, then x position should come after the node, on left it should be 0, before the node
								// otherwise (top and bottom) it should take x value from tile settings.
								friendsRight = (right && isNaN(parseFloat(friends.x)) && node ? node.width : (left ? 0 : tileSettings.friendsX)),
								// if position is bottom, then y position should come after the node, on top it should be 0, before the node
								// otherwise (left and right) it should take y value from tile settings.
								friendsBottom = (bottom && isNaN(parseFloat(friends.y)) && node ? node.height : (top ? 0 : tileSettings.friendsY)),
								// position of the container if it is before the milestone icon
								friendsLeft = (left ? friendsWidth : 0),
								friendsTop = (top ? friendsHeight : 0),
								// x and y value for inner views
								x = (deltaX === -1 ? friendsWidth - tileSettings.friendWidth : 0),
								y = (deltaY === -1 ? friendsHeight - tileSettings.friendHeight : 0);

							itemView = itemViews[tag] = this._itemCtors[tag].obtainView({
								superview: this.getSuperview(),
								ms: tile.id,
								x: this.style.x + friends.x * tileSettings.tileWidth - friendsLeft + friendsRight,
								y: this.style.y + friends.y * tileSettings.tileHeight - friendsTop + friendsBottom
							});
						}
					} else if (this._itemCtors[tag] instanceof Viewpool) {
							itemView = itemViews[tag] = this._itemCtors[tag].obtainView({
								superview: this.getSuperview(),
								tag: tag,
								zIndex: 999999999,
								tile: tile,
								x: this.style.x,
								y: this.style.y
							});
							itemView.update && itemView.update(tile);
					} else {
						itemView = this._adventureMapView._nodeItems[tag];
						if (!itemView) {
							itemView = new this._itemCtors[tag]({
								superview: this.getSuperview(),
								adventureMapView: this._adventureMapView,
								zIndex: 999999999,
								tag: tag,
								tile: tile
							});
							this._adventureMapView._nodeItems[tag] = itemView;
						} else {
							itemView.updateOpts({
								superview: this.getSuperview(),
								tile: tile
							});
							itemView.removeAllListeners('InputSelect');
						}
						itemView.show();
						itemView.on('InputSelect', bind(this, 'onSelectTag', tag, tile, itemView));

						itemViews[tag] = itemView;
						if (!('centerTag' in this._tileSettings) || this._tileSettings.centerTag) {
							itemView.style.x = this.style.x + (this.style.width * 0.15);
							itemView.style.y = this.style.y - (itemView.style.height * 0.3 + this.style.height);
						} else {
							itemView.style.x = this.style.x + (this.style.width * 0.15);
							itemView.style.y = this.style.y - (itemView.style.height * 0.3 + this.style.height);
						}
						itemView.update && itemView.update(tile);
					}
				}
			}

			for (var tag in hideViews) {
				if (hideViews[tag]) {
					if (hideViews[tag]._obtainedFromPool) {
						this._itemCtors[tag].releaseView(itemViews[tag]);
					} else {
						itemViews[tag].removeFromSuperview();
					}
					delete itemViews[tag];
				}
			}

			if (tile.id && node.characterSettings && tile.tags) {
				this._idText.updateOpts({
					x: node.characterSettings.x || 0,
					y: node.characterSettings.y || 0,
					width: node.width,
					height: node.characterSettings.height || node.height,
					visible: true
				});
				this._idText.setCharacterData(node.characterSettings.data);
				this._idText.setText(tile.id);
				if (node.characterSettings !== this._characterSettings) {
					this._characterSettings = node.characterSettings.data;
				}
				this._idText._container.style.x = -10;
				this._idText._container.style.y = (node.height - node.characterSettings.height) * 0.5-30;
			} else {
				this._idText.hide();
			}

			this._itemView.removeAllListeners('InputSelect');
			this._itemView.on('InputSelect', bind(this, 'onSelectNode', tile));
		} else {
			this._itemView.style.visible = false;
		}

		/*if (tile && tile.doodad) {
			var doodad = this._doodads[tile.doodad - 1];
			if (doodad) {
				var style = this._doodadView.style;

				this._doodadView.setImage(doodad.image);
				style.x = tile.doodadX * this._tileSettings.tileWidth - doodad.width * 0.5;
				style.y = tile.doodadY * this._tileSettings.tileHeight - doodad.height * 0.5;
				style.width = doodad.width;
				style.height = doodad.height;
				style.visible = true;
			} else {
				this._doodadView.style.visible = false;
			}
		} else {
			this._doodadView.style.visible = false;
		}*/

		this.style.visible = tile.node;
	};

	this.onSelectTag = function (tag, tile, itemView) {
		this._adventureMapView.emit('ClickTag', tag, tile, itemView);
	};

	this.onSelectNode = function (tile) {
		this._adventureMapView.emit('ClickNode', tile);
	};

	this.refreshLoc = function() {
		this.style.x = this.initial[0];
		this.style.y = this.initial[1];
		this._locSet = false;
	};

	this.onReleaseNode = function (grid, x, y) {
		var tile = grid[y][x];
		this._idText.hide();
		this.refreshLoc();
		this._itemView.removeAllListeners('InputSelect');

		for (tag in tile.tags) {
			if (tile.itemViews[tag] && tile.itemViews[tag]._obtainedFromPool) {
				this._itemCtors[tag].releaseView(tile.itemViews[tag])
			}
			delete tile.itemViews[tag];
		}
	}
});
<|endoftext|>


<commit_before>(function() {
    gf.Sprite = gf.Entity.extend({
        //initializes a new entity with the start position (pos) and the settings defined in Tiled
        init: function(pos, settings) {
            /****************************************************************************
             * Properties that are defined in the `settings` object,
             * these can be specified in the properties of the object layer
             * in Tiled, and overriden on a per-object basis
             ****************************************************************************/
            //size of the sprite (each frame)
            this.size = new THREE.Vector2(0, 0);

            //number of frames accross x / y (calculated, not set)
            this.numFrames = new THREE.Vector2(0, 0);

            //offset in the image to the first frame (in pixels)
            this.offset = new THREE.Vector2(0, 0);

            //opacity of the sprite
            this.opacity = 1.0;

            //raw THREE.Texture instance loaded by the gf.loader
            this.texture = null;

            //defined sprite animations
            this.anim = {};

            //currently active animation
            this.currentAnim = null;

            //currently active frame's active time
            this.currentFrameTime = 0;

            //animations paused
            this.animPaused = false;

            //use screen coords instead of world coords
            this.useScreenCoords = false;

            /****************************************************************************
             * Call base constructor
             ****************************************************************************/
            this._super(pos, settings);

            this._baseHitSize = this.hitSize.clone();
            this._baseScaledHitSize = this.scaledHitSize.clone();
            this._baseHitOffset = this.hitOffset.clone();

            // create a default animation sequence with all sprites
            this.addAnimation('default', null, 1000, true);
            // set as default
            this.setActiveAnimation('default');
        },
        //add a new animation
        addAnimation: function(name, settings) {
            settings = settings || {};

            if(settings instanceof Array)
                settings = { frames: settings };

            this.anim[name] = {
                name: name,
                frames: [],
                idx: 0,
                length: 0,
                frameTime: 0,
                loop: !!settings.loop,
                hitSize: settings.hitSize,
                hitOffset: settings.hitOffset
            };

            if(!settings.frames) {
                settings.frames = [];
                // create a default animation with all sprites in the spritesheet
                for(var f = 0, fl = this.numFrames.x * this.numFrames.y; f < fl; ++f) {
                    settings.frames[f] = f;
                }
            }

            // compute and add the offset of each frame
            for(var i = 0, il = settings.frames.length; i < il; ++i) {
                this.anim[name].frames[i] = new THREE.Vector2(this.size.x * (settings.frames[i] % this.numFrames.x), this.size.y * Math.floor(settings.frames[i] / this.numFrames.x));
            }
            this.anim[name].length = this.anim[name].frames.length;
            this.anim[name].frameTime = (settings.duration || 0) / this.anim[name].frames.length;

            return this;
        },
        setActiveAnimation: function(name, resetAnim, cb) {
            if(typeof resetAnim == 'function') {
                cb = resetAnim;
                resetAnim = null;
            }

            if(!this.anim[name]) {
                this.currentAnim = name;
            } else {
                if(this.currentAnim && this.currentAnim._cb && !this.currentAnim._cbCalled) {
                    this.currentAnim._cbCalled = true;
                    this.currentAnim._cb(true);
                }

                this.currentAnim = this.anim[name];
                this.currentAnim._done = false;
                this.currentAnim._cbCalled = false;
                this.currentAnim._cb = cb;
                if(resetAnim) this.currentAnim.idx = 0;
                this._setOffset();

                //if we are changing hitbox, save current settings and update
                if(this.currentAnim.hitSize) {
                    if(this.currentAnim.hitSize instanceof THREE.Vector2) {
                        this.hitSize.copy(this.currentAnim.hitSize);
                        this.scaledHitSize.copy(this.currentAnim.hitSize).multiplyScalar(this.scale);
                    }
                    else if(this.currentAnim.hitSize instanceof Array) {
                        this.hitSize.set(this.currentAnim.hitSize[0], this.currentAnim.hitSize[1]);
                        this.scaledHitSize.set(this.currentAnim.hitSize[0], this.currentAnim.hitSize[1]).multiplyScalar(this.scale);
                    }
                }
                else {
                    this.hitSize.copy(this._baseHitSize);
                    this.scaledHitSize.copy(this._baseScaledHitSize);
                }

                if(this.currentAnim.hitOffset) {
                    if(this.currentAnim.hitOffset instanceof THREE.Vector2)
                        this.hitOffset.copy(this.currentAnim.hitOffset);
                    else if(this.currentAnim.hitOffset instanceof Array)
                        this.hitOffset.set(this.currentAnim.hitOffset[0], this.currentAnim.hitOffset[1]);
                }
                else {
                    this.hitOffset.copy(this._baseHitOffset);
                }

                this._hitboxMesh.scale.set(this.scaledHitSize.x, this.scaledHitSize.y, 1);
                this.setPosition(this._mesh.position);
            }

            this.currentFrameTime = 0;

            return this;
        },
        isActiveAnimation: function(name) {
            return this.currentAnim.name == name;
        },
        update: function() {
            this._super();

            if(!this.currentAnim || this.currentAnim.frameTime === 0 || this.currentAnim.length <= 1) return;

            this.currentFrameTime += gf.game._delta * 1000;

            //update animation if necessary
            if (this.isVisible && !this.animPaused && !this.currentAnim._done && (this.currentFrameTime > this.currentAnim.frameTime)) {
                while(this.currentFrameTime > this.currentAnim.frameTime) {
                    this.currentFrameTime -= this.currentAnim.frameTime;
                    this.currentAnim.idx++;

                    if(this.currentAnim.idx == this.currentAnim.length) {
                        if(this.currentAnim.loop) {
                            this.currentAnim.idx = 0;
                        }
                        else {
                            this.currentAnim._done = true;
                            if(this.currentAnim._cb && !this.currentAnim._cbCalled) {
                                this.currentAnim._cbCalled = true;
                                this.currentAnim._cb();
                            }
                            return;
                        }
                    }

                    this._setOffset();
                }
            }

            return this;
        },
        _setOffset: function() {
            //for some reason when inversed, the tiles need to start at 1 instead of 0
            var add = this.currentAnim.inverse ? 1 : 0,
                frame = this.currentAnim.frames[this.currentAnim.idx];

            this._material.uvOffset.set(
                frame.x / this.texture.image.width,
                1 - (this.size.y / this.texture.image.height) - (frame.y / this.texture.image.height)
            );
        },
        //override Entity mesh with a sprite instead
        _createMesh: function() {
            if(this._mesh) return;

            if(this.filtered) {
                this.texture.magFilter = THREE.LinearFilter;
                this.texture.minFilter = THREE.LinearMipMapLinearFilter;
            } else {
                this.texture.magFilter = THREE.NearestFilter;
                this.texture.minFilter = THREE.NearestMipMapNearestFilter;
            }

            this.numFrames.set(this.texture.image.width / this.size.x, this.texture.image.height / this.size.y);

            this._material = new THREE.SpriteMaterial({
                color: 0xffffff,
                opacity: 1,
                map: this.texture,

                blending: THREE.NormalBlending,
                alignment: THREE.SpriteAlignment.center,
                useScreenCoordinates: this.useScreenCoords,
                //depthTest: false, //default: !useScreenCoordinates
                sizeAttenuation: true, //default: !useScreenCoordinates
                //scaledByViewport: true //default: !sizeAttenuation
            });

            this._material.uvScale.set(
                1 / this.numFrames.x,
                1 / this.numFrames.y
            );
            this._material.uvOffset.set(
                0,
                1 - this._material.uvScale.y //transform to topleft offset
            );

            this._mesh = new THREE.Sprite(this._material);

            this._mesh.scale.set(
                1 / this.numFrames.x / 2, //(this.scaledSize.x / bias),
                1 / this.numFrames.y / 3, (this.scaledSize.y / bias),
                1
            );
        }
    });
})();<commit_msg>kill some dead code<commit_after>(function() {
    gf.Sprite = gf.Entity.extend({
        //initializes a new entity with the start position (pos) and the settings defined in Tiled
        init: function(pos, settings) {
            /****************************************************************************
             * Properties that are defined in the `settings` object,
             * these can be specified in the properties of the object layer
             * in Tiled, and overriden on a per-object basis
             ****************************************************************************/
            //size of the sprite (each frame)
            this.size = new THREE.Vector2(0, 0);

            //number of frames accross x / y (calculated, not set)
            this.numFrames = new THREE.Vector2(0, 0);

            //offset in the image to the first frame (in pixels)
            this.offset = new THREE.Vector2(0, 0);

            //opacity of the sprite
            this.opacity = 1.0;

            //raw THREE.Texture instance loaded by the gf.loader
            this.texture = null;

            //defined sprite animations
            this.anim = {};

            //currently active animation
            this.currentAnim = null;

            //currently active frame's active time
            this.currentFrameTime = 0;

            //animations paused
            this.animPaused = false;

            //use screen coords instead of world coords
            this.useScreenCoords = false;

            /****************************************************************************
             * Call base constructor
             ****************************************************************************/
            this._super(pos, settings);

            this._baseHitSize = this.hitSize.clone();
            this._baseScaledHitSize = this.scaledHitSize.clone();
            this._baseHitOffset = this.hitOffset.clone();

            // create a default animation sequence with all sprites
            this.addAnimation('default', null, 1000, true);
            // set as default
            this.setActiveAnimation('default');
        },
        //add a new animation
        addAnimation: function(name, settings) {
            settings = settings || {};

            if(settings instanceof Array)
                settings = { frames: settings };

            this.anim[name] = {
                name: name,
                frames: [],
                idx: 0,
                length: 0,
                frameTime: 0,
                loop: !!settings.loop,
                hitSize: settings.hitSize,
                hitOffset: settings.hitOffset
            };

            if(!settings.frames) {
                settings.frames = [];
                // create a default animation with all sprites in the spritesheet
                for(var f = 0, fl = this.numFrames.x * this.numFrames.y; f < fl; ++f) {
                    settings.frames[f] = f;
                }
            }

            // compute and add the offset of each frame
            for(var i = 0, il = settings.frames.length; i < il; ++i) {
                this.anim[name].frames[i] = new THREE.Vector2(this.size.x * (settings.frames[i] % this.numFrames.x), this.size.y * Math.floor(settings.frames[i] / this.numFrames.x));
            }
            this.anim[name].length = this.anim[name].frames.length;
            this.anim[name].frameTime = (settings.duration || 0) / this.anim[name].frames.length;

            return this;
        },
        setActiveAnimation: function(name, resetAnim, cb) {
            if(typeof resetAnim == 'function') {
                cb = resetAnim;
                resetAnim = null;
            }

            if(!this.anim[name]) {
                this.currentAnim = name;
            } else {
                if(this.currentAnim && this.currentAnim._cb && !this.currentAnim._cbCalled) {
                    this.currentAnim._cbCalled = true;
                    this.currentAnim._cb(true);
                }

                this.currentAnim = this.anim[name];
                this.currentAnim._done = false;
                this.currentAnim._cbCalled = false;
                this.currentAnim._cb = cb;
                if(resetAnim) this.currentAnim.idx = 0;
                this._setOffset();

                //if we are changing hitbox, save current settings and update
                if(this.currentAnim.hitSize) {
                    if(this.currentAnim.hitSize instanceof THREE.Vector2) {
                        this.hitSize.copy(this.currentAnim.hitSize);
                        this.scaledHitSize.copy(this.currentAnim.hitSize).multiplyScalar(this.scale);
                    }
                    else if(this.currentAnim.hitSize instanceof Array) {
                        this.hitSize.set(this.currentAnim.hitSize[0], this.currentAnim.hitSize[1]);
                        this.scaledHitSize.set(this.currentAnim.hitSize[0], this.currentAnim.hitSize[1]).multiplyScalar(this.scale);
                    }
                }
                else {
                    this.hitSize.copy(this._baseHitSize);
                    this.scaledHitSize.copy(this._baseScaledHitSize);
                }

                if(this.currentAnim.hitOffset) {
                    if(this.currentAnim.hitOffset instanceof THREE.Vector2)
                        this.hitOffset.copy(this.currentAnim.hitOffset);
                    else if(this.currentAnim.hitOffset instanceof Array)
                        this.hitOffset.set(this.currentAnim.hitOffset[0], this.currentAnim.hitOffset[1]);
                }
                else {
                    this.hitOffset.copy(this._baseHitOffset);
                }

                this._hitboxMesh.scale.set(this.scaledHitSize.x, this.scaledHitSize.y, 1);
                this.setPosition(this._mesh.position);
            }

            this.currentFrameTime = 0;

            return this;
        },
        isActiveAnimation: function(name) {
            return this.currentAnim.name == name;
        },
        update: function() {
            this._super();

            if(!this.currentAnim || this.currentAnim.frameTime === 0 || this.currentAnim.length <= 1) return;

            this.currentFrameTime += gf.game._delta * 1000;

            //update animation if necessary
            if (this.isVisible && !this.animPaused && !this.currentAnim._done && (this.currentFrameTime > this.currentAnim.frameTime)) {
                while(this.currentFrameTime > this.currentAnim.frameTime) {
                    this.currentFrameTime -= this.currentAnim.frameTime;
                    this.currentAnim.idx++;

                    if(this.currentAnim.idx == this.currentAnim.length) {
                        if(this.currentAnim.loop) {
                            this.currentAnim.idx = 0;
                        }
                        else {
                            this.currentAnim._done = true;
                            if(this.currentAnim._cb && !this.currentAnim._cbCalled) {
                                this.currentAnim._cbCalled = true;
                                this.currentAnim._cb();
                            }
                            return;
                        }
                    }

                    this._setOffset();
                }
            }

            return this;
        },
        _setOffset: function() {
            //for some reason when inversed, the tiles need to start at 1 instead of 0
            var add = this.currentAnim.inverse ? 1 : 0,
                frame = this.currentAnim.frames[this.currentAnim.idx];

            this._material.uvOffset.set(
                frame.x / this.texture.image.width,
                1 - (this.size.y / this.texture.image.height) - (frame.y / this.texture.image.height)
            );
        },
        //override Entity mesh with a sprite instead
        _createMesh: function() {
            if(this._mesh) return;

            if(this.filtered) {
                this.texture.magFilter = THREE.LinearFilter;
                this.texture.minFilter = THREE.LinearMipMapLinearFilter;
            } else {
                this.texture.magFilter = THREE.NearestFilter;
                this.texture.minFilter = THREE.NearestMipMapNearestFilter;
            }

            this.numFrames.set(this.texture.image.width / this.size.x, this.texture.image.height / this.size.y);

            this._material = new THREE.SpriteMaterial({
                color: 0xffffff,
                opacity: 1,
                map: this.texture,

                blending: THREE.NormalBlending,
                alignment: THREE.SpriteAlignment.center,
                useScreenCoordinates: this.useScreenCoords,
                //depthTest: false, //default: !useScreenCoordinates
                sizeAttenuation: true, //default: !useScreenCoordinates
                //scaledByViewport: true //default: !sizeAttenuation
            });

            this._material.uvScale.set(
                1 / this.numFrames.x,
                1 / this.numFrames.y
            );
            this._material.uvOffset.set(
                0,
                1 - this._material.uvScale.y //transform to topleft offset
            );

            this._mesh = new THREE.Sprite(this._material);

            this._mesh.scale.set(
                1 / this.numFrames.x / 2,
                1 / this.numFrames.y / 3,
                1
            );
        }
    });
})();<|endoftext|>


<commit_before>Module.STDWEB_PRIVATE.alloc = function alloc( size ) {
    return Module.web_malloc( size );
};

Module.STDWEB_PRIVATE.dyncall = function( signature, ptr, args ) {
    return Module.web_table.get( ptr ).apply( null, args );
};

// This is based on code from Emscripten's preamble.js.
Module.STDWEB_PRIVATE.utf8_len = function utf8_len( str ) {
    let len = 0;
    for( let i = 0; i < str.length; ++i ) {
        // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! So decode UTF16->UTF32->UTF8.
        // See http://unicode.org/faq/utf_bom.html#utf16-3
        let u = str.charCodeAt( i ); // possibly a lead surrogate
        if( u >= 0xD800 && u <= 0xDFFF ) {
            u = 0x10000 + ((u & 0x3FF) << 10) | (str.charCodeAt( ++i ) & 0x3FF);
        }

        if( u <= 0x7F ) {
            ++len;
        } else if( u <= 0x7FF ) {
            len += 2;
        } else if( u <= 0xFFFF ) {
            len += 3;
        } else if( u <= 0x1FFFFF ) {
            len += 4;
        } else if( u <= 0x3FFFFFF ) {
            len += 5;
        } else {
            len += 6;
        }
    }
    return len;
};

Module.STDWEB_PRIVATE.prepare_any_arg = function( value ) {
    var arg = Module.STDWEB_PRIVATE.alloc( 16 );
    Module.STDWEB_PRIVATE.from_js( arg, value );
    return arg;
};

Module.STDWEB_PRIVATE.acquire_tmp = function( dummy ) {
    var value = Module.STDWEB_PRIVATE.tmp;
    Module.STDWEB_PRIVATE.tmp = null;
    return value;
};
<commit_msg>Make `wasm32-unknown-unknown` runtime ES5 compatible<commit_after>Module.STDWEB_PRIVATE.alloc = function alloc( size ) {
    return Module.web_malloc( size );
};

Module.STDWEB_PRIVATE.dyncall = function( signature, ptr, args ) {
    return Module.web_table.get( ptr ).apply( null, args );
};

// This is based on code from Emscripten's preamble.js.
Module.STDWEB_PRIVATE.utf8_len = function utf8_len( str ) {
    var len = 0;
    for( var i = 0; i < str.length; ++i ) {
        // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! So decode UTF16->UTF32->UTF8.
        // See http://unicode.org/faq/utf_bom.html#utf16-3
        var u = str.charCodeAt( i ); // possibly a lead surrogate
        if( u >= 0xD800 && u <= 0xDFFF ) {
            u = 0x10000 + ((u & 0x3FF) << 10) | (str.charCodeAt( ++i ) & 0x3FF);
        }

        if( u <= 0x7F ) {
            ++len;
        } else if( u <= 0x7FF ) {
            len += 2;
        } else if( u <= 0xFFFF ) {
            len += 3;
        } else if( u <= 0x1FFFFF ) {
            len += 4;
        } else if( u <= 0x3FFFFFF ) {
            len += 5;
        } else {
            len += 6;
        }
    }
    return len;
};

Module.STDWEB_PRIVATE.prepare_any_arg = function( value ) {
    var arg = Module.STDWEB_PRIVATE.alloc( 16 );
    Module.STDWEB_PRIVATE.from_js( arg, value );
    return arg;
};

Module.STDWEB_PRIVATE.acquire_tmp = function( dummy ) {
    var value = Module.STDWEB_PRIVATE.tmp;
    Module.STDWEB_PRIVATE.tmp = null;
    return value;
};
<|endoftext|>


<commit_before>/* global require, module, process, console */
/* jshint -W097 */
'use strict';

var HTTPerrors = [
  100,101,
  200,201,202,203,204,205,206,
  300,301,302,303,304,305,306,307,
  400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,
  500,501,502,503,504,505
];

var errors = {
  default: {
    code:    500,
    message: 'Internal Server Error'
  },
  notFound: {
    code:    404,
    message: 'Not found'
  },
  validation: {
    code:    422,
    message: 'Validation Error'
  }
};

/**
 * Error code normalization
 *
 * Some errors have a code and status attributes, where code
 * is the error type and status is the number. This normalizes
 * that weirdness.
 *
 * @param  {Object} err The error object
 * @return {Number}     The error code
 */
var normalizeErrorCode = function(err) {
  var code = err.code;

  if(isNaN(err.code)) {
    code = (err.status && !isNaN(err.status)) ?
      err.status : /* istanbul ignore next */ errors.default.code;
  }

  return code;
};

/**
 * Mongoose does not throw validation errors for dupplicate values on
 * fields with a 'unique' index. Instead it throws a 11000 error with
 * an obscure description not suitable to be shown to the users.
 * This returns the field with the dupplicate key so a more user friendly
 * validation error can be thrown.
 *
 * @param  {String} errMessage The error message from Mongo
 * @return {String}            The name of the field that triggered the error
 */
var getPathNameFromMongoUniqueIndexError = function(errMessage) {
  // Try to get the problematic field (it's a bit hacky because there key might be a composite one)
  //
  // The error message should be something like:
  //   E11000 duplicate key error index: dbName.collection.$errPath_1 dup key: { : ObjectId('__id__'), : "someValue" }
  //
  var field = errMessage.split('.$')[1];

  field = field.split(' dup key')[0];                 // -> 'errPath_1 dup key'
  field = field.substring(0, field.lastIndexOf('_')); // -> 'errPath'

  // if this is a compound key, probably is something like
  // 'owner_1_errPath_1'
  // where owner is the client (currently there are no other types of compound keys
  // that might trigger this err). Try to clean it up.
  field.split('_').filter(function(k) {
    return ['1', '-1', 'owner'].indexOf(k) === -1;
  }).join(' ');

  return field;
};

/**
 * Error handling middleware
 */
var appErrorHandler = function(err, req, res, next) {

  var code, message, resp = { meta: {} };

  // normalize the code
  if(err.code) {
    err.code = normalizeErrorCode(err);
  }

  if(err.code && HTTPerrors.indexOf(err.code) > -1) {  // custom HTTP errors
    code = err.code;

    if(err.message) {
      message = err.message;

    } else {
      message = (code === 404) ?
        errors.notFound.message : /* istanbul ignore next */ errors.default.message;
    }

  } else if(err.name === 'CastError' && err.path === '_id') {
    code    = errors.notFound.code;
    message = errors.notFound.message;

  } else if(err.code === 11000) { // mongo error dupplicate unique index
    code    = errors.validation.code;
    message = errors.validation.message;

    var field = getPathNameFromMongoUniqueIndexError(err.message);

    if(field) {
      resp.errors = {};
      resp.errors[field] = ['Must be unique'];
    }

  } else if(err.name === 'ValidationError') {
    code    = errors.validation.code;
    message = errors.validation.message;

    resp.errors = {};

    for (var errName in err.errors) {
      /* istanbul ignore if */
      if(errors[errName]) {
        resp.errors[errName].push(err.errors[errName].message);
      } else {
        resp.errors[errName] = [err.errors[errName].message];
      }
    }

  } else {
    code    = errors.default.code;
    message = errors.default.message;
  }

  // build the response
  resp.error = {
    code:    code,
    message: message
  };

  return res.status(code).json(resp);
};

// export everything so it can be tested
module.exports = {
  HTTPerrors: HTTPerrors,
  errors: errors,
  normalizeErrorCode: normalizeErrorCode,
  middleware: appErrorHandler
};
<commit_msg>fix: return the field name once cleaned<commit_after>/* global require, module, process, console */
/* jshint -W097 */
'use strict';

var HTTPerrors = [
  100,101,
  200,201,202,203,204,205,206,
  300,301,302,303,304,305,306,307,
  400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,
  500,501,502,503,504,505
];

var errors = {
  default: {
    code:    500,
    message: 'Internal Server Error'
  },
  notFound: {
    code:    404,
    message: 'Not found'
  },
  validation: {
    code:    422,
    message: 'Validation Error'
  }
};

/**
 * Error code normalization
 *
 * Some errors have a code and status attributes, where code
 * is the error type and status is the number. This normalizes
 * that weirdness.
 *
 * @param  {Object} err The error object
 * @return {Number}     The error code
 */
var normalizeErrorCode = function(err) {
  var code = err.code;

  if(isNaN(err.code)) {
    code = (err.status && !isNaN(err.status)) ?
      err.status : /* istanbul ignore next */ errors.default.code;
  }

  return code;
};

/**
 * Mongoose does not throw validation errors for dupplicate values on
 * fields with a 'unique' index. Instead it throws a 11000 error with
 * an obscure description not suitable to be shown to the users.
 * This returns the field with the dupplicate key so a more user friendly
 * validation error can be thrown.
 *
 * @param  {String} errMessage The error message from Mongo
 * @return {String}            The name of the field that triggered the error
 */
var getPathNameFromMongoUniqueIndexError = function(errMessage) {
  // Try to get the problematic field (it's a bit hacky because there key might be a composite one)
  //
  // The error message should be something like:
  //   E11000 duplicate key error index: dbName.collection.$errPath_1 dup key: { : ObjectId('__id__'), : "someValue" }
  //
  var field = errMessage.split('.$')[1];

  field = field.split(' dup key')[0];                 // -> 'errPath_1 dup key'
  field = field.substring(0, field.lastIndexOf('_')); // -> 'errPath'

  // if this is a compound key, probably is something like
  // 'owner_1_errPath_1'
  // where owner is the client (currently there are no other types of compound keys
  // that might trigger this err). Try to clean it up.
  return field.split('_').filter(function(k) {
    return ['1', '-1', 'owner'].indexOf(k) === -1;
  }).join(' ');
};

/**
 * Error handling middleware
 */
var appErrorHandler = function(err, req, res, next) {

  var code, message, resp = { meta: {} };

  // normalize the code
  if(err.code) {
    err.code = normalizeErrorCode(err);
  }

  if(err.code && HTTPerrors.indexOf(err.code) > -1) {  // custom HTTP errors
    code = err.code;

    if(err.message) {
      message = err.message;

    } else {
      message = (code === 404) ?
        errors.notFound.message : /* istanbul ignore next */ errors.default.message;
    }

  } else if(err.name === 'CastError' && err.path === '_id') {
    code    = errors.notFound.code;
    message = errors.notFound.message;

  } else if(err.code === 11000) { // mongo error dupplicate unique index
    code    = errors.validation.code;
    message = errors.validation.message;

    var field = getPathNameFromMongoUniqueIndexError(err.message);

    if(field) {
      resp.errors = {};
      resp.errors[field] = ['Must be unique'];
    }

  } else if(err.name === 'ValidationError') {
    code    = errors.validation.code;
    message = errors.validation.message;

    resp.errors = {};

    for (var errName in err.errors) {
      /* istanbul ignore if */
      if(errors[errName]) {
        resp.errors[errName].push(err.errors[errName].message);
      } else {
        resp.errors[errName] = [err.errors[errName].message];
      }
    }

  } else {
    code    = errors.default.code;
    message = errors.default.message;
  }

  // build the response
  resp.error = {
    code:    code,
    message: message
  };

  return res.status(code).json(resp);
};

// export everything so it can be tested
module.exports = {
  HTTPerrors: HTTPerrors,
  errors: errors,
  normalizeErrorCode: normalizeErrorCode,
  middleware: appErrorHandler
};
<|endoftext|>


<commit_before>export default [
    '(business|client|community|culture|customer|data|goal|intelligence|market' +
        '|process|quality|results|role|sales|subject|service|user)' +
        '.(centric(ity)?|facing|oriented|driven|focused|assessment|service|process)',
    '10x',
    '24/7',
    'ai',
    'agile',
    'ambassador',
    'artificial intelligence',
    'at (your|their) fingertips?',
    'autonomous',
    'a[-/]b testing',
    'acquisition',
    'action items?',
    'act in time',
    'advantages?',
    'agents?',
    'aggregat(e|ion)',
    'accelerate',
    'all.in.one',
    'all.new',
    'amazing',
    'analytics?',
    'application service providers?',
    'as a service',
    'assets?',
    'astonishing',
    'authoritative',
    'automated',
    'augmented',
    'extended reality',
    'award.winning',
    'b2(b|c)',
    'back to the drawing board',
    'ball.?park',
    'band.aid',
    'bandwidth',
    '(benefit|gap) analysis',
    'bespoke',
    'best.in.class',
    'best.of.breed',
    'best.practice',
    'big.data',
    'big picture',
    'big thinkers?',
    'block.?chain',
    'blazing(ly)? fast',
    'boil the ocean',
    'bottom.line',
    'bottom.up',
    'boost(s|ing)?',
    'brain.?storm(ing)?',
    'brain.?dump',
    'brand(s?|ing|ed)',
    'bright',
    'building.trust',
    'bulletproof',
    'burn.rates?',
    'business( cases| plans)',
    'buzz',
    'call to action',
    'capacity',
    'capabilit(y|ies)',
    'capitali(s|z)e',
    'centers? of excellence',
    'challenges?',
    'change agents?',
    'circle the wagons',
    'client-centered',
    'client-centric',
    'client-focused',
    'cloud',
    'cloud native',
    'cloudify',
    'collaborat(e|ion|ive)s?',
    'comfort( zone)?',
    'committee',
    'communicat(e|ion)s?',
    'company-employee.fit',
    'compelling',
    'competitive( advantage)?',
    'connected systems?',
    'complex(ity)?',
    'comprehensive',
    'connect the dots',
    'container orchestration',
    'containerizat(e|ion|ing)',
    'content management',
    'contextual(ly)?',
    'contingency plans?',
    'control groups?',
    'control plane',
    'convergence',
    'convergent',
    'conversions?',
    'core business',
    'core competenc(y|ies)',
    'core.to.edge',
    'cosmic',
    'cost-effective',
    'cost/benefit',
    'cost control',
    'craftsmanship',
    'critical path',
    'crypto.currency',
    'crypto(?!graphy).\\w+',
    'crm',
    'cross.sell',
    'crowd.?(fund(s?|ed|ing)|sourc(ed|e|ing))',
    'customer obsession',
    'cutting.edge',
    'cyber',
    'dashboards?',
    'dashboarding',
    'data mining',
    'decentrali(s|z)ed',
    'de-?dupe',
    'deep dive',
    'deep learning',
    'delight',
    'deliverables?',
    'demographic',
    'demystify',
    'demystifying',
    'deployless',
    'devops',
    'digital transformation',
    'discovery',
    'distributed ledgers?',
    'disrupt(ive|tor|ion)?',
    'dollar.productive',
    'downsi(s|z)e',
    'drill down',
    'drink the kool-aid',
    'drop.?in',
    'drop the ball',
    'due dilligence',
    'dynamic(s|ally)?',
    'e-?(business|commerce|tailers)',
    'early.stage',
    'eas(y|ily)',
    'ecosystems?',
    'efficien(t|cy)',
    'effortless(ly)?',
    'elastic',
    'elaboration',
    'elephant in the room',
    'elevator pitch(ing)?',
    'enabl(e|ing)',
    'emerging markets?',
    'empower(ing|ment|s)?',
    'enablement',
    'end of the day',
    'end.to.end',
    'engulf',
    'engag(e|ing|ment)',
    'enhanced?',
    'enterprise',
    'erp',
    'estimate',
    'eta',
    'etched in stone',
    'evolution',
    'exceed expectations',
    'exclusive(ly)?',
    'exhaustive',
    'expedite',
    'experiences',
    'experts?',
    'expertise',
    'exposure',
    'extraordinary',
    'facilitat(e|or)',
    'fast track',
    'fault.tolerant',
    'first.to.market',
    'flexibility',
    'flux',
    'foot view',
    'forward-thinking',
    'four pillars',
    'frictionless',
    'front lines',
    'frustration[- ]free',
    'functional',
    'futurist',
    'full benefit',
    'future.proof',
    'game changer',
    'game plan',
    'behavioral',
    'global(ly)?',
    'go public',
    'go.to.market',
    'goals?',
    'god-speed',
    'going forward',
    'granular',
    'ground.?breaking',
    'growth',
    'grow',
    'guidance',
    'guru',
    'hackathon',
    'hacker( mindset)?',
    'happiness manage(ment|rs?)',
    'hardball',
    'heavy.lifting',
    'herding cats',
    'hidden.gem',
    'hidden.meaning',
    'high.level',
    '(high|mass).impact',
    'highly.scalable',
    'hive ?mind',
    'hybrid environments?',
    'hyper.personalization',
    'hyperconverged',
    'holistic',
    'ideathon',
    'impactful',
    'impeccable',
    'in( |-)a( |-)nutshell',
    'incent',
    'incentivi(s|z)e',
    'increase the odds',
    'incredibl(e|y)',
    '(inflat|redeem)able value',
    'influencers?',
    'influx',
    'innovat(e|ed|ion|ive|ing|or)s?',
    'inspir(e|ing|ation)',
    'insights?',
    'integrat(e|ed|ion)s?',
    'internet[- ]of[- ]things',
    'intellectual property',
    'intuitive',
    'iot',
    'key results?',
    'kickstart(er|ed)?s?',
    'killjoy',
    'knowledge.(base|transfer|sharing)',
    'kpis?',
    'landing pages?',
    'lead the field',
    'leading',
    'leaders?',
    'leadership',
    'learnings',
    'legacy',
    'lessons learned',
    'level (the )? playing field',
    'level set',
    'leverag(e|ing)',
    'lifecycle',
    'low.hanging fruit',
    'look.(&|and).feel',
    'm2m',
    'machine learning',
    'made simple',
    'magical',
    'market (chang(er|ing)|leader|window|simplified|fit)',
    'market.ready',
    'marketing collateral',
    'maximi(s|z)e',
    'meaningful( client | )interactions?',
    'measurements?',
    'methodolog(y|ies)',
    'metrics',
    'middleware',
    'milestone',
    'military.grade encryption',
    'mind ?share',
    'mind ?shower',
    'mind-boggling',
    'mindset',
    '(mission|time).critical',
    'ml',
    'moneti(s|z)e',
    'mov(e|ing) (fast|forward)',
    'multitask(ing?)',
    'multifaceted',
    'multi-?tenant(ed)?',
    'mvp',
    'negotiated',
    'networking',
    'new.economy',
    'new.breed',
    '(new|next|second).(level|gen|generation)',
    'niches?',
    'ninja',
    'no-brainer',
    'non-traditional management',
    'objectives',
    'occupy the field',
    'off.site',
    'off.the.(radar|shelf)',
    'on board',
    'on.premises?',
    'on the (back end|radar screen|same page|house)',
    'one to one',
    'open the kimono',
    'opportunit(y|ies)',
    'outperform',
    'optimal',
    'orthogonal',
    'outstanding',
    'out(side)?.(of)?.the.(box|loop)',
    'outsourc(e|ed|ing)',
    '(total cost of )?ownership',
    'paradigms?( shift)?',
    'partner(ships?)?',
    'patents?',
    'performance indicators',
    'personaliz(e|ed|ation)',
    'perspective',
    'phases?',
    'phased approach',
    'pipeline',
    'pioneers',
    'pivot',
    'planning horizon',
    'platforms?',
    'plug.?in',
    'potentials?',
    'powerful',
    'prioriti(s|z)ed?',
    'proactive',
    'problem space',
    'processes',
    'profit(ability)?',
    'promotion',
    'promotional collateral',
    'prominent',
    'proprietary',
    'proof.of.concept',
    'purpose.built',
    'push the envelope',
    'push.back',
    'production.ready',
    'productivity',
    'pushing on open doors',
    'quick wins?',
    'rais(e|ing) the bar',
    'ramp.up',
    'ravishing',
    'relationship management',
    'responsive',
    'engage(ments?)?',
    'reach out',
    'reactivation',
    'real.time',
    'real.world',
    'reconfigure',
    'redefin(e|ed|ing)',
    'red flags?',
    'reengineering',
    'reimagin(e|ed|ing)',
    'reinvent(ing)? the(.square)? wheel',
    'reinvigorate',
    'relevance',
    'repurpose',
    'resilien(ce|cy|t)',
    'resource allocation',
    'restructuring',
    'retention',
    'return on investment',
    'results',
    'reus(e|ability)',
    'revenue',
    'reverse.engineer',
    'revisit',
    'revolution',
    'rich',
    'road ?map',
    'robust',
    'rock.?star',
    'roi',
    'run the numbers',
    '(s|p)aas',
    'sacrific(e|es|ing)',
    'scal(e|es|ing|ability)',
    'high availability',
    'scenarios?',
    'scope',
    'scrum( master)?',
    'seamless',
    'secret sauce',
    'search engine optimization',
    'segments?',
    'self-managed team',
    'seo',
    '(serial )?entrepreneurs?',
    'serverless',
    'service mesh',
    'shareholder value',
    'significant(ly)?',
    'single-source responsibility',
    'skill ?sets?',
    'smart(er)?',
    'smoke (&|and) mirrors',
    'social(.media|.gaming|.networks?)',
    'solidality',
    'solutions?',
    'sophisticated',
    'soup to nuts',
    'sow',
    'spatial.computing',
    'stakeholders?',
    'start.up?',
    'statement of work',
    'state.of.the.art',
    'step.changes?',
    'sticky-?ness',
    'strateg(y|ic|ize|ise)',
    'streamlin(ed|e|ing)',
    'story points?',
    'success(ful)?',
    'super(critical|star|nova)',
    'sustainab(le|ility)',
    'synerg(y|ies|ized|i)',
    'systems?',
    'tailwinds?',
    'talented',
    'take offline',
    'talking points',
    'target (audience|group)',
    'targeted',
    'tasked',
    'tco',
    'team.building',
    'team.player',
    'teamwork',
    'technolog(y|ies)',
    'that being said',
    'throughput',
    'time.to.awesome',
    'time.to.market',
    'timelines?',
    'top.down',
    'top.of.the.game',
    'total quality',
    'touch.base',
    'touchpoints?',
    'traction',
    'transfor(m|ming)',
    'trends?',
    'true',
    'truths?',
    'turnkey',
    'ultimate',
    'up.to.speed',
    'up-?sell',
    'upside',
    'user.friendly',
    'user funnels?',
    'user.experience',
    'utili(s|z)(e|ation)',
    'uncover',
    'unicorn',
    'unique approach',
    'unlimited.holidays',
    'values?',
    'valueable',
    'value.add(ed)?',
    'venture',
    'venturing',
    'vertical market',
    'viral',
    'virtual(ization|isation)?',
    'visibility',
    'visio(n|nary)',
    'walk the talk',
    'wearable',
    'web.enabled',
    'win-win',
    'wisdom of crowds',
    'with due respect',
    'with ease',
    'wizards?',
    'workflows?',
    'workloads?',
    'workplaceless',
    'workspace',
    'world.?class',
    'world a better place',
    'wow.factor',
    'you\'ve never seen (a|an) \\w+',
    'zeitgeist',
];
<commit_msg>Add 'differentiation' term (#140)<commit_after>export default [
    '(business|client|community|culture|customer|data|goal|intelligence|market' +
        '|process|quality|results|role|sales|subject|service|user)' +
        '.(centric(ity)?|facing|oriented|driven|focused|assessment|service|process)',
    '10x',
    '24/7',
    'ai',
    'agile',
    'ambassador',
    'artificial intelligence',
    'at (your|their) fingertips?',
    'autonomous',
    'a[-/]b testing',
    'acquisition',
    'action items?',
    'act in time',
    'advantages?',
    'agents?',
    'aggregat(e|ion)',
    'accelerate',
    'all.in.one',
    'all.new',
    'amazing',
    'analytics?',
    'application service providers?',
    'as a service',
    'assets?',
    'astonishing',
    'authoritative',
    'automated',
    'augmented',
    'extended reality',
    'award.winning',
    'b2(b|c)',
    'back to the drawing board',
    'ball.?park',
    'band.aid',
    'bandwidth',
    '(benefit|gap) analysis',
    'bespoke',
    'best.in.class',
    'best.of.breed',
    'best.practice',
    'big.data',
    'big picture',
    'big thinkers?',
    'block.?chain',
    'blazing(ly)? fast',
    'boil the ocean',
    'bottom.line',
    'bottom.up',
    'boost(s|ing)?',
    'brain.?storm(ing)?',
    'brain.?dump',
    'brand(s?|ing|ed)',
    'bright',
    'building.trust',
    'bulletproof',
    'burn.rates?',
    'business( cases| plans)',
    'buzz',
    'call to action',
    'capacity',
    'capabilit(y|ies)',
    'capitali(s|z)e',
    'centers? of excellence',
    'challenges?',
    'change agents?',
    'circle the wagons',
    'client-centered',
    'client-centric',
    'client-focused',
    'cloud',
    'cloud native',
    'cloudify',
    'collaborat(e|ion|ive)s?',
    'comfort( zone)?',
    'committee',
    'communicat(e|ion)s?',
    'company-employee.fit',
    'compelling',
    'competitive( advantage)?',
    'connected systems?',
    'complex(ity)?',
    'comprehensive',
    'connect the dots',
    'container orchestration',
    'containerizat(e|ion|ing)',
    'content management',
    'contextual(ly)?',
    'contingency plans?',
    'control groups?',
    'control plane',
    'convergence',
    'convergent',
    'conversions?',
    'core business',
    'core competenc(y|ies)',
    'core.to.edge',
    'cosmic',
    'cost-effective',
    'cost/benefit',
    'cost control',
    'craftsmanship',
    'critical path',
    'crypto.currency',
    'crypto(?!graphy).\\w+',
    'crm',
    'cross.sell',
    'crowd.?(fund(s?|ed|ing)|sourc(ed|e|ing))',
    'customer obsession',
    'cutting.edge',
    'cyber',
    'dashboards?',
    'dashboarding',
    'data mining',
    'decentrali(s|z)ed',
    'de-?dupe',
    'deep dive',
    'deep learning',
    'delight',
    'deliverables?',
    'demographic',
    'demystify',
    'demystifying',
    'deployless',
    'devops',
    'digital transformation',
    'differentiation',
    'discovery',
    'distributed ledgers?',
    'disrupt(ive|tor|ion)?',
    'dollar.productive',
    'downsi(s|z)e',
    'drill down',
    'drink the kool-aid',
    'drop.?in',
    'drop the ball',
    'due dilligence',
    'dynamic(s|ally)?',
    'e-?(business|commerce|tailers)',
    'early.stage',
    'eas(y|ily)',
    'ecosystems?',
    'efficien(t|cy)',
    'effortless(ly)?',
    'elastic',
    'elaboration',
    'elephant in the room',
    'elevator pitch(ing)?',
    'enabl(e|ing)',
    'emerging markets?',
    'empower(ing|ment|s)?',
    'enablement',
    'end of the day',
    'end.to.end',
    'engulf',
    'engag(e|ing|ment)',
    'enhanced?',
    'enterprise',
    'erp',
    'estimate',
    'eta',
    'etched in stone',
    'evolution',
    'exceed expectations',
    'exclusive(ly)?',
    'exhaustive',
    'expedite',
    'experiences',
    'experts?',
    'expertise',
    'exposure',
    'extraordinary',
    'facilitat(e|or)',
    'fast track',
    'fault.tolerant',
    'first.to.market',
    'flexibility',
    'flux',
    'foot view',
    'forward-thinking',
    'four pillars',
    'frictionless',
    'front lines',
    'frustration[- ]free',
    'functional',
    'futurist',
    'full benefit',
    'future.proof',
    'game changer',
    'game plan',
    'behavioral',
    'global(ly)?',
    'go public',
    'go.to.market',
    'goals?',
    'god-speed',
    'going forward',
    'granular',
    'ground.?breaking',
    'growth',
    'grow',
    'guidance',
    'guru',
    'hackathon',
    'hacker( mindset)?',
    'happiness manage(ment|rs?)',
    'hardball',
    'heavy.lifting',
    'herding cats',
    'hidden.gem',
    'hidden.meaning',
    'high.level',
    '(high|mass).impact',
    'highly.scalable',
    'hive ?mind',
    'hybrid environments?',
    'hyper.personalization',
    'hyperconverged',
    'holistic',
    'ideathon',
    'impactful',
    'impeccable',
    'in( |-)a( |-)nutshell',
    'incent',
    'incentivi(s|z)e',
    'increase the odds',
    'incredibl(e|y)',
    '(inflat|redeem)able value',
    'influencers?',
    'influx',
    'innovat(e|ed|ion|ive|ing|or)s?',
    'inspir(e|ing|ation)',
    'insights?',
    'integrat(e|ed|ion)s?',
    'internet[- ]of[- ]things',
    'intellectual property',
    'intuitive',
    'iot',
    'key results?',
    'kickstart(er|ed)?s?',
    'killjoy',
    'knowledge.(base|transfer|sharing)',
    'kpis?',
    'landing pages?',
    'lead the field',
    'leading',
    'leaders?',
    'leadership',
    'learnings',
    'legacy',
    'lessons learned',
    'level (the )? playing field',
    'level set',
    'leverag(e|ing)',
    'lifecycle',
    'low.hanging fruit',
    'look.(&|and).feel',
    'm2m',
    'machine learning',
    'made simple',
    'magical',
    'market (chang(er|ing)|leader|window|simplified|fit)',
    'market.ready',
    'marketing collateral',
    'maximi(s|z)e',
    'meaningful( client | )interactions?',
    'measurements?',
    'methodolog(y|ies)',
    'metrics',
    'middleware',
    'milestone',
    'military.grade encryption',
    'mind ?share',
    'mind ?shower',
    'mind-boggling',
    'mindset',
    '(mission|time).critical',
    'ml',
    'moneti(s|z)e',
    'mov(e|ing) (fast|forward)',
    'multitask(ing?)',
    'multifaceted',
    'multi-?tenant(ed)?',
    'mvp',
    'negotiated',
    'networking',
    'new.economy',
    'new.breed',
    '(new|next|second).(level|gen|generation)',
    'niches?',
    'ninja',
    'no-brainer',
    'non-traditional management',
    'objectives',
    'occupy the field',
    'off.site',
    'off.the.(radar|shelf)',
    'on board',
    'on.premises?',
    'on the (back end|radar screen|same page|house)',
    'one to one',
    'open the kimono',
    'opportunit(y|ies)',
    'outperform',
    'optimal',
    'orthogonal',
    'outstanding',
    'out(side)?.(of)?.the.(box|loop)',
    'outsourc(e|ed|ing)',
    '(total cost of )?ownership',
    'paradigms?( shift)?',
    'partner(ships?)?',
    'patents?',
    'performance indicators',
    'personaliz(e|ed|ation)',
    'perspective',
    'phases?',
    'phased approach',
    'pipeline',
    'pioneers',
    'pivot',
    'planning horizon',
    'platforms?',
    'plug.?in',
    'potentials?',
    'powerful',
    'prioriti(s|z)ed?',
    'proactive',
    'problem space',
    'processes',
    'profit(ability)?',
    'promotion',
    'promotional collateral',
    'prominent',
    'proprietary',
    'proof.of.concept',
    'purpose.built',
    'push the envelope',
    'push.back',
    'production.ready',
    'productivity',
    'pushing on open doors',
    'quick wins?',
    'rais(e|ing) the bar',
    'ramp.up',
    'ravishing',
    'relationship management',
    'responsive',
    'engage(ments?)?',
    'reach out',
    'reactivation',
    'real.time',
    'real.world',
    'reconfigure',
    'redefin(e|ed|ing)',
    'red flags?',
    'reengineering',
    'reimagin(e|ed|ing)',
    'reinvent(ing)? the(.square)? wheel',
    'reinvigorate',
    'relevance',
    'repurpose',
    'resilien(ce|cy|t)',
    'resource allocation',
    'restructuring',
    'retention',
    'return on investment',
    'results',
    'reus(e|ability)',
    'revenue',
    'reverse.engineer',
    'revisit',
    'revolution',
    'rich',
    'road ?map',
    'robust',
    'rock.?star',
    'roi',
    'run the numbers',
    '(s|p)aas',
    'sacrific(e|es|ing)',
    'scal(e|es|ing|ability)',
    'high availability',
    'scenarios?',
    'scope',
    'scrum( master)?',
    'seamless',
    'secret sauce',
    'search engine optimization',
    'segments?',
    'self-managed team',
    'seo',
    '(serial )?entrepreneurs?',
    'serverless',
    'service mesh',
    'shareholder value',
    'significant(ly)?',
    'single-source responsibility',
    'skill ?sets?',
    'smart(er)?',
    'smoke (&|and) mirrors',
    'social(.media|.gaming|.networks?)',
    'solidality',
    'solutions?',
    'sophisticated',
    'soup to nuts',
    'sow',
    'spatial.computing',
    'stakeholders?',
    'start.up?',
    'statement of work',
    'state.of.the.art',
    'step.changes?',
    'sticky-?ness',
    'strateg(y|ic|ize|ise)',
    'streamlin(ed|e|ing)',
    'story points?',
    'success(ful)?',
    'super(critical|star|nova)',
    'sustainab(le|ility)',
    'synerg(y|ies|ized|i)',
    'systems?',
    'tailwinds?',
    'talented',
    'take offline',
    'talking points',
    'target (audience|group)',
    'targeted',
    'tasked',
    'tco',
    'team.building',
    'team.player',
    'teamwork',
    'technolog(y|ies)',
    'that being said',
    'throughput',
    'time.to.awesome',
    'time.to.market',
    'timelines?',
    'top.down',
    'top.of.the.game',
    'total quality',
    'touch.base',
    'touchpoints?',
    'traction',
    'transfor(m|ming)',
    'trends?',
    'true',
    'truths?',
    'turnkey',
    'ultimate',
    'up.to.speed',
    'up-?sell',
    'upside',
    'user.friendly',
    'user funnels?',
    'user.experience',
    'utili(s|z)(e|ation)',
    'uncover',
    'unicorn',
    'unique approach',
    'unlimited.holidays',
    'values?',
    'valueable',
    'value.add(ed)?',
    'venture',
    'venturing',
    'vertical market',
    'viral',
    'virtual(ization|isation)?',
    'visibility',
    'visio(n|nary)',
    'walk the talk',
    'wearable',
    'web.enabled',
    'win-win',
    'wisdom of crowds',
    'with due respect',
    'with ease',
    'wizards?',
    'workflows?',
    'workloads?',
    'workplaceless',
    'workspace',
    'world.?class',
    'world a better place',
    'wow.factor',
    'you\'ve never seen (a|an) \\w+',
    'zeitgeist',
];
<|endoftext|>


<commit_before>var bullshitTerms = [
    '(market|goal|community|quality|results|sales|user|customer' +
        '|subject|role|service|client|process|business)' +
        '.(centric(ity)?|facing|oriented|driven|focused|assessment|service)',
    '24/7',
    'a-b testing',
    'accessib(le|ility)',
    'acquisition',
    'action items?',
    'advantages?',
    'aggregate',
    'analytics?',
    'application service providers?',
    'assets?',
    'authoritative',
    'automated',
    'b2b',
    'back to the drawing board',
    'ball.?park',
    'band.aid',
    'bandwidth',
    'benchmark',
    '(benefit|gap) analysis',
    'best.of.breed',
    'best.practice',
    'big.data',
    'big picture',
    'bottom line',
    'bottom.up',
    'brain.?storm',
    'brain.?dump',
    'brand(s?|ing|ed)',
    'burn.rates?',
    'business.(cases|plans)?',
    'buzz',
    'call to action',
    'capacity',
    'capitalize',
    'center of excellence',
    'challenges?',
    'change agent',
    'circle the wagons',
    'collaborat(e|ion)',
    'communicat(e|ion)',
    'compelling',
    'competitive( advantage)?',
    'connect the dots',
    'content management',
    'contingency plan',
    'control group',
    'convergent',
    'conversion',
    'core business',
    'core competenc(y|ies)',
    'cost-effective',
    'cost/benefit',
    'cost control',
    'craftsmanship',
    'critical path',
    'crm',
    'cross.sell',
    'crowd.?(fund(s?|ed|ing)|sourc(ed|e|ing))',
    'cutting.edge',
    'data mining',
    'deep dive',
    'delight the customers?',
    'deliverables?',
    'demographic',
    'discovery',
    'diversity',
    'downsize',
    'drill down',
    'drink the kool-aid',
    'drop.?in',
    'drop the ball',
    'due dilligence',
    'dynamic',
    'e-?(business|commerce|tailers)',
    'ecosystems?',
    'efficien(t|cy)',
    'elaboration',
    'elephant in the room',
    'elevator pitch',
    'emerging markets',
    'empower(ment)?',
    'end of the day',
    'end to end',
    'engag(e|ing)',
    'enhance',
    'enterprise',
    'eta',
    'etched in stone',
    'exceed expectations',
    'expectations',
    'experiences',
    'experts?',
    'expertise',
    'exposure',
    'eyeballs',
    'facilitat(e|or)',
    'fast track',
    'fault.tolerant',
    'first to market',
    'flexibility',
    'followup',
    'foot view',
    'front lines',
    'functional',
    'full benefit',
    'game plan',
    'go public',
    'go to market',
    'goals?',
    'going forward',
    'google juice',
    'graceful.degradation',
    'gradual.enhancement',
    'granular',
    'growth',
    'grow',
    'guidance',
    'hardball',
    'having said that',
    'heads.up',
    'heavy.lifting',
    'herding cats',
    'high.level',
    '(high|mass).impact',
    'impactful',
    'impeccable',
    'implementation',
    'in a nutshell',
    'incent',
    'incentivize',
    'increase the odds',
    'innovat(e|ed|ion|ive|ing|or)',
    'inspir(e|ing|ation)',
    'integrat(e|ed|ion)',
    'internet of things',
    'intellectual property',
    'intuitive',
    'knowledge base',
    'knowledge transfer',
    'landing pages?',
    'lead the field',
    'leadership',
    'legacy',
    'lessons learned',
    'level playing field',
    'level set',
    'leverage',
    'low-hanging fruit',
    'look.(&|and).feel',
    'market leader',
    'market window',
    'marketing collateral',
    'maximize',
    'measurement',
    'methodolog(y|ies)',
    'metrics',
    'middleware',
    'milestone',
    'mind share',
    'mind shower',
    'mindset',
    'mindshare',
    '(mission|time).critical',
    'monetize',
    'moving forward',
    'multitask(ing?)',
    'multifaceted',
    'negotiated',
    'networking',
    'new economy',
    'new breed',
    'next level',
    'niches?',
    'no-brainer',
    'non-traditional management',
    'objectives',
    'occupy the field',
    'off.site',
    'off.the.(radar|shelf)',
    'on board',
    'on the (back end|radar screen|same page)',
    'one to one',
    'opportunit(y|ies)',
    '(search engine )?optimization',
    'optimal',
    'out(side)?.of.the.(box|loop)',
    'outsourc(e|ed|ing)',
    '(total cost of )?ownership',
    'paradigms?( shift)?',
    'partner(ships?)?',
    'patent',
    'performance indicators',
    'personalization',
    'perspective',
    'phase',
    'phased approach',
    'pipeline',
    'planning horizon',
    'plug.?in',
    'prioritized?',
    'proactive',
    'problem space',
    'processes',
    'profit(ability)?',
    'promotion',
    'promotional collateral',
    'prominent',
    'proprietary',
    'proof.of.concept',
    'push the envelope',
    'push.back',
    'quick win',
    'rais(e|ing) the bar',
    'ramp.up',
    'relationship management',
    'responsive',
    'engage(ments?)?',
    'reach out',
    'reactivation',
    'real.time',
    'real.world',
    'reconfigure',
    'red flag',
    'reengineering',
    'reinvent(ing)? the(.square)? wheel',
    'reinvigorate',
    'relevance',
    'repurpose',
    'resource allocation',
    'restructuring',
    'retention',
    'return on investment',
    'reus(e|ability)',
    'revenue',
    'reverse.engineer',
    'revisit',
    'road ?map',
    'robust',
    'roi',
    'run the numbers',
    'scale',
    'scenarios?',
    'scope',
    'seamless',
    'secret sauce',
    'segment',
    'self-managed team',
    'seo',
    'shareholder value',
    'single-source responsibility',
    'skill sets?',
    'smoke (&|and) mirrors',
    'social(.media|.gaming|.networks?)',
    'solutions?',
    'soup to nuts',
    'sow',
    'stakeholder',
    'start.up?',
    'statement of work',
    'sticky-?ness',
    'strateg(y|ic|ize)',
    'streamline',
    'success(ful)?',
    'sustainab(le|ility)',
    'synerg(y|ies)',
    'tailwinds?',
    'take offline',
    'talking points',
    'target (audience|group)',
    'targeted',
    'tasked',
    'tco',
    'team.building',
    'team.player',
    'teamwork',
    'technologies',
    'that being said',
    'time.to.market',
    'timelines?',
    'top.down',
    'top of the game',
    'total quality',
    'touch.base',
    'touchpoints',
    'traction',
    'trends?',
    'turnkey',
    'up.to.speed',
    'up-?sell',
    'upside',
    'user.friendly',
    'user.experience',
    'utiliz(e|ation)',
    'unique approach',
    'values?',
    'valueable',
    'value-added',
    'vertical market',
    'viral',
    'virtual(ization)?',
    'visibility',
    'vision',
    'walk the talk',
    'web.enabled',
    'win-win',
    'wisdom of crowds',
    'workflow',
    'workshop',
    'world.?class',
    'wow.factor',

    // technical bullshit
    'cloud',
    '(object|aspect).oriented',
    '(framework|platform).agnostic',
    '(front.?end.|ui.)?framework',
    'html5',
    'mv(c|p)',
    'nosql',
    'off-?line',
    'oop',
    'web (2|3)\\.0'
];
<commit_msg>Added new words<commit_after>var bullshitTerms = [
    '(market|goal|community|quality|results|sales|user|customer' +
        '|subject|role|service|client|process|business)' +
        '.(centric(ity)?|facing|oriented|driven|focused|assessment|service)',
    '24/7',
    'a-b testing',
    'accessib(le|ility)',
    'acquisition',
    'action items?',
    'advantages?',
    'aggregate',
    'analytics?',
    'application service providers?',
    'assets?',
    'authoritative',
    'automated',
    'b2b',
    'back to the drawing board',
    'ball.?park',
    'band.aid',
    'bandwidth',
    'benchmark',
    '(benefit|gap) analysis',
    'best.of.breed',
    'best.practice',
    'big.data',
    'big picture',
    'bottom line',
    'bottom.up',
    'brain.?storm',
    'brain.?dump',
    'brand(s?|ing|ed)',
    'burn.rates?',
    'business.(cases|plans)?',
    'buzz',
    'call to action',
    'capacity',
    'capitalize',
    'center of excellence',
    'challenges?',
    'change agent',
    'circle the wagons',
    'collaborat(e|ion)',
    'communicat(e|ion)',
    'compelling',
    'competitive( advantage)?',
    'connect the dots',
    'content management',
    'contextual(ly)?',
    'contingency plan',
    'control group',
    'convergent',
    'conversion',
    'core business',
    'core competenc(y|ies)',
    'cost-effective',
    'cost/benefit',
    'cost control',
    'craftsmanship',
    'critical path',
    'crm',
    'cross.sell',
    'crowd.?(fund(s?|ed|ing)|sourc(ed|e|ing))',
    'cutting.edge',
    'data mining',
    'de-dupe',
    'deep dive',
    'delight the customers?',
    'deliverables?',
    'demographic',
    'discovery',
    'diversity',
    'downsize',
    'drill down',
    'drink the kool-aid',
    'drop.?in',
    'drop the ball',
    'due dilligence',
    'dynamic',
    'e-?(business|commerce|tailers)',
    'ecosystems?',
    'efficien(t|cy)',
    'elaboration',
    'elephant in the room',
    'elevator pitch',
    'emerging markets',
    'empower(ment)?',
    'end of the day',
    'end to end',
    'engag(e|ing)',
    'enhance',
    'enterprise',
    'erp',
    'eta',
    'etched in stone',
    'exceed expectations',
    'expectations',
    'experiences',
    'experts?',
    'expertise',
    'exposure',
    'eyeballs',
    'facilitat(e|or)',
    'fast track',
    'fault.tolerant',
    'first to market',
    'flexibility',
    'followup',
    'foot view',
    'front lines',
    'functional',
    'full benefit',
    'game plan',
    'geo-behavioral'
    'go public',
    'go to market',
    'goals?',
    'going forward',
    'google juice',
    'graceful.degradation',
    'gradual.enhancement',
    'granular',
    'growth',
    'grow',
    'guidance',
    'hardball',
    'having said that',
    'heads.up',
    'heavy.lifting',
    'herding cats',
    'high.level',
    '(high|mass).impact',
    'impactful',
    'impeccable',
    'implementation',
    'in a nutshell',
    'incent',
    'incentivize',
    'increase the odds',
    'innovat(e|ed|ion|ive|ing|or)',
    'inspir(e|ing|ation)',
    'integrat(e|ed|ion)',
    'internet of things',
    'intellectual property',
    'intuitive',
    'knowledge base',
    'knowledge transfer',
    'landing pages?',
    'lead the field',
    'leadership',
    'legacy',
    'lessons learned',
    'level playing field',
    'level set',
    'leverage',
    'low-hanging fruit',
    'look.(&|and).feel',
    'm2m',
    'market leader',
    'market window',
    'marketing collateral',
    'maximize',
    'measurement',
    'methodolog(y|ies)',
    'metrics',
    'middleware',
    'milestone',
    'mind share',
    'mind shower',
    'mindset',
    'mindshare',
    '(mission|time).critical',
    'monetize',
    'moving forward',
    'multitask(ing?)',
    'multifaceted',
    'negotiated',
    'networking',
    'new economy',
    'new breed',
    'next level',
    'niches?',
    'no-brainer',
    'non-traditional management',
    'objectives',
    'occupy the field',
    'off.site',
    'off.the.(radar|shelf)',
    'on board',
    'on the (back end|radar screen|same page)',
    'one to one',
    'opportunit(y|ies)',
    '(search engine )?optimization',
    'optimal',
    'out(side)?.of.the.(box|loop)',
    'outsourc(e|ed|ing)',
    '(total cost of )?ownership',
    'paradigms?( shift)?',
    'partner(ships?)?',
    'patent',
    'performance indicators',
    'personalization',
    'perspective',
    'phase',
    'phased approach',
    'pipeline',
    'planning horizon',
    'platforms?',
    'plug.?in',
    'prioritized?',
    'proactive',
    'problem space',
    'processes',
    'profit(ability)?',
    'promotion',
    'promotional collateral',
    'prominent',
    'proprietary',
    'proof.of.concept',
    'push the envelope',
    'push.back',
    'quick win',
    'rais(e|ing) the bar',
    'ramp.up',
    'relationship management',
    'responsive',
    'engage(ments?)?',
    'reach out',
    'reactivation',
    'real.time',
    'real.world',
    'reconfigure',
    'red flag',
    'reengineering',
    'reinvent(ing)? the(.square)? wheel',
    'reinvigorate',
    'relevance',
    'repurpose',
    'resource allocation',
    'restructuring',
    'retention',
    'return on investment',
    'reus(e|ability)',
    'revenue',
    'reverse.engineer',
    'revisit',
    'road ?map',
    'robust',
    'roi',
    'run the numbers',
    'scale',
    'scenarios?',
    'scope',
    'seamless',
    'secret sauce',
    'segment',
    'self-managed team',
    'seo',
    'shareholder value',
    'single-source responsibility',
    'skill sets?',
    'smoke (&|and) mirrors',
    'social(.media|.gaming|.networks?)',
    'solutions?',
    'soup to nuts',
    'sow',
    'stakeholder',
    'start.up?',
    'statement of work',
    'sticky-?ness',
    'strateg(y|ic|ize)',
    'streamline',
    'success(ful)?',
    'sustainab(le|ility)',
    'synerg(y|ies)',
    'tailwinds?',
    'take offline',
    'talking points',
    'target (audience|group)',
    'targeted',
    'tasked',
    'tco',
    'team.building',
    'team.player',
    'teamwork',
    'technologies',
    'that being said',
    'time.to.market',
    'timelines?',
    'top.down',
    'top of the game',
    'total quality',
    'touch.base',
    'touchpoints',
    'traction',
    'trends?',
    'turnkey',
    'up.to.speed',
    'up-?sell',
    'upside',
    'user.friendly',
    'user.experience',
    'utiliz(e|ation)',
    'unique approach',
    'values?',
    'valueable',
    'value-added',
    'vertical market',
    'viral',
    'virtual(ization)?',
    'visibility',
    'vision',
    'walk the talk',
    'web.enabled',
    'win-win',
    'wisdom of crowds',
    'workflow',
    'workshop',
    'world.?class',
    'wow.factor',

    // technical bullshit
    'cloud',
    '(object|aspect).oriented',
    '(framework|platform).agnostic',
    '(front.?end.|ui.)?framework',
    'html5',
    'mv(c|p)',
    'nosql',
    'off-?line',
    'oop',
    'web (2|3)\\.0'
];
<|endoftext|>