<commit_before>/* eslint-env mocha */
import Chai from 'chai';
import ChaiString from 'chai-string';
import Sinon from 'sinon';
import SinonChai from 'sinon-chai';

Chai.use(ChaiString);
Chai.use(SinonChai);

beforeEach(function() {
  this.sandbox = Sinon.sandbox.create({
    injectInto: this,
    properties: ['spy', 'stub', 'mock'],
    useFakeTimers: false,
    useFakeServer: false
  });
});
afterEach(function() {
  this.sandbox.restore();
});

/* istanbul ignore next */
function unhandledRejection(err) {
  throw err;
}
before(function() {
  process.on('unhandledRejection', unhandledRejection);
});
after(function() {
  process.removeListener('unhandledRejection', unhandledRejection);
});
<commit_msg>Add error logging to unhandled rejection.<commit_after>/* eslint-env mocha */
import Chai from 'chai';
import ChaiString from 'chai-string';
import Sinon from 'sinon';
import SinonChai from 'sinon-chai';

Chai.use(ChaiString);
Chai.use(SinonChai);

beforeEach(function() {
  this.sandbox = Sinon.sandbox.create({
    injectInto: this,
    properties: ['spy', 'stub', 'mock'],
    useFakeTimers: false,
    useFakeServer: false
  });
});
afterEach(function() {
  this.sandbox.restore();
});

/* istanbul ignore next */
function unhandledRejection(err) {
  console.error(`Unhandled rejections: ${err.stack || err}`);
  throw err;
}
before(function() {
  process.on('unhandledRejection', unhandledRejection);
});
after(function() {
  process.removeListener('unhandledRejection', unhandledRejection);
});
<|endoftext|>


<commit_before>/* eslint-disable react/prop-types */
import { Button } from 'react-bootstrap'
import { connect } from 'react-redux'
import { FormattedMessage } from 'react-intl'
import coreUtils from '@opentripplanner/core-utils'
import React, { Component } from 'react'

import {
  clearDefaultSettings,
  resetForm,
  storeDefaultSettings
} from '../../actions/form'
import Icon from '../util/icon'

/**
 * This component contains the `Remember/Forget my trip options` and `Restore defaults` commands
 * that let the user save the selected trip settings such as mode choices,
 * walk/bike distance and speed, and trip optimization flags.
 * (The code below was previously embedded inside the `SettingsSelectorPanel` component.)
 */
class UserTripSettings extends Component {
  _toggleStoredSettings = () => {
    const options = coreUtils.query.getTripOptionsFromQuery(this.props.query)
    // If user defaults are set, clear them. Otherwise, store them.
    if (this.props.defaults) this.props.clearDefaultSettings()
    else this.props.storeDefaultSettings(options)
  }

  render() {
    const { config, defaults, query, resetForm } = this.props

    // Do not permit remembering trip options if they do not differ from the
    // defaults and nothing has been stored
    const queryIsDefault = !coreUtils.query.isNotDefaultQuery(query, config)
    const rememberIsDisabled = queryIsDefault && !defaults

    return (

        <Button
          bsSize="xsmall"
          bsStyle="link"
          disabled={rememberIsDisabled}
          onClick={this._toggleStoredSettings}
        >
          {defaults ? (

              <Icon type="times" />{' '}
              <FormattedMessage id="components.UserTripSettings.forgetOptions" />

          ) : (

              <Icon type="lock" />{' '}
              <FormattedMessage id="components.UserTripSettings.rememberOptions" />

          )}
        </Button>
        <Button
          bsSize="xsmall"
          bsStyle="link"
          disabled={queryIsDefault && !defaults}
          onClick={resetForm}
        >
          <Icon type="undo" withSpace />
          <FormattedMessage
            id="components.UserTripSettings.restoreOptions"
            values={{ defaults }}
          />
        </Button>

    )
  }
}

// connect to redux store

const mapStateToProps = (state) => {
  const { config, currentQuery } = state.otp
  const { defaults } = state.user.localUser

  return {
    config,
    defaults,
    query: currentQuery
  }
}

const mapDispatchToProps = {
  clearDefaultSettings,
  resetForm,
  storeDefaultSettings
}

export default connect(mapStateToProps, mapDispatchToProps)(UserTripSettings)
<commit_msg>refactor(user-trip-settings): remove fa icons<commit_after>/* eslint-disable react/prop-types */
import { Button } from 'react-bootstrap'
import { connect } from 'react-redux'
import { FormattedMessage } from 'react-intl'
import { Lock } from '@styled-icons/fa-solid/Lock'
import { Times } from '@styled-icons/fa-solid/Times'
import { Undo } from '@styled-icons/fa-solid/Undo'
import coreUtils from '@opentripplanner/core-utils'
import React, { Component } from 'react'

import {
  clearDefaultSettings,
  resetForm,
  storeDefaultSettings
} from '../../actions/form'
import StyledIconWrapper from '../util/styledIcon'

/**
 * This component contains the `Remember/Forget my trip options` and `Restore defaults` commands
 * that let the user save the selected trip settings such as mode choices,
 * walk/bike distance and speed, and trip optimization flags.
 * (The code below was previously embedded inside the `SettingsSelectorPanel` component.)
 */
class UserTripSettings extends Component {
  _toggleStoredSettings = () => {
    const options = coreUtils.query.getTripOptionsFromQuery(this.props.query)
    // If user defaults are set, clear them. Otherwise, store them.
    if (this.props.defaults) this.props.clearDefaultSettings()
    else this.props.storeDefaultSettings(options)
  }

  render() {
    const { config, defaults, query, resetForm } = this.props

    // Do not permit remembering trip options if they do not differ from the
    // defaults and nothing has been stored
    const queryIsDefault = !coreUtils.query.isNotDefaultQuery(query, config)
    const rememberIsDisabled = queryIsDefault && !defaults

    return (

        <Button
          bsSize="xsmall"
          bsStyle="link"
          disabled={rememberIsDisabled}
          onClick={this._toggleStoredSettings}
        >
          {defaults ? (

              <FormattedMessage id="components.UserTripSettings.forgetOptions" />

          ) : (

              <FormattedMessage id="components.UserTripSettings.rememberOptions" />

          )}
        </Button>
        <Button
          bsSize="xsmall"
          bsStyle="link"
          disabled={queryIsDefault && !defaults}
          onClick={resetForm}
        >

          <FormattedMessage
            id="components.UserTripSettings.restoreOptions"
            values={{ defaults }}
          />
        </Button>

    )
  }
}

// connect to redux store

const mapStateToProps = (state) => {
  const { config, currentQuery } = state.otp
  const { defaults } = state.user.localUser

  return {
    config,
    defaults,
    query: currentQuery
  }
}

const mapDispatchToProps = {
  clearDefaultSettings,
  resetForm,
  storeDefaultSettings
}

export default connect(mapStateToProps, mapDispatchToProps)(UserTripSettings)
<|endoftext|>


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

import * as zrUtil from 'zrender/src/core/util';
import * as graphic from '../../util/graphic';
import * as textContain from 'zrender/src/contain/text';
import * as formatUtil from '../../util/format';
import * as matrix from 'zrender/src/core/matrix';
import * as axisHelper from '../../coord/axisHelper';
import AxisBuilder from '../axis/AxisBuilder';

/**
 * @param {module:echarts/model/Model} axisPointerModel
 */
export function buildElStyle(axisPointerModel) {
    var axisPointerType = axisPointerModel.get('type');
    var styleModel = axisPointerModel.getModel(axisPointerType + 'Style');
    var style;
    if (axisPointerType === 'line') {
        style = styleModel.getLineStyle();
        style.fill = null;
    }
    else if (axisPointerType === 'shadow') {
        style = styleModel.getAreaStyle();
        style.stroke = null;
    }
    return style;
}

/**
 * @param {Function} labelPos {align, verticalAlign, position}
 */
export function buildLabelElOption(
    elOption, axisModel, axisPointerModel, api, labelPos
) {
    var value = axisPointerModel.get('value');
    var text = getValueLabel(
        value, axisModel.axis, axisModel.ecModel,
        axisPointerModel.get('seriesDataIndices'),
        {
            precision: axisPointerModel.get('label.precision'),
            formatter: axisPointerModel.get('label.formatter')
        }
    );
    var labelModel = axisPointerModel.getModel('label');
    var paddings = formatUtil.normalizeCssArray(labelModel.get('padding') || 0);

    var font = labelModel.getFont();
    var textRect = textContain.getBoundingRect(text, font);

    var position = labelPos.position;
    var width = textRect.width + paddings[1] + paddings[3];
    var height = textRect.height + paddings[0] + paddings[2];

    // Adjust by align.
    var align = labelPos.align;
    align === 'right' && (position[0] -= width);
    align === 'center' && (position[0] -= width / 2);
    var verticalAlign = labelPos.verticalAlign;
    verticalAlign === 'bottom' && (position[1] -= height);
    verticalAlign === 'middle' && (position[1] -= height / 2);

    // Not overflow ec container
    confineInContainer(position, width, height, api);

    var bgColor = labelModel.get('backgroundColor');
    if (!bgColor || bgColor === 'auto') {
        bgColor = axisModel.get('axisLine.lineStyle.color');
    }

    elOption.label = {
        shape: {x: 0, y: 0, width: width, height: height, r: labelModel.get('borderRadius')},
        position: position.slice(),
        // TODO: rich
        style: {
            text: text,
            textFont: font,
            textFill: labelModel.getTextColor(),
            textPosition: 'inside',
            fill: bgColor,
            stroke: labelModel.get('borderColor') || 'transparent',
            lineWidth: labelModel.get('borderWidth') || 0,
            shadowBlur: labelModel.get('shadowBlur'),
            shadowColor: labelModel.get('shadowColor'),
            shadowOffsetX: labelModel.get('shadowOffsetX'),
            shadowOffsetY: labelModel.get('shadowOffsetY')
        },
        // Lable should be over axisPointer.
        z2: 10
    };
}

// Do not overflow ec container
function confineInContainer(position, width, height, api) {
    var viewWidth = api.getWidth();
    var viewHeight = api.getHeight();
    position[0] = Math.min(position[0] + width, viewWidth) - width;
    position[1] = Math.min(position[1] + height, viewHeight) - height;
    position[0] = Math.max(position[0], 0);
    position[1] = Math.max(position[1], 0);
}

/**
 * @param {number} value
 * @param {module:echarts/coord/Axis} axis
 * @param {module:echarts/model/Global} ecModel
 * @param {Object} opt
 * @param {Array.<Object>} seriesDataIndices
 * @param {number|string} opt.precision 'auto' or a number
 * @param {string|Function} opt.formatter label formatter
 */
export function getValueLabel(value, axis, ecModel, seriesDataIndices, opt) {
    value = axis.scale.parse(value);
    var text = axis.scale.getLabel(
        // If `precision` is set, width can be fixed (like '12.00500'), which
        // helps to debounce when when moving label.
        value, {precision: opt.precision}
    );
    var formatter = opt.formatter;

    if (formatter) {
        var params = {
            value: axisHelper.getAxisRawValue(axis, value),
            axis: axis,
            seriesData: []
        };
        zrUtil.each(seriesDataIndices, function (idxItem) {
            var series = ecModel.getSeriesByIndex(idxItem.seriesIndex);
            var dataIndex = idxItem.dataIndexInside;
            var dataParams = series && series.getDataParams(dataIndex);
            dataParams && params.seriesData.push(dataParams);
        });

        if (zrUtil.isString(formatter)) {
            text = formatter.replace('{value}', text);
        }
        else if (zrUtil.isFunction(formatter)) {
            text = formatter(params);
        }
    }

    return text;
}

/**
 * @param {module:echarts/coord/Axis} axis
 * @param {number} value
 * @param {Object} layoutInfo {
 *  rotation, position, labelOffset, labelDirection, labelMargin
 * }
 */
export function getTransformedPosition(axis, value, layoutInfo) {
    var transform = matrix.create();
    matrix.rotate(transform, transform, layoutInfo.rotation);
    matrix.translate(transform, transform, layoutInfo.position);

    return graphic.applyTransform([
        axis.dataToCoord(value),
        (layoutInfo.labelOffset || 0)
            + (layoutInfo.labelDirection || 1) * (layoutInfo.labelMargin || 0)
    ], transform);
}

export function buildCartesianSingleLabelElOption(
    value, elOption, layoutInfo, axisModel, axisPointerModel, api
) {
    var textLayout = AxisBuilder.innerTextLayout(
        layoutInfo.rotation, 0, layoutInfo.labelDirection
    );
    layoutInfo.labelMargin = axisPointerModel.get('label.margin');
    buildLabelElOption(elOption, axisModel, axisPointerModel, api, {
        position: getTransformedPosition(axisModel.axis, value, layoutInfo),
        align: textLayout.textAlign,
        verticalAlign: textLayout.textVerticalAlign
    });
}

/**
 * @param {Array.<number>} p1
 * @param {Array.<number>} p2
 * @param {number} [xDimIndex=0] or 1
 */
export function makeLineShape(p1, p2, xDimIndex) {
    xDimIndex = xDimIndex || 0;
    return {
        x1: p1[xDimIndex],
        y1: p1[1 - xDimIndex],
        x2: p2[xDimIndex],
        y2: p2[1 - xDimIndex]
    };
}

/**
 * @param {Array.<number>} xy
 * @param {Array.<number>} wh
 * @param {number} [xDimIndex=0] or 1
 */
export function makeRectShape(xy, wh, xDimIndex) {
    xDimIndex = xDimIndex || 0;
    return {
        x: xy[xDimIndex],
        y: xy[1 - xDimIndex],
        width: wh[xDimIndex],
        height: wh[1 - xDimIndex]
    };
}

export function makeSectorShape(cx, cy, r0, r, startAngle, endAngle) {
    return {
        cx: cx,
        cy: cy,
        r0: r0,
        r: r,
        startAngle: startAngle,
        endAngle: endAngle,
        clockwise: true
    };
}
<commit_msg>axis in a inner data structure, should not be exposed to user.<commit_after>/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied.  See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import * as zrUtil from 'zrender/src/core/util';
import * as graphic from '../../util/graphic';
import * as textContain from 'zrender/src/contain/text';
import * as formatUtil from '../../util/format';
import * as matrix from 'zrender/src/core/matrix';
import * as axisHelper from '../../coord/axisHelper';
import AxisBuilder from '../axis/AxisBuilder';

/**
 * @param {module:echarts/model/Model} axisPointerModel
 */
export function buildElStyle(axisPointerModel) {
    var axisPointerType = axisPointerModel.get('type');
    var styleModel = axisPointerModel.getModel(axisPointerType + 'Style');
    var style;
    if (axisPointerType === 'line') {
        style = styleModel.getLineStyle();
        style.fill = null;
    }
    else if (axisPointerType === 'shadow') {
        style = styleModel.getAreaStyle();
        style.stroke = null;
    }
    return style;
}

/**
 * @param {Function} labelPos {align, verticalAlign, position}
 */
export function buildLabelElOption(
    elOption, axisModel, axisPointerModel, api, labelPos
) {
    var value = axisPointerModel.get('value');
    var text = getValueLabel(
        value, axisModel.axis, axisModel.ecModel,
        axisPointerModel.get('seriesDataIndices'),
        {
            precision: axisPointerModel.get('label.precision'),
            formatter: axisPointerModel.get('label.formatter')
        }
    );
    var labelModel = axisPointerModel.getModel('label');
    var paddings = formatUtil.normalizeCssArray(labelModel.get('padding') || 0);

    var font = labelModel.getFont();
    var textRect = textContain.getBoundingRect(text, font);

    var position = labelPos.position;
    var width = textRect.width + paddings[1] + paddings[3];
    var height = textRect.height + paddings[0] + paddings[2];

    // Adjust by align.
    var align = labelPos.align;
    align === 'right' && (position[0] -= width);
    align === 'center' && (position[0] -= width / 2);
    var verticalAlign = labelPos.verticalAlign;
    verticalAlign === 'bottom' && (position[1] -= height);
    verticalAlign === 'middle' && (position[1] -= height / 2);

    // Not overflow ec container
    confineInContainer(position, width, height, api);

    var bgColor = labelModel.get('backgroundColor');
    if (!bgColor || bgColor === 'auto') {
        bgColor = axisModel.get('axisLine.lineStyle.color');
    }

    elOption.label = {
        shape: {x: 0, y: 0, width: width, height: height, r: labelModel.get('borderRadius')},
        position: position.slice(),
        // TODO: rich
        style: {
            text: text,
            textFont: font,
            textFill: labelModel.getTextColor(),
            textPosition: 'inside',
            fill: bgColor,
            stroke: labelModel.get('borderColor') || 'transparent',
            lineWidth: labelModel.get('borderWidth') || 0,
            shadowBlur: labelModel.get('shadowBlur'),
            shadowColor: labelModel.get('shadowColor'),
            shadowOffsetX: labelModel.get('shadowOffsetX'),
            shadowOffsetY: labelModel.get('shadowOffsetY')
        },
        // Lable should be over axisPointer.
        z2: 10
    };
}

// Do not overflow ec container
function confineInContainer(position, width, height, api) {
    var viewWidth = api.getWidth();
    var viewHeight = api.getHeight();
    position[0] = Math.min(position[0] + width, viewWidth) - width;
    position[1] = Math.min(position[1] + height, viewHeight) - height;
    position[0] = Math.max(position[0], 0);
    position[1] = Math.max(position[1], 0);
}

/**
 * @param {number} value
 * @param {module:echarts/coord/Axis} axis
 * @param {module:echarts/model/Global} ecModel
 * @param {Object} opt
 * @param {Array.<Object>} seriesDataIndices
 * @param {number|string} opt.precision 'auto' or a number
 * @param {string|Function} opt.formatter label formatter
 */
export function getValueLabel(value, axis, ecModel, seriesDataIndices, opt) {
    value = axis.scale.parse(value);
    var text = axis.scale.getLabel(
        // If `precision` is set, width can be fixed (like '12.00500'), which
        // helps to debounce when when moving label.
        value, {precision: opt.precision}
    );
    var formatter = opt.formatter;

    if (formatter) {
        var params = {
            value: axisHelper.getAxisRawValue(axis, value),
            axisDimension: axis.dim,
            axisIndex: axis.index,
            seriesData: []
        };
        zrUtil.each(seriesDataIndices, function (idxItem) {
            var series = ecModel.getSeriesByIndex(idxItem.seriesIndex);
            var dataIndex = idxItem.dataIndexInside;
            var dataParams = series && series.getDataParams(dataIndex);
            dataParams && params.seriesData.push(dataParams);
        });

        if (zrUtil.isString(formatter)) {
            text = formatter.replace('{value}', text);
        }
        else if (zrUtil.isFunction(formatter)) {
            text = formatter(params);
        }
    }

    return text;
}

/**
 * @param {module:echarts/coord/Axis} axis
 * @param {number} value
 * @param {Object} layoutInfo {
 *  rotation, position, labelOffset, labelDirection, labelMargin
 * }
 */
export function getTransformedPosition(axis, value, layoutInfo) {
    var transform = matrix.create();
    matrix.rotate(transform, transform, layoutInfo.rotation);
    matrix.translate(transform, transform, layoutInfo.position);

    return graphic.applyTransform([
        axis.dataToCoord(value),
        (layoutInfo.labelOffset || 0)
            + (layoutInfo.labelDirection || 1) * (layoutInfo.labelMargin || 0)
    ], transform);
}

export function buildCartesianSingleLabelElOption(
    value, elOption, layoutInfo, axisModel, axisPointerModel, api
) {
    var textLayout = AxisBuilder.innerTextLayout(
        layoutInfo.rotation, 0, layoutInfo.labelDirection
    );
    layoutInfo.labelMargin = axisPointerModel.get('label.margin');
    buildLabelElOption(elOption, axisModel, axisPointerModel, api, {
        position: getTransformedPosition(axisModel.axis, value, layoutInfo),
        align: textLayout.textAlign,
        verticalAlign: textLayout.textVerticalAlign
    });
}

/**
 * @param {Array.<number>} p1
 * @param {Array.<number>} p2
 * @param {number} [xDimIndex=0] or 1
 */
export function makeLineShape(p1, p2, xDimIndex) {
    xDimIndex = xDimIndex || 0;
    return {
        x1: p1[xDimIndex],
        y1: p1[1 - xDimIndex],
        x2: p2[xDimIndex],
        y2: p2[1 - xDimIndex]
    };
}

/**
 * @param {Array.<number>} xy
 * @param {Array.<number>} wh
 * @param {number} [xDimIndex=0] or 1
 */
export function makeRectShape(xy, wh, xDimIndex) {
    xDimIndex = xDimIndex || 0;
    return {
        x: xy[xDimIndex],
        y: xy[1 - xDimIndex],
        width: wh[xDimIndex],
        height: wh[1 - xDimIndex]
    };
}

export function makeSectorShape(cx, cy, r0, r, startAngle, endAngle) {
    return {
        cx: cx,
        cy: cy,
        r0: r0,
        r: r,
        startAngle: startAngle,
        endAngle: endAngle,
        clockwise: true
    };
}
<|endoftext|>


<commit_before>'use strict';

var mongoose = require('mongoose'),
  Schema = mongoose.Schema;

/**
 * User Schema
 */
var UserSchema = new Schema({
  _id: { type: String },
  nickname: { type: String, required: true }, // 닉네임
  email: { type: String, required: true }, // 이메일
  birthday: { type: String, required: true }, // 생일
  accessToken: { type: String, required: true }, // 네이버 액세스 토큰
  refreshToken: { type: String, required: true }, // 네이버 리프레시 토큰
  emotionStatus: { type: Number, default: 3 }, // 이모션 상태(1:bad ~ 5:good)
  createDate: { type: Date, default: Date.now() }, // 생성 시간
  updateDate: { type: Date, default: Date.now() } // 수정 시간
}, { collection: 'users' });

UserSchema.index({ name: 1 }, { unique: true });

/**
 * Model Methods
 */

module.exports = mongoose.model('User', UserSchema);<commit_msg>Update<commit_after>'use strict';

var mongoose = require('mongoose'),
  Schema = mongoose.Schema;

/**
 * User Schema
 */
var UserSchema = new Schema({
  _id: { type: String },
  nickname: { type: String, required: true }, // 닉네임
  email: { type: String, required: true }, // 이메일
  birthday: { type: String, required: true }, // 생일
  accessToken: { type: String, required: true }, // 네이버 액세스 토큰
  refreshToken: { type: String, required: true }, // 네이버 리프레시 토큰
  emotionStatus: { type: Number, default: 3 }, // 이모션 상태(1:bad ~ 5:good)
  createDate: { type: Date, default: Date.now() }, // 생성 시간
  updateDate: { type: Date, default: Date.now() } // 수정 시간
}, { collection: 'users' });

UserSchema.index({ nickname: 1 }, { unique: true });

/**
 * Model Methods
 */

module.exports = mongoose.model('User', UserSchema);<|endoftext|>


<commit_before>// @flow
export type Environment = {
  network: string,
  apiVersion: string,
  mobxDevTools: boolean | string,
  current: string,
  reportUrl: string,
  isDev: boolean,
  isTest: boolean,
  isProduction: boolean,
  isMainnet: boolean,
  isStaging: boolean,
  isTestnet: boolean,
  isDevelopment: boolean,
  isWatchMode: boolean,
  build: string,
  buildNumber: string,
  buildLabel: string,
  platform: string,
  os: string,
  installerVersion: string,
  version: string,
  isWindows: boolean,
  isMacOS: boolean,
  isLinux: boolean
};
// constants
export const PRODUCTION = 'production';
export const DEVELOPMENT = 'development';
export const TEST = 'test';
export const MAINNET = 'mainnet';
export const STAGING = 'staging';
export const TESTNET = 'testnet';
export const STAGING_REPORT_URL = 'http://staging-report-server.awstest.iohkdev.io:8080/';
export const MAC_OS = 'darwin';
export const WINDOWS = 'win32';
export const LINUX = 'linux';
export const OS_NAMES = {
  [MAC_OS]: 'macOS',
  [WINDOWS]: 'Windows',
  [LINUX]: 'Linux',
};
<commit_msg>[DDW-517] Adds platformVersion property to environment type<commit_after>// @flow
export type Environment = {
  network: string,
  apiVersion: string,
  mobxDevTools: boolean | string,
  current: string,
  reportUrl: string,
  isDev: boolean,
  isTest: boolean,
  isProduction: boolean,
  isMainnet: boolean,
  isStaging: boolean,
  isTestnet: boolean,
  isDevelopment: boolean,
  isWatchMode: boolean,
  build: string,
  buildNumber: string,
  buildLabel: string,
  platform: string,
  platformVersion: string,
  os: string,
  installerVersion: string,
  version: string,
  isWindows: boolean,
  isMacOS: boolean,
  isLinux: boolean
};
// constants
export const PRODUCTION = 'production';
export const DEVELOPMENT = 'development';
export const TEST = 'test';
export const MAINNET = 'mainnet';
export const STAGING = 'staging';
export const TESTNET = 'testnet';
export const STAGING_REPORT_URL = 'http://staging-report-server.awstest.iohkdev.io:8080/';
export const MAC_OS = 'darwin';
export const WINDOWS = 'win32';
export const LINUX = 'linux';
export const OS_NAMES = {
  [MAC_OS]: 'macOS',
  [WINDOWS]: 'Windows',
  [LINUX]: 'Linux',
};
<|endoftext|>


<commit_before>// Code goes here

/*
 * Although the following code work, it does not scale well. The problem
 * is that each of the names, `createWorker` and `worker` are
 * **global**. In our current situation, having these two variables in
 * the global namespace causes no problems.
 *
 * Now imagine a situation in which this script is part of many
 * different scripts bundled together on a page. Unfortunately, naming a
 * variable, `worker` and naming a function, `createWorker` is
 * **common**. Many of our team members have similar names in our code.
 *
 * When we attempt to run this code together with our co-workers, we now
 * have a problem. When the JavaScript interpreter encounters the name,
 * `worker`, which value is it it bound to? If my teammates script
 * changed the value to which `worker` is bound **before** I evaluate
 * the expression `worker.job1()`, what will happen? We just do not
 * know. :()
 */

/*
 * Adding an enclosing scope can reduce **many* global names to a single
 * name.
 */
var program = function() {
	var createWorker = function() {

		/*
		 * Remember that any variables defined in this function are
		 * only visible within this function; that is, they are private. But
		 * they **are** visible to functions defined within this function.
		 */
		var workerCount = 0;

		/*
		 * `task1` is the name of an **internal** function. It is **not**
		 * exposed to consumers of the returned value.
		 *
		 * `task1` increments the local (private) variable `workerCount` and
		 * then logs its value.
		 */
		var task1 = function() {
			workerCount++;
			console.log("task1", workerCount);
		}

		/*
		 * Similarly, `task2` is another internal function. Because of
		 * JavaScript scoping rules, its name is only available in the scope
		 * of `createWorker` (and any enclosed scopes).
		 *
		 * Similarly, `task2` increments the private variable `workerCount`.
		 *
		 */
		var task2 = function() {
			workerCount++;
			console.log("task2", workerCount);
		}

		/*
		 * Finally, we return an object. The returned object exposes two
		 * members, `job1` and `job2` which are bound to the internal
		 * functions that do our work.
		 */
		return {
			job1: task1,
			job2: task2
		}
	}

	var worker = createWorker();

	/*
	 * We invoke `task1` and `task2`, from the global scope but we
	 * "see" neither `task1 nor `task2`. But we do see their result. :)
	 *
	 * Invoking `job1` and `job2` increments the variable `workerCount`
	 * which is only local to the `createWorker` function.
	 */
	worker.job1();
	worker.job2();
	worker.job2();
	worker.job2();
}

/*
 * We now invoke a **single** function to do all our work. Notice that
 * our script still has the same **behavior** as the previous versions;
 * however, it "pollutes" the global scope far, far less because it only
 * defines a single, global name.
 */
program();
<commit_msg>Error executing an anonymous JavaScript function<commit_after>// Code goes here

/*
 * To avoid polluting the global scope, suppose I simply create an
 * anonymous function and then immediately invoke it?
 *
 * Although it seems this should work, it actually generates a syntax
 * error. (I do not understand why. This error differs from the issue
 * describe in the Pluralsight video.)
 *
 * On refreshing the page, the console has the error:
 *
 *     Uncaught SyntaxError: Unexpected token (
 *
 * The console function indicates that this error occurs at line 7 of
 * the script:
 *
 * 		`function() {`
 */
function() {
	var createWorker = function() {

		/*
		 * Remember that any variables defined in this function are
		 * only visible within this function; that is, they are private. But
		 * they **are** visible to functions defined within this function.
		 */
		var workerCount = 0;

		/*
		 * `task1` is the name of an **internal** function. It is **not**
		 * exposed to consumers of the returned value.
		 *
		 * `task1` increments the local (private) variable `workerCount` and
		 * then logs its value.
		 */
		var task1 = function() {
			workerCount++;
			console.log("task1", workerCount);
		}

		/*
		 * Similarly, `task2` is another internal function. Because of
		 * JavaScript scoping rules, its name is only available in the scope
		 * of `createWorker` (and any enclosed scopes).
		 *
		 * Similarly, `task2` increments the private variable `workerCount`.
		 *
		 */
		var task2 = function() {
			workerCount++;
			console.log("task2", workerCount);
		}

		/*
		 * Finally, we return an object. The returned object exposes two
		 * members, `job1` and `job2` which are bound to the internal
		 * functions that do our work.
		 */
		return {
			job1: task1,
			job2: task2
		}
	}

	var worker = createWorker();

	/*
	 * We invoke `task1` and `task2`, from the global scope but we
	 * "see" neither `task1 nor `task2`. But we do see their result. :)
	 *
	 * Invoking `job1` and `job2` increments the variable `workerCount`
	 * which is only local to the `createWorker` function.
	 */
	worker.job1();
	worker.job2();
	worker.job2();
	worker.job2();
}();

<|endoftext|>


<commit_before>	function handleSingleClick(shape){
        var data_class = $(shape).attr("data-class");
            if(data_class == "feature"){
                var data_index = $(shape).attr("data-index");
                document.getElementById("lastClickedObject").innerHTML = data_class + " " + data_index;
                showRelationsForNode(data_index);
            }
			if(data_class == "relation"){
				var shape_type = $(shape).attr("def");
				var first = shape.getAttribute("data-firstId");
				var second = shape.getAttribute("data-secondId");
                document.getElementById("lastClickedObject").innerHTML = data_class + " " +shape_type +" "+first + " "+ second;
				changeRelation(shape);
            }
            else{
				document.getElementById("lastClickedObject").innerHTML = data_class + " false";
            }
    }

    function showRelationsForNode(nodeId) {
        var x = document.getElementsByTagName("shape");
        var i;
        for (i = 0; i < x.length; i++) {
            var data_class = x[i].getAttribute("data-class");
            if(data_class == "relation"){
                var firstId = x[i].getAttribute("data-firstId");
                var secondId = x[i].getAttribute("data-secondId");
                if(firstId == nodeId || secondId == nodeId){
                    x[i].render = "true";
                }
                else{
                    x[i].render = "false";
                }
            }
        }
    }

    function showAllRelations() {
        var x = document.getElementsByTagName("shape");
        var i;
        for (i = 0; i < x.length; i++) {
            var data_class = x[i].getAttribute("data-class");
            if(data_class == "relation"){
                x[i].render = "true";
            }
        }
    }

	function addNewColor(){
		var table = document.getElementById("colorTable");
		var done = false;

		var newInputColor = document.getElementById("NewInputColor").value;
		var newOutputColor = document.getElementById("NewOutputColor").value;

		if((newInputColor.split(" ")).length == 1){
			newInputColor = parseFloat(newInputColor);
		}

		newOutputColor = newOutputColor.split(" ");

		if(newOutputColor.length == 3){
			var red = parseFloat(newOutputColor[0]);
			var green = parseFloat(newOutputColor[1]);
			var blue = parseFloat(newOutputColor[2]);

			if( !isNaN(newInputColor) && red>=0 && red<=1 && green>=0 && green<=1 && blue>=0 && blue<=1 ){
				var valuePresent = false;
				var i = 1;
				var table_length = table.rows.length;

				for(;i<table_length;i++){
					if (parseFloat(table.rows[i].cells[0].innerHTML) == newInputColor){
						valuePresent = true;
						break;
					}
				}

				if(!valuePresent){
					var rows = table.rows.length;
					var newRow = table.insertRow(rows);
					var inputColor = newRow.insertCell(0);
					var outputColor = newRow.insertCell(1);
					inputColor.innerHTML = newInputColor;
					outputColor.innerHTML = red + " "+green +" "+blue;
				}
				else{
					table.rows[i].cells[1].innerHTML = red + " "+green +" "+blue;
				}
				done = true;
			}

		}

		if(done){
			document.getElementById("NewInputColor").value = "";
			document.getElementById("NewOutputColor").value = "";
		}

	}

	function addNewWidth(){
		var done = false;
		var table = document.getElementById("widthTable");

		var newInputWidth = document.getElementById("NewInputWidth").value;
		var newOutputWidth = document.getElementById("NewOutputWidth").value;

		if( (newInputWidth.split(" ")).length == 1 && (newOutputWidth.split(" ")).length == 1){
			newInputWidth = parseFloat(newInputWidth);
			newOutputWidth = parseFloat(newOutputWidth);
		}

		if( !isNaN(newInputWidth) && !isNaN(newOutputWidth) ){

			var valuePresent = false;
			var i = 1;
			var table_length = table.rows.length;

			for(;i<table_length;i++){
				if (parseFloat(table.rows[i].cells[0].innerHTML) == newInputWidth){
					valuePresent = true;
					break;
				}
			}

			if(!valuePresent){
				var rows = table.rows.length;
				var newRow = table.insertRow(rows);
				var inputWidth = newRow.insertCell(0);
				var outputWidth = newRow.insertCell(1);
				inputWidth.innerHTML = newInputWidth;
				outputWidth.innerHTML = newOutputWidth;
			}
			else{
				table.rows[i].cells[1].innerHTML = newOutputWidth;
			}
			done = true;
		}
		if(done){
			document.getElementById("NewInputWidth").value = "";
			document.getElementById("NewOutputWidth").value = "";
		}

	}

	function deleteNewColor(){
		var table = document.getElementById("colorTable");
		var rows = document.getElementById("colorTable").rows.length;
		table.deleteRow(rows-1);
	}

	function deleteNewWidth(){
		var table = document.getElementById("widthTable");
		var rows = document.getElementById("widthTable").rows.length;
		table.deleteRow(rows-1);
	}
	function sortColorTable(f,n){
	  var rows = $('#colorTable tbody  tr').get();

	  rows.sort(function(a, b) {

	  var A = $(a).children('td').eq(n).text().toUpperCase();
	  var B = $(b).children('td').eq(n).text().toUpperCase();

	  A = parseFloat(A);
	  B = parseFloat(B);

	  if(A < B) {
		return 1*f;
	  }
	  if(A > B) {
		return -1*f;
	  }
	  return 0;
	  });

	  $.each(rows, function(index, row) {
		$('#colorTable').children('tbody').append(row);
	  });
	}

	function sortColorFunction(){
		var f_sl = 1;
		f_sl *= -1;
		var n = 0;
		sortColorTable(f_sl,n);
	};

	function sortWidthTable(f,n){
	  var rows = $('#widthTable tbody  tr').get();

	  rows.sort(function(a, b) {

	  var A = $(a).children('td').eq(n).text().toUpperCase();
	  var B = $(b).children('td').eq(n).text().toUpperCase();

	  A = parseFloat(A);
	  B = parseFloat(B);

	  if(A < B) {
		return 1*f;
	  }
	  if(A > B) {
		return -1*f;
	  }
	  return 0;
	  });

	  $.each(rows, function(index, row) {
		$('#widthTable').children('tbody').append(row);
	  });
	}

	function sortWidthFunction(){
		var f_sl = 1;
		f_sl *= -1;
		var n = 0;
		sortWidthTable(f_sl,n);
	};

	function getInputColors(){
		var inputColors = []
		var table = document.getElementById("colorTable");
		var table_length = table.rows.length;

		for(var i = 1;i<table_length;i++){
			var inputColorValue = table.rows[i].cells[0].innerHTML;
			inputColors.push(inputColorValue);
		}
		return inputColors;
	};

	function getOutputColors(){
		var outputColors = []
		var table = document.getElementById("colorTable");
		var table_length = table.rows.length;

		for(var i = 1;i<table_length;i++){
			var outputColorValue = table.rows[i].cells[1].innerHTML;
			outputColorValue = outputColorValue.split(" ");
			var red = parseFloat(outputColorValue[0]);
			var green = parseFloat(outputColorValue[1]);
			var blue = parseFloat(outputColorValue[2]);
			var color = new T3dColor("RGB", red, green, blue, 1);
			outputColors.push(color);
		}
		return outputColors;
	};

	function getInputWidths(){
		var inputWidths = []
		var table = document.getElementById("widthTable");
		var table_length = table.rows.length;

		for(var i = 1;i<table_length;i++){
			var inputWidthValue = table.rows[i].cells[0].innerHTML;
			inputWidths.push(inputWidthValue);
		}
		return inputWidths;
	};

	function getOutputWidths(){
		var outputWidths = []
		var table = document.getElementById("widthTable");
		var table_length = table.rows.length;

		for(var i = 1;i<table_length;i++){
			var outputWidthValue = table.rows[i].cells[1].innerHTML;
			outputWidths.push(outputWidthValue);
		}
		return outputWidths;
	};

	function getColorMapper(){
		sortColorFunction();
		var inputColors = getInputColors();
		var outputColors = getOutputColors();

		var colorMapper = new MpSimpleHypsometricColor();
		colorMapper.setPalette(inputColors, outputColors, true);
		return colorMapper;
	}

	function getWidthMapper(){
		sortWidthFunction();
		var inputWidths = getInputWidths();
		var outputWidths = getOutputWidths();

		var widthMapper = new MpValue2NumericExtent();
		widthMapper.setPalette(inputWidths, outputWidths, true);
		return widthMapper;
	}

	function changeColors(nodeId) {
		var colorMapper = getColorMapper();
        var x = document.getElementsByTagName("material");
        var i;
        for (i = 0; i < x.length; i++) {
			if(x[i].hasAttribute("data-weight")){
				var data_weight = x[i].getAttribute("data-weight");
				data_weight = parseFloat(data_weight);
				var transformedColor = colorMapper.transform(data_weight);
				var red = transformedColor.mRed;
				var green = transformedColor.mGreen;
				var blue = transformedColor.mBlue;
				var color = red + ' '+ blue + ' ' + green;
				x[i].setAttribute('diffuseColor', color);
			}
        }
    }

    function changeRelation(relation) {
        var x = document.getElementsByTagName("shape");
		var shape_type = relation.getAttribute("def");
		if(shape_type == "ellipseShape"){
			shape_type = "cylinderShape";
		}
		else if(shape_type == "cylinderShape"){
			shape_type = "ribbonShape";
		}
		else if(shape_type == "ribbonShape"){
			shape_type = "ellipseShape";
		}
		else{
			shape_type = "cylinderShape";
		}

		var first_id = relation.getAttribute("data-firstId");
		var second_id = relation.getAttribute("data-secondId");

        var i;
        for (i = 0; i < x.length; i++) {
            if(x[i].getAttribute("data-class") == "relation" &&
			x[i].getAttribute("data-firstId") == first_id &&
			x[i].getAttribute("data-secondId") == second_id &&
			x[i].getAttribute("def") == shape_type){
                    x[i].render = "true";

            }
        }
		relation.render = "false";
    }

    $(document).ready(function(){
        $("shape").each(function() {
            $(this).attr("onclick", "handleSingleClick(this)");
        });
    });
<commit_msg>Removed bug that just displayed a cone<commit_after>	function handleSingleClick(shape){
        var data_class = $(shape).attr("data-class");
            if(data_class == "feature"){
                var data_index = $(shape).attr("data-index");
                document.getElementById("lastClickedObject").innerHTML = data_class + " " + data_index;
                showRelationsForNode(data_index);
            }
			if(data_class == "relation"){
				var shape_type = $(shape).attr("def");
				var first = shape.getAttribute("data-firstId");
				var second = shape.getAttribute("data-secondId");
                document.getElementById("lastClickedObject").innerHTML = data_class + " " +shape_type +" "+first + " "+ second;
				changeRelation(shape);
            }
            else{
				document.getElementById("lastClickedObject").innerHTML = data_class + " false";
            }
    }

    function showRelationsForNode(nodeId) {
        var x = document.getElementsByTagName("shape");
        var i;
        for (i = 0; i < x.length; i++) {
            var data_class = x[i].getAttribute("data-class");
            if(data_class == "relation"){
                var firstId = x[i].getAttribute("data-firstId");
                var secondId = x[i].getAttribute("data-secondId");
                if(firstId == nodeId || secondId == nodeId){
                    x[i].render = "true";
                }
                else{
                    x[i].render = "false";
                }
            }
        }
    }

    function showAllRelations() {
        var x = document.getElementsByTagName("shape");
        var i;
        for (i = 0; i < x.length; i++) {
            var data_class = x[i].getAttribute("data-class");
            if(data_class == "relation"){
                x[i].render = "true";
            }
        }
    }

	function addNewColor(){
		var table = document.getElementById("colorTable");
		var done = false;

		var newInputColor = document.getElementById("NewInputColor").value;
		var newOutputColor = document.getElementById("NewOutputColor").value;

		if((newInputColor.split(" ")).length == 1){
			newInputColor = parseFloat(newInputColor);
		}

		newOutputColor = newOutputColor.split(" ");

		if(newOutputColor.length == 3){
			var red = parseFloat(newOutputColor[0]);
			var green = parseFloat(newOutputColor[1]);
			var blue = parseFloat(newOutputColor[2]);

			if( !isNaN(newInputColor) && red>=0 && red<=1 && green>=0 && green<=1 && blue>=0 && blue<=1 ){
				var valuePresent = false;
				var i = 1;
				var table_length = table.rows.length;

				for(;i<table_length;i++){
					if (parseFloat(table.rows[i].cells[0].innerHTML) == newInputColor){
						valuePresent = true;
						break;
					}
				}

				if(!valuePresent){
					var rows = table.rows.length;
					var newRow = table.insertRow(rows);
					var inputColor = newRow.insertCell(0);
					var outputColor = newRow.insertCell(1);
					inputColor.innerHTML = newInputColor;
					outputColor.innerHTML = red + " "+green +" "+blue;
				}
				else{
					table.rows[i].cells[1].innerHTML = red + " "+green +" "+blue;
				}
				done = true;
			}

		}

		if(done){
			document.getElementById("NewInputColor").value = "";
			document.getElementById("NewOutputColor").value = "";
		}

	}

	function addNewWidth(){
		var done = false;
		var table = document.getElementById("widthTable");

		var newInputWidth = document.getElementById("NewInputWidth").value;
		var newOutputWidth = document.getElementById("NewOutputWidth").value;

		if( (newInputWidth.split(" ")).length == 1 && (newOutputWidth.split(" ")).length == 1){
			newInputWidth = parseFloat(newInputWidth);
			newOutputWidth = parseFloat(newOutputWidth);
		}

		if( !isNaN(newInputWidth) && !isNaN(newOutputWidth) ){

			var valuePresent = false;
			var i = 1;
			var table_length = table.rows.length;

			for(;i<table_length;i++){
				if (parseFloat(table.rows[i].cells[0].innerHTML) == newInputWidth){
					valuePresent = true;
					break;
				}
			}

			if(!valuePresent){
				var rows = table.rows.length;
				var newRow = table.insertRow(rows);
				var inputWidth = newRow.insertCell(0);
				var outputWidth = newRow.insertCell(1);
				inputWidth.innerHTML = newInputWidth;
				outputWidth.innerHTML = newOutputWidth;
			}
			else{
				table.rows[i].cells[1].innerHTML = newOutputWidth;
			}
			done = true;
		}
		if(done){
			document.getElementById("NewInputWidth").value = "";
			document.getElementById("NewOutputWidth").value = "";
		}

	}

	function deleteNewColor(){
		var table = document.getElementById("colorTable");
		var rows = document.getElementById("colorTable").rows.length;
		table.deleteRow(rows-1);
	}

	function deleteNewWidth(){
		var table = document.getElementById("widthTable");
		var rows = document.getElementById("widthTable").rows.length;
		table.deleteRow(rows-1);
	}
	function sortColorTable(f,n){
	  var rows = $('#colorTable tbody  tr').get();

	  rows.sort(function(a, b) {

	  var A = $(a).children('td').eq(n).text().toUpperCase();
	  var B = $(b).children('td').eq(n).text().toUpperCase();

	  A = parseFloat(A);
	  B = parseFloat(B);

	  if(A < B) {
		return 1*f;
	  }
	  if(A > B) {
		return -1*f;
	  }
	  return 0;
	  });

	  $.each(rows, function(index, row) {
		$('#colorTable').children('tbody').append(row);
	  });
	}

	function sortColorFunction(){
		var f_sl = 1;
		f_sl *= -1;
		var n = 0;
		sortColorTable(f_sl,n);
	};

	function sortWidthTable(f,n){
	  var rows = $('#widthTable tbody  tr').get();

	  rows.sort(function(a, b) {

	  var A = $(a).children('td').eq(n).text().toUpperCase();
	  var B = $(b).children('td').eq(n).text().toUpperCase();

	  A = parseFloat(A);
	  B = parseFloat(B);

	  if(A < B) {
		return 1*f;
	  }
	  if(A > B) {
		return -1*f;
	  }
	  return 0;
	  });

	  $.each(rows, function(index, row) {
		$('#widthTable').children('tbody').append(row);
	  });
	}

	function sortWidthFunction(){
		var f_sl = 1;
		f_sl *= -1;
		var n = 0;
		sortWidthTable(f_sl,n);
	};

	function getInputColors(){
		var inputColors = []
		var table = document.getElementById("colorTable");
		var table_length = table.rows.length;

		for(var i = 1;i<table_length;i++){
			var inputColorValue = table.rows[i].cells[0].innerHTML;
			inputColors.push(inputColorValue);
		}
		return inputColors;
	};

	function getOutputColors(){
		var outputColors = []
		var table = document.getElementById("colorTable");
		var table_length = table.rows.length;

		for(var i = 1;i<table_length;i++){
			var outputColorValue = table.rows[i].cells[1].innerHTML;
			outputColorValue = outputColorValue.split(" ");
			var red = parseFloat(outputColorValue[0]);
			var green = parseFloat(outputColorValue[1]);
			var blue = parseFloat(outputColorValue[2]);
			var color = new T3dColor("RGB", red, green, blue, 1);
			outputColors.push(color);
		}
		return outputColors;
	};

	function getInputWidths(){
		var inputWidths = []
		var table = document.getElementById("widthTable");
		var table_length = table.rows.length;

		for(var i = 1;i<table_length;i++){
			var inputWidthValue = table.rows[i].cells[0].innerHTML;
			inputWidths.push(inputWidthValue);
		}
		return inputWidths;
	};

	function getOutputWidths(){
		var outputWidths = []
		var table = document.getElementById("widthTable");
		var table_length = table.rows.length;

		for(var i = 1;i<table_length;i++){
			var outputWidthValue = table.rows[i].cells[1].innerHTML;
			outputWidths.push(outputWidthValue);
		}
		return outputWidths;
	};

	function getColorMapper(){
		sortColorFunction();
		var inputColors = getInputColors();
		var outputColors = getOutputColors();

		var colorMapper = new MpSimpleHypsometricColor();
		colorMapper.setPalette(inputColors, outputColors, true);
		return colorMapper;
	}

	function getWidthMapper(){
		sortWidthFunction();
		var inputWidths = getInputWidths();
		var outputWidths = getOutputWidths();

		var widthMapper = new MpValue2NumericExtent();
		widthMapper.setPalette(inputWidths, outputWidths, true);
		return widthMapper;
	}

	function changeColors(nodeId) {
		var colorMapper = getColorMapper();
        var x = document.getElementsByTagName("material");
        var i;
        for (i = 0; i < x.length; i++) {
			if(x[i].hasAttribute("data-weight")){
				var data_weight = x[i].getAttribute("data-weight");
				data_weight = parseFloat(data_weight);
				var transformedColor = colorMapper.transform(data_weight);
				var red = transformedColor.mRed;
				var green = transformedColor.mGreen;
				var blue = transformedColor.mBlue;
				var color = red + ' '+ blue + ' ' + green;
				x[i].setAttribute('diffuseColor', color);
			}
        }
    }

    function changeRelation(relation) {
        var x = document.getElementsByTagName("shape");
		var shape_type = relation.getAttribute("def");
		if(shape_type == "ellipseShape"){
			shape_type = "cylinderShape";
		}
		else if(shape_type == "cylinderShape"){
			shape_type = "ribbonShape";
		}
		else if(shape_type == "ribbonShape"){
			shape_type = "ellipseShape";
		}

		var first_id = relation.getAttribute("data-firstId");
		var second_id = relation.getAttribute("data-secondId");

        var i;
        for (i = 0; i < x.length; i++) {
            if(x[i].getAttribute("data-class") == "relation" &&
			x[i].getAttribute("data-firstId") == first_id &&
			x[i].getAttribute("data-secondId") == second_id &&
			x[i].getAttribute("def") == shape_type){
                    x[i].render = "true";

            }
        }
		if(shape_type != "arrowConeShape" || shape_type != "arrowCylinderShape"){
			relation.render = "false";
		}
    }

    $(document).ready(function(){
        $("shape").each(function() {
            $(this).attr("onclick", "handleSingleClick(this)");
        });
    });
<|endoftext|>


<commit_before>/// <reference path="../declares.d.ts" />
'use strict';
define(["require", "exports"], function (require, exports) {
    exports.language = {
        displayName: 'ObjectPascal',
        name: 'objectpascal',
        mimeTypes: [],
        ignoreCase: true,
        defaultToken: '',
        lineComment: '//',
        blockCommentStart: '{',
        blockCommentEnd: '}',

        brackets: [
            { token: 'delimiter.array', open: '[', close: ']' },
            { token: 'delimiter.parenthesis', open: '(', close: ')' },
            { token: 'delimiter.generic', open: '<', close: '>' },
            { token: 'keyword.tag-begin', open: 'begin', close: 'end' },
            { token: 'keyword.tag-begin', open: 'try', close: 'end' },
            { token: 'keyword.tag-begin', open: 'class', close: 'end' },
            { token: 'keyword.tag-begin', open: 'interface', close: 'end' },
            { token: 'keyword.tag-begin', open: 'unit', close: 'end' },
            { token: 'keyword.tag-begin', open: 'program', close: 'end' },
            //{ token: 'keyword.tag-program', open: 'program', close: 'end.' },
            //{ token: 'keyword.tag-try', open: 'try', close: 'end' },
        ],
        /*
        enhancedBrackets: [
            { open: /begin$/i, closeComplete: 'end' },
            { open: /unit$/i, closeComplete: 'end' },
        ],      */
        textAfterBrackets: true,

        // the default separators except `@$`
        wordDefinition: /(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
        keywords: [
        'ABSOLUTE',
        'ABSTRACT',
        'AND',
        'ARRAY',
        'ASM',
        'ASSEMBLER',
        'BEGIN',
        'CASE',
        'CONST',
        'CONSTRUCTOR',
        'DESTRUCTOR',
        'DIV',
        'DO',
        'DOWNTO',
        'ELSE',
        'END',
        'EXCEPT',
        'EXPORTS',
        'EXTERNAL',
        'FAR',
        'FALSE',
        'FILE',
        'FINALLY',
        'FOR',
        'FORWARD',
        'FUNCTION',
        'GOTO',
        'HELPER',
        'IF',
        'IMPLEMENTATION',
        'IN',
        'INDEX',
        'INHERITED',
        'INLINE',
        'INTERFACE',
        'INTERRUPT',
        'LABEL',
        'LIBRARY',
        'MOD',
        'NAME',
        'NEAR',
        'NIL',
        'NOT',
        'OBJECT',
        'OF',
        'ON',
        'OR',
        'PACKED',
        'POINTER',
        'PRIVATE',
        'PROCEDURE',
        'PROGRAM',
        'PROTECTED',
        'PUBLIC',
        'PUBLISHED',
        'RECORD',
        'REFERENCE',
        'REPEAT',
        'RESIDENT',
        'SET',
        'SHL',
        'SHR',
        'STATIC',
        'STDCALL',
        'STRING',
        'THEN',
        'TO',
        'TRUE',
        'TRY',
        'TYPE',
        'UNIT',
        'UNTIL',
        'USES',
        'VAR',
        'VIRTUAL',
        'WHILE',
        'WITH',
        'XOR',
        ],

        tagwords: [
            'begin',
            'try',
            'unit',
            'class',
            'program',
            'interface',
            'end'
        ],
        operators: [
            '=',
            '>',
            '<',
            '!',
            '~',
            '?',
            ':',
            '==',
            '<=',
            '>=',
            '!=',
            '&&',
            '||',
            '++',
            '--',
            '+',
            '-',
            '*',
            '/',
            '&',
            '|',
            '^',
            '%',
            '<<',
            '>>',
            '>>>',
            '+=',
            '-=',
            '*=',
            '/=',
            '&=',
            '|=',
            '^=',
            '%=',
            '<<=',
            '>>=',
            '>>>='
        ],
        // we include these common regular expressions
        symbols: /[=><!~?:&|+\-*\/\^%]+/,
        escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
        // The main tokenizer for our languages
        tokenizer: {
            root: [
                //[/[a-zA-Z_$][\w$]*/, { cases: { '@keywords': { token: 'keyword.$0' }, '@default': 'identifier' } }],
                { include: '@whitespace' },
                //[/end\w*/, { token: 'keyword.tag-begin', bracket: '@close' }],
                //[/[a-zA-Z_]\w*/, { cases: { '@tagwords': { token: 'keyword.tag-$0', bracket: '@open' }, '@keywords': { token: 'keyword.$0' }, '@default': 'identifier' } }],
                [/[a-zA-Z_]\w*/, { cases: { '@tagwords': '@brackets', '@keywords': { token: 'keyword.$0' }, '@default': 'identifier' } }],
                [/[{}()\[\]]/, '@brackets'],
                [/[<>](?!@symbols)/, '@brackets'],
                [/@symbols/, { cases: { '@operators': 'delimiter', '@default': '' } }],
                ///[a-zA-Z_]\w*/, { cases: { '@tagwords': { token: 'keyword.tag-$0', bracket: '@open' }, '@keywords': { token: 'keyword.$0' }, '@default': 'identifier' } }],
                //[/\{/, 'comment', '@comment'],
                [/@\s*[a-zA-Z_\$][\w\$]*/, 'annotation'],
                [/\d*\d+[eE]([\-+]?\d+)?[fFdD]?/, 'number.float'],
                [/\d*\.\d+([eE][\-+]?\d+)?[fFdD]?/, 'number.float'],
                [/0[xX][0-9a-fA-F_]*[0-9a-fA-F][Ll]?/, 'number.hex'],
                [/0[0-7_]*[0-7][Ll]?/, 'number.octal'],
                [/0[bB][0-1_]*[0-1][Ll]?/, 'number.binary'],
                [/\d+[fFdD]/, 'number.float'],
                [/\d+[lL]?/, 'number'],
                [/[;,.]/, 'delimiter'],
                [/'([^'\\]|\\.)*$/, 'string.invalid'],
                [/'/, 'string', '@string'],
                [/'[^\\']'/, 'string'],
                [/(')(@escapes)(')/, ['string', 'string.escape', 'string']],
                [/'/, 'string.invalid']
            ],
            whitespace: [
                [/[ \t\r\n]+/, ''],
                [/{/, 'comment', '@comment'],
                [/\(\*/, 'comment', '@comment'],
                [/\/\/.*$/, 'comment'],
            ],

            comment: [
                [/[^}]+/, 'comment'],
                [/}/, 'comment', '@pop'],
                [/{/, 'comment'],

                [/[^\*]+/, 'comment'],
                [/\*\)/, 'comment', '@pop'],
                [/\*/, 'comment']
            ],

            /*
            comment: [
                [/[^\{]+/, 'comment'],
                ['\\}', 'comment', '@pop'],
                [/[\}]/, 'comment']
            ],
            */
            string: [
                [/[^\\']+/, 'string'],
                [/@escapes/, 'string.escape'],
                [/\\./, 'string.escape.invalid'],
                [/'/, 'string', '@pop']
            ],
        },
    };
});
<commit_msg>Added some keywords<commit_after>/// <reference path="../declares.d.ts" />
'use strict';
define(["require", "exports"], function (require, exports) {
    exports.language = {
        displayName: 'ObjectPascal',
        name: 'objectpascal',
        mimeTypes: [],
        ignoreCase: true,
        defaultToken: '',
        lineComment: '//',
        blockCommentStart: '{',
        blockCommentEnd: '}',

        brackets: [
            { token: 'delimiter.array', open: '[', close: ']' },
            { token: 'delimiter.parenthesis', open: '(', close: ')' },
            { token: 'delimiter.generic', open: '<', close: '>' },
            { token: 'keyword.tag-begin', open: 'begin', close: 'end' },
            { token: 'keyword.tag-begin', open: 'try', close: 'end' },
            { token: 'keyword.tag-begin', open: 'class', close: 'end' },
            { token: 'keyword.tag-begin', open: 'interface', close: 'end' },
            { token: 'keyword.tag-begin', open: 'unit', close: 'end' },
            { token: 'keyword.tag-begin', open: 'program', close: 'end' },
            //{ token: 'keyword.tag-program', open: 'program', close: 'end.' },
            //{ token: 'keyword.tag-try', open: 'try', close: 'end' },
        ],
        /*
        enhancedBrackets: [
            { open: /begin$/i, closeComplete: 'end' },
            { open: /unit$/i, closeComplete: 'end' },
        ],      */
        textAfterBrackets: true,

        // the default separators except `@$`
        wordDefinition: /(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
        keywords: [
            'ABSOLUTE',
            'ABSTRACT',
            'AND',
            'ARRAY',
            'ASM',
            'ASSEMBLER',
            'BEGIN',
            'CASE',
            'CONST',
            'CONSTRUCTOR',
            'DESTRUCTOR',
            'DIV',
            'DO',
            'DOWNTO',
            'ELSE',
            'END',
            'EXCEPT',
            'EXPORTS',
            'EXTERNAL',
            'FAR',
            'FALSE',
            'FILE',
            'FINALLY',
            'FINALIZATION',
            'FOR',
            'FORWARD',
            'FUNCTION',
            'GOTO',
            'HELPER',
            'IF',
            'IMPLEMENTATION',
            'IN',
            'INDEX',
            'INHERITED',
            'INITIALIZATION',
            'INLINE',
            'INTERFACE',
            'INTERRUPT',
            'LABEL',
            'LIBRARY',
            'MESSAGE',
            'MOD',
            'NAME',
            'NEAR',
            'NIL',
            'NOT',
            'OBJECT',
            'OF',
            'ON',
            'OR',
            'PACKED',
            'POINTER',
            'PRIVATE',
            'PROCEDURE',
            'PROGRAM',
            'PROPERTY',
            'PROTECTED',
            'PUBLIC',
            'PUBLISHED',
            'READ',
            'RECORD',
            'REFERENCE',
            'REPEAT',
            'RESIDENT',
            'SET',
            'SHL',
            'SHR',
            'STATIC',
            'STDCALL',
            'STRING',
            'THEN',
            'TO',
            'TRUE',
            'TRY',
            'TYPE',
            'UNIT',
            'UNTIL',
            'USES',
            'VAR',
            'VIRTUAL',
            'WHILE',
            'WRITE',
            'WITH',
            'XOR',
        ],

        tagwords: [
            'begin',
            'try',
            'unit',
            'class',
            'program',
            'interface',
            'end'
        ],
        operators: [
            '=',
            '>',
            '<',
            '!',
            '~',
            '?',
            ':',
            '==',
            '<=',
            '>=',
            '!=',
            '&&',
            '||',
            '++',
            '--',
            '+',
            '-',
            '*',
            '/',
            '&',
            '|',
            '^',
            '%',
            '<<',
            '>>',
            '>>>',
            '+=',
            '-=',
            '*=',
            '/=',
            '&=',
            '|=',
            '^=',
            '%=',
            '<<=',
            '>>=',
            '>>>='
        ],
        // we include these common regular expressions
        symbols: /[=><!~?:&|+\-*\/\^%]+/,
        escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
        // The main tokenizer for our languages
        tokenizer: {
            root: [
                //[/[a-zA-Z_$][\w$]*/, { cases: { '@keywords': { token: 'keyword.$0' }, '@default': 'identifier' } }],
                { include: '@whitespace' },
                //[/end\w*/, { token: 'keyword.tag-begin', bracket: '@close' }],
                //[/[a-zA-Z_]\w*/, { cases: { '@tagwords': { token: 'keyword.tag-$0', bracket: '@open' }, '@keywords': { token: 'keyword.$0' }, '@default': 'identifier' } }],
                [/[a-zA-Z_]\w*/, { cases: { '@tagwords': '@brackets', '@keywords': { token: 'keyword.$0' }, '@default': 'identifier' } }],
                [/[{}()\[\]]/, '@brackets'],
                [/[<>](?!@symbols)/, '@brackets'],
                [/@symbols/, { cases: { '@operators': 'delimiter', '@default': '' } }],
                ///[a-zA-Z_]\w*/, { cases: { '@tagwords': { token: 'keyword.tag-$0', bracket: '@open' }, '@keywords': { token: 'keyword.$0' }, '@default': 'identifier' } }],
                //[/\{/, 'comment', '@comment'],
                [/@\s*[a-zA-Z_\$][\w\$]*/, 'annotation'],
                [/\d*\d+[eE]([\-+]?\d+)?[fFdD]?/, 'number.float'],
                [/\d*\.\d+([eE][\-+]?\d+)?[fFdD]?/, 'number.float'],
                [/0[xX][0-9a-fA-F_]*[0-9a-fA-F][Ll]?/, 'number.hex'],
                [/0[0-7_]*[0-7][Ll]?/, 'number.octal'],
                [/0[bB][0-1_]*[0-1][Ll]?/, 'number.binary'],
                [/\d+[fFdD]/, 'number.float'],
                [/\d+[lL]?/, 'number'],
                [/[;,.]/, 'delimiter'],
                [/'([^'\\]|\\.)*$/, 'string.invalid'],
                [/'/, 'string', '@string'],
                [/'[^\\']'/, 'string'],
                [/(')(@escapes)(')/, ['string', 'string.escape', 'string']],
                [/'/, 'string.invalid']
            ],
            whitespace: [
                [/[ \t\r\n]+/, ''],
                [/{/, 'comment', '@comment'],
                [/\(\*/, 'comment', '@comment'],
                [/\/\/.*$/, 'comment'],
            ],

            comment: [
                [/[^}]+/, 'comment'],
                [/}/, 'comment', '@pop'],
                [/{/, 'comment'],

                [/[^\*]+/, 'comment'],
                [/\*\)/, 'comment', '@pop'],
                [/\*/, 'comment']
            ],

            /*
            comment: [
                [/[^\{]+/, 'comment'],
                ['\\}', 'comment', '@pop'],
                [/[\}]/, 'comment']
            ],
            */
            string: [
                [/[^\\']+/, 'string'],
                [/@escapes/, 'string.escape'],
                [/\\./, 'string.escape.invalid'],
                [/'/, 'string', '@pop']
            ],
        },
    };
});
<|endoftext|>


<commit_before>
var myDashboards = [];
var myDashboardIndex = 0;
var myDashboardRefreshInterval = 10000;

// Render our page title
var renderChatrouletteTitle = function(name) {
  $('.header h1').find('span').remove();
  $('.header h1').append(' - ' + name + '');
}

var renderGraphs = function() {
  $.ajax({
    accepts: {json: 'application/json'},
    cache: false,
    dataType: 'json',
    error: function(xhr, textStatus, errorThrown) { console.log(errorThrown); },
    url: '/chartroulette'
  }).done(function(d) {
    if (d.length > 0) {
      myDashboards = d;
      renderNextDashboard();
      setInterval(function() {
        clearGraphs();
        renderNextDashboard();
      }, myDashboardRefreshInterval);
    } else {
      $('div.graphs').append('
Oops!
');
      $('div.graphs').append("
Sorry, we don't have anything to show you yet. Why don't you favorite (star) a couple dashboards and come back again?");
      console.log('no favorited dashboards to display');
    }
  });
}

var renderNextDashboard = function() {
  return $.ajax({
    accepts: {json: 'application/json'},
    cache: false,
    dataType: 'json',
    error: function(xhr, textStatus, errorThrown) { console.log(errorThrown); },
    url: '/dashboards/' + myDashboards[myDashboardIndex].uuid
  }).done(function(d) {
    if (d.graphs.length === 0) {
      console.log('No graphs found');
    }
    var row = 0;
    $('div.graphs').append('

');
    for (var i=0; i < d.graphs.length; i++) {
      var targets = [];
      for (var j in $.parseJSON(d.graphs[i].configuration).target) {
        targets.push({name: $.parseJSON(d.graphs[i].configuration).target[j]});
      }
      var c = $.extend($.parseJSON(d.graphs[i].configuration), $.parseJSON(d.graphs[i].overrides), {targets: targets});
      row = Math.floor( i / myColumns );
      var spanSize = ( 12 / myColumns );
      if (($('div.graphs div.row').length - 1) !== row) {
        $('div.graphs').append('

');
      }
      $($('div.graphs div.row')[row]).append('
');
      var myGraphWidth = $($('div.row span.graph')[0]).width();
      var graphCloseIcon = '';
      $('div.graphs div.row span#' + d.graphs[i].uuid).append('' + d.graphs[i].name + '');
      $('div.graphs div.row span#' + d.graphs[i].uuid).append('');
      $('div.graphs div.row span.graph img').load(function() {
        // hide spinner on successful load
        $(this).parent('a').parent('span').css('background-image', 'none')
      }).error(function() {
        console.log('failed to load ' + $(this)[0].name);
        var broken_img = $(this);
        // hide spinner and set background color
        broken_img.css('display', 'none');
        broken_img.parent('a').parent('span').css('background-image', 'none').css('background-color', '#eee')
        broken_img.parent('a').parent('span').find('label').css('margin', '10px 0 0 15px');
        // change label and link to image profile
        broken_img.parent('a').parent('span').find('label').html('Unable to load ' + broken_img[0].alt + '');
      });
    }
    renderChatrouletteTitle(d.dashboard.name);
    myDashboardIndex++;
    if (myDashboardIndex == myDashboards.length) {
      myDashboardIndex = 0;
    }
  });
}

// Not used in dashboards
var scrollNextPage = function() {
  return true;
}
<commit_msg>link chartroulette title to respective dashboard<commit_after>
var myDashboards = [];
var myDashboardIndex = 0;
var myDashboardRefreshInterval = 10000;

// Render our page title
var renderChatrouletteTitle = function(dashboard) {
  $('.header h1').find('span').remove();
  $('.header h1').append(' - ' + dashboard.name + '');
}

var renderGraphs = function() {
  $.ajax({
    accepts: {json: 'application/json'},
    cache: false,
    dataType: 'json',
    error: function(xhr, textStatus, errorThrown) { console.log(errorThrown); },
    url: '/chartroulette'
  }).done(function(d) {
    if (d.length > 0) {
      myDashboards = d;
      renderNextDashboard();
      setInterval(function() {
        clearGraphs();
        renderNextDashboard();
      }, myDashboardRefreshInterval);
    } else {
      $('div.graphs').append('
Oops!
');
      $('div.graphs').append("
Sorry, we don't have anything to show you yet. Why don't you favorite (star) a couple dashboards and come back again?");
      console.log('no favorited dashboards to display');
    }
  });
}

var renderNextDashboard = function() {
  return $.ajax({
    accepts: {json: 'application/json'},
    cache: false,
    dataType: 'json',
    error: function(xhr, textStatus, errorThrown) { console.log(errorThrown); },
    url: '/dashboards/' + myDashboards[myDashboardIndex].uuid
  }).done(function(d) {
    if (d.graphs.length === 0) {
      console.log('No graphs found');
    }
    var row = 0;
    $('div.graphs').append('

');
    for (var i=0; i < d.graphs.length; i++) {
      var targets = [];
      for (var j in $.parseJSON(d.graphs[i].configuration).target) {
        targets.push({name: $.parseJSON(d.graphs[i].configuration).target[j]});
      }
      var c = $.extend($.parseJSON(d.graphs[i].configuration), $.parseJSON(d.graphs[i].overrides), {targets: targets});
      row = Math.floor( i / myColumns );
      var spanSize = ( 12 / myColumns );
      if (($('div.graphs div.row').length - 1) !== row) {
        $('div.graphs').append('

');
      }
      $($('div.graphs div.row')[row]).append('
');
      var myGraphWidth = $($('div.row span.graph')[0]).width();
      var graphCloseIcon = '';
      $('div.graphs div.row span#' + d.graphs[i].uuid).append('' + d.graphs[i].name + '');
      $('div.graphs div.row span#' + d.graphs[i].uuid).append('');
      $('div.graphs div.row span.graph img').load(function() {
        // hide spinner on successful load
        $(this).parent('a').parent('span').css('background-image', 'none')
      }).error(function() {
        console.log('failed to load ' + $(this)[0].name);
        var broken_img = $(this);
        // hide spinner and set background color
        broken_img.css('display', 'none');
        broken_img.parent('a').parent('span').css('background-image', 'none').css('background-color', '#eee')
        broken_img.parent('a').parent('span').find('label').css('margin', '10px 0 0 15px');
        // change label and link to image profile
        broken_img.parent('a').parent('span').find('label').html('Unable to load ' + broken_img[0].alt + '');
      });
    }
    renderChatrouletteTitle(d.dashboard);
    myDashboardIndex++;
    if (myDashboardIndex == myDashboards.length) {
      myDashboardIndex = 0;
    }
  });
}

// Not used in dashboards
var scrollNextPage = function() {
  return true;
}
<|endoftext|>


<commit_before>import React, { Component } from 'react';
import Icon from 'react-icons/lib/fa/exclamation-triangle';
import List from 'react-toolbox/lib/list/List';
import ListSubHeader from 'react-toolbox/lib/list/ListSubHeader';
import ListItem from 'react-toolbox/lib/list/ListItem';
import Dialog from 'react-toolbox/lib/dialog/Dialog';
import Button from 'react-toolbox/lib/button/Button';
import Snackbar from 'react-toolbox/lib/snackbar/Snackbar';
import * as Actions from '@actions';

class AppResetSetting extends Component {
    state = {
        isDialogActive: false,
        isSnackbarActive: false,
    };

    handleToggle = () => {
        this.setState({ isDialogActive: !this.state.isDialogActive });
    }

    resetExtension = () => {
        Actions.resetApp();
        this.handleToggle();
        this.setState({ isSnackbarActive: true });
    }

    handleSnackbarTimeout = () => {
        this.setState({ isSnackbarActive: false });
    }

    actions = [
        { label: "Cancel", onClick: this.handleToggle, raised: true },
        { label: "Proceed", onClick: this.resetExtension, raised: true, accent: true },
    ];

    render() {
        const {
            isDialogActive,
            isSnackbarActive
        } = this.state;
        return (
            <List>
                <ListSubHeader caption="Reset Extension" />
                <ListItem
                    selectable={false}
                    ripple={false}
                    itemContent=
                    {
                        <Button accent raised
                            label="Delete data and reset"
                            icon={<Icon />}
                            onClick={this.handleToggle} />
                    } >
                </ListItem>
                <Dialog
                    actions={this.actions}
                    active={isDialogActive}
                    onEscKeyDown={this.handleToggle}
                    onOverlayClick={this.handleToggle}
                    title="Reset Extension"
                    type="small" >

                        This will reset the application to its original state.
                        All customizations and data that you might have stored in the application, will be lost.
                        Are you sure?

                </Dialog>
                <Snackbar
                    active={isSnackbarActive}
                    label="Application reset successful"
                    timeout={2000}
                    onTimeout={this.handleSnackbarTimeout}
                />
            </List>
        );
    }
}

export default AppResetSetting;
<commit_msg>:bug: Refresh state on reset app settings<commit_after>import React, { Component } from 'react';
import Icon from 'react-icons/lib/fa/exclamation-triangle';
import List from 'react-toolbox/lib/list/List';
import ListSubHeader from 'react-toolbox/lib/list/ListSubHeader';
import ListItem from 'react-toolbox/lib/list/ListItem';
import Dialog from 'react-toolbox/lib/dialog/Dialog';
import Button from 'react-toolbox/lib/button/Button';
import Snackbar from 'react-toolbox/lib/snackbar/Snackbar';
import * as Actions from '@actions';

class AppResetSetting extends Component {
    state = {
        isDialogActive: false,
        isSnackbarActive: false,
    };

    handleToggle = () => {
        this.setState({ isDialogActive: !this.state.isDialogActive });
    }

    resetExtension = () => {
        Actions.resetApp();
        Actions.refreshModules();
        this.handleToggle();
        this.setState({ isSnackbarActive: true });
    }

    handleSnackbarTimeout = () => {
        this.setState({ isSnackbarActive: false });
    }

    actions = [
        { label: "Cancel", onClick: this.handleToggle, raised: true },
        { label: "Proceed", onClick: this.resetExtension, raised: true, accent: true },
    ];

    render() {
        const {
            isDialogActive,
            isSnackbarActive
        } = this.state;
        return (
            <List>
                <ListSubHeader caption="Reset Extension" />
                <ListItem
                    selectable={false}
                    ripple={false}
                    itemContent=
                    {
                        <Button accent raised
                            label="Delete data and reset"
                            icon={<Icon />}
                            onClick={this.handleToggle} />
                    } >
                </ListItem>
                <Dialog
                    actions={this.actions}
                    active={isDialogActive}
                    onEscKeyDown={this.handleToggle}
                    onOverlayClick={this.handleToggle}
                    title="Reset Extension"
                    type="small" >

                        This will reset the application to its original state.
                        All customizations and data that you might have stored in the application, will be lost.
                        Are you sure?

                </Dialog>
                <Snackbar
                    active={isSnackbarActive}
                    label="Application reset successful"
                    timeout={2000}
                    onTimeout={this.handleSnackbarTimeout}
                />
            </List>
        );
    }
}

export default AppResetSetting;
<|endoftext|>


<commit_before>/**
 * @author Eric Wooley
 */

function make_row(wine){
	 var global = require('ui/common/globals');
	name = wine.Name;
	try{
		winetype = wine.Varietal.WineType.Name;
	}
	catch(err){
		winetype = "Unknown";
	}
	img_width = '20%';
	txt_width = '80%';

	location = wine.Appellation.Name + " - " +wine.Appellation.Region.Name;
	//imageurl = wine.Labels[wine.Labels.length-1].Url;
	imageurl = wine.Labels[0].Url;
	var row = Ti.UI.createTableViewRow
	({
		hasChild:false,
		height:Ti.UI.SIZE,
		className: 'WineRow',

	});

	row.wine = {
		id: wine.Id,
		name: name,
		winetype: winetype,
		location: location,
		all_information: wine
	};
	var row_block = Ti.UI.createView({
		width: Ti.UI.FILL,
		height: Ti.UI.SIZE,
		top: 10,
		left: 10,
		right: 10,
		borderRadius: 5,
		backgroundColor: '#fbf2df',
		layout: 'vertical'

	});
	var wine_info = Ti.UI.createView({
		width: Ti.UI.FILL,
		height: Ti.UI.SIZE,
		layout: 'horizontal'

	});

	// This image will be the image of the wine
	var image = Ti.UI.createView({
		height: Ti.UI.SIZE,
		width: '20%',

	});
	image.add(Ti.UI.createImageView({
		width: 50,
		top: 10,
		left: 10,
		image: imageurl,
		backgroundImage: 'blue'
	}));

	var txt_container = Ti.UI.createView({
		height: Ti.UI.SIZE,
		width: '80%',
		layout: 'vertical',

	});
	// Label for the location of the wine within the row
	var lbl_location = Ti.UI.createLabel
	({
		color:'black',
		bottom:5,
		right: 5,
		text: location,
		font: {fontSize: 12, fontStyle: 'italic'},
		textAlign: Ti.UI.TEXT_ALIGNMENT_RIGHT,
		touchEnabled:false
	});

	// Label for the type of wine within the row
	var lbl_type = Ti.UI.createLabel
	({
		right: 5,
		color:'black',
		text: name,
		left: 10,
		bottom:lbl_location.top,
		font:{fontSize:14,fontWeight:'bold',fontFamily:'Helvetica Neue'},
		touchEnabled:false

	});

	// Label for the name
	var lbl_name = Ti.UI.createLabel
	({
		right:5,
		color:'black',
		text: winetype,

		font: {fontSize: 12, fontStyle: 'italic'},
		textAlign: Ti.UI.TEXT_ALIGNMENT_RIGHT,
		touchEnabled:false
	});

	// Add each of these features to the row, then push the row
	wine_info.add(image);
	wine_info.add(txt_container);
	txt_container.add(lbl_name);
	txt_container.add(lbl_type);
	txt_container.add(lbl_location);
	row_block.add(wine_info);
	if(wine.friend){
		var friend_name = wine.friend.fname + ' ' + wine.friend.lname + ' checked in';
		var friend_info_row = Ti.UI.createView({
			width: Ti.UI.FILL,
			height: Ti.UI.SIZE,
			layout: 'horizontal'
		});

		var friend_picture = Ti.UI.createView({height: Ti.UI.SIZE, width: '20%',top: 10, bottom: 10});
		friend_picture.add(Ti.UI.createImageView({
			image: wine.friend.picture_url,
			width: 50,
			left: 10,

			borderRadius: 10,
			backgroundColor: 'black'
		}));

		var rating_container = Ti.UI.createView({
			width: '80%',
			height: Ti.UI.SIZE,
			layout: 'vertical'
		});

		// Add user rating
		rating_container.add(Ti.UI.createLabel({
			color: 'black',
			text: wine.friend.rating + '/10',
			left: 10,
			font: {fontSize: 20, fontStyle: 'bold'}
		}));
		// Add User Comment
		rating_container.add(Ti.UI.createLabel({
			color: 'black',
			text: '"'+wine.friend.comment+'"',
			textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER,
			font: {fontSize: 12, fontStyle: 'italic'}
		}));

		friend_info_row.add(friend_picture);
		friend_info_row.add(rating_container);
		row_block.add(friend_info_row);
	}

	row.add(row_block);
	return row;
};
module.exports = make_row;<commit_msg>added the word "Rated" to the home page wine reviews to make it clear what it was<commit_after>/**
 * @author Eric Wooley
 */

function make_row(wine){
	 var global = require('ui/common/globals');
	name = wine.Name;
	try{
		winetype = wine.Varietal.WineType.Name;
	}
	catch(err){
		winetype = "Unknown";
	}
	img_width = '20%';
	txt_width = '80%';

	location = wine.Appellation.Name + " - " +wine.Appellation.Region.Name;
	//imageurl = wine.Labels[wine.Labels.length-1].Url;
	imageurl = wine.Labels[0].Url;
	var row = Ti.UI.createTableViewRow
	({
		hasChild:false,
		height:Ti.UI.SIZE,
		className: 'WineRow',

	});

	row.wine = {
		id: wine.Id,
		name: name,
		winetype: winetype,
		location: location,
		all_information: wine
	};
	var row_block = Ti.UI.createView({
		width: Ti.UI.FILL,
		height: Ti.UI.SIZE,
		top: 10,
		left: 10,
		right: 10,
		borderRadius: 5,
		backgroundColor: '#fbf2df',
		layout: 'vertical'

	});
	var wine_info = Ti.UI.createView({
		width: Ti.UI.FILL,
		height: Ti.UI.SIZE,
		layout: 'horizontal'

	});

	// This image will be the image of the wine
	var image = Ti.UI.createView({
		height: Ti.UI.SIZE,
		width: '20%',

	});
	image.add(Ti.UI.createImageView({
		width: 50,
		top: 10,
		left: 10,
		image: imageurl,
		backgroundImage: 'blue'
	}));

	var txt_container = Ti.UI.createView({
		height: Ti.UI.SIZE,
		width: '80%',
		layout: 'vertical',

	});
	// Label for the location of the wine within the row
	var lbl_location = Ti.UI.createLabel
	({
		color:'black',
		bottom:5,
		right: 5,
		text: location,
		font: {fontSize: 12, fontStyle: 'italic'},
		textAlign: Ti.UI.TEXT_ALIGNMENT_RIGHT,
		touchEnabled:false
	});

	// Label for the type of wine within the row
	var lbl_type = Ti.UI.createLabel
	({
		right: 5,
		color:'black',
		text: name,
		left: 10,
		bottom:lbl_location.top,
		font:{fontSize:14,fontWeight:'bold',fontFamily:'Helvetica Neue'},
		touchEnabled:false

	});

	// Label for the name
	var lbl_name = Ti.UI.createLabel
	({
		right:5,
		color:'black',
		text: winetype,

		font: {fontSize: 12, fontStyle: 'italic'},
		textAlign: Ti.UI.TEXT_ALIGNMENT_RIGHT,
		touchEnabled:false
	});

	// Add each of these features to the row, then push the row
	wine_info.add(image);
	wine_info.add(txt_container);
	txt_container.add(lbl_name);
	txt_container.add(lbl_type);
	txt_container.add(lbl_location);
	row_block.add(wine_info);
	if(wine.friend){
		var friend_name = wine.friend.fname + ' ' + wine.friend.lname + ' checked in';
		var friend_info_row = Ti.UI.createView({
			width: Ti.UI.FILL,
			height: Ti.UI.SIZE,
			layout: 'horizontal'
		});

		var friend_picture = Ti.UI.createView({height: Ti.UI.SIZE, width: '20%',top: 10, bottom: 10});
		friend_picture.add(Ti.UI.createImageView({
			image: wine.friend.picture_url,
			width: 50,
			left: 10,

			borderRadius: 10,
			backgroundColor: 'black'
		}));

		var rating_container = Ti.UI.createView({
			width: '80%',
			height: Ti.UI.SIZE,
			layout: 'vertical'
		});

		// Add user rating
		rating_container.add(Ti.UI.createLabel({
			color: 'black',
			text: 'Rated ' + wine.friend.rating + '/10',
			left: 10,
			font: {fontSize: 18, fontStyle: 'bold'}
		}));
		// Add User Comment
		rating_container.add(Ti.UI.createLabel({
			color: 'black',
			text: '"'+wine.friend.comment+'"',
			textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER,
			font: {fontSize: 12, fontStyle: 'italic'}
		}));

		friend_info_row.add(friend_picture);
		friend_info_row.add(rating_container);
		row_block.add(friend_info_row);
	}

	row.add(row_block);
	return row;
};
module.exports = make_row;<|endoftext|>


<commit_before><commit_msg>unlisted changes<commit_after><|endoftext|>