<commit_before>define(['backbone', 'backbone.pageable.collection', 'config', 'models/marker'],
  function(Backbone, PageableCollection, Config, ResultModel) {

    var DelvingResultModel = ResultModel.extend({
      parse: function(res) {

        var fields = res.item.fields;

        var f = {
          title: fields.dc_title,
          description: fields.dc_description,
          latitude: fields.delving_locationLat,
          longitude: fields.delving_locationLong
        };

        // Image
        var img = _.find( fields.delving_resourceUri, function( resource ) {
          var imageRegex = /.*\.(jpg|jpeg)$/;
          return imageRegex.test(resource);
        });
        if (img) f.image = img;

        // Youtube
        var youtube = _.find( fields.delving_resourceUri, function( resource ) {
          var reg = /youtube\.com/;
          return reg.test(resource);
        });
        if (youtube) {
          var reg = /v=([^&]*)/;
          if ( youtube.match(reg ) ) {
            f.image = "http://img.youtube.com/vi/" + youtube.match(reg)[1] + "/0.jpg";
            f.youtubeid = youtube.match( reg )[1];
          }
          f.youtube = youtube;
        }

        return f;
      }
    });

    return PageableCollection.extend({
      hasPrevious: function() {
        return this.hasPreviousPage();
      },
      hasNext: function() {
        return this.hasNextPage();
      },
      model: DelvingResultModel,
      queryParams: {
        currentPage: null,
        pageSize: null,
        format: 'json',
        pt: function() {
          return this.state.lat + ',' + this.state.lng;
        },
        d: function() {
          return Math.round(this.state.searchDistance);
        },
        sfield: "delving_locationLatLong_location",
        query: function() {
          return this.state.terms;
        },
        start: function() {
          return (this.state.currentPage - this.state.firstPage) * this.state.pageSize;
        }
      },
      parseRecords: function(resp) {
        return resp.result.items;
      },
      parseState: function(resp) {
        return {
          pagination: resp.result.pagination,
          facets: resp.result.facets,
          totalRecords: resp.result.pagination.numFound
        }
      },
      state: {
        d: 100,
        firstPage: 1,
        terms: "*"
      },
      url: Config.delving.uri + '/search'
    });

});<commit_msg>Fix bug in Delving search. Filter on viewport can now be turned off.<commit_after>define(['backbone', 'backbone.pageable.collection', 'config', 'models/marker'],
  function(Backbone, PageableCollection, Config, ResultModel) {

    var DelvingResultModel = ResultModel.extend({
      parse: function(res) {

        var fields = res.item.fields;

        var f = {
          title: fields.dc_title,
          description: fields.dc_description,
          latitude: fields.delving_locationLat,
          longitude: fields.delving_locationLong
        };

        // Image
        var img = _.find( fields.delving_resourceUri, function( resource ) {
          var imageRegex = /.*\.(jpg|jpeg)$/;
          return imageRegex.test(resource);
        });
        if (img) f.image = img;

        // Youtube
        var youtube = _.find( fields.delving_resourceUri, function( resource ) {
          var reg = /youtube\.com/;
          return reg.test(resource);
        });
        if (youtube) {
          var reg = /v=([^&]*)/;
          if ( youtube.match(reg ) ) {
            f.image = "http://img.youtube.com/vi/" + youtube.match(reg)[1] + "/0.jpg";
            f.youtubeid = youtube.match( reg )[1];
          }
          f.youtube = youtube;
        }

        return f;
      }
    });

    return PageableCollection.extend({
      hasPrevious: function() {
        return this.hasPreviousPage();
      },
      hasNext: function() {
        return this.hasNextPage();
      },
      model: DelvingResultModel,
      queryParams: {
        currentPage: null,
        pageSize: null,
        format: 'json',
        pt: function() {
          return _.isNumber(this.state.lat) && _.isNumber(this.state.lat) ? this.state.lat + ',' + this.state.lng : null;
        },
        d: function() {
          return _.isNumber(this.state.searchDistance) ? Math.round(this.state.searchDistance) : null;
        },
        sfield: "delving_locationLatLong_location",
        query: function() {
          return this.state.terms;
        },
        start: function() {
          return (this.state.currentPage - this.state.firstPage) * this.state.pageSize;
        }
      },
      parseRecords: function(resp) {
        return resp.result.items;
      },
      parseState: function(resp) {
        return {
          pagination: resp.result.pagination,
          facets: resp.result.facets,
          totalRecords: resp.result.pagination.numFound
        }
      },
      state: {
        d: 100,
        firstPage: 1,
        terms: "*"
      },
      url: Config.delving.uri + '/search'
    });

});<|endoftext|>


<commit_before>Edgecase = new JS.Module('Edgecase', {
    include: Ojay.Observable,

    _visible: true,

    setElement: function(element) {
        this._element = Ojay(element);

        return this;
    },

    setContainer: function(container) {
        this._container = container ? Ojay(container) : null;

        return this;
    },

    setAspectRatio: function(ratio) {
        this._aspectRatio = ratio;

        return this;
    },

    getAspectRatio: function() {
        return this._aspectRatio;
    },

    setup: function() {
        Ojay(window).on('resize', function() {
            if (this._visible) {
                this.fitToContainer();
            }
        }, this);

        this.fitToContainer();
        this.notifyObservers('load', this);

        return this;
    },

    show: function() {
        if (this._visible) return;

        this.fitToContainer();
        this._element.show();

        this._visible = true;

        this.notifyObservers('show', this);

        return this;
    },

    hide: function() {
        if (!this._visible) return;

        this._element.hide();

        this._visible = false;

        this.notifyObservers('hide', this);

        return this;
    },

    getHTML: function() {
        return this._element;
    },

    fitToContainer: function() {
        if (this._container) {
            this.fitToContainerXY(this._container.getWidth(), this._container.getHeight());
        } else {
            this.fitToViewport();
        }

        return this;
    },

    fitToViewport: function() {
        var portsize = Ojay.getViewportSize();

        this.fitToContainerXY(portsize.width, portsize.height);

        return this;
    },

    fitToContainerXY: function(containerWidth, containerHeight) {
        var containerAspectRatio = containerWidth / containerHeight,
            style = {display: 'block', position: 'absolute'},
            x, y;

        if (containerAspectRatio > this.getAspectRatio()) {
            y = containerWidth / this.getAspectRatio();

            style.width  = containerWidth + 'px';
            style.height = Math.ceil(y) + 'px';
            style.left   = 0;
            style.top    = Math.ceil((containerHeight - y) / 2) + 'px';
        } else {
            x = containerHeight * this.getAspectRatio();

            style.width  = Math.ceil(x) + 'px';
            style.height = containerHeight + 'px';
            style.left   = Math.ceil((containerWidth - x) / 2) + 'px';
            style.top    = 0;
        }

        this._element.setStyle(style);
    }
});

Edgecase.Concrete = new JS.Class('Edgecase.Concrete', {
    include: Edgecase,

    initialize: function(image, options) {
        var ratio, html, x, y;

        options = options || {};

        this.setElement(image);
        this.setContainer(options.container);
        this.getHTML().setStyle({display: 'block'});

        if (options.aspectRatio) {
            ratio = options.aspectRatio;
        } else {
            html  = this.getHTML();
            x     = html.getWidth();
            y     = html.getHeight();
            ratio = x / y;
        }

        this.setAspectRatio(ratio);
    }
});
<commit_msg>Change image size when fitting to container.<commit_after>Edgecase = new JS.Module('Edgecase', {
    include: Ojay.Observable,

    _visible: true,

    setElement: function(element) {
        this._element = Ojay(element);

        return this;
    },

    setContainer: function(container) {
        this._container = container ? Ojay(container) : null;

        return this;
    },

    setAspectRatio: function(ratio) {
        this._aspectRatio = ratio;

        this.fitToContainer();

        return this;
    },

    getAspectRatio: function() {
        return this._aspectRatio;
    },

    setup: function() {
        Ojay(window).on('resize', function() {
            if (this._visible) {
                this.fitToContainer();
            }
        }, this);

        this.fitToContainer();
        this.notifyObservers('load', this);

        return this;
    },

    show: function() {
        if (this._visible) return;

        this.fitToContainer();
        this._element.show();

        this._visible = true;

        this.notifyObservers('show', this);

        return this;
    },

    hide: function() {
        if (!this._visible) return;

        this._element.hide();

        this._visible = false;

        this.notifyObservers('hide', this);

        return this;
    },

    getHTML: function() {
        return this._element;
    },

    fitToContainer: function() {
        if (this._container) {
            this.fitToContainerXY(this._container.getWidth(), this._container.getHeight());
        } else {
            this.fitToViewport();
        }

        return this;
    },

    fitToViewport: function() {
        var portsize = Ojay.getViewportSize();

        this.fitToContainerXY(portsize.width, portsize.height);

        return this;
    },

    fitToContainerXY: function(containerWidth, containerHeight) {
        var containerAspectRatio = containerWidth / containerHeight,
            style = {display: 'block', position: 'absolute'},
            x, y;

        if (containerAspectRatio > this.getAspectRatio()) {
            y = containerWidth / this.getAspectRatio();

            style.width  = containerWidth + 'px';
            style.height = Math.ceil(y) + 'px';
            style.left   = 0;
            style.top    = Math.ceil((containerHeight - y) / 2) + 'px';
        } else {
            x = containerHeight * this.getAspectRatio();

            style.width  = Math.ceil(x) + 'px';
            style.height = containerHeight + 'px';
            style.left   = Math.ceil((containerWidth - x) / 2) + 'px';
            style.top    = 0;
        }

        this._element.setStyle(style);
    }
});

Edgecase.Concrete = new JS.Class('Edgecase.Concrete', {
    include: Edgecase,

    initialize: function(image, options) {
        var ratio, html, x, y;

        options = options || {};

        this.setElement(image);
        this.setContainer(options.container);
        this.getHTML().setStyle({display: 'block'});

        if (options.aspectRatio) {
            ratio = options.aspectRatio;
        } else {
            html  = this.getHTML();
            x     = html.getWidth();
            y     = html.getHeight();
            ratio = x / y;
        }

        this.setAspectRatio(ratio);
    }
});
<|endoftext|>


<commit_before>'use strict';
var BaseModel = require('model-toolkit').BaseModel;

module.exports = class WeeklyPlanItem extends BaseModel {
    constructor(source, type) {
        super(type || 'weekly-plan-item', '1.0.0');

        this.weekNumber = {};
        this.startDate = new Date();
        this.endDate = new Date();
        this.month = 1;
        this.copy(source);
    }
};<commit_msg>fix value month<commit_after>'use strict';
var BaseModel = require('model-toolkit').BaseModel;

module.exports = class WeeklyPlanItem extends BaseModel {
    constructor(source, type) {
        super(type || 'weekly-plan-item', '1.0.0');

        this.weekNumber = {};
        this.startDate = new Date();
        this.endDate = new Date();
        this.month = 0;
        this.copy(source);
    }
};<|endoftext|>


<commit_before>exports.drop = function (driver, opts, cb) {
	var i, queries = [], pending;

	queries.push("DROP TABLE IF EXISTS " + driver.query.escapeId(opts.table));

	for (i = 0; i < opts.many_associations.length; i++) {
		queries.push("DROP TABLE IF EXISTS " + driver.query.escapeId(opts.many_associations[i].mergeTable));
	}

	pending = queries.length;
	for (i = 0; i < queries.length; i++) {
		driver.db.query(queries[i], function (err) {
			if (--pending === 0) {
				return cb(err);
			}
		});
	}
};

exports.sync = function (driver, opts, cb) {
	var tables = [];
	var subqueries = [];
	var typequeries = [];
	var definitions = [];
	var k, i, pending;

	definitions.push(driver.query.escapeId(opts.id) + " SERIAL PRIMARY KEY");

	for (k in opts.properties) {
		definitions.push(buildColumnDefinition(driver, opts.table, k, opts.properties[k]));

		if (opts.properties[k].type == "enum") {
			typequeries.push(
				"CREATE TYPE " + driver.query.escapeId("enum_" + opts.table + "_" + k) + " AS ENUM (" +
				opts.properties[k].values.map(driver.query.escapeVal.bind(driver)) + ")"
			);
		}
	}

	for (i = 0; i < opts.one_associations.length; i++) {
		if (opts.one_associations[i].reversed) continue;
		definitions.push(
			driver.query.escapeId(opts.one_associations[i].field) + " INTEGER" +
			(opts.one_associations[i].required ? ' NOT NULL' : '')
		);
	}

	for (k in opts.properties) {
		if (opts.properties[k].unique === true) {
			definitions.push("UNIQUE (" + driver.query.escapeId(k) + ")");
		} else if (opts.properties[k].index) {
			definitions.push("INDEX (" + driver.query.escapeId(k) + ")");
		}
	}

	tables.push({
		name       : opts.table,
		query      : "CREATE TABLE " + driver.query.escapeId(opts.table) +
		             " (" + definitions.join(", ") + ")",
		typequeries: typequeries,
		subqueries : subqueries
	});
	tables[tables.length - 1].subqueries.push(
		"CREATE INDEX ON " + driver.query.escapeId(opts.table) +
		" (" + driver.query.escapeId(opts.id) + ")"
	);

	for (i = 0; i < opts.one_associations.length; i++) {
		if (opts.one_associations[i].reversed) continue;
		tables[tables.length - 1].subqueries.push(
			"CREATE INDEX ON " + driver.query.escapeId(opts.table) +
			" (" + driver.query.escapeId(opts.one_associations[i].field) + ")"
		);
	}

	for (i = 0; i < opts.indexes.length; i++) {
		tables[tables.length - 1].subqueries.push(
			"CREATE INDEX ON " + driver.query.escapeId(opts.table) +
			" (" + opts.indexes[i].split(/[,;]+/).map(function (el) {
				return driver.query.escapeId(el);
			}).join(", ") + ")"
		);
	}

	for (i = 0; i < opts.many_associations.length; i++) {
		definitions = [];
		typequeries = [];

		definitions.push(driver.query.escapeId(opts.many_associations[i].mergeId) + " INTEGER NOT NULL");
		definitions.push(driver.query.escapeId(opts.many_associations[i].mergeAssocId) + " INTEGER NOT NULL");

		for (k in opts.many_associations[i].props) {
			definitions.push(buildColumnDefinition(driver, opts.many_associations[i].mergeTable,
			                                       k, opts.many_associations[i].props[k]));
			if (opts.many_associations[i].props[k].type == "enum") {
				typequeries.push(
					"CREATE TYPE " + driver.query.escapeId("enum_" + opts.many_associations[i].mergeTable + "_" + k) + " AS ENUM (" +
					opts.many_associations[i].props[k].values.map(driver.query.escapeVal.bind(driver)) + ")"
				);
			}
		}

		tables.push({
			name       : opts.many_associations[i].mergeTable,
			query      : "CREATE TABLE IF NOT EXISTS " + driver.query.escapeId(opts.many_associations[i].mergeTable) +
			             " (" + definitions.join(", ") + ")",
			typequeries: typequeries,
			subqueries : []
		});
		tables[tables.length - 1].subqueries.push(
			"CREATE INDEX ON " + driver.query.escapeId(opts.many_associations[i].mergeTable) +
			" (" +
			driver.query.escapeId(opts.many_associations[i].mergeId) + ", " +
			driver.query.escapeId(opts.many_associations[i].mergeAssocId) +
			")"
		);
	}

	pending = tables.length;

	for (i = 0; i < tables.length; i++) {
		createTableSchema(driver, tables[i], function (err) {
			if (--pending === 0) {
				// this will bring trouble in the future...
				// some errors are not avoided (like ENUM types already defined, etc..)
				return cb(err);
			}
		});
	}
};

function createTableSchema(driver, table, cb) {
	var pending = table.typequeries.length;
	var createTable = function () {
		driver.db.query(table.query, function (err) {
			if (err || table.subqueries.length === 0) {
				return cb();
			}

			var pending = table.subqueries.length;

			for (var i = 0; i < table.subqueries.length; i++) {
				driver.db.query(table.subqueries[i], function (err) {
					if (--pending === 0) {
						return cb();
					}
				});
			}
		});
	};

	if (pending === 0) {
		return createTable();
	}

	for (var i = 0; i < table.typequeries.length; i++) {
		driver.db.query(table.typequeries[i], function (err) {
			if (--pending === 0) {
				return createTable();
			}
		});
	}
}

function buildColumnDefinition(driver, table, name, prop) {
	var def;

	switch (prop.type) {
		case "text":
			def = driver.query.escapeId(name) + " VARCHAR(" + Math.min(Math.max(parseInt(prop.size, 10) || 255, 1), 65535) + ")";
			break;
		case "number":
			if (prop.rational === false) {
				def = driver.query.escapeId(name) + " INTEGER";
			} else {
				def = driver.query.escapeId(name) + " REAL";
			}
			break;
		case "boolean":
			def = driver.query.escapeId(name) + " BOOLEAN NOT NULL";
			break;
		case "date":
			if (prop.time === false) {
				def = driver.query.escapeId(name) + " DATE";
			} else {
				def = driver.query.escapeId(name) + " TIMESTAMP WITHOUT TIME ZONE";
			}
			break;
		case "binary":
		case "object":
			def = driver.query.escapeId(name) + " BYTEA";
			break;
		case "enum":
			def = driver.query.escapeId(name) + " " + driver.query.escapeId("enum_" + table + "_" + name);
			break;
		default:
			throw new Error("Unknown property type: '" + prop.type + "'");
	}
	if (prop.hasOwnProperty("defaultValue")) {
		def += " DEFAULT " + driver.escape(prop.defaultValue);
	}
	return def;
}
<commit_msg>Removes index on postgresql primary keys<commit_after>exports.drop = function (driver, opts, cb) {
	var i, queries = [], pending;

	queries.push("DROP TABLE IF EXISTS " + driver.query.escapeId(opts.table));

	for (i = 0; i < opts.many_associations.length; i++) {
		queries.push("DROP TABLE IF EXISTS " + driver.query.escapeId(opts.many_associations[i].mergeTable));
	}

	pending = queries.length;
	for (i = 0; i < queries.length; i++) {
		driver.db.query(queries[i], function (err) {
			if (--pending === 0) {
				return cb(err);
			}
		});
	}
};

exports.sync = function (driver, opts, cb) {
	var tables = [];
	var subqueries = [];
	var typequeries = [];
	var definitions = [];
	var k, i, pending;

	definitions.push(driver.query.escapeId(opts.id) + " SERIAL PRIMARY KEY");

	for (k in opts.properties) {
		definitions.push(buildColumnDefinition(driver, opts.table, k, opts.properties[k]));

		if (opts.properties[k].type == "enum") {
			typequeries.push(
				"CREATE TYPE " + driver.query.escapeId("enum_" + opts.table + "_" + k) + " AS ENUM (" +
				opts.properties[k].values.map(driver.query.escapeVal.bind(driver)) + ")"
			);
		}
	}

	for (i = 0; i < opts.one_associations.length; i++) {
		if (opts.one_associations[i].reversed) continue;
		definitions.push(
			driver.query.escapeId(opts.one_associations[i].field) + " INTEGER" +
			(opts.one_associations[i].required ? ' NOT NULL' : '')
		);
	}

	for (k in opts.properties) {
		if (opts.properties[k].unique === true) {
			definitions.push("UNIQUE (" + driver.query.escapeId(k) + ")");
		} else if (opts.properties[k].index) {
			definitions.push("INDEX (" + driver.query.escapeId(k) + ")");
		}
	}

	tables.push({
		name       : opts.table,
		query      : "CREATE TABLE " + driver.query.escapeId(opts.table) +
		             " (" + definitions.join(", ") + ")",
		typequeries: typequeries,
		subqueries : subqueries
	});

	for (i = 0; i < opts.one_associations.length; i++) {
		if (opts.one_associations[i].reversed) continue;
		tables[tables.length - 1].subqueries.push(
			"CREATE INDEX ON " + driver.query.escapeId(opts.table) +
			" (" + driver.query.escapeId(opts.one_associations[i].field) + ")"
		);
	}

	for (i = 0; i < opts.indexes.length; i++) {
		tables[tables.length - 1].subqueries.push(
			"CREATE INDEX ON " + driver.query.escapeId(opts.table) +
			" (" + opts.indexes[i].split(/[,;]+/).map(function (el) {
				return driver.query.escapeId(el);
			}).join(", ") + ")"
		);
	}

	for (i = 0; i < opts.many_associations.length; i++) {
		definitions = [];
		typequeries = [];

		definitions.push(driver.query.escapeId(opts.many_associations[i].mergeId) + " INTEGER NOT NULL");
		definitions.push(driver.query.escapeId(opts.many_associations[i].mergeAssocId) + " INTEGER NOT NULL");

		for (k in opts.many_associations[i].props) {
			definitions.push(buildColumnDefinition(driver, opts.many_associations[i].mergeTable,
			                                       k, opts.many_associations[i].props[k]));
			if (opts.many_associations[i].props[k].type == "enum") {
				typequeries.push(
					"CREATE TYPE " + driver.query.escapeId("enum_" + opts.many_associations[i].mergeTable + "_" + k) + " AS ENUM (" +
					opts.many_associations[i].props[k].values.map(driver.query.escapeVal.bind(driver)) + ")"
				);
			}
		}

		tables.push({
			name       : opts.many_associations[i].mergeTable,
			query      : "CREATE TABLE IF NOT EXISTS " + driver.query.escapeId(opts.many_associations[i].mergeTable) +
			             " (" + definitions.join(", ") + ")",
			typequeries: typequeries,
			subqueries : []
		});
		tables[tables.length - 1].subqueries.push(
			"CREATE INDEX ON " + driver.query.escapeId(opts.many_associations[i].mergeTable) +
			" (" +
			driver.query.escapeId(opts.many_associations[i].mergeId) + ", " +
			driver.query.escapeId(opts.many_associations[i].mergeAssocId) +
			")"
		);
	}

	pending = tables.length;

	for (i = 0; i < tables.length; i++) {
		createTableSchema(driver, tables[i], function (err) {
			if (--pending === 0) {
				// this will bring trouble in the future...
				// some errors are not avoided (like ENUM types already defined, etc..)
				return cb(err);
			}
		});
	}
};

function createTableSchema(driver, table, cb) {
	var pending = table.typequeries.length;
	var createTable = function () {
		driver.db.query(table.query, function (err) {
			if (err || table.subqueries.length === 0) {
				return cb();
			}

			var pending = table.subqueries.length;

			for (var i = 0; i < table.subqueries.length; i++) {
				driver.db.query(table.subqueries[i], function (err) {
					if (--pending === 0) {
						return cb();
					}
				});
			}
		});
	};

	if (pending === 0) {
		return createTable();
	}

	for (var i = 0; i < table.typequeries.length; i++) {
		driver.db.query(table.typequeries[i], function (err) {
			if (--pending === 0) {
				return createTable();
			}
		});
	}
}

function buildColumnDefinition(driver, table, name, prop) {
	var def;

	switch (prop.type) {
		case "text":
			def = driver.query.escapeId(name) + " VARCHAR(" + Math.min(Math.max(parseInt(prop.size, 10) || 255, 1), 65535) + ")";
			break;
		case "number":
			if (prop.rational === false) {
				def = driver.query.escapeId(name) + " INTEGER";
			} else {
				def = driver.query.escapeId(name) + " REAL";
			}
			break;
		case "boolean":
			def = driver.query.escapeId(name) + " BOOLEAN NOT NULL";
			break;
		case "date":
			if (prop.time === false) {
				def = driver.query.escapeId(name) + " DATE";
			} else {
				def = driver.query.escapeId(name) + " TIMESTAMP WITHOUT TIME ZONE";
			}
			break;
		case "binary":
		case "object":
			def = driver.query.escapeId(name) + " BYTEA";
			break;
		case "enum":
			def = driver.query.escapeId(name) + " " + driver.query.escapeId("enum_" + table + "_" + name);
			break;
		default:
			throw new Error("Unknown property type: '" + prop.type + "'");
	}
	if (prop.hasOwnProperty("defaultValue")) {
		def += " DEFAULT " + driver.escape(prop.defaultValue);
	}
	return def;
}
<|endoftext|>


<commit_before>/*ngInject*/
export function setupRoutes($stateProvider, $urlRouterProvider) {
    $stateProvider
        .state('login', {
            url: '/login',
            template: '<mc-login></mc-login>'
        })
        .state('join', {
            url: '/join',
            template: '<mc-join></mc-join>'
        })
        .state('validate', {
            url: '/validate/:validation_uuid',
            template: '<mc-join-validate></mc-join-validate>'
        })
        .state('reset', {
            url: '/reset',
            template: '<mc-reset-password></mc-reset-password>'
        })
        .state('rvalidate', {
            url: '/rvalidate/:validation_uuid',
            template: '<mc-reset-validate></mc-reset-validate>'
        })
        .state('projects', {
            url: '/projects',
            abstract: true,
            template: '

',
        })
        .state('projects.list', {
            url: '/list',
            template: '<mc-projects-list-view-container flex layout="column"></mc-projects-list-view-container>'
        })
        .state('globus', {
            url: '/globus',
            abstract: true,
            template: '

'
        })
        .state('globus.auth', {
            url: '/auth',
            abstract: true,
            template: '

'
        })
        .state('globus.auth.testing', {
            url: '/testing',
            template: '<mc-globus-auth-testing></mc-globus-auth-testing>'
        })
        .state('account', {
            url: '/account',
            abstract: true,
            template: '

'
        })
        .state('account.settings', {
            url: '/settings',
            template: '<md-content><mc-account-settings></mc-account-settings></md-content>'
        })
        .state('account.settings.profile', {
            url: '/profile',
            template: '<mc-account-settings-profile></mc-account-settings-profile>'
        })
        .state('account.settings.projects', {
            url: '/projects',
            template: '<mc-account-settings-projects></mc-account-settings-projects>'
        })
        .state('templates', {
            url: '/templates',
            abstract: true,
            template: '<md-content ui-view layout="column" flex></md-content>'
        })
        .state('templates.builder', {
            url: '/builder',
            template: '<mc-template-builder layout="column" layout-fill class="height-100"></mc-template-builder>'
        })
        .state('admin', {
            url: '/admin',
            abstract: true,
            template: '

'
        })
        .state('admin.info', {
            url: '/info',
            template: '<mc-admin-info></mc-admin-info>'
        })
        .state('admin.info.users', {
            url: '/users',
            template: '<mc-admin-info-users></mc-admin-info-users>'
        })
        .state('admin.info.projects', {
            url: '/users',
            template: '<mc-admin-info-projects></mc-admin-info-projects>'
        })
        .state('admin.info.globus', {
            url: '/globus',
            template: '<mc-admin-info-globus></mc-admin-info-globus>'
        })
        .state('public', {
            url: '/public',
            abstract: true,
            template: '

'
        })
        .state('public.templates', {
            url: '/templates',
            template: '<mc-public-templates layout="column" layout-fill class="height-100"></mc-public-templates>'
        })
        .state('project', {
            url: '/project/:project_id',
            template: '<mc-project-view-container class="height-100" flex="100" layout="column"></mc-project-view-container>',
            resolve: {
                _projstore: ['mcprojstore', (mcprojstore) => mcprojstore.ready()],

                _ignore: ['mcprojstore', '$stateParams', '_projstore',
                    (mcprojstore, $stateParams) => mcprojstore.getProject($stateParams.project_id)],

                _project: ['projectsAPI', '$stateParams', 'mcStateStore',
                    function(projectsAPI, $stateParams, mcStateStore) {
                        return projectsAPI.getProjectOverview($stateParams.project_id).then(p => {
                            mcStateStore.updateState('project', p);
                            return p;
                        });
                    }]
            }
        })
        .state('project.home', {
            url: '/home',
            template: '<md-content layout="column" className="height-100"><mc-project-home class="height-100"></mc-project-home></md-content>'
        })
        .state('project.details', {
            url: '/details',
            template: '<md-content layout="column" class="height-100"><mc-project-details class="height-100"></mc-project-details></md-content>'
        })
        .state('project.search', {
            url: '/search/:query',
            template: '<mc-project-search></mc-project-search>'
        })
        .state('project.notes', {
            url: '/notes',
            template: '<md-content layout="column" class="height-100"><mc-project-notes class="height-100"></mc-project-notes></md-content>'
        })
        .state('project.create', {
            url: '/create',
            abstract: true,
            template: '<ui-view flex layout="column"></ui-view>'
        })
        .state('project.experiment', {
            url: '/experiment/:experiment_id',
            template: `<mc-experiment experiment="$resolve.experiment" class="height-100"></mc-experiment>`,
            resolve: {
                experiment: ['$stateParams', 'experimentsAPI', 'mcStateStore',
                    ($stateParams, experimentsAPI, mcStateStore) => {
                        let e = mcStateStore.getState(`experiment:${$stateParams.experiment_id}`);
                        if (e !== null) {
                            return e;
                        }

                        return experimentsAPI.getExperimentForProject2($stateParams.project_id, $stateParams.experiment_id).then((e) => e);
                    }
                ]
            }
        })
        .state('project.experiment.details', {
            url: '/details',
            template: '<md-content layout="column" class="height-100"><mc-experiment-details experiment="$resolve.experiment" show-note="true"></mc-experiment-details></md-content>'
        })
        .state('project.experiment.workflow', {
            url: '/workflow',
            template: '<mc-experiment-workflow-view-container2 experiment="$resolve.experiment"></mc-experiment-workflow-view-container2>'
        })
        .state('project.experiment.samples', {
            url: '/samples',
            template: '<md-content layout="column" class="height-100"><mc-project-samples samples="$resolve.samples"></mc-project-samples></md-content>',
            resolve: {
                samples: ['experimentsAPI', '$stateParams',
                    (experimentsAPI, $stateParams) => {
                        return experimentsAPI.getSamplesForExperiment($stateParams.project_id, $stateParams.experiment_id);
                    }
                ]
            }
        })
        .state('project.experiment.files', {
            url: '/files',
            template: '<md-content layout="column" class="height-100"><mc-experiment-files files="$resolve.files"></mc-experiment-files></md-content>',
            resolve: {
                files: ['experimentsAPI', '$stateParams',
                    (experimentsAPI, $stateParams) =>
                        experimentsAPI.getFilesForExperiment($stateParams.project_id, $stateParams.experiment_id)
                ]
            }
        })
        .state('project.experiment.tbuilder', {
            url: '/tbuilder',
            template: '<md-content layout="column" class="height-100"><mc-template-builder layout="column" layout-fill></mc-template-builder></md-content>'
        })
        .state('project.experiment.publish', {
            url: '/publish',
            template: '<mc-experiment-publish></mc-experiment-publish>'
        })
        .state('project.experiment.datasets', {
            url: '/datasets',
            template: '<md-content layout="column" class="height-100">

</md-content>',
            abstract: true
        })
        .state('project.experiment.datasets.list', {
            url: '/list',
            template: '<mc-experiment-datasets layout="column" flex></mc-experiment-datasets>'
        })
        .state('project.experiment.datasets.dataset', {
            url: '/dataset/:dataset_id',
            template: '<mc-experiment-dataset layout="column" flex layout-fill></mc-experiment-dataset>'
        })
        .state('project.experiment.sample', {
            url: '/sample/:sample_id',
            template: '<mc-show-sample sample-id="ctrl.sampleId"></mc-show-sample>',
            controllerAs: 'ctrl',
            controller: ['$stateParams', function($stateParams) {
                this.sampleId = $stateParams.sample_id;
            }]
        })
        .state('project.experiments', {
            url: '/experiments',
            template: '<mc-project-experiments experiments="$resolve.experiments"></mc-project-experiments>',
            resolve: {
                experiments: ['experimentsAPI', '$stateParams',
                    (experimentsAPI, $stateParams) =>
                        experimentsAPI.getAllForProject($stateParams.project_id)
                ]
            }
        })
        .state('project.processes', {
            url: '/processes',
            template: `
                <md-content layout="column" class="height-100">
                    <mc-project-processes-view-container class="height-100"></mc-project-processes-view-container>
                </md-content>`,
        })
        .state('project.process', {
            url: '/process/:process_id',
            template: `
                <md-content layout="column" class="height-100">
                    <mc-project-process-view-container></mc-project-process-view-container>
                </md-content>`
        })
        .state('project.samples', {
            url: '/samples',
            template: '<md-content layout="column" class="height-100"><mc-project-samples samples="$resolve.samples" class="height-100" layout-margin></mc-project-samples></md-content>',
            resolve: {
                samples: ['samplesAPI', '$stateParams',
                    (samplesAPI, $stateParams) =>
                        samplesAPI.getProjectSamples($stateParams.project_id)
                ]
            }
        })

        // .state('project.samples', {
        //     url: '/samples',
        //     template: `
        //         <md-content layout="column" class="height-100">
        //             <mc-project-samples-view-container class="height-100"></mc-project-samples-view-container>
        //         </md-content>`,
        // })

        .state('project.sample', {
            url: '/sample/:sample_id',
            template: `
            <md-content layout="column" class="height-100">
                    <mc-project-sample-view-container></mc-project-sample-view-container>
            </md-content>
            `
        })
        .state('project.files', {
            url: '/files',
            // template: '<mc-file-tree flex layout-fill></mc-file-tree>'
            template: '<mc-project-files-view-container flex layout-fill></mc-project-files-view-container>'
        })
        .state('project.files.uploads2', {
            url: '/uploads2/:directory_id',
            template: '<mc-file-tree-uploader-container></mc-file-tree-uploader-container>'
        })
        .state('project.files.uploads', {
            url: '/uploads',
            template: '<mc-file-uploads reset-files="true"></mc-file-uploads>'
        })
        .state('project.files.file', {
            url: '/file/:file_id',
            template: '<mc-file-container></mc-file-container>'
        })
        .state('project.files.dir', {
            url: '/dir/:dir_id',
            template: '<mc-dir-container></mc-dir-container>'
        })
        .state('project.file', {
            url: '/file/:file_id',
            template: '<md-content layout="column"><mc-file-container class="height-100"></mc-file-container></md-content>'
        })
        .state('project.datasets', {
            url: '/datasets',
            abstract: true,
            template: '<md-content>

</md-content>',
        })
        .state('project.datasets.list', {
            url: '/list',
            template: '<mc-project-datasets-view-container layout-fill flex></mc-project-datasets-view-container>'
        })
        .state('project.datasets.dataset', {
            url: '/dataset/:dataset_id',
            // template: '<md-content layout-fill flex layout="column" style="background-color:brown"><mc-project-dataset-view-container></mc-project-dataset-view-container></md-content>'
            template: '<mc-project-dataset-view-container></mc-project-dataset-view-container>'
        })
        .state('project.settings', {
            url: '/settings',
            template: '<mc-project-settings></mc-project-settings>'
        })
        .state('project.collaborators', {
            url: '/collaborators',
            template: '<mc-project-collaborators class="height-100"></mc-project-collaborators>'
        })
        .state('data', {
            url: '/data',
            abstract: true,
            // template: '<md-content ui-view flex></md-content>'
            template: '

'
        })
        .state('data.dataset', {
            url: '/dataset/:dataset_id',
            template: '<mc-dataset-overview-container layout="column" flex></mc-dataset-overview-container>'
        })
        .state('data.home', {
            url: '/home',
            template: '<md-content flex><mc-data-home tags="$resolve.tags"></mc-data-home></md-content>',
            resolve: {
                tags: ['publicTagsAPI',
                    (publicTagsAPI) => publicTagsAPI.getPopularTags().then(
                        (tags) => tags.map(t => t.tag)
                    )
                ]
            }
        })
        .state('data.tag', {
            url: '/tag/:tag',
            template: '<mc-dataset-list datasets="$resolve.datasets" details-route="data.dataset" layout-margin></mc-dataset-list>',
            resolve: {
                datasets: ['publicDatasetsAPI', '$stateParams',
                    (publicDatasetsAPI, $stateParams) => publicDatasetsAPI.getDatasetsForTag($stateParams.tag)
                ]
            }
        })
        .state('data.home.recent', {
            url: '/recent',
            template: '<mc-dataset-list datasets="$resolve.datasets" details-route="data.dataset"></mc-dataset-list>',
            resolve: {
                datasets: ['publicDatasetsAPI',
                    (publicDatasetsAPI) => publicDatasetsAPI.getRecent()
                ]
            }
        })
        .state('data.home.top', {
            url: '/top',
            template: '<mc-dataset-list datasets="$resolve.datasets" details-route="data.dataset"></mc-dataset-list>',
            resolve: {
                datasets: ['publicDatasetsAPI',
                    (publicDatasetsAPI) => publicDatasetsAPI.getTopViewed()
                ]
            }
        });

    // $urlRouterProvider.otherwise('/login');
    $urlRouterProvider.otherwise('/data/home/top');
}
<commit_msg>roll back to work in process<commit_after>/*ngInject*/
export function setupRoutes($stateProvider, $urlRouterProvider) {
    $stateProvider
        .state('login', {
            url: '/login',
            template: '<mc-login></mc-login>'
        })
        .state('join', {
            url: '/join',
            template: '<mc-join></mc-join>'
        })
        .state('validate', {
            url: '/validate/:validation_uuid',
            template: '<mc-join-validate></mc-join-validate>'
        })
        .state('reset', {
            url: '/reset',
            template: '<mc-reset-password></mc-reset-password>'
        })
        .state('rvalidate', {
            url: '/rvalidate/:validation_uuid',
            template: '<mc-reset-validate></mc-reset-validate>'
        })
        .state('projects', {
            url: '/projects',
            abstract: true,
            template: '

',
        })
        .state('projects.list', {
            url: '/list',
            template: '<mc-projects-list-view-container flex layout="column"></mc-projects-list-view-container>'
        })
        .state('globus', {
            url: '/globus',
            abstract: true,
            template: '

'
        })
        .state('globus.auth', {
            url: '/auth',
            abstract: true,
            template: '

'
        })
        .state('globus.auth.testing', {
            url: '/testing',
            template: '<mc-globus-auth-testing></mc-globus-auth-testing>'
        })
        .state('account', {
            url: '/account',
            abstract: true,
            template: '

'
        })
        .state('account.settings', {
            url: '/settings',
            template: '<md-content><mc-account-settings></mc-account-settings></md-content>'
        })
        .state('account.settings.profile', {
            url: '/profile',
            template: '<mc-account-settings-profile></mc-account-settings-profile>'
        })
        .state('account.settings.projects', {
            url: '/projects',
            template: '<mc-account-settings-projects></mc-account-settings-projects>'
        })
        .state('templates', {
            url: '/templates',
            abstract: true,
            template: '<md-content ui-view layout="column" flex></md-content>'
        })
        .state('templates.builder', {
            url: '/builder',
            template: '<mc-template-builder layout="column" layout-fill class="height-100"></mc-template-builder>'
        })
        .state('admin', {
            url: '/admin',
            abstract: true,
            template: '

'
        })
        .state('admin.info', {
            url: '/info',
            template: '<mc-admin-info></mc-admin-info>'
        })
        .state('admin.info.users', {
            url: '/users',
            template: '<mc-admin-info-users></mc-admin-info-users>'
        })
        .state('admin.info.projects', {
            url: '/users',
            template: '<mc-admin-info-projects></mc-admin-info-projects>'
        })
        .state('admin.info.globus', {
            url: '/globus',
            template: '<mc-admin-info-globus></mc-admin-info-globus>'
        })
        .state('public', {
            url: '/public',
            abstract: true,
            template: '

'
        })
        .state('public.templates', {
            url: '/templates',
            template: '<mc-public-templates layout="column" layout-fill class="height-100"></mc-public-templates>'
        })
        .state('project', {
            url: '/project/:project_id',
            template: '<mc-project-view-container class="height-100" flex="100" layout="column"></mc-project-view-container>',
            resolve: {
                _projstore: ['mcprojstore', (mcprojstore) => mcprojstore.ready()],

                _ignore: ['mcprojstore', '$stateParams', '_projstore',
                    (mcprojstore, $stateParams) => mcprojstore.getProject($stateParams.project_id)],

                _project: ['projectsAPI', '$stateParams', 'mcStateStore',
                    function(projectsAPI, $stateParams, mcStateStore) {
                        return projectsAPI.getProjectOverview($stateParams.project_id).then(p => {
                            mcStateStore.updateState('project', p);
                            return p;
                        });
                    }]
            }
        })
        .state('project.home', {
            url: '/home',
            template: '<md-content layout="column" className="height-100"><mc-project-home class="height-100"></mc-project-home></md-content>'
        })
        .state('project.details', {
            url: '/details',
            template: '<md-content layout="column" class="height-100"><mc-project-details class="height-100"></mc-project-details></md-content>'
        })
        .state('project.search', {
            url: '/search/:query',
            template: '<mc-project-search></mc-project-search>'
        })
        .state('project.notes', {
            url: '/notes',
            template: '<md-content layout="column" class="height-100"><mc-project-notes class="height-100"></mc-project-notes></md-content>'
        })
        .state('project.create', {
            url: '/create',
            abstract: true,
            template: '<ui-view flex layout="column"></ui-view>'
        })
        .state('project.experiment', {
            url: '/experiment/:experiment_id',
            template: `<mc-experiment experiment="$resolve.experiment" class="height-100"></mc-experiment>`,
            resolve: {
                experiment: ['$stateParams', 'experimentsAPI', 'mcStateStore',
                    ($stateParams, experimentsAPI, mcStateStore) => {
                        let e = mcStateStore.getState(`experiment:${$stateParams.experiment_id}`);
                        if (e !== null) {
                            return e;
                        }

                        return experimentsAPI.getExperimentForProject2($stateParams.project_id, $stateParams.experiment_id).then((e) => e);
                    }
                ]
            }
        })
        .state('project.experiment.details', {
            url: '/details',
            template: '<md-content layout="column" class="height-100"><mc-experiment-details experiment="$resolve.experiment" show-note="true"></mc-experiment-details></md-content>'
        })
        .state('project.experiment.workflow', {
            url: '/workflow',
            template: '<mc-experiment-workflow-view-container2 experiment="$resolve.experiment"></mc-experiment-workflow-view-container2>'
        })
        .state('project.experiment.samples', {
            url: '/samples',
            template: '<md-content layout="column" class="height-100"><mc-project-samples samples="$resolve.samples"></mc-project-samples></md-content>',
            resolve: {
                samples: ['experimentsAPI', '$stateParams',
                    (experimentsAPI, $stateParams) => {
                        return experimentsAPI.getSamplesForExperiment($stateParams.project_id, $stateParams.experiment_id);
                    }
                ]
            }
        })
        .state('project.experiment.files', {
            url: '/files',
            template: '<md-content layout="column" class="height-100"><mc-experiment-files files="$resolve.files"></mc-experiment-files></md-content>',
            resolve: {
                files: ['experimentsAPI', '$stateParams',
                    (experimentsAPI, $stateParams) =>
                        experimentsAPI.getFilesForExperiment($stateParams.project_id, $stateParams.experiment_id)
                ]
            }
        })
        .state('project.experiment.tbuilder', {
            url: '/tbuilder',
            template: '<md-content layout="column" class="height-100"><mc-template-builder layout="column" layout-fill></mc-template-builder></md-content>'
        })
        .state('project.experiment.publish', {
            url: '/publish',
            template: '<mc-experiment-publish></mc-experiment-publish>'
        })
        .state('project.experiment.datasets', {
            url: '/datasets',
            template: '<md-content layout="column" class="height-100">

</md-content>',
            abstract: true
        })
        .state('project.experiment.datasets.list', {
            url: '/list',
            template: '<mc-experiment-datasets layout="column" flex></mc-experiment-datasets>'
        })
        .state('project.experiment.datasets.dataset', {
            url: '/dataset/:dataset_id',
            template: '<mc-experiment-dataset layout="column" flex layout-fill></mc-experiment-dataset>'
        })
        .state('project.experiment.sample', {
            url: '/sample/:sample_id',
            template: '<mc-show-sample sample-id="ctrl.sampleId"></mc-show-sample>',
            controllerAs: 'ctrl',
            controller: ['$stateParams', function($stateParams) {
                this.sampleId = $stateParams.sample_id;
            }]
        })
        .state('project.experiments', {
            url: '/experiments',
            template: '<mc-project-experiments experiments="$resolve.experiments"></mc-project-experiments>',
            resolve: {
                experiments: ['experimentsAPI', '$stateParams',
                    (experimentsAPI, $stateParams) =>
                        experimentsAPI.getAllForProject($stateParams.project_id)
                ]
            }
        })
        .state('project.processes', {
            url: '/processes',
            template: `
                <md-content layout="column" class="height-100">
                    <mc-project-processes-view-container class="height-100"></mc-project-processes-view-container>
                </md-content>`,
        })
        .state('project.process', {
            url: '/process/:process_id',
            template: `
                <md-content layout="column" class="height-100">
                    <mc-project-process-view-container></mc-project-process-view-container>
                </md-content>`
        })
        // .state('project.samples', {
        //     url: '/samples',
        //     template: '<md-content layout="column" class="height-100"><mc-project-samples samples="$resolve.samples" class="height-100" layout-margin></mc-project-samples></md-content>',
        //     resolve: {
        //         samples: ['samplesAPI', '$stateParams',
        //             (samplesAPI, $stateParams) =>
        //                 samplesAPI.getProjectSamples($stateParams.project_id)
        //         ]
        //     }
        // })
        .state('project.samples', {
            url: '/samples',
            template: `
                <md-content layout="column" class="height-100">
                    <mc-project-samples-view-container class="height-100"></mc-project-samples-view-container>
                </md-content>`,
        })
        .state('project.sample', {
            url: '/sample/:sample_id',
            template: `
            <md-content layout="column" class="height-100">
                    <mc-project-sample-view-container></mc-project-sample-view-container>
            </md-content>
            `
        })
        .state('project.files', {
            url: '/files',
            // template: '<mc-file-tree flex layout-fill></mc-file-tree>'
            template: '<mc-project-files-view-container flex layout-fill></mc-project-files-view-container>'
        })
        .state('project.files.uploads2', {
            url: '/uploads2/:directory_id',
            template: '<mc-file-tree-uploader-container></mc-file-tree-uploader-container>'
        })
        .state('project.files.uploads', {
            url: '/uploads',
            template: '<mc-file-uploads reset-files="true"></mc-file-uploads>'
        })
        .state('project.files.file', {
            url: '/file/:file_id',
            template: '<mc-file-container></mc-file-container>'
        })
        .state('project.files.dir', {
            url: '/dir/:dir_id',
            template: '<mc-dir-container></mc-dir-container>'
        })
        .state('project.file', {
            url: '/file/:file_id',
            template: '<md-content layout="column"><mc-file-container class="height-100"></mc-file-container></md-content>'
        })
        .state('project.datasets', {
            url: '/datasets',
            abstract: true,
            template: '<md-content>

</md-content>',
        })
        .state('project.datasets.list', {
            url: '/list',
            template: '<mc-project-datasets-view-container layout-fill flex></mc-project-datasets-view-container>'
        })
        .state('project.datasets.dataset', {
            url: '/dataset/:dataset_id',
            // template: '<md-content layout-fill flex layout="column" style="background-color:brown"><mc-project-dataset-view-container></mc-project-dataset-view-container></md-content>'
            template: '<mc-project-dataset-view-container></mc-project-dataset-view-container>'
        })
        .state('project.settings', {
            url: '/settings',
            template: '<mc-project-settings></mc-project-settings>'
        })
        .state('project.collaborators', {
            url: '/collaborators',
            template: '<mc-project-collaborators class="height-100"></mc-project-collaborators>'
        })
        .state('data', {
            url: '/data',
            abstract: true,
            // template: '<md-content ui-view flex></md-content>'
            template: '

'
        })
        .state('data.dataset', {
            url: '/dataset/:dataset_id',
            template: '<mc-dataset-overview-container layout="column" flex></mc-dataset-overview-container>'
        })
        .state('data.home', {
            url: '/home',
            template: '<md-content flex><mc-data-home tags="$resolve.tags"></mc-data-home></md-content>',
            resolve: {
                tags: ['publicTagsAPI',
                    (publicTagsAPI) => publicTagsAPI.getPopularTags().then(
                        (tags) => tags.map(t => t.tag)
                    )
                ]
            }
        })
        .state('data.tag', {
            url: '/tag/:tag',
            template: '<mc-dataset-list datasets="$resolve.datasets" details-route="data.dataset" layout-margin></mc-dataset-list>',
            resolve: {
                datasets: ['publicDatasetsAPI', '$stateParams',
                    (publicDatasetsAPI, $stateParams) => publicDatasetsAPI.getDatasetsForTag($stateParams.tag)
                ]
            }
        })
        .state('data.home.recent', {
            url: '/recent',
            template: '<mc-dataset-list datasets="$resolve.datasets" details-route="data.dataset"></mc-dataset-list>',
            resolve: {
                datasets: ['publicDatasetsAPI',
                    (publicDatasetsAPI) => publicDatasetsAPI.getRecent()
                ]
            }
        })
        .state('data.home.top', {
            url: '/top',
            template: '<mc-dataset-list datasets="$resolve.datasets" details-route="data.dataset"></mc-dataset-list>',
            resolve: {
                datasets: ['publicDatasetsAPI',
                    (publicDatasetsAPI) => publicDatasetsAPI.getTopViewed()
                ]
            }
        });

    // $urlRouterProvider.otherwise('/login');
    $urlRouterProvider.otherwise('/data/home/top');
}
<|endoftext|>


<commit_before>var path = function(){
    var saving = false;
    var cStep = null;
    var tPubic = 'public';
    var tPrivate = 'private';
    var tEval = 'eval';
    var $dataInput = null;

    function addslashes(str){
        return (str + '').replace(/[\"]/g, '"');
    }
    function _appendTest(tcDetails){
        $("#{0}_test_tbody".format(tcDetails.tType)).append($.tmpl("testcase_row",tcDetails));
        $(".eval_expression, .expected_output, .fail_hint").unbind().change(function() {path.updateTest($(this))});
        $(".delete_test").unbind().click(function() {path.deleteTest(($(this)))});
    }

    /** data types **/

    function _newTest(){
        return {
            expected: "",
            expression: "",
            hint:""
        };
    }

    return {
        data: {
            private: [],
            public: [],
            eval: []
        },

        saveQuestion: function(){
            saving = true;
            $dataInput.val(JSON.stringify(path.data));
        },
        initialize: function() {
            $("#saveCQ").click(path.saveQuestion);
            cStep = path.data;
            $dataInput = $("#coding_question_data");
            var tcType = JSON.parse($("#tc-type-data").val());
            path.loadTestTypes(tcType);
            if( $dataInput.val() != "") {
                path.data =  JSON.parse($dataInput.val());
                path.loadStep();
            }
        },

        /** tests **/
        addTest: function(event){
            var testType = event.data.param1;
            var ci = cStep;
            var tNo = ci[testType].length;
            ci[testType].push(_newTest());

            _appendTest({
                tNo:tNo,
                tType: testType,
                expression: "",
                expected: "",
                fail_hint: "",
                has_hint: testType == tPrivate
            });
        },

        updateTest: function($ele){
            var $tr = $ele.parents(".test_case");
            var c = $tr.attr("data-test-no") - 0;
            var $eo = $tr.find(".expected_output");
            var $ep = $tr.find(".eval_expression");
            var $hint = $tr.find(".fail_hint");

            cStep[$tr.attr("data-test-type")][c] = {
                expression: $ep.val(),
                expected: $eo.val(),
                hint: $hint.val()
            };
        },

        deleteTest: function($del){
            var $tr = $del.parents(".test_case");
            var c = $tr.attr("data-test-no") - 0;
            var testType = $tr.attr("data-test-type");
            cStep[testType].splice(c, 1);
            $tr.remove();
            $("#"+testType+"_test_tbody").children().each(function(index, e){
                $(e).attr("data-test-no", index);
            });
        } ,
        loadTestTypes: function(tcType) {
            var $tcDiv = $("#path_testcases");
            for (var type in tcType) {
                $tcDiv.append($.tmpl("testcase_table", {type: type, title: tcType[type], has_hint: type == tPrivate}));
                $("#add-{0}-test".format(type)).click({param1: type}, path.addTest);
            }
        },
        loadStep:function(){
            cStep = path.data;

            $("#public_test_tbody").html("");
            $("#private_test_tbody").html("");
            $("#eval_test_tbody").html("");
            var i = 0;
            var testTypes = [tPubic, tPrivate, tEval];

            for (var tt in testTypes) {
                var tType = testTypes[tt];
                if(cStep[tType]) {
                    for(i = 0 ; i < cStep[tType].length; i++){
                        var tcDetail = cStep[tType][i];
                        tcDetail["tNo"] = i;
                        tcDetail["tType"] = tType;
                        tcDetail["has_hint"] = tType == tPrivate;
                        _appendTest(tcDetail);
                    }
                } else {
                    cStep[tType] = [];
                }
            }
        }
    };
}();

$(document).ready(function() {
    //TODO: handle change of language
    var code_blocks = $("[render='code']");
    if (code_blocks.length > 0) {
        code_blocks.each(function(){
            $block = $(this);
            var language = $block.attr("language"), version = $block.attr("version");
            var cmBlock;
            var options = {
                mode: {name: language, version: version, singleLineStringErrors: false},
                lineNumbers: true,
                indentUnit: 4,
                tabMode: "shift",
                matchBrackets: true,
//                TODO: refactor theme
                theme:'molokai',
                extraKeys: {
                    "Tab": function(){
                        cmBlock.replaceSelection("    " , "end");
                    }
                }
            };
            cmBlock = CodeMirror.fromTextArea(this, options);
            cmBlock.on("change",function(){
                $block.val(cmBlock.getValue());
            });
        })
    }
    if(document.getElementById("pathstep_content")) {
        path.initialize();
    }
});
<commit_msg>Autoremove empty test cases in coding questions<commit_after>var path = function(){
    var saving = false;
    var cStep = null;
    var tPubic = 'public';
    var tPrivate = 'private';
    var tEval = 'eval';
    var $dataInput = null;

    function addslashes(str){
        return (str + '').replace(/[\"]/g, '"');
    }
    function _appendTest(tcDetails){
        $("#{0}_test_tbody".format(tcDetails.tType)).append($.tmpl("testcase_row",tcDetails));
        $(".eval_expression, .expected_output, .fail_hint").unbind().change(function() {path.updateTest($(this))});
        $(".delete_test").unbind().click(function() {path.deleteTest(($(this)))});
    }

    /** data types **/

    function _newTest(){
        return {
            expected: "",
            expression: "",
            hint:""
        };
    }

    return {
        data: {
            private: [],
            public: [],
            eval: []
        },

        removeEmptyTestCases: function(data){
            var tcType = JSON.parse($("#tc-type-data").val());
            for (var type in tcType) {
                var tests = data[type];
                for (var i = tests.length-1; i >= 0; --i ){
                    if (tests[i].expected == "" || tests[i].expression == ""){
                        tests.splice(i,1);
                    }
                }
            }
        },

        saveQuestion: function(){
            saving = true;
            path.removeEmptyTestCases(path.data);
            $dataInput.val(JSON.stringify(path.data));
        },
        initialize: function() {
            $("#saveCQ").click(path.saveQuestion);
            cStep = path.data;
            $dataInput = $("#coding_question_data");
            var tcType = JSON.parse($("#tc-type-data").val());
            path.loadTestTypes(tcType);
            if( $dataInput.val() != "") {
                path.data =  JSON.parse($dataInput.val());
                path.loadStep();
            }
        },

        /** tests **/
        addTest: function(event){
            var testType = event.data.param1;
            var ci = cStep;
            var tNo = ci[testType].length;
            ci[testType].push(_newTest());

            _appendTest({
                tNo:tNo,
                tType: testType,
                expression: "",
                expected: "",
                fail_hint: "",
                has_hint: testType == tPrivate
            });
        },

        updateTest: function($ele){
            var $tr = $ele.parents(".test_case");
            var c = $tr.attr("data-test-no") - 0;
            var $eo = $tr.find(".expected_output");
            var $ep = $tr.find(".eval_expression");
            var $hint = $tr.find(".fail_hint");

            cStep[$tr.attr("data-test-type")][c] = {
                expression: $ep.val(),
                expected: $eo.val(),
                hint: $hint.val()
            };
        },

        deleteTest: function($del){
            var $tr = $del.parents(".test_case");
            var c = $tr.attr("data-test-no") - 0;
            var testType = $tr.attr("data-test-type");
            cStep[testType].splice(c, 1);
            $tr.remove();
            $("#"+testType+"_test_tbody").children().each(function(index, e){
                $(e).attr("data-test-no", index);
            });
        } ,
        loadTestTypes: function(tcType) {
            var $tcDiv = $("#path_testcases");
            for (var type in tcType) {
                $tcDiv.append($.tmpl("testcase_table", {type: type, title: tcType[type], has_hint: type == tPrivate}));
                $("#add-{0}-test".format(type)).click({param1: type}, path.addTest);
            }
        },
        loadStep:function(){
            cStep = path.data;

            $("#public_test_tbody").html("");
            $("#private_test_tbody").html("");
            $("#eval_test_tbody").html("");
            var i = 0;
            var testTypes = [tPubic, tPrivate, tEval];

            for (var tt in testTypes) {
                var tType = testTypes[tt];
                if(cStep[tType]) {
                    for(i = 0 ; i < cStep[tType].length; i++){
                        var tcDetail = cStep[tType][i];
                        tcDetail["tNo"] = i;
                        tcDetail["tType"] = tType;
                        tcDetail["has_hint"] = tType == tPrivate;
                        _appendTest(tcDetail);
                    }
                } else {
                    cStep[tType] = [];
                }
            }
        }
    };
}();

$(document).ready(function() {
    //TODO: handle change of language
    var code_blocks = $("[render='code']");
    if (code_blocks.length > 0) {
        code_blocks.each(function(){
            $block = $(this);
            var language = $block.attr("language"), version = $block.attr("version");
            var cmBlock;
            var options = {
                mode: {name: language, version: version, singleLineStringErrors: false},
                lineNumbers: true,
                indentUnit: 4,
                tabMode: "shift",
                matchBrackets: true,
//                TODO: refactor theme
                theme:'molokai',
                extraKeys: {
                    "Tab": function(){
                        cmBlock.replaceSelection("    " , "end");
                    }
                }
            };
            cmBlock = CodeMirror.fromTextArea(this, options);
            cmBlock.on("change",function(){
                $block.val(cmBlock.getValue());
            });
        })
    }
    if(document.getElementById("pathstep_content")) {
        path.initialize();
    }
});
<|endoftext|>


<commit_before>"use strict";

if (location.hash.slice(1).startsWith(encodeURIComponent("{"))) {
  location.pathname = "/playground/";
}

window.addEventListener("load", () => {
  // We don't have access to a unique body css attribute for just the homepage
  // so instead it is set on load. It's only really visible on a vertical overscroll
  document.body.style.backgroundColor = "rgb(24, 32, 37)";

  const logoWrapper = document.querySelector(".animatedLogoWrapper");
  const logo = document.querySelector(".prettier-logo-wide");
  const lastDash = logo.querySelector("g:last-of-type path:last-of-type");

  function handleLogoDrag(event) {
    logo.classList.add("rolling");
    event.preventDefault();
  }

  logoWrapper.setAttribute("draggable", "true");
  logoWrapper.addEventListener("touchstart", handleLogoDrag);
  logoWrapper.addEventListener("dragstart", handleLogoDrag);

  lastDash.addEventListener("animationend", (event) => {
    if (/roll/.test(event.animationName)) {
      logo.classList.remove("rolling");
    }
  });

  const yarnButton = document.querySelector(".showYarnButton");
  const npmButton = document.querySelector(".showNpmButton");
  const getStartedSection = document.querySelector(".getStartedSection");

  npmButton.addEventListener("click", (event) => {
    event.preventDefault();
    npmButton.classList.add("active");
    yarnButton.classList.remove("active");
    getStartedSection.classList.add("getStartedSection--npm");
  });
  yarnButton.addEventListener("click", (event) => {
    event.preventDefault();
    yarnButton.classList.add("active");
    npmButton.classList.remove("active");
    getStartedSection.classList.remove("getStartedSection--npm");
  });
});
<commit_msg>website: remove js for removed elements<commit_after>"use strict";

if (location.hash.slice(1).startsWith(encodeURIComponent("{"))) {
  location.pathname = "/playground/";
}

window.addEventListener("load", () => {
  // We don't have access to a unique body css attribute for just the homepage
  // so instead it is set on load. It's only really visible on a vertical overscroll
  document.body.style.backgroundColor = "rgb(24, 32, 37)";

  const logoWrapper = document.querySelector(".animatedLogoWrapper");
  const logo = document.querySelector(".prettier-logo-wide");
  const lastDash = logo.querySelector("g:last-of-type path:last-of-type");

  function handleLogoDrag(event) {
    logo.classList.add("rolling");
    event.preventDefault();
  }

  logoWrapper.setAttribute("draggable", "true");
  logoWrapper.addEventListener("touchstart", handleLogoDrag);
  logoWrapper.addEventListener("dragstart", handleLogoDrag);

  lastDash.addEventListener("animationend", (event) => {
    if (/roll/.test(event.animationName)) {
      logo.classList.remove("rolling");
    }
  });
});
<|endoftext|>


<commit_before>/* eslint-env worker */
/* eslint no-var: off, strict: off */

// "Polyfills" in order for all the code to run
self.global = self;
self.util = {};
self.path = {};
self.Buffer = {
  isBuffer: function() {
    return false;
  }
};
self.constants = {};
// eslint-disable-next-line
module$1 = module = path = os = crypto = {};
self.fs = { readFile: function() {} };
// eslint-disable-next-line no-undef
os.homedir = function() {
  return "/home/prettier";
};
self.process = { argv: [], env: { PRETTIER_DEBUG: true }, version: "v8.5.0" };
self.assert = { ok: function() {}, strictEqual: function() {} };
self.require = function require(path) {
  if (path === "stream") {
    return { PassThrough() {} };
  }
  if (path === "./third-party") {
    return {};
  }

  if (~path.indexOf("parser-")) {
    var parser = path.replace(/.+-/, "");
    if (!parsersLoaded[parser]) {
      importScripts("lib/parser-" + parser + ".js");
      parsersLoaded[parser] = true;
    }
    return self[parser];
  }

  return self[path];
};

importScripts("lib/index.js");
var prettier = index; // eslint-disable-line

var parsersLoaded = {};

self.onmessage = function(event) {
  var uid = event.data.uid;
  var message = event.data.message;
  switch (message.type) {
    case "meta":
      self.postMessage({
        uid: uid,
        message: {
          type: "meta",
          supportInfo: prettier.getSupportInfo("1.9.0"),
          version: prettier.version
        }
      });
      break;

    case "format":
      var options = message.options || {};

      delete options.ast;
      delete options.doc;
      delete options.output2;

      self.postMessage({
        uid: uid,
        message: {
          formatted: formatCode(message.code, options)
        }
      });
      break;
  }
};

function formatCode(text, options) {
  try {
    return prettier.format(text, options);
  } catch (e) {
    return String(e);
  }
}
<commit_msg>fix prettier loading<commit_after>/* eslint-env worker */
/* eslint no-var: off, strict: off */

// "Polyfills" in order for all the code to run
self.global = self;
self.util = {};
self.path = {};
self.Buffer = {
  isBuffer: function() {
    return false;
  }
};
self.constants = {};
// eslint-disable-next-line
module$1 = module = path = os = crypto = {};
self.fs = { readFile: function() {} };
// eslint-disable-next-line no-undef
os.homedir = function() {
  return "/home/prettier";
};
self.process = { argv: [], env: { PRETTIER_DEBUG: true }, version: "v8.5.0" };
self.assert = { ok: function() {}, strictEqual: function() {} };
self.require = function require(path) {
  if (path === "stream") {
    return { PassThrough() {} };
  }
  if (path === "./third-party") {
    return {};
  }

  if (~path.indexOf("parser-")) {
    var parser = path.replace(/.+-/, "");
    if (!parsersLoaded[parser]) {
      importScripts("lib/parser-" + parser + ".js");
      parsersLoaded[parser] = true;
    }
    return self[parser];
  }

  return self[path];
};

var prettier;
importScripts("lib/index.js");
if (typeof prettier === "undefined") {
  prettier = module.exports; // eslint-disable-line
}
if (typeof prettier === "undefined") {
  prettier = index; // eslint-disable-line
}

var parsersLoaded = {};

self.onmessage = function(event) {
  var uid = event.data.uid;
  var message = event.data.message;
  switch (message.type) {
    case "meta":
      self.postMessage({
        uid: uid,
        message: {
          type: "meta",
          supportInfo: prettier.getSupportInfo("1.9.0"),
          version: prettier.version
        }
      });
      break;

    case "format":
      var options = message.options || {};

      delete options.ast;
      delete options.doc;
      delete options.output2;

      self.postMessage({
        uid: uid,
        message: {
          formatted: formatCode(message.code, options)
        }
      });
      break;
  }
};

function formatCode(text, options) {
  try {
    return prettier.format(text, options);
  } catch (e) {
    return String(e);
  }
}
<|endoftext|>


<commit_before>import React from 'react'
import PropTypes from 'prop-types'

import {OAuthTokenArrayPropType} from 'src/propTypes'
import {DropdownMenuButton, IconFont, UserIconWithHost} from 'src/pages/parts'
import {
  COLUMN_TIMELINE, COLUMN_FRIENDS, COLUMN_NOTIFICATIONS,
  TIMELINE_FEDERATION, TIMELINE_LOCAL, TIMELINE_HOME, SUBJECT_MIXED,
  TOOTFORM_PLACEHOLDER,
} from 'src/constants'
import TootWindow from '../TootWindow'

/**
 * ダッシュボードのヘッダ
 * [logo] [toot欄] [account icon] [account icon] [account icon] [account icon] .... [歯車]
 */
export default class DashboardHeader extends React.Component {
  static propTypes = {
    tokens: OAuthTokenArrayPropType.isRequired,
    onStartAddAccount: PropTypes.func.isRequired,
    onOpenColumn: PropTypes.func.isRequired,
    onGenKey: PropTypes.func.isRequired,
  }

  /**
   * @constructor
   */
  constructor(...args) {
    super(...args)

    this.state = {
      isShowTootWindow: false,
    }
  }

  /**
   * @override
   */
  render() {
    const {isShowTootWindow} = this.state
    const {tokens} = this.props

    return (

        <DropdownMenuButton modifier="mixedColumMenu" onRenderMenu={::this.onRenderCompoundMenu}>

        </DropdownMenuButton>

          <input
            className={`${isShowTootWindow ? 'is-hidden' : ''}`}
            type="text" placeholder={TOOTFORM_PLACEHOLDER}
            onFocus={::this.onTootFocus} />
          {isShowTootWindow && <TootWindow onClose={::this.onTootWindowClose} />}

          {tokens.map((token) => this.renderAccount(token))}

            <button className="naumanniDashboard-header-addAccountButton"
              onClick={() => this.props.onStartAddAccount()}>
              <IconFont iconName="plus" />
            </button>

        <button className="naumanniDashboard-header-configButton">
          <IconFont iconName="cog" />
        </button>

    )
  }

  /**
   * ヘッダに顔アイコンを書くよ
   * @param {OAuthToken} token
   * @return {React.Component}
   */
  renderAccount(token) {
    if(token.isAlive()) {
      // 正常Token
      return (

          <DropdownMenuButton onRenderMenu={this.onRenderAccountMenu.bind(this, token)}>
            <UserIconWithHost account={token.account} />
          </DropdownMenuButton>

      )
    } else {
      // 読み込みに失敗したToken
      return (

          <DropdownMenuButton onRenderMenu={this.onRenderBadAccountMenu.bind(this, token)}>

×

          </DropdownMenuButton>

      )
    }
  }

  // callbacks
  onRenderCompoundMenu() {
    return (

          <IconFont className="menu-itemIcon" iconName="home" />
          United Home timeline

          <IconFont className="menu-itemIcon" iconName="users" />
          United Local timeline

          <IconFont className="menu-itemIcon" iconName="globe" />
          United Federated timeline

          <IconFont className="menu-itemIcon" iconName="bell" />
          United Notification

    )
  }

  onRenderAccountMenu(token) {
    const {account} = token

    return (

          <UserIconWithHost account={account} />

            {account.display_name}

            {account.acct}

              {account.hasPublicKey && <IconFont iconName="key" />pub}

              {account.hasPrivateKey && <IconFont iconName="key" />prv}

            <button onClick={this.props.onGenKey.bind(this, token, account)}>Create key</button>

          <IconFont className="menu-itemIcon" iconName="home" />
          Home timeline

          <IconFont className="menu-itemIcon" iconName="users" />
          Local timeline

          <IconFont className="menu-itemIcon" iconName="globe" />
          Federated timeline

          <IconFont className="menu-itemIcon" iconName="bell" />
          Notifications

          <IconFont className="menu-itemIcon" iconName="mail" />
          Message

    )
  }

  /**
   * 読み込みエラーになったTokenに関するMenu
   * @param {OAuthToken} token
   * @return {React.Component}
   */
  onRenderBadAccountMenu(token) {
    return (

          Host: {token.host}

            Network communication error

    )
  }

  onTootFocus(e) {
    this.setState({isShowTootWindow: true})
  }

  onTootWindowClose() {
    this.setState({isShowTootWindow: false})
  }
}
<commit_msg>Key生成ボタンは一旦消す<commit_after>import React from 'react'
import PropTypes from 'prop-types'

import {OAuthTokenArrayPropType} from 'src/propTypes'
import {DropdownMenuButton, IconFont, UserIconWithHost} from 'src/pages/parts'
import {
  COLUMN_TIMELINE, COLUMN_FRIENDS, COLUMN_NOTIFICATIONS,
  TIMELINE_FEDERATION, TIMELINE_LOCAL, TIMELINE_HOME, SUBJECT_MIXED,
  TOOTFORM_PLACEHOLDER,
} from 'src/constants'
import TootWindow from '../TootWindow'

/**
 * ダッシュボードのヘッダ
 * [logo] [toot欄] [account icon] [account icon] [account icon] [account icon] .... [歯車]
 */
export default class DashboardHeader extends React.Component {
  static propTypes = {
    tokens: OAuthTokenArrayPropType.isRequired,
    onStartAddAccount: PropTypes.func.isRequired,
    onOpenColumn: PropTypes.func.isRequired,
    onGenKey: PropTypes.func.isRequired,
  }

  /**
   * @constructor
   */
  constructor(...args) {
    super(...args)

    this.state = {
      isShowTootWindow: false,
    }
  }

  /**
   * @override
   */
  render() {
    const {isShowTootWindow} = this.state
    const {tokens} = this.props

    return (

        <DropdownMenuButton modifier="mixedColumMenu" onRenderMenu={::this.onRenderCompoundMenu}>

        </DropdownMenuButton>

          <input
            className={`${isShowTootWindow ? 'is-hidden' : ''}`}
            type="text" placeholder={TOOTFORM_PLACEHOLDER}
            onFocus={::this.onTootFocus} />
          {isShowTootWindow && <TootWindow onClose={::this.onTootWindowClose} />}

          {tokens.map((token) => this.renderAccount(token))}

            <button className="naumanniDashboard-header-addAccountButton"
              onClick={() => this.props.onStartAddAccount()}>
              <IconFont iconName="plus" />
            </button>

        <button className="naumanniDashboard-header-configButton">
          <IconFont iconName="cog" />
        </button>

    )
  }

  /**
   * ヘッダに顔アイコンを書くよ
   * @param {OAuthToken} token
   * @return {React.Component}
   */
  renderAccount(token) {
    if(token.isAlive()) {
      // 正常Token
      return (

          <DropdownMenuButton onRenderMenu={this.onRenderAccountMenu.bind(this, token)}>
            <UserIconWithHost account={token.account} />
          </DropdownMenuButton>

      )
    } else {
      // 読み込みに失敗したToken
      return (

          <DropdownMenuButton onRenderMenu={this.onRenderBadAccountMenu.bind(this, token)}>

×

          </DropdownMenuButton>

      )
    }
  }

  // callbacks
  onRenderCompoundMenu() {
    return (

          <IconFont className="menu-itemIcon" iconName="home" />
          United Home timeline

          <IconFont className="menu-itemIcon" iconName="users" />
          United Local timeline

          <IconFont className="menu-itemIcon" iconName="globe" />
          United Federated timeline

          <IconFont className="menu-itemIcon" iconName="bell" />
          United Notification

    )
  }

  onRenderAccountMenu(token) {
    const {account} = token

    return (

          <UserIconWithHost account={account} />

            {account.display_name}

            {account.acct}

              {account.hasPublicKey && <IconFont iconName="key" />pub}

              {account.hasPrivateKey && <IconFont iconName="key" />prv}

          <IconFont className="menu-itemIcon" iconName="home" />
          Home timeline

          <IconFont className="menu-itemIcon" iconName="users" />
          Local timeline

          <IconFont className="menu-itemIcon" iconName="globe" />
          Federated timeline

          <IconFont className="menu-itemIcon" iconName="bell" />
          Notifications

          <IconFont className="menu-itemIcon" iconName="mail" />
          Message

    )
  }

  /**
   * 読み込みエラーになったTokenに関するMenu
   * @param {OAuthToken} token
   * @return {React.Component}
   */
  onRenderBadAccountMenu(token) {
    return (

          Host: {token.host}

            Network communication error

    )
  }

  onTootFocus(e) {
    this.setState({isShowTootWindow: true})
  }

  onTootWindowClose() {
    this.setState({isShowTootWindow: false})
  }
}
<|endoftext|>


<commit_before>// Setup CSRF token for all jQuery AJAX requests.
// Note that this file should be included right after jQuery and before other scripts.
$(document).ready(function () {
  var token = $('meta[name="csrf-token"]').attr('content');
  $.ajaxSetup({
    beforeSend: function (xhr) {
      xhr.setRequestHeader('X-CSRF-Token', token);
    }
  });
});
<commit_msg>Don't set X-CSRF-Token header in every req (it was breaking Shutterbug)<commit_after>// Setup CSRF token for all jQuery AJAX requests.
// Note that this file should be included right after jQuery and before other scripts.
$(document).ready(function () {
  var token = $('meta[name="csrf-token"]').attr('content');
  // "Free" URI parser in JS.
  var urlParser = document.createElement('a');
  $.ajaxSetup({
    beforeSend: function (xhr, settings) {
      // Note that <a> element will set .hostname to correct value even
      // if we provide relative path like '/api/v1/something'.
      // Set X-CSRF-Token only while issuing request to LARA API,
      // as this header was e.g. breaking Shutterbug service.
      urlParser.href = settings.url;
      if (urlParser.hostname == window.location.hostname) {
        xhr.setRequestHeader('X-CSRF-Token', token);
  	  }
    }
  });
});
<|endoftext|>