<commit_before>/**
 * Remove classnames module import
 * Convert classnames to inline styles
 * @param file
 * @param api
 * @return {string}
 */

const path = require("path");
const resolve = require("resolve");

const mediaQueries = ["min-width", "minWidth", "max-width", "maxWidth"];
const toSource = require("./util/to-source");

module.exports = function (file, api) {
    const j = api.jscodeshift;
    const root = j(file.source);
    var styles = null;

    const resolveOptions = {
        paths: [],
        basedir: path.dirname(file.path),
        extensions: [".js"],
        moduleDirectory: path.dirname(file.path)
    };

    const getAttribute = function (attrName, attributes) {
        const attrs = attributes.filter(function (attribute) {
            if (!attribute.name) {
                return false;
            }

            return attribute.name.name === attrName;
        });

        return attrs[0] || null;
    };

    const getClassAttribute = function (attributes) {
        return getAttribute("className", attributes);
    };

    const getStyleAttribute = function (attributes) {
        return getAttribute("style", attributes);
    };

    const getKeyAttribute = function (attributes) {
        return getAttribute("key", attributes);
    };

    const logError = function (attr) {
        if (attr.loc && attr.loc.start) {
            const line = attr.loc.start.line;
            console.error("%s: Could not update styles on line %s", file.path, line);
        }
    };

    const isInteractiveStyle = function (style) {
        if (!style) {
            return false;
        }

        if (style[":hover"]) {
            return true;
        }

        for (var prop in style) {
            if (style.hasOwnProperty(prop)) {
                for (var query in mediaQueries) {
                    if (prop.indexOf(mediaQueries[query]) > -1) {
                        return true;
                    }
                }
            }
        }

        return false;
    };

    const getInteractiveKey = function (expressions) {
        for (var expression in expressions) {
            if (expressions[expression].type !== "MemberExpression") {
                continue;
            }

            if (expressions[expression].object.name === "styles") {
                const style = expressions[expression].property.name;
                if (isInteractiveStyle(styles[style])) {
                    return style;
                }
            }
        }

        return null;
    };

    const createStyleAttribute = function (styleObjects) {
        if (styleObjects.length === 0) {
            return null;
        }

        var styleValue = null;
        if (styleObjects.length > 1) {
            const spreadObjects = styleObjects.map(function (style) {
                return j.spreadProperty(style);
            });
            styleValue = j.objectExpression(spreadObjects);
        } else {
            styleValue = styleObjects[0];
        }

        return j.jsxAttribute(
            j.jsxIdentifier("style"),
            j.jsxExpressionContainer(styleValue)
        );
    };

    const createClassAttribute = function (classes) {
        return j.jsxAttribute(
            j.jsxIdentifier("className"),
            j.literal(classes)
        );
    };

    const applyClassesAndStyles = function (attrs, allStyles) {
        const stringArgs = allStyles.filter(function (style) {
            return style.type === "Literal";
        }).map(function (style) {
            return style.value;
        }).join(" ");

        const objArgs = allStyles.filter(function (style) {
            return style.type !== "Literal";
        });

        if (objArgs.length) {
            const styleAttribute = createStyleAttribute(objArgs);
            attrs.push(styleAttribute);
        }

        if (stringArgs.length) {
            const classAttribute = createClassAttribute(stringArgs);
            attrs.push(classAttribute);
        }

        const interactiveKey = styles && getInteractiveKey(objArgs);
        if (interactiveKey && !getKeyAttribute(attrs)) {
            const keyAttribute = j.jsxAttribute(
                j.jsxIdentifier("key"),
                j.literal(interactiveKey)
            );
            attrs.push(keyAttribute);
        }
    };

    const updateStyles = function (p) {
        const attrs = p.value.attributes;
        const classAttribute = getClassAttribute(attrs);
        const styleAttribute = getStyleAttribute(attrs);

        const classValue = classAttribute.value;

        if (classValue.expression && classValue.expression.type === "CallExpression") {
            const conditionalStyles = classValue.expression.arguments.filter(function (arg) {
                return (arg.type === "ObjectExpression");
            });

            if (conditionalStyles.length) {
                logError(classAttribute);
                return;
            }
        }

        var allStyles = [];
        if (classValue.type === "Literal") {
            allStyles.push(classValue);
        } else if (classValue.expression.type === "CallExpression") {
            allStyles = allStyles.concat(classValue.expression.arguments);
        } else {
            allStyles.push(classValue.expression);
        }

        if (classAttribute) {
            attrs.splice(attrs.indexOf(classAttribute), 1);
        }

        if (styleAttribute) {
            attrs.splice(attrs.indexOf(styleAttribute), 1);
            allStyles.push(styleAttribute.value.expression);
        }

        applyClassesAndStyles(attrs, allStyles);
    };

    const radiumImport = j.importDeclaration(
        [j.importDefaultSpecifier(
            j.identifier("radium")
        )],
        j.literal("react-wildcat-radium")
    );

    root
        .find(j.ImportDeclaration, {
            specifiers: [{
                local: {
                    name: "styles"
                }
            }]
        }).forEach(function (p) {
            const styleImport = p.value.source.value;
            const absoluteImportPath = resolve.sync(styleImport, resolveOptions);

            if (p.value.specifiers[0].type === "ImportDefaultSpecifier") {
                styles = require(absoluteImportPath);
            } else {
                styles = require(absoluteImportPath).styles;
            }
        });

    root
        .find(j.ImportDeclaration, {
            source: {
                type: "Literal",
                value: "react"
            }
        }).forEach(function (p) {
            j(p).insertAfter(radiumImport);
        });

    root
        .find(j.ImportDeclaration, {
            source: {
                type: "Literal",
                value: "classnames"
            }
        }).forEach(function (p) {
            j(p).replaceWith("");
        });

    root
        .find(j.JSXOpeningElement)
        .filter(function (p) {
            const attrs = p.value.attributes;
            return getClassAttribute(attrs) !== null;
        }).forEach(function (p) {
            updateStyles(p);
        });

    root
        .find(j.ClassDeclaration)
        .forEach(function (p) {
            const hasStyles = root
                .find(j.JSXOpeningElement)
                .filter(function (x) {
                    const attrs = x.value.attributes;
                    return getStyleAttribute(attrs) !== null;
                });

            if (hasStyles.paths().length) {
                if (!p.node.decorators) {
                    p.node.decorators = [];
                }

                p.node.decorators.push(
                    j.decorator(
                        j.identifier("radium")
                    )
                );
            }
        });

    return toSource(root, j);
};
<commit_msg>Couple the @radium decorator with the radium import.<commit_after>/**
 * Remove classnames module import
 * Convert classnames to inline styles
 * @param file
 * @param api
 * @return {string}
 */

const path = require("path");
const resolve = require("resolve");

const mediaQueries = ["min-width", "minWidth", "max-width", "maxWidth"];
const toSource = require("./util/to-source");

module.exports = function (file, api) {
    const j = api.jscodeshift;
    const root = j(file.source);
    var styles = null;

    const resolveOptions = {
        paths: [],
        basedir: path.dirname(file.path),
        extensions: [".js"],
        moduleDirectory: path.dirname(file.path)
    };

    const getAttribute = function (attrName, attributes) {
        const attrs = attributes.filter(function (attribute) {
            if (!attribute.name) {
                return false;
            }

            return attribute.name.name === attrName;
        });

        return attrs[0] || null;
    };

    const getClassAttribute = function (attributes) {
        return getAttribute("className", attributes);
    };

    const getStyleAttribute = function (attributes) {
        return getAttribute("style", attributes);
    };

    const getKeyAttribute = function (attributes) {
        return getAttribute("key", attributes);
    };

    const logError = function (attr) {
        if (attr.loc && attr.loc.start) {
            const line = attr.loc.start.line;
            console.error("%s: Could not update styles on line %s", file.path, line);
        }
    };

    const isInteractiveStyle = function (style) {
        if (!style) {
            return false;
        }

        if (style[":hover"]) {
            return true;
        }

        for (var prop in style) {
            if (style.hasOwnProperty(prop)) {
                for (var query in mediaQueries) {
                    if (prop.indexOf(mediaQueries[query]) > -1) {
                        return true;
                    }
                }
            }
        }

        return false;
    };

    const getInteractiveKey = function (expressions) {
        for (var expression in expressions) {
            if (expressions[expression].type !== "MemberExpression") {
                continue;
            }

            if (expressions[expression].object.name === "styles") {
                const style = expressions[expression].property.name;
                if (isInteractiveStyle(styles[style])) {
                    return style;
                }
            }
        }

        return null;
    };

    const createStyleAttribute = function (styleObjects) {
        if (styleObjects.length === 0) {
            return null;
        }

        var styleValue = null;
        if (styleObjects.length > 1) {
            const spreadObjects = styleObjects.map(function (style) {
                return j.spreadProperty(style);
            });
            styleValue = j.objectExpression(spreadObjects);
        } else {
            styleValue = styleObjects[0];
        }

        return j.jsxAttribute(
            j.jsxIdentifier("style"),
            j.jsxExpressionContainer(styleValue)
        );
    };

    const createClassAttribute = function (classes) {
        return j.jsxAttribute(
            j.jsxIdentifier("className"),
            j.literal(classes)
        );
    };

    const applyClassesAndStyles = function (attrs, allStyles) {
        const stringArgs = allStyles.filter(function (style) {
            return style.type === "Literal";
        }).map(function (style) {
            return style.value;
        }).join(" ");

        const objArgs = allStyles.filter(function (style) {
            return style.type !== "Literal";
        });

        if (objArgs.length) {
            const styleAttribute = createStyleAttribute(objArgs);
            attrs.push(styleAttribute);
        }

        if (stringArgs.length) {
            const classAttribute = createClassAttribute(stringArgs);
            attrs.push(classAttribute);
        }

        const interactiveKey = styles && getInteractiveKey(objArgs);
        if (interactiveKey && !getKeyAttribute(attrs)) {
            const keyAttribute = j.jsxAttribute(
                j.jsxIdentifier("key"),
                j.literal(interactiveKey)
            );
            attrs.push(keyAttribute);
        }
    };

    const updateStyles = function (p) {
        const attrs = p.value.attributes;
        const classAttribute = getClassAttribute(attrs);
        const styleAttribute = getStyleAttribute(attrs);

        const classValue = classAttribute.value;

        if (classValue.expression && classValue.expression.type === "CallExpression") {
            const conditionalStyles = classValue.expression.arguments.filter(function (arg) {
                return (arg.type === "ObjectExpression");
            });

            if (conditionalStyles.length) {
                logError(classAttribute);
                return;
            }
        }

        var allStyles = [];
        if (classValue.type === "Literal") {
            allStyles.push(classValue);
        } else if (classValue.expression.type === "CallExpression") {
            allStyles = allStyles.concat(classValue.expression.arguments);
        } else {
            allStyles.push(classValue.expression);
        }

        if (classAttribute) {
            attrs.splice(attrs.indexOf(classAttribute), 1);
        }

        if (styleAttribute) {
            attrs.splice(attrs.indexOf(styleAttribute), 1);
            allStyles.push(styleAttribute.value.expression);
        }

        applyClassesAndStyles(attrs, allStyles);
    };

    root
        .find(j.ImportDeclaration, {
            specifiers: [{
                local: {
                    name: "styles"
                }
            }]
        }).forEach(function (p) {
            const styleImport = p.value.source.value;
            const absoluteImportPath = resolve.sync(styleImport, resolveOptions);

            if (p.value.specifiers[0].type === "ImportDefaultSpecifier") {
                styles = require(absoluteImportPath);
            } else {
                styles = require(absoluteImportPath).styles;
            }
        });

    root
        .find(j.ImportDeclaration, {
            source: {
                type: "Literal",
                value: "classnames"
            }
        }).forEach(function (p) {
            j(p).replaceWith("");
        });

    root
        .find(j.JSXOpeningElement)
        .filter(function (p) {
            const attrs = p.value.attributes;
            return getClassAttribute(attrs) !== null;
        }).forEach(function (p) {
            updateStyles(p);
        });

    const hasStyles = root
        .find(j.JSXOpeningElement)
        .filter(function (p) {
            const attrs = p.value.attributes;
            return getStyleAttribute(attrs) !== null;
        });

    if (hasStyles.paths().length) {
        const radiumImport = j.importDeclaration(
            [j.importDefaultSpecifier(
                j.identifier("radium")
            )],
            j.literal("react-wildcat-radium")
        );

        root
            .find(j.ImportDeclaration, {
                source: {
                    type: "Literal",
                    value: "react"
                }
            }).forEach(function (p) {
                j(p).insertAfter(radiumImport);
            });

        root
            .find(j.ClassDeclaration)
            .forEach(function (p) {
                if (hasStyles.paths().length) {
                    if (!p.node.decorators) {
                        p.node.decorators = [];
                    }

                    p.node.decorators.push(
                        j.decorator(
                            j.identifier("radium")
                        )
                    );
                }
            });
    }

    return toSource(root, j);
};
<|endoftext|>


<commit_before>module.exports = {
  config: {
    // default font size in pixels for all tabs
    fontSize: 12,

    // font family with optional fallbacks
    fontFamily: 'Menlo, "DejaVu Sans Mono", Consolas, "Lucida Console", monospace',

    // terminal cursor background color and opacity (hex, rgb, hsl, hsv, hwb or cmyk)
    cursorColor: 'rgba(248,28,229,0.8)',

    // `BEAM` for |, `UNDERLINE` for _, `BLOCK` for █
    cursorShape: 'BLOCK',

    // color of the text
    foregroundColor: '#fff',

    // terminal background color
    backgroundColor: '#000',

    // border color (window, tabs)
    borderColor: '#333',

    // custom css to embed in the main window
    css: '',

    // custom css to embed in the terminal window
    termCSS: '',

    // set to `true` (without backticks) if you're using a Linux setup that doesn't show native menus
    // default: `false` on Linux, `true` on Windows (ignored on macOS)
    showHamburgerMenu: '',

    // set to `false` if you want to hide the minimize, maximize and close buttons
    // additionally, set to `'left'` if you want them on the left, like in Ubuntu
    // default: `true` on windows and Linux (ignored on macOS)
    showWindowControls: '',

    // custom padding (css format, i.e.: `top right bottom left`)
    padding: '12px 14px',

    // the full list. if you're going to provide the full color palette,
    // including the 6 x 6 color cubes and the grayscale map, just provide
    // an array here instead of a color map object
    colors: {
      black: '#000000',
      red: '#ff0000',
      green: '#33ff00',
      yellow: '#ffff00',
      blue: '#0066ff',
      magenta: '#cc00ff',
      cyan: '#00ffff',
      white: '#d0d0d0',
      lightBlack: '#808080',
      lightRed: '#ff0000',
      lightGreen: '#33ff00',
      lightYellow: '#ffff00',
      lightBlue: '#0066ff',
      lightMagenta: '#cc00ff',
      lightCyan: '#00ffff',
      lightWhite: '#ffffff'
    },

    // the shell to run when spawning a new session (i.e. /usr/local/bin/fish)
    // if left empty, your system's login shell will be used by default
    shell: '',

    // for setting shell arguments (i.e. for using interactive shellArgs: ['-i'])
    // by default ['--login'] will be used
    shellArgs: ['--login'],

    // for environment variables
    env: {},

    // set to false for no bell
    bell: 'SOUND',

    // if true, selected text will automatically be copied to the clipboard
    copyOnSelect: false

    // URL to custom bell
    // bellSoundURL: 'http://example.com/bell.mp3',

    // for advanced config flags please refer to https://hyper.is/#cfg
  },

  // a list of plugins to fetch and install from npm
  // format: [@org/]project[#version]
  // examples:
  //   `hyperpower`
  //   `@company/project`
  //   `project#1.0.1`
  plugins: [],

  // in development, you can create a directory under
  // `~/.hyper_plugins/local/` and include it here
  // to load it and avoid it being `npm install`ed
  localPlugins: []
};
<commit_msg>Add notes about full paths for the `shell` config and about PowerShell Closes #1020<commit_after>module.exports = {
  config: {
    // default font size in pixels for all tabs
    fontSize: 12,

    // font family with optional fallbacks
    fontFamily: 'Menlo, "DejaVu Sans Mono", Consolas, "Lucida Console", monospace',

    // terminal cursor background color and opacity (hex, rgb, hsl, hsv, hwb or cmyk)
    cursorColor: 'rgba(248,28,229,0.8)',

    // `BEAM` for |, `UNDERLINE` for _, `BLOCK` for █
    cursorShape: 'BLOCK',

    // color of the text
    foregroundColor: '#fff',

    // terminal background color
    backgroundColor: '#000',

    // border color (window, tabs)
    borderColor: '#333',

    // custom css to embed in the main window
    css: '',

    // custom css to embed in the terminal window
    termCSS: '',

    // set to `true` (without backticks) if you're using a Linux setup that doesn't show native menus
    // default: `false` on Linux, `true` on Windows (ignored on macOS)
    showHamburgerMenu: '',

    // set to `false` if you want to hide the minimize, maximize and close buttons
    // additionally, set to `'left'` if you want them on the left, like in Ubuntu
    // default: `true` on windows and Linux (ignored on macOS)
    showWindowControls: '',

    // custom padding (css format, i.e.: `top right bottom left`)
    padding: '12px 14px',

    // the full list. if you're going to provide the full color palette,
    // including the 6 x 6 color cubes and the grayscale map, just provide
    // an array here instead of a color map object
    colors: {
      black: '#000000',
      red: '#ff0000',
      green: '#33ff00',
      yellow: '#ffff00',
      blue: '#0066ff',
      magenta: '#cc00ff',
      cyan: '#00ffff',
      white: '#d0d0d0',
      lightBlack: '#808080',
      lightRed: '#ff0000',
      lightGreen: '#33ff00',
      lightYellow: '#ffff00',
      lightBlue: '#0066ff',
      lightMagenta: '#cc00ff',
      lightCyan: '#00ffff',
      lightWhite: '#ffffff'
    },

    // the shell to run when spawning a new session (i.e. /usr/local/bin/fish)
    // if left empty, your system's login shell will be used by default
    // make sure to use a full path if the binary name doesn't work
    // (e.g `C:\\Windows\\System32\\bash.exe` instad of just `bash.exe`)
    // if you're using powershell, make sure to remove the `--login` below
    shell: '',

    // for setting shell arguments (i.e. for using interactive shellArgs: ['-i'])
    // by default ['--login'] will be used
    shellArgs: ['--login'],

    // for environment variables
    env: {},

    // set to false for no bell
    bell: 'SOUND',

    // if true, selected text will automatically be copied to the clipboard
    copyOnSelect: false

    // URL to custom bell
    // bellSoundURL: 'http://example.com/bell.mp3',

    // for advanced config flags please refer to https://hyper.is/#cfg
  },

  // a list of plugins to fetch and install from npm
  // format: [@org/]project[#version]
  // examples:
  //   `hyperpower`
  //   `@company/project`
  //   `project#1.0.1`
  plugins: [],

  // in development, you can create a directory under
  // `~/.hyper_plugins/local/` and include it here
  // to load it and avoid it being `npm install`ed
  localPlugins: []
};
<|endoftext|>


<commit_before>/** A simple collapsible element for hiding children */

import React, { Component, PropTypes } from 'react'
import Icon from './icon'

export default class Collapsible extends Component {
  static propTypes = {
    title: PropTypes.string.isRequired,
    defaultExpanded: PropTypes.bool
  }

  static defaultProps = {
    defaultExpanded: false
  }

  componentWillMount () {
    this.state = {
      expanded: this.props.defaultExpanded
    }
  }

  toggleExpanded = () => {
    this.setState({ ...this.state, expanded: !this.state.expanded })
  }

  render () {
    const {expanded} = this.state
    const {title, children} = this.props
    return

          <Icon type={expanded ? 'caret-down' : 'caret-right'} />
          {title}

      { expanded && children }

  }
}
<commit_msg>fix(collapsible): Revert accidentally-overwritten changes.<commit_after>/** A simple collapsible element for hiding children */

import React, { Component, PropTypes } from 'react'
import Icon from './icon'

export default class Collapsible extends Component {
  static propTypes = {
    title: PropTypes.string.isRequired,
    defaultExpanded: PropTypes.bool
  }

  static defaultProps = {
    defaultExpanded: false
  }

  componentWillMount () {
    this.state = {
      expanded: this.props.defaultExpanded
    }
  }

  toggleExpanded = () => {
    this.setState({ ...this.state, expanded: !this.state.expanded })
  }

  render () {
    const {expanded} = this.state
    const {title, children} = this.props
    return

          <Icon type={expanded ? 'chevron-down' : 'chevron-right'} />
          {title}

      { expanded && children }

  }
}
<|endoftext|>


<commit_before>import Class from '../core/Class';
import Shader from '../shader/Shader';
import screenVert from '../shader/screen.vert';
import screenFrag from '../shader/screen.frag';
import Cache from '../utils/Cache';
import log from '../utils/log';
import Program from './Program';
import VertexArrayObject from './VertexArrayObject';
import math from '../math/math';
import Color from '../math/Color';
import GeometryData from '../geometry/GeometryData';
import Texture from '../texture/Texture';
import {
    getTypedArrayClass
} from '../utils/util';

import constants from '../constants';

const {
    TEXTURE_2D,
    RGBA,
    UNSIGNED_BYTE,
    COLOR_ATTACHMENT0,
    DEPTH_STENCIL,
    DEPTH_TEST,
    CULL_FACE,
    TRIANGLE_STRIP,
    NEAREST,
    CLAMP_TO_EDGE
} = constants;

const cache = new Cache();

/**
 * 帧缓冲
 * @class
 */
const Framebuffer = Class.create(/** @lends Framebuffer.prototype */ {
    Statics: {
        /**
         * 缓存
         * @readOnly
         * @memberOf Framebuffer
         * @type {Cache}
         */
        cache: {
            get() {
                return cache;
            }
        },
        /**
         * 重置所有framebuffer
         * @memberOf Framebuffer
         * @param  {WebGLRenderingContext} gl
         */
        reset(gl) { // eslint-disable-line no-unused-vars
            cache.each((framebuffer) => {
                framebuffer.reset();
            });
        },
        /**
         * 销毁所有 Framebuffer
         * @memberOf Framebuffer
         * @param  {WebGLRenderingContext} gl
         */
        destroy(gl) { // eslint-disable-line no-unused-vars
            cache.each((framebuffer) => {
                framebuffer.destroy();
            });
        }
    },

    /**
     * @default Framebuffer
     * @type {String}
     */
    className: 'Framebuffer',

    /**
     * @default true
     * @type {Boolean}
     */
    isFramebuffer: true,

    /**
     * bufferInternalFormat
     * @type {GLenum}
     * @default gl.DEPTH_STENCIL
     */
    bufferInternalFormat: DEPTH_STENCIL,

    /**
     * texture target
     * @type {GLenum}
     * @default gl.TEXTURE_2D
     */
    target: TEXTURE_2D,

    /**
     * texture format
     * @type {GLenum}
     * @default gl.RGBA
     */
    format: RGBA,

    /**
     * texture internalFormat
     * @type {GLenum}
     * @default gl.RGBA
     */
    internalFormat: RGBA,

    /**
     * texture type
     * @type {GLenum}
     * @default gl.UNSIGNED_BYTE
     */
    type: UNSIGNED_BYTE,
    /**
     * texture minFilter
     * @type {GLenum}
     * @default gl.NEAREST
     */
    minFilter: NEAREST,

    /**
     * texture magFilter
     * @type {GLenum}
     * @default gl.NEAREST
     */
    magFilter: NEAREST,

    /**
     * texture data
     * @type {TypedArray}
     * @default null
     */
    data: null,

    /**
     * attachment
     * @type {GLenum}
     * @default gl.COLOR_ATTACHMENT0
     */
    attachment: COLOR_ATTACHMENT0,

    /**
     * 是否需要renderbuffer
     * @type {Boolean}
     * @default true
     */
    needRenderbuffer: true,

    /**
     * 是否使用VAO
     * @type {Boolean}
     * @default true
     */
    useVao: true,

    /**
     * renderer
     * @type {WebGLRenderer}
     * @default null
     */
    renderer: null,

    /**
     * texture
     * @type {Texture}
     */
    texture: null,

    /**
     * renderbuffer
     * @type {WebGLRenderbuffer}
     */
    renderbuffer: null,

    /**
     * framebuffer
     * @type {WebGLFramebuffer}
     */
    framebuffer: null,

    _isInit: false,

    /**
     * @constructs
     * @param {WebGLRenderer}  renderer
     * @param  {Object} [params] 初始化参数，所有params都会复制到实例上
     */
    constructor(renderer, params) {
        this.id = math.generateUUID(this.className);
        this.renderer = renderer;
        Object.assign(this, params);

        if (!this.width) {
            this.width = renderer.width;
        }

        if (!this.height) {
            this.height = renderer.height;
        }

        cache.add(this.id, this);
    },
    /**
     * init
     */
    init() {
        if (!this._isInit && this.renderer.isInit) {
            this._isInit = true;
            const renderer = this.renderer;
            this.gl = renderer.gl;
            this.state = renderer.state;
            this.reset();
        }
    },
    /**
     * reset
     * @private
     */
    reset() {
        this.destroyResource();
        const gl = this.gl;
        /**
         * framebuffer
         * @type {WebGLFramebuffer}
         */
        this.framebuffer = gl.createFramebuffer();
        this.bind();
        if (this.needRenderbuffer) {
            this.renderbuffer = this.createRenderbuffer();
        }

        this.texture = this.createTexture();

        if (!this.isComplete()) {
            log.warn('Framebuffer is not complete => ' + gl.checkFramebufferStatus(gl.FRAMEBUFFER));
        }

        this.unbind();
    },
    /**
     * framebuffer 是否完成
     * @return {Boolean}
     */
    isComplete() {
        const gl = this.gl;
        if (gl && gl.checkFramebufferStatus(gl.FRAMEBUFFER) === gl.FRAMEBUFFER_COMPLETE) {
            return true;
        }
        return false;
    },
    /**
     * 绑定
     */
    bind() {
        this.init();
        if (this._isInit) {
            this.state.bindFramebuffer(this.gl.FRAMEBUFFER, this.framebuffer);
        }
    },
    /**
     * 解绑
     */
    unbind() {
        this.init();
        if (this._isInit) {
            const state = this.state;
            state.bindFramebuffer(this.gl.FRAMEBUFFER, state.preFramebuffer);
        }
    },
    clear(clearColor = new Color(0, 0, 0, 0)) {
        if (this._isInit) {
            const {
                gl
            } = this;
            gl.clearColor(clearColor.r, clearColor.g, clearColor.b, clearColor.a);
            gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
        }
    },
    /**
     * 渲染当前纹理
     * @param  {Number} [x=0]
     * @param  {Number} [y=0]
     * @param  {Number} [width=1]
     * @param  {Number} [height=1]
     * @param  {Color} [clearColor=null]
     */
    render(x = 0, y = 0, width = 1, height = 1, clearColor) {
        if (this._isInit) {
            const {
                gl,
                state
            } = this;
            state.disable(DEPTH_TEST);
            state.disable(CULL_FACE);

            if (clearColor) {
                this.clear(clearColor);
            }

            const shader = Shader.getCustomShader(screenVert, screenFrag, '', 'FramebufferTextureShader');
            const program = Program.getProgram(shader, state);
            program.useProgram();

            const vaoId = `${x}_${y}_${width}_${height}_${program.id}`;
            const vao = VertexArrayObject.getVao(gl, vaoId, {
                useVao: this.useVao,
                useInstanced: false,
                mode: TRIANGLE_STRIP
            });

            if (vao.isDirty) {
                vao.isDirty = false;
                x = x * 2 - 1;
                y = 1 - y * 2;
                width *= 2;
                height *= 2;
                const vertices = [x, y, x + width, y, x, y - height, x + width, y - height];
                vao.addAttribute(new GeometryData(new Float32Array(vertices), 2), program.attributes.a_position);
                vao.addAttribute(new GeometryData(new Float32Array([0, 1, 1, 1, 0, 0, 1, 0]), 2), program.attributes.a_texcoord0);
            }

            state.activeTexture(gl.TEXTURE0);
            state.bindTexture(gl.TEXTURE_2D, this.texture.getGLTexture(state));
            vao.draw();
        }
    },
    /**
     * 生成 Renderbuffer
     * @private
     * @return {WebGLRenderbuffer}
     */
    createRenderbuffer() {
        const {
            gl,
            width,
            height
        } = this;
        const renderbuffer = gl.createRenderbuffer();
        gl.bindRenderbuffer(gl.RENDERBUFFER, renderbuffer);
        gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height);
        gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, renderbuffer);
        return renderbuffer;
    },
    /**
     * 生成纹理
     * @private
     * @return {Texture}
     */
    createTexture() {
        const state = this.state;
        const gl = state.gl;
        const texture = new Texture({
            minFilter: this.minFilter,
            magFilter: this.magFilter,
            internalFormat: this.internalFormat,
            format: this.format,
            type: this.type,
            width: this.width,
            height: this.height,
            image: this.data,
            wrapS: CLAMP_TO_EDGE,
            wrapT: CLAMP_TO_EDGE
        });

        const glTexture = texture.getGLTexture(state);
        gl.framebufferTexture2D(gl.FRAMEBUFFER, this.attachment, this.target, glTexture, 0);

        return texture;
    },
    /**
     * resize
     * @param  {Number} width
     * @param  {Number} height
     * @param  {Boolean} [force=true]
     */
    resize(width, height, force) {
        if (force || this.width !== width || this.height !== height) {
            this.width = width;
            this.height = height;

            if (this._isInit) {
                this.reset();
            }
        }
    },
    /**
     * 读取区域像素
     * @param  {Number} x
     * @param  {Number} y
     * @param  {Number} [width=1]
     * @param  {Number} [height=1]
     * @return {TypedArray}
     */
    readPixels(x, y, width = 1, height = 1) {
        const TypedArray = getTypedArrayClass(this.type);
        const pixels = new TypedArray(width * height * 4);

        if (this._isInit) {
            const gl = this.gl;
            // convert to webgl coordinate system
            y = this.height - y - height;

            this.bind();
            gl.readPixels(x, y, width, height, this.format, this.type, pixels);
            this.unbind();
        }

        return pixels;
    },
    destroy() {
        this.destroyResource();
        this.gl = null;
        cache.removeObject(this);
    },
    /**
     * 销毁资源
     */
    destroyResource() {
        const gl = this.gl;
        if (gl) {
            if (this.framebuffer) {
                gl.deleteFramebuffer(this.framebuffer);
                this.framebuffer = null;
            }

            if (this.renderbuffer) {
                gl.deleteRenderbuffer(this.renderbuffer);
                this.renderbuffer = null;
            }

            if (this.texture) {
                this.texture.destroy();
                this.texture = null;
            }
        }
    }
});

export default Framebuffer;
<commit_msg>refactor: optimize multiple destroy framebuffer<commit_after>import Class from '../core/Class';
import Shader from '../shader/Shader';
import screenVert from '../shader/screen.vert';
import screenFrag from '../shader/screen.frag';
import Cache from '../utils/Cache';
import log from '../utils/log';
import Program from './Program';
import VertexArrayObject from './VertexArrayObject';
import math from '../math/math';
import Color from '../math/Color';
import GeometryData from '../geometry/GeometryData';
import Texture from '../texture/Texture';
import {
    getTypedArrayClass
} from '../utils/util';

import constants from '../constants';

const {
    TEXTURE_2D,
    RGBA,
    UNSIGNED_BYTE,
    COLOR_ATTACHMENT0,
    DEPTH_STENCIL,
    DEPTH_TEST,
    CULL_FACE,
    TRIANGLE_STRIP,
    NEAREST,
    CLAMP_TO_EDGE
} = constants;

const cache = new Cache();

/**
 * 帧缓冲
 * @class
 */
const Framebuffer = Class.create(/** @lends Framebuffer.prototype */ {
    Statics: {
        /**
         * 缓存
         * @readOnly
         * @memberOf Framebuffer
         * @type {Cache}
         */
        cache: {
            get() {
                return cache;
            }
        },
        /**
         * 重置所有framebuffer
         * @memberOf Framebuffer
         * @param  {WebGLRenderingContext} gl
         */
        reset(gl) { // eslint-disable-line no-unused-vars
            cache.each((framebuffer) => {
                framebuffer.reset();
            });
        },
        /**
         * 销毁所有 Framebuffer
         * @memberOf Framebuffer
         * @param  {WebGLRenderingContext} gl
         */
        destroy(gl) { // eslint-disable-line no-unused-vars
            cache.each((framebuffer) => {
                framebuffer.destroy();
            });
        }
    },

    /**
     * @default Framebuffer
     * @type {String}
     */
    className: 'Framebuffer',

    /**
     * @default true
     * @type {Boolean}
     */
    isFramebuffer: true,

    /**
     * bufferInternalFormat
     * @type {GLenum}
     * @default gl.DEPTH_STENCIL
     */
    bufferInternalFormat: DEPTH_STENCIL,

    /**
     * texture target
     * @type {GLenum}
     * @default gl.TEXTURE_2D
     */
    target: TEXTURE_2D,

    /**
     * texture format
     * @type {GLenum}
     * @default gl.RGBA
     */
    format: RGBA,

    /**
     * texture internalFormat
     * @type {GLenum}
     * @default gl.RGBA
     */
    internalFormat: RGBA,

    /**
     * texture type
     * @type {GLenum}
     * @default gl.UNSIGNED_BYTE
     */
    type: UNSIGNED_BYTE,
    /**
     * texture minFilter
     * @type {GLenum}
     * @default gl.NEAREST
     */
    minFilter: NEAREST,

    /**
     * texture magFilter
     * @type {GLenum}
     * @default gl.NEAREST
     */
    magFilter: NEAREST,

    /**
     * texture data
     * @type {TypedArray}
     * @default null
     */
    data: null,

    /**
     * attachment
     * @type {GLenum}
     * @default gl.COLOR_ATTACHMENT0
     */
    attachment: COLOR_ATTACHMENT0,

    /**
     * 是否需要renderbuffer
     * @type {Boolean}
     * @default true
     */
    needRenderbuffer: true,

    /**
     * 是否使用VAO
     * @type {Boolean}
     * @default true
     */
    useVao: true,

    /**
     * renderer
     * @type {WebGLRenderer}
     * @default null
     */
    renderer: null,

    /**
     * texture
     * @type {Texture}
     */
    texture: null,

    /**
     * renderbuffer
     * @type {WebGLRenderbuffer}
     */
    renderbuffer: null,

    /**
     * framebuffer
     * @type {WebGLFramebuffer}
     */
    framebuffer: null,

    _isInit: false,

    /**
     * @constructs
     * @param {WebGLRenderer}  renderer
     * @param  {Object} [params] 初始化参数，所有params都会复制到实例上
     */
    constructor(renderer, params) {
        this.id = math.generateUUID(this.className);
        this.renderer = renderer;
        Object.assign(this, params);

        if (!this.width) {
            this.width = renderer.width;
        }

        if (!this.height) {
            this.height = renderer.height;
        }

        cache.add(this.id, this);
    },
    /**
     * init
     */
    init() {
        if (!this._isInit && this.renderer.isInit) {
            this._isInit = true;
            const renderer = this.renderer;
            this.gl = renderer.gl;
            this.state = renderer.state;
            this.reset();
        }
    },
    /**
     * reset
     * @private
     */
    reset() {
        this.destroyResource();
        const gl = this.gl;
        /**
         * framebuffer
         * @type {WebGLFramebuffer}
         */
        this.framebuffer = gl.createFramebuffer();
        this.bind();
        if (this.needRenderbuffer) {
            this.renderbuffer = this.createRenderbuffer();
        }

        this.texture = this.createTexture();

        if (!this.isComplete()) {
            log.warn('Framebuffer is not complete => ' + gl.checkFramebufferStatus(gl.FRAMEBUFFER));
        }

        this.unbind();
    },
    /**
     * framebuffer 是否完成
     * @return {Boolean}
     */
    isComplete() {
        const gl = this.gl;
        if (gl && gl.checkFramebufferStatus(gl.FRAMEBUFFER) === gl.FRAMEBUFFER_COMPLETE) {
            return true;
        }
        return false;
    },
    /**
     * 绑定
     */
    bind() {
        this.init();
        if (this._isInit) {
            this.state.bindFramebuffer(this.gl.FRAMEBUFFER, this.framebuffer);
        }
    },
    /**
     * 解绑
     */
    unbind() {
        this.init();
        if (this._isInit) {
            const state = this.state;
            state.bindFramebuffer(this.gl.FRAMEBUFFER, state.preFramebuffer);
        }
    },
    clear(clearColor = new Color(0, 0, 0, 0)) {
        if (this._isInit) {
            const {
                gl
            } = this;
            gl.clearColor(clearColor.r, clearColor.g, clearColor.b, clearColor.a);
            gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
        }
    },
    /**
     * 渲染当前纹理
     * @param  {Number} [x=0]
     * @param  {Number} [y=0]
     * @param  {Number} [width=1]
     * @param  {Number} [height=1]
     * @param  {Color} [clearColor=null]
     */
    render(x = 0, y = 0, width = 1, height = 1, clearColor) {
        if (this._isInit) {
            const {
                gl,
                state
            } = this;
            state.disable(DEPTH_TEST);
            state.disable(CULL_FACE);

            if (clearColor) {
                this.clear(clearColor);
            }

            const shader = Shader.getCustomShader(screenVert, screenFrag, '', 'FramebufferTextureShader');
            const program = Program.getProgram(shader, state);
            program.useProgram();

            const vaoId = `${x}_${y}_${width}_${height}_${program.id}`;
            const vao = VertexArrayObject.getVao(gl, vaoId, {
                useVao: this.useVao,
                useInstanced: false,
                mode: TRIANGLE_STRIP
            });

            if (vao.isDirty) {
                vao.isDirty = false;
                x = x * 2 - 1;
                y = 1 - y * 2;
                width *= 2;
                height *= 2;
                const vertices = [x, y, x + width, y, x, y - height, x + width, y - height];
                vao.addAttribute(new GeometryData(new Float32Array(vertices), 2), program.attributes.a_position);
                vao.addAttribute(new GeometryData(new Float32Array([0, 1, 1, 1, 0, 0, 1, 0]), 2), program.attributes.a_texcoord0);
            }

            state.activeTexture(gl.TEXTURE0);
            state.bindTexture(gl.TEXTURE_2D, this.texture.getGLTexture(state));
            vao.draw();
        }
    },
    /**
     * 生成 Renderbuffer
     * @private
     * @return {WebGLRenderbuffer}
     */
    createRenderbuffer() {
        const {
            gl,
            width,
            height
        } = this;
        const renderbuffer = gl.createRenderbuffer();
        gl.bindRenderbuffer(gl.RENDERBUFFER, renderbuffer);
        gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height);
        gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, renderbuffer);
        return renderbuffer;
    },
    /**
     * 生成纹理
     * @private
     * @return {Texture}
     */
    createTexture() {
        const state = this.state;
        const gl = state.gl;
        const texture = new Texture({
            minFilter: this.minFilter,
            magFilter: this.magFilter,
            internalFormat: this.internalFormat,
            format: this.format,
            type: this.type,
            width: this.width,
            height: this.height,
            image: this.data,
            wrapS: CLAMP_TO_EDGE,
            wrapT: CLAMP_TO_EDGE
        });

        const glTexture = texture.getGLTexture(state);
        gl.framebufferTexture2D(gl.FRAMEBUFFER, this.attachment, this.target, glTexture, 0);

        return texture;
    },
    /**
     * resize
     * @param  {Number} width
     * @param  {Number} height
     * @param  {Boolean} [force=true]
     */
    resize(width, height, force) {
        if (force || this.width !== width || this.height !== height) {
            this.width = width;
            this.height = height;

            if (this._isInit) {
                this.reset();
            }
        }
    },
    /**
     * 读取区域像素
     * @param  {Number} x
     * @param  {Number} y
     * @param  {Number} [width=1]
     * @param  {Number} [height=1]
     * @return {TypedArray}
     */
    readPixels(x, y, width = 1, height = 1) {
        const TypedArray = getTypedArrayClass(this.type);
        const pixels = new TypedArray(width * height * 4);

        if (this._isInit) {
            const gl = this.gl;
            // convert to webgl coordinate system
            y = this.height - y - height;

            this.bind();
            gl.readPixels(x, y, width, height, this.format, this.type, pixels);
            this.unbind();
        }

        return pixels;
    },
    /**
     * 销毁资源
     * @return {Framebuffer} this
     */
    destroy() {
        if (this._isDestroyed) {
            return this;
        }
        this.destroyResource();
        this.gl = null;
        cache.removeObject(this);

        this._isDestroyed = true;
        return this;
    },
    /**
     * 只销毁 gl 资源
     * @return {Framebuffer} this
     */
    destroyResource() {
        const gl = this.gl;
        if (gl) {
            if (this.framebuffer) {
                gl.deleteFramebuffer(this.framebuffer);
                this.framebuffer = null;
            }

            if (this.renderbuffer) {
                gl.deleteRenderbuffer(this.renderbuffer);
                this.renderbuffer = null;
            }

            if (this.texture) {
                this.texture.destroy();
                this.texture = null;
            }
        }
    }
});

export default Framebuffer;
<|endoftext|>


<commit_before>$(document).ready(function() {

  $('body').append(
  "
 \
   \

This portfolio is under contruction.
 \
   \
   Please click here to visit my past portfolio
 \

"
  );

  $('#popup').css({
    "color":"white",
    "float":"right",
    "margin":"20px",
    "cursor": "pointer"
  });

  var $popup = $('#popup');
  $popup.on('click', function(){
  $('.notice').remove();
  });

  setTimeout(function() {
  $('.notice').remove();
  }, 12000)

});<commit_msg>2.03 -- update for js<commit_after>$(document).ready(function() {

  $( window ).unload(function() {

  $('body').append(
  "
 \
   \

This portfolio is under contruction.
 \
   \
   Please click here to visit my past portfolio
 \

"
  );

  $('#popup').css({
    "color":"white",
    "float":"right",
    "margin":"20px",
    "cursor": "pointer"
  });

  var $popup = $('#popup');
  $popup.on('click', function(){
  $('.notice').remove();
  });

  setTimeout(function() {
  $('.notice').remove();
  }, 12000)

 });

})
<|endoftext|>


<commit_before>var path 		= require('path');
var rootPath 	= path.normalize(__dirname + '/../../');

module.exports 	= {
    local: {
        baseUrl: 'http://localhost:3004',
        db: 'mongodb://localhost/rp_local',
        rootPath: rootPath,
        port: process.env.PORT || 3004
    },
    staging : {
        baseUrl: 'http://dev.resourceprojects.org',
        //db: '@aws-us-east-1-portal.14.dblayer.com:10669/rp_dev?ssl=true',
        db: '@aws-us-east-1-portal.14.dblayer.com:10669,aws-us-east-1-portal.13.dblayer.com:10499/rp_dev?ssl=true',
        rootPath: rootPath,
        port: process.env.PORT || 80
    }
};
<commit_msg>changed port<commit_after>var path 		= require('path');
var rootPath 	= path.normalize(__dirname + '/../../');

module.exports 	= {
    local: {
        baseUrl: 'http://localhost:3030',
        db: 'mongodb://localhost/rp_local',
        rootPath: rootPath,
        port: process.env.PORT || 3030
    },
    staging : {
        baseUrl: 'http://dev.resourceprojects.org',
        //db: '@aws-us-east-1-portal.14.dblayer.com:10669/rp_dev?ssl=true',
        db: '@aws-us-east-1-portal.14.dblayer.com:10669,aws-us-east-1-portal.13.dblayer.com:10499/rp_dev?ssl=true',
        rootPath: rootPath,
        port: process.env.PORT || 80
    }
};
<|endoftext|>


<commit_before>var
	sourceMap = require('source-map'),
	SourceMapGenerator = sourceMap.SourceMapGenerator;

var
	Parser = require('./build/parser'),
	path = require('path'),
	fs = require('fs');

var collection = require('collection.js');

global.Collection = collection.Collection;
global.$C = collection.$C;

/** @type {!Array} */
exports.VERSION = [1, 2, 0];

/**
 * Builds a file
 *
 * @param {string} file - the file path
 * @param {Object} params - additional parameters
 * @param {Object=} [params.flags] - a map of flags
 * @param {Object=} [params.labels] - a map of labels
 * @param {?string} [params.content] - the file text
 * @param {?string} [params.lineSeparator] - EOL symbol
 * @param {Array=} [params.replacers] - an array of transform functions
 * @param {?boolean} [params.sourceMaps] - if is true, then will be generated a source map
 * @param {?string} [params.sourceMapName] - a filename of the source map
 * @param {?string} [params.sourceFileName] - a filename of the generated file that this source map is associated with
 * @param {?string} [params.sourceRoot] - a root for all relative URLs in this source map
 * @param {function(Error, string=, string=, SourceMapGenerator=)} callback - a callback function
 */
exports.compile = function (file, params, callback) {
	params = params || {};

	params.flags = params.flags || {};
	params.labels = params.labels || {};
	params.lineSeparator = params.lineSeparator || '\n';
	params.replacers = params.replacers || [];
	params.sourceMaps = Boolean(params.sourceMaps);

	file = url(file);
	params.sourceMapName = params.sourceMapName && url(params.sourceMapName);
	params.sourceFileName = params.sourceFileName ?
		url(params.sourceFileName) : file;

	function finish(err, fileStructure, path) {
		if (err) {
			return callback(err);
		}

		var map = params.sourceMaps ?
			new SourceMapGenerator({
				file: params.sourceFileName,
				sourceRoot: params.sourceRoot
			}) : null;

		var result = fileStructure.compile(params.labels, params.flags, map);

		if (params.sourceMapName) {
			fs.writeFile(params.sourceMapName, String(map), function (err) {
				callback(err, result, path, map);
			});

		} else {
			callback(null, result, path, map);
		}
	}

	function url(url) {
		return path.normalize(
			path.resolve(module.parent ?
				path.dirname(module.parent.filename) : '', url)
		);
	}

	var parser = new Parser({
		nl: params.lineSeparator,
		replacers: params.replacers,
		sourceMaps: params.sourceMaps
	});

	Parser.cursor = 1;
	Parser.diff = 0;
	Parser.tmpDiff = 0;
	Parser.diffMap = {};
	Parser.current = null;

	if (params.content != null) {
		parser.normalizePath(file, function (err, file) {
			if (err) {
				return callback(err);
			}

			parser.parse(file, String(params.content), finish);
		});

	} else {
		parser.parseFile(file, finish);
	}
};
<commit_msg>Working on support for sourcemaps<commit_after>var
	sourceMap = require('source-map'),
	SourceMapGenerator = sourceMap.SourceMapGenerator;

var
	Parser = require('./build/parser'),
	path = require('path'),
	fs = require('fs'),
	async = require('async');

var collection = require('collection.js');

global.Collection = collection.Collection;
global.$C = collection.$C;

/** @type {!Array} */
exports.VERSION = [1, 2, 0];

/**
 * Builds a file
 *
 * @param {string} file - the file path
 * @param {Object} params - additional parameters
 * @param {Object=} [params.flags] - a map of flags
 * @param {Object=} [params.labels] - a map of labels
 * @param {?string} [params.content] - the file text
 * @param {?string} [params.lineSeparator] - EOL symbol
 * @param {Array=} [params.replacers] - an array of transform functions
 * @param {?boolean} [params.sourceMaps] - if is true, then will be generated a source map
 * @param {?string} [params.sourceMapName] - a filename of the source map
 * @param {?string} [params.sourceFileName] - a filename of the generated file that this source map is associated with
 * @param {?string} [params.sourceRoot] - a root for all relative URLs in this source map
 * @param {function(Error, string=, string=, SourceMapGenerator=)} callback - a callback function
 */
exports.compile = function (file, params, callback) {
	params = params || {};

	params.flags = params.flags || {};
	params.labels = params.labels || {};
	params.lineSeparator = params.lineSeparator || '\n';
	params.replacers = params.replacers || [];
	params.sourceMaps = Boolean(params.sourceMaps);

	file = url(file);
	const
		sourceMapName = params.sourceMapName && url(params.sourceMapName),
		sourceFileName = params.sourceFileName ?
			url(params.sourceFileName) : file;

	function finish(err, fileStructure, src) {
		if (err) {
			return callback(err);
		}

		var map = params.sourceMaps ?
			new SourceMapGenerator({
				file: sourceFileName,
				sourceRoot: params.sourceRoot
			}) : null;

		var
			result = fileStructure.compile(params.labels, params.flags, map),
			tasks = [];

		if (sourceMapName) {
			tasks.push(function (cb) {
				fs.writeFile(sourceMapName, String(map), cb);
			});
		}

		if (params.sourceFileName) {
			tasks.push(function (cb) {
				result +=
					params.lineSeparator +
					'//# sourceMappingURL=' +

					path.join(
						path.relative(path.dirname(sourceFileName), path.dirname(sourceMapName)),
						path.basename(sourceMapName)
					) +

					params.lineSeparator;

				fs.writeFile(sourceFileName, result, cb);
			});
		}

		async.parallel(tasks, function () {
			callback(err, result, src, map);
		})
	}

	function url(url) {
		return path.normalize(
			path.resolve(module.parent ?
				path.dirname(module.parent.filename) : '', url)
		);
	}

	var parser = new Parser({
		nl: params.lineSeparator,
		replacers: params.replacers,
		sourceMaps: params.sourceMaps
	});

	Parser.cursor = 1;
	Parser.diff = 0;
	Parser.tmpDiff = 0;
	Parser.diffMap = {};
	Parser.current = null;

	if (params.content != null) {
		parser.normalizePath(file, function (err, file) {
			if (err) {
				return callback(err);
			}

			parser.parse(file, String(params.content), finish);
		});

	} else {
		parser.parseFile(file, finish);
	}
};
<|endoftext|>


<commit_before>var epeek_theme_tree_ensembl_genetree_annot = function() {
    "use strict";

    var height = 30;

    var tree = epeek.tree();
    var annot = epeek.track();

    var theme = function (ta, div) {

        var label = epeek.tree.label.text()
            .text(function (node) {
                if (node.children) {
                    return "";
                } else {
                    return node.id.accession
                }
            })
            .fontsize(10)
	    .height(height);

	var rest = epeek.eRest();

	var gene_tree_id = "ENSGT00390000003602";
	var gene_tree_url = rest.url.gene_tree ({
	    id : gene_tree_id,
	    aligned : true
	});

	d3.json('http://127.0.0.1:1337/themes/ensembl_genetree_annot/ENSGT00390000003602.json', function (err, resp) {
	    deploy_vis(resp);
	});

	// rest.call ({url : gene_tree_url,
	// 	    success : function (resp) {
	// 		deploy_vis(resp)
	// 	    }
	// 	   });

	// TREE SIDE
	var deploy_vis = function (tree_obj) {
	    tree
		.data (tree_obj.tree)
		.layout (epeek.tree.layout.vertical()
			 .width(430)
			 .scale(false)
			)
		.label (label);

	    var reduce_row = function (row) {
		var data = [];
		var curr = {
		    streak : 0,
		    val    : undefined,
		    start  : 1
		};
		var curr_streak = 0;
		for (var i=0; i<row.length; i++) {
		    if (curr.val === undefined) {
			curr.val = row[i];
		    }
		    if (row[i] === curr.val) {
			curr.streak++;
		    } else {
			if (curr.val > 0 && curr.streak > 5) {
			    data.push ({ start : curr.start,
					 end   : i,
					 type  : (curr.val > 1) ? 'high' : 'low'
				      });
			}
			curr.streak = 1;
			curr.val    = row[i];
			curr.start  = i;
		    }
		}
		if (curr.val > 0) {
		    data.push ({ start : curr.start,
				end   : row.length,
				 type  : (curr.val > 1) ? 'high' : 'low'
			      });
		}

		return data;
	    };

	    var reduce = function (rows) {
		var obj = {};

		var red = epeek.utils.reduce();
		for (var id in rows) {
		    if (rows.hasOwnProperty (id)) {
			// obj[id] = reduce_row(rows[id]);
			obj[id] = red(rows[id]);
		    }
		}

		return obj;
	    };

	    var process_aln = function (seqs) {
		var cons_seqs = {};
		var conservation = {};
		for (var i=0; i<seqs.length; i++) {
		    cons_seqs[seqs[i].data()._id] = [];
		}

		for (var i=0; i<seqs.length; i++) {
		    conservation[seqs[i].data()._id] = [];
		}

		for (var i=0; i<seqs[0].data().sequence.mol_seq.seq.length; i++) {
		    var cons = {};
		    for (var j=0; j<seqs.length; j++) {
			var p = seqs[j].data();
			if (cons[p.sequence.mol_seq.seq[i]] === undefined) {
			    cons[p.sequence.mol_seq.seq[i]] = 0;
			}
			cons[p.sequence.mol_seq.seq[i]]++;
		    }

		    for (var j=0; j<seqs.length; j++) {
			var val = cons[seqs[j].data().sequence.mol_seq.seq[i]] / seqs.length;
			var f = 0;
			if (val > 0.33 && val < 0.66) {
			    f = 1;
			}
			if (val > 0.66) {
			    f = 2;
			}
			cons_seqs[seqs[j].data()._id].push(f);
			conservation[seqs[j].data()._id].push({
			    pos : i,
			    val : val
			})
		    }
		}

		// var processed = reduce (cons_seqs);
		// return processed;
		return reduce (conservation);
	    };

	    var leaves = tree.tree().get_all_leaves();
	    var data = process_aln(leaves);

	    // TRACK SIDE
	    annot
		.from(0)
		.width(300);

	    var track = function (leaf) {
		var id = leaf._id;
		return epeek.track.track()
                    .foreground_color("steelblue")
                    .background_color("#EBF5FF")
                    .data (epeek.track.data()
			   .update ( epeek.track.retriever.sync()
				     .retriever (function () {
					 return data[id] || [];
				     })
				   )
			  )
		    .display(epeek.track.feature.area()
			     .index(function (d) {
				 return d.pos;
			     }));
            };

	    var max_val = d3.max(leaves, function (d) {return d.data().sequence.mol_seq.seq.length});

	    ta.tree(tree);
	    ta.annotation(annot
			  .to(max_val)
			  .right(max_val)
			  .zoom_out(max_val)
			 );
	    ta.ruler("both");
	    ta.track(track);

	    ta(div);
	}
    }

    return theme;
};
<commit_msg>fixing path to json file<commit_after>var epeek_theme_tree_ensembl_genetree_annot = function() {
    "use strict";

    var height = 30;

    var tree = epeek.tree();
    var annot = epeek.track();

    var theme = function (ta, div) {

        var label = epeek.tree.label.text()
            .text(function (node) {
                if (node.children) {
                    return "";
                } else {
                    return node.id.accession
                }
            })
            .fontsize(10)
	    .height(height);

	var rest = epeek.eRest();

	var gene_tree_id = "ENSGT00390000003602";
	var gene_tree_url = rest.url.gene_tree ({
	    id : gene_tree_id,
	    aligned : true
	});

	d3.json('/themes/ensembl_genetree_annot/ENSGT00390000003602.json', function (err, resp) {
	    deploy_vis(resp);
	});

	// rest.call ({url : gene_tree_url,
	// 	    success : function (resp) {
	// 		deploy_vis(resp)
	// 	    }
	// 	   });

	// TREE SIDE
	var deploy_vis = function (tree_obj) {
	    tree
		.data (tree_obj.tree)
		.layout (epeek.tree.layout.vertical()
			 .width(430)
			 .scale(false)
			)
		.label (label);

	    var reduce_row = function (row) {
		var data = [];
		var curr = {
		    streak : 0,
		    val    : undefined,
		    start  : 1
		};
		var curr_streak = 0;
		for (var i=0; i<row.length; i++) {
		    if (curr.val === undefined) {
			curr.val = row[i];
		    }
		    if (row[i] === curr.val) {
			curr.streak++;
		    } else {
			if (curr.val > 0 && curr.streak > 5) {
			    data.push ({ start : curr.start,
					 end   : i,
					 type  : (curr.val > 1) ? 'high' : 'low'
				      });
			}
			curr.streak = 1;
			curr.val    = row[i];
			curr.start  = i;
		    }
		}
		if (curr.val > 0) {
		    data.push ({ start : curr.start,
				end   : row.length,
				 type  : (curr.val > 1) ? 'high' : 'low'
			      });
		}

		return data;
	    };

	    var reduce = function (rows) {
		var obj = {};

		var red = epeek.utils.reduce();
		for (var id in rows) {
		    if (rows.hasOwnProperty (id)) {
			// obj[id] = reduce_row(rows[id]);
			obj[id] = red(rows[id]);
		    }
		}

		return obj;
	    };

	    var process_aln = function (seqs) {
		var cons_seqs = {};
		var conservation = {};
		for (var i=0; i<seqs.length; i++) {
		    cons_seqs[seqs[i].data()._id] = [];
		}

		for (var i=0; i<seqs.length; i++) {
		    conservation[seqs[i].data()._id] = [];
		}

		for (var i=0; i<seqs[0].data().sequence.mol_seq.seq.length; i++) {
		    var cons = {};
		    for (var j=0; j<seqs.length; j++) {
			var p = seqs[j].data();
			if (cons[p.sequence.mol_seq.seq[i]] === undefined) {
			    cons[p.sequence.mol_seq.seq[i]] = 0;
			}
			cons[p.sequence.mol_seq.seq[i]]++;
		    }

		    for (var j=0; j<seqs.length; j++) {
			var val = cons[seqs[j].data().sequence.mol_seq.seq[i]] / seqs.length;
			var f = 0;
			if (val > 0.33 && val < 0.66) {
			    f = 1;
			}
			if (val > 0.66) {
			    f = 2;
			}
			cons_seqs[seqs[j].data()._id].push(f);
			conservation[seqs[j].data()._id].push({
			    pos : i,
			    val : val
			})
		    }
		}

		// var processed = reduce (cons_seqs);
		// return processed;
		return reduce (conservation);
	    };

	    var leaves = tree.tree().get_all_leaves();
	    var data = process_aln(leaves);

	    // TRACK SIDE
	    annot
		.from(0)
		.width(300);

	    var track = function (leaf) {
		var id = leaf._id;
		return epeek.track.track()
                    .foreground_color("steelblue")
                    .background_color("#EBF5FF")
                    .data (epeek.track.data()
			   .update ( epeek.track.retriever.sync()
				     .retriever (function () {
					 return data[id] || [];
				     })
				   )
			  )
		    .display(epeek.track.feature.area()
			     .index(function (d) {
				 return d.pos;
			     }));
            };

	    var max_val = d3.max(leaves, function (d) {return d.data().sequence.mol_seq.seq.length});

	    ta.tree(tree);
	    ta.annotation(annot
			  .to(max_val)
			  .right(max_val)
			  .zoom_out(max_val)
			 );
	    ta.ruler("both");
	    ta.track(track);

	    ta(div);
	}
    }

    return theme;
};
<|endoftext|>


<commit_before>(function () {

    'use strict';
    var scripts = document.getElementsByTagName("script");
    var currentScriptPath = scripts[scripts.length - 1].src;

    angular.module('acdesarrollos.cotizador', ['ngRoute', ['mailer/mailer.js']])
        .controller('CotizadorController', CotizadorController);

    CotizadorController.$inject = ['$scope', '$location', 'MailerService'];

    function CotizadorController($scope, $location, MailerService) {
        var vm = this;

        //Contacto
        /*
        vm.nombre = '';
        vm.empresa = '';
        vm.email = '';
        vm.telefono = '';
        vm.message = '';
*/
        //Nuestros Servicios
        vm.desarrolloweb = false;
        vm.hosting = false;
        vm.logotipos = false;
        vm.desarrollografico = false;
        vm.dominio = false;
        vm.impresion = false;

        //Diseo de Pgina Web
        vm.nuevapagina = false;
        vm.comentario = '';
        vm.slider_fijo = false;
        vm.slider_administrable = false;
        vm.contactos = false;
        vm.empresa_info = false;
        vm.producto_info = false;
        vm.multipaginas = false;
        vm.noticias = false;
        vm.usuarios = false;
        vm.ecommerce = false;
        vm.chat = false;
        vm.cobros_online = false;
        vm.imagenes_admin = false;
        vm.website_referencia = '';

        //Registro de Dominios
        vm.extension_1 = false;
        vm.extension_2 = false;
        vm.extension_3 = false;
        vm.dominio_deseado = '';

        //Diseo Grfico
        vm.logotipo = false;
        vm.tarjeta = false;
        vm.catalogo = false;
        vm.otro_disenio_grafico = '';

        //Informacin adicional
        vm.como_nos_conocio = '';
        vm.desea_reunion = [];
        vm.lugar_reunion = '';
        vm.fecha_reunion = '';

        vm.clienteEntity = {};
        vm.reunionEntity = {};
        vm.hostingEntity = {};

        vm.nuestros_servicios = [];
        vm.pagina_web = [];
        vm.registro_dominio = [];
        vm.dominio_a_registrar = [];
        vm.hosting_y_correo = [];
        vm.graficos = [];
        vm.plan_hosting = [
            {id:0, nombre:'--- Seleccione un plan ---'},
            {id:1, nombre:'Hosting Emprendedores (1 GB de espacio)', precio: 50},
            {id:2, nombre:'Hosting Empresarial (10 GB de espacio)', precio: 150}
        ];

        vm.hosting_selected = vm.plan_hosting[0];

        //Funciones
        vm.sendMail = sendMail;

        function sendMail() {
            if (vm.clienteEntity.nombre.trim() == '') {
                return;
            }
            if (vm.clienteEntity.email.trim() == '') {
                return;
            }
            if (vm.clienteEntity.telefono.trim() == '') {
                return;
            }

            console.log(vm.nuevapagina);

            //var cliente = {nombre:vm.nombre, empresa:vm.empresa, email:vm.email, telefono:vm.telefono, message:vm.message};

            //Diseo de Pgina Web
            var nueva_web = '';
            if(vm.nuevapagina == 1) {
                nueva_web = 'Diseo de una nueva pgina web';
            } else if(vm.nuevapagina == 2) {
                nueva_web = 'Rediseo de su pgina actual';
            } else if(vm.nuevapagina == 3) {
                nueva_web = 'Servicio de Mantenimiento';
            }

            //Servicio de Hosting y Correos
            createHosting();

            //Registro de Dominios
            var dominio_info = '';
            if(vm.registro_dominio == 1) {
                dominio_info = 'Registrar un nuevo dominio';
            } else if(vm.registro_dominio == 2) {
                dominio_info = 'No, ya tengo el dominio';
            } else if(vm.registro_dominio == 3) {
                dominio_info = 'No estoy seguro';
            }

            //Informacin Adicional
            if(vm.desea_reunion == 1 || vm.desea_reunion == 3) {
                if(fecha == undefined)
                    return;
            }

            addServicios();

            addPaginaWeb();

            addRegistroDominio();

            addDisenioGrafico();

            createReunion();

            MailerService.sendCotizacion(vm.clienteEntity, vm.nuestros_servicios, nueva_web, vm.pagina_web,
                vm.comentario, vm.website_referencia, dominio_info, vm.dominio_a_registrar,
                vm.dominio_deseado, vm.graficos, vm.otro_disenio_grafico, vm.reunionEntity, vm.hostingEntity,
                function(data){
                    console.log(data);

                    cleanVariables();
            });
        }

        function createHosting() {
            var hosting_correo = '';
            if(vm.hosting_y_correo == 1) {
                hosting_correo = 'Si';
            } else if(vm.hosting_y_correo == 2) {
                hosting_correo = 'No, ya tengo el hosting';
            } else if(vm.hosting_y_correo == 3) {
                hosting_correo = 'No estoy seguro';
            }

            console.log(vm.hosting_selected);

            vm.hostingEntity = {
                solicitar_hosting: hosting_correo,
                plan: vm.hosting_selected.nombre,
                precio: vm.hosting_selected.precio
            }
        }

        function createReunion() {
            var desea_una_reunion = '';
            if(vm.desea_reunion == 1 || vm.desea_reunion == 3) {
                desea_una_reunion = 'SI';
            } else if(vm.desea_reunion == 2) {
                desea_una_reunion = 'NO';
            }

            vm.reunionEntity = {
                como_nos_conocio: vm.como_nos_conocio,
                desea_reunion: desea_una_reunion,
                lugar_reunion: vm.lugar_reunion,
                fecha_reunion: formattedDate(vm.fecha_reunion)
            };
        }

        function addServicios() {
            if (vm.desarrolloweb) {
                vm.nuestros_servicios.push({nombre:'Diseo de Pgina Web', precio:'150'});
            }
            if (vm.hosting) {
                vm.nuestros_servicios.push({nombre:'Hosting', precio:'100'});
            }
            if (vm.logotipos) {
                vm.nuestros_servicios.push({nombre:'Diseo de Logotipos', precio:'250'});
            }
            if (vm.desarrollografico) {
                vm.nuestros_servicios.push({nombre:'Diseo Grfico', precio:'120'});
            }
            if (vm.dominio) {
                vm.nuestros_servicios.push({nombre:'Registro de Dominio', precio:'300'});
            }
            if (vm.impresion) {
                vm.nuestros_servicios.push({nombre:'Impresin', precio:'100'});
            }

            console.log(vm.nuestros_servicios);
        }

        function addPaginaWeb() {
            if (vm.slider_fijo) {
                vm.pagina_web.push({nombre:'Slider Fijo', precio:'550'});
            }
            if (vm.slider_administrable) {
                vm.pagina_web.push({nombre:'Slider Autoadministrable', precio:'100'});
            }
            if (vm.contactos) {
                vm.pagina_web.push({nombre:'Contactos', precio:'250'});
            }
            if (vm.empresa_info) {
                vm.pagina_web.push({nombre:'Informacin de Empresas', precio:'120'});
            }
            if (vm.producto_info) {
                vm.pagina_web.push({nombre:'Informacin de Productos', precio:'300'});
            }
            if (vm.multipaginas) {
                vm.pagina_web.push({nombre:'Multipgina', precio:'500'});
            }
            if (vm.noticias) {
                vm.pagina_web.push({nombre:'Noticias', precio:'400'});
            }
            if (vm.usuarios) {
                vm.pagina_web.push({nombre:'Usuarios', precio:'230'});
            }
            if (vm.ecommerce) {
                vm.pagina_web.push({nombre:'Ecommerce', precio:'100'});
            }
            if (vm.chat) {
                vm.pagina_web.push({nombre:'Chat en linea', precio:'150'});
            }
            if (vm.cobros_online) {
                vm.pagina_web.push({nombre:'Cobros Online', precio:'200'});
            }
            if (vm.imagenes_admin) {
                vm.pagina_web.push({nombre:'Administracin de Imgenes', precio:'300'});
            }

            console.log(vm.pagina_web);
        }

        function addRegistroDominio() {
            if (vm.extension_1) {
                vm.dominio_a_registrar.push({nombre:'.com / .net /', precio:'550'});
            }
            if (vm.extension_2) {
                vm.dominio_a_registrar.push({nombre:'.com.do / .do', precio:'100'});
            }
            if (vm.extension_3) {
                vm.dominio_a_registrar.push({nombre:'otro', precio:'250'});
            }

            console.log(vm.dominio_a_registrar);
        }

        function addDisenioGrafico(){
            if (vm.logotipo) {
                vm.graficos.push({nombre:'Diseo de Logotipo', precio:'550'});
            }
            if (vm.tarjeta) {
                vm.graficos.push({nombre:'Tarjetas', precio:'100'});
            }
            if (vm.catalogo) {
                vm.graficos.push({nombre:'Catlogo', precio:'250'});
            }

            console.log(vm.graficos);
        }

        function formattedDate(date) {
            var d = new Date(date || Date.now()),
                month = '' + (d.getMonth() + 1),
                day = '' + d.getDate(),
                year = d.getFullYear();

            if (month.length < 2) month = '0' + month;
            if (day.length < 2) day = '0' + day;

            return [day, month, year].join('/');
        }

        function cleanVariables() {
            vm.clienteEntity = {};
            vm.reunionEntity = {};
            vm.hostingEntity = {};

            //Nuestros Servicios
            vm.desarrolloweb = false;
            vm.hosting = false;
            vm.logotipos = false;
            vm.desarrollografico = false;
            vm.dominio = false;
            vm.impresion = false;

            //Diseo de Pgina Web
            vm.nuevapagina = false;
            vm.comentario = '';
            vm.slider_fijo = false;
            vm.slider_administrable = false;
            vm.contactos = false;
            vm.empresa_info = false;
            vm.producto_info = false;
            vm.multipaginas = false;
            vm.noticias = false;
            vm.usuarios = false;
            vm.ecommerce = false;
            vm.chat = false;
            vm.cobros_online = false;
            vm.imagenes_admin = false;
            vm.website_referencia = '';

            //Registro de Dominios
            vm.extension_1 = false;
            vm.extension_2 = false;
            vm.extension_3 = false;
            vm.dominio_deseado = '';

            //Diseo Grfico
            vm.logotipo = false;
            vm.tarjeta = false;
            vm.catalogo = false;
            vm.otro_disenio_grafico = '';

            //Informacin adicional
            vm.como_nos_conocio = '';
            vm.desea_reunion = [];
            vm.lugar_reunion = '';
            vm.fecha_reunion = '';

            vm.nuestros_servicios = [];
            vm.pagina_web = [];
            vm.registro_dominio = [];
            vm.dominio_a_registrar = [];
            vm.hosting_y_correo = [];
            vm.graficos = [];
        }

    };

})();

<commit_msg>Mejoras<commit_after>(function () {

    'use strict';
    var scripts = document.getElementsByTagName("script");
    var currentScriptPath = scripts[scripts.length - 1].src;

    angular.module('acdesarrollos.cotizador', ['ngRoute', ['mailer/mailer.js']])
        .controller('CotizadorController', CotizadorController);

    CotizadorController.$inject = ['$scope', '$location', 'MailerService'];

    function CotizadorController($scope, $location, MailerService) {
        var vm = this;

        //Contacto
        /*
        vm.nombre = '';
        vm.empresa = '';
        vm.email = '';
        vm.telefono = '';
        vm.message = '';
*/
        //Nuestros Servicios
        vm.desarrolloweb = false;
        vm.hosting = false;
        vm.logotipos = false;
        vm.desarrollografico = false;
        vm.dominio = false;
        vm.impresion = false;

        //Diseo de Pgina Web
        vm.nuevapagina = false;
        vm.comentario = '';
        vm.slider_fijo = false;
        vm.slider_administrable = false;
        vm.contactos = false;
        vm.empresa_info = false;
        vm.producto_info = false;
        vm.multipaginas = false;
        vm.noticias = false;
        vm.usuarios = false;
        vm.ecommerce = false;
        vm.chat = false;
        vm.cobros_online = false;
        vm.imagenes_admin = false;
        vm.website_referencia = '';

        //Registro de Dominios
        vm.extension_1 = false;
        vm.extension_2 = false;
        vm.extension_3 = false;
        vm.dominio_deseado = '';

        //Diseo Grfico
        vm.logotipo = false;
        vm.tarjeta = false;
        vm.catalogo = false;
        vm.otro_disenio_grafico = '';

        //Informacin adicional
        vm.como_nos_conocio = '';
        vm.desea_reunion = [];
        vm.lugar_reunion = '';
        vm.fecha_reunion = '';

        vm.clienteEntity = {};
        vm.reunionEntity = {};
        vm.hostingEntity = {};

        vm.nuestros_servicios = [];
        vm.pagina_web = [];
        vm.registro_dominio = [];
        vm.dominio_a_registrar = [];
        vm.hosting_y_correo = [];
        vm.graficos = [];
        vm.plan_hosting = [
            {id:0, nombre:'--- Seleccione un plan ---'},
            {id:1, nombre:'Hosting Emprendedores (1 GB de espacio)', precio: 50},
            {id:2, nombre:'Hosting Empresarial (10 GB de espacio)', precio: 150}
        ];

        vm.hosting_selected = vm.plan_hosting[0];

        //Funciones
        vm.sendMail = sendMail;

        function sendMail() {
            if (vm.clienteEntity.nombre.trim() == '') {
                return;
            }
            if (vm.clienteEntity.email.trim() == '') {
                return;
            }
            if (vm.clienteEntity.telefono.trim() == '') {
                return;
            }

            console.log(vm.nuevapagina);

            //var cliente = {nombre:vm.nombre, empresa:vm.empresa, email:vm.email, telefono:vm.telefono, message:vm.message};

            //Diseo de Pgina Web
            var nueva_web = '';
            if(vm.nuevapagina == 1) {
                nueva_web = 'Diseo de una nueva pgina web';
            } else if(vm.nuevapagina == 2) {
                nueva_web = 'Rediseo de su pgina actual';
            } else if(vm.nuevapagina == 3) {
                nueva_web = 'Servicio de Mantenimiento';
            }

            //Servicio de Hosting y Correos
            createHosting();

            //Registro de Dominios
            var dominio_info = '';
            if(vm.registro_dominio == 1) {
                dominio_info = 'Registrar un nuevo dominio';
            } else if(vm.registro_dominio == 2) {
                dominio_info = 'No, ya tengo el dominio';
            } else if(vm.registro_dominio == 3) {
                dominio_info = 'No estoy seguro';
            }

            //Informacin Adicional

            addServicios();

            addPaginaWeb();

            addRegistroDominio();

            addDisenioGrafico();

            createReunion();

            MailerService.sendCotizacion(vm.clienteEntity, vm.nuestros_servicios, nueva_web, vm.pagina_web,
                vm.comentario, vm.website_referencia, dominio_info, vm.dominio_a_registrar,
                vm.dominio_deseado, vm.graficos, vm.otro_disenio_grafico, vm.reunionEntity, vm.hostingEntity,
                function(data){
                    console.log(data);

                    cleanVariables();
            });
        }

        function createHosting() {
            var hosting_correo = '';
            if(vm.hosting_y_correo == 1) {
                hosting_correo = 'Si';
            } else if(vm.hosting_y_correo == 2) {
                hosting_correo = 'No, ya tengo el hosting';
            } else if(vm.hosting_y_correo == 3) {
                hosting_correo = 'No estoy seguro';
            }

            console.log(vm.hosting_selected);

            vm.hostingEntity = {
                solicitar_hosting: hosting_correo,
                plan: vm.hosting_selected.nombre,
                precio: vm.hosting_selected.precio
            }
        }

        function createReunion() {
            var desea_una_reunion = '';
            if(vm.desea_reunion == 1 || vm.desea_reunion == 3) {
                desea_una_reunion = 'SI';
            } else if(vm.desea_reunion == 2) {
                desea_una_reunion = 'NO';
            }

            vm.reunionEntity = {
                como_nos_conocio: vm.como_nos_conocio,
                desea_reunion: desea_una_reunion,
                lugar_reunion: vm.lugar_reunion,
                fecha_reunion: formattedDate(vm.fecha_reunion)
            };
        }

        function addServicios() {
            if (vm.desarrolloweb) {
                vm.nuestros_servicios.push({nombre:'Diseo de Pgina Web', precio:'150'});
            }
            if (vm.hosting) {
                vm.nuestros_servicios.push({nombre:'Hosting', precio:'100'});
            }
            if (vm.logotipos) {
                vm.nuestros_servicios.push({nombre:'Diseo de Logotipos', precio:'250'});
            }
            if (vm.desarrollografico) {
                vm.nuestros_servicios.push({nombre:'Diseo Grfico', precio:'120'});
            }
            if (vm.dominio) {
                vm.nuestros_servicios.push({nombre:'Registro de Dominio', precio:'300'});
            }
            if (vm.impresion) {
                vm.nuestros_servicios.push({nombre:'Impresin', precio:'100'});
            }

            console.log(vm.nuestros_servicios);
        }

        function addPaginaWeb() {
            if (vm.slider_fijo) {
                vm.pagina_web.push({nombre:'Slider Fijo', precio:'550'});
            }
            if (vm.slider_administrable) {
                vm.pagina_web.push({nombre:'Slider Autoadministrable', precio:'100'});
            }
            if (vm.contactos) {
                vm.pagina_web.push({nombre:'Contactos', precio:'250'});
            }
            if (vm.empresa_info) {
                vm.pagina_web.push({nombre:'Informacin de Empresas', precio:'120'});
            }
            if (vm.producto_info) {
                vm.pagina_web.push({nombre:'Informacin de Productos', precio:'300'});
            }
            if (vm.multipaginas) {
                vm.pagina_web.push({nombre:'Multipgina', precio:'500'});
            }
            if (vm.noticias) {
                vm.pagina_web.push({nombre:'Noticias', precio:'400'});
            }
            if (vm.usuarios) {
                vm.pagina_web.push({nombre:'Usuarios', precio:'230'});
            }
            if (vm.ecommerce) {
                vm.pagina_web.push({nombre:'Ecommerce', precio:'100'});
            }
            if (vm.chat) {
                vm.pagina_web.push({nombre:'Chat en linea', precio:'150'});
            }
            if (vm.cobros_online) {
                vm.pagina_web.push({nombre:'Cobros Online', precio:'200'});
            }
            if (vm.imagenes_admin) {
                vm.pagina_web.push({nombre:'Administracin de Imgenes', precio:'300'});
            }

            console.log(vm.pagina_web);
        }

        function addRegistroDominio() {
            if (vm.extension_1) {
                vm.dominio_a_registrar.push({nombre:'.com / .net /', precio:'550'});
            }
            if (vm.extension_2) {
                vm.dominio_a_registrar.push({nombre:'.com.do / .do', precio:'100'});
            }
            if (vm.extension_3) {
                vm.dominio_a_registrar.push({nombre:'otro', precio:'250'});
            }

            console.log(vm.dominio_a_registrar);
        }

        function addDisenioGrafico(){
            if (vm.logotipo) {
                vm.graficos.push({nombre:'Diseo de Logotipo', precio:'550'});
            }
            if (vm.tarjeta) {
                vm.graficos.push({nombre:'Tarjetas', precio:'100'});
            }
            if (vm.catalogo) {
                vm.graficos.push({nombre:'Catlogo', precio:'250'});
            }

            console.log(vm.graficos);
        }

        function formattedDate(date) {
            var d = new Date(date || Date.now()),
                month = '' + (d.getMonth() + 1),
                day = '' + d.getDate(),
                year = d.getFullYear();

            if (month.length < 2) month = '0' + month;
            if (day.length < 2) day = '0' + day;

            return [day, month, year].join('/');
        }

        function cleanVariables() {
            vm.clienteEntity = {};
            vm.reunionEntity = {};
            vm.hostingEntity = {};

            //Nuestros Servicios
            vm.desarrolloweb = false;
            vm.hosting = false;
            vm.logotipos = false;
            vm.desarrollografico = false;
            vm.dominio = false;
            vm.impresion = false;

            //Diseo de Pgina Web
            vm.nuevapagina = false;
            vm.comentario = '';
            vm.slider_fijo = false;
            vm.slider_administrable = false;
            vm.contactos = false;
            vm.empresa_info = false;
            vm.producto_info = false;
            vm.multipaginas = false;
            vm.noticias = false;
            vm.usuarios = false;
            vm.ecommerce = false;
            vm.chat = false;
            vm.cobros_online = false;
            vm.imagenes_admin = false;
            vm.website_referencia = '';

            //Registro de Dominios
            vm.extension_1 = false;
            vm.extension_2 = false;
            vm.extension_3 = false;
            vm.dominio_deseado = '';

            //Diseo Grfico
            vm.logotipo = false;
            vm.tarjeta = false;
            vm.catalogo = false;
            vm.otro_disenio_grafico = '';

            //Informacin adicional
            vm.como_nos_conocio = '';
            vm.desea_reunion = [];
            vm.lugar_reunion = '';
            vm.fecha_reunion = '';

            vm.nuestros_servicios = [];
            vm.pagina_web = [];
            vm.registro_dominio = [];
            vm.dominio_a_registrar = [];
            vm.hosting_y_correo = [];
            vm.graficos = [];
        }

    };

})();

<|endoftext|>