<commit_before>var path = require('path');
var webpack = require('webpack');
var Mix = require('laravel-mix').config;
var plugins = require('laravel-mix').plugins;

/*
 |--------------------------------------------------------------------------
 | Mix Initialization
 |--------------------------------------------------------------------------
 |
 | As our first step, we'll require the project's Laravel Mix file
 | and record the user's requested compilation and build steps.
 | Once those steps have been recorded, we may get to work.
 |
 */

Mix.initialize();

/*
 |--------------------------------------------------------------------------
 | Webpack Context
 |--------------------------------------------------------------------------
 |
 | This prop will determine the appropriate context, when running Webpack.
 | Since you have the option of publishing this webpack.config.js file
 | to your project root, we will dynamically set the path for you.
 |
 */

module.exports.context = Mix.Paths.root();

/*
 |--------------------------------------------------------------------------
 | Webpack Entry
 |--------------------------------------------------------------------------
 |
 | We'll first specify the entry point for Webpack. By default, we'll
 | assume a single bundled file, but you may call Mix.extract()
 | to make a separate bundle specifically for vendor libraries.
 |
 */

module.exports.entry = Mix.entry();

if (Mix.js.vendor) {
    module.exports.entry.vendor = Mix.js.vendor;
}

/*
 |--------------------------------------------------------------------------
 | Webpack Output
 |--------------------------------------------------------------------------
 |
 | Webpack naturally requires us to specify our desired output path and
 | file name. We'll simply echo what you passed to with Mix.js().
 | Note that, for Mix.version(), we'll properly hash the file.
 |
 */

module.exports.output = Mix.output();

/*
 |--------------------------------------------------------------------------
 | Rules
 |--------------------------------------------------------------------------
 |
 | Webpack rules allow us to register any number of loaders and options.
 | Out of the box, we'll provide a handful to get you up and running
 | as quickly as possible, though feel free to add to this list.
 |
 */

module.exports.module = {
    rules: [
        {
            test: /\.vue$/,
            loader: 'vue-loader',
            options: {
                loaders: {
                    js: 'babel-loader' + Mix.babelConfig(),
                    scss: 'vue-style-loader!css-loader!sass-loader',
                    sass: 'vue-style-loader!css-loader!sass-loader?indentedSyntax'
                },

                postcss: [
                    require('autoprefixer')
                ]
            }
        },

        {
            test: /\.js$/,
            exclude: /(node_modules|bower_components)/,
            loader: 'babel-loader' + Mix.babelConfig()
        },

        {
            test: /\.(png|jpg|gif)$/,
            loader: 'file-loader',
            options: {
                name: '[name].[ext]?[hash]'
            }
        },

        {
            test: /\.(woff2?|ttf|eot|svg|otf)$/,
            loader: 'file-loader',
            options: {
                name: 'fonts/[name].[ext]?[hash]',
                publicPath: '/'
            }
        }
    ]
};

if (Mix.cssPreprocessor) {
    Mix[Mix.cssPreprocessor].forEach(toCompile => {
        let extractPlugin = new plugins.ExtractTextPlugin(
            Mix.cssOutput(toCompile)
        );

        module.exports.module.rules.push({
            test: new RegExp(toCompile.src.file),
            loader: extractPlugin.extract({
                fallbackLoader: 'style-loader',
                loader: [
                    'css-loader',
                    'postcss-loader',
                    'resolve-url-loader',
                    (Mix.cssPreprocessor == 'sass') ? 'sass-loader?sourceMap' : 'less-loader'
                ]
            })
        });

        module.exports.plugins = (module.exports.plugins || []).concat(extractPlugin);
    });
}

/*
 |--------------------------------------------------------------------------
 | Resolve
 |--------------------------------------------------------------------------
 |
 | Here, we may set any options/aliases that affect Webpack's resolving
 | of modules. To begin, we will provide the necessary Vue alias to
 | load the Vue common library. You may delete this, if needed.
 |
 */

module.exports.resolve = {
    extensions: ['*', '.js', '.jsx', '.vue'],

    alias: {
        'vue$': 'vue/dist/vue.common.js'
    }
};

/*
 |--------------------------------------------------------------------------
 | Stats
 |--------------------------------------------------------------------------
 |
 | By default, Webpack spits a lot of information out to the terminal,
 | each you time you compile. Let's keep things a bit more minimal
 | and hide a few of those bits and pieces. Adjust as you wish.
 |
 */

module.exports.stats = {
    hash: false,
    version: false,
    timings: false,
    children: false,
    errors: false
};

module.exports.performance = { hints: false };

/*
 |--------------------------------------------------------------------------
 | Devtool
 |--------------------------------------------------------------------------
 |
 | Sourcemaps allow us to access our original source code within the
 | browser, even if we're serving a bundled script or stylesheet.
 | You may activate sourcemaps, by adding Mix.sourceMaps().
 |
 */

module.exports.devtool = Mix.sourcemaps;

/*
 |--------------------------------------------------------------------------
 | Webpack Dev Server Configuration
 |--------------------------------------------------------------------------
 |
 | If you want to use that flashy hot module replacement feature, then
 | we've got you covered. Here, we'll set some basic initial config
 | for the Node server. You very likely won't want to edit this.
 |
 */
module.exports.devServer = {
    historyApiFallback: true,
    noInfo: true,
    compress: true
};

/*
 |--------------------------------------------------------------------------
 | Plugins
 |--------------------------------------------------------------------------
 |
 | Lastly, we'll register a number of plugins to extend and configure
 | Webpack. To get you started, we've included a handful of useful
 | extensions, for versioning, OS notifications, and much more.
 |
 */

module.exports.plugins = (module.exports.plugins || []).concat([
    new webpack.ProvidePlugin(Mix.autoload || {
        jQuery: 'jquery',
        $: 'jquery',
        jquery: 'jquery',
        'window.jQuery': 'jquery'
    }),

    new plugins.FriendlyErrorsWebpackPlugin(),

    new plugins.StatsWriterPlugin({
        filename: "mix-manifest.json",
        transform: Mix.manifest.transform,
    }),

    new plugins.WebpackMd5HashPlugin(),

    new webpack.LoaderOptionsPlugin({
        minimize: Mix.inProduction,
        options: {
            postcss: [
                require('autoprefixer')
            ],
            context: __dirname,
            output: { path: './' }
        }
    })
]);

if (Mix.notifications) {
    module.exports.plugins.push(
        new plugins.WebpackNotifierPlugin({
            title: 'Laravel Mix',
            alwaysNotify: true,
            contentImage: Mix.Paths.root('node_modules/laravel-mix/icons/laravel.png')
        })
    );
}

if (Mix.versioning) {
    Mix.versioning.record();

    module.exports.plugins.push(
        new plugins.WebpackOnBuildPlugin(() => {
            Mix.versioning.prune(Mix.publicPath);
        })
    );
}

if (Mix.combine || Mix.minify) {
    module.exports.plugins.push(
        new plugins.WebpackOnBuildPlugin(() => {
            Mix.concatenateAll().minifyAll();
        })
    );
}

if (Mix.copy) {
    Mix.copy.forEach(copy => {
        module.exports.plugins.push(
            new plugins.CopyWebpackPlugin([copy])
        );
    });
}

if (Mix.js.vendor) {
    module.exports.plugins.push(
        new webpack.optimize.CommonsChunkPlugin({
            names: ['vendor', 'manifest']
        })
    );
}

if (Mix.inProduction) {
    module.exports.plugins = module.exports.plugins.concat([
        new webpack.DefinePlugin({
            'process.env': {
                NODE_ENV: '"production"'
            }
        }),

        new webpack.optimize.UglifyJsPlugin({
            sourceMap: true,
            compress: {
                warnings: false
            }
        })
    ]);
}

/*
 |--------------------------------------------------------------------------
 | Mix Finalizing
 |--------------------------------------------------------------------------
 |
 | Now that we've declared the entirety of our Webpack configuration, the
 | final step is to scan for any custom configuration in the Mix file.
 | If mix.webpackConfig() is called, we'll merge it in, and build!
 |
 */
Mix.finalize(module.exports);
<commit_msg>Set SASS precision level to 8<commit_after>var path = require('path');
var webpack = require('webpack');
var Mix = require('laravel-mix').config;
var plugins = require('laravel-mix').plugins;

/*
 |--------------------------------------------------------------------------
 | Mix Initialization
 |--------------------------------------------------------------------------
 |
 | As our first step, we'll require the project's Laravel Mix file
 | and record the user's requested compilation and build steps.
 | Once those steps have been recorded, we may get to work.
 |
 */

Mix.initialize();

/*
 |--------------------------------------------------------------------------
 | Webpack Context
 |--------------------------------------------------------------------------
 |
 | This prop will determine the appropriate context, when running Webpack.
 | Since you have the option of publishing this webpack.config.js file
 | to your project root, we will dynamically set the path for you.
 |
 */

module.exports.context = Mix.Paths.root();

/*
 |--------------------------------------------------------------------------
 | Webpack Entry
 |--------------------------------------------------------------------------
 |
 | We'll first specify the entry point for Webpack. By default, we'll
 | assume a single bundled file, but you may call Mix.extract()
 | to make a separate bundle specifically for vendor libraries.
 |
 */

module.exports.entry = Mix.entry();

if (Mix.js.vendor) {
    module.exports.entry.vendor = Mix.js.vendor;
}

/*
 |--------------------------------------------------------------------------
 | Webpack Output
 |--------------------------------------------------------------------------
 |
 | Webpack naturally requires us to specify our desired output path and
 | file name. We'll simply echo what you passed to with Mix.js().
 | Note that, for Mix.version(), we'll properly hash the file.
 |
 */

module.exports.output = Mix.output();

/*
 |--------------------------------------------------------------------------
 | Rules
 |--------------------------------------------------------------------------
 |
 | Webpack rules allow us to register any number of loaders and options.
 | Out of the box, we'll provide a handful to get you up and running
 | as quickly as possible, though feel free to add to this list.
 |
 */

module.exports.module = {
    rules: [
        {
            test: /\.vue$/,
            loader: 'vue-loader',
            options: {
                loaders: {
                    js: 'babel-loader' + Mix.babelConfig(),
                    scss: 'vue-style-loader!css-loader!sass-loader',
                    sass: 'vue-style-loader!css-loader!sass-loader?indentedSyntax'
                },

                postcss: [
                    require('autoprefixer')
                ]
            }
        },

        {
            test: /\.js$/,
            exclude: /(node_modules|bower_components)/,
            loader: 'babel-loader' + Mix.babelConfig()
        },

        {
            test: /\.(png|jpg|gif)$/,
            loader: 'file-loader',
            options: {
                name: '[name].[ext]?[hash]'
            }
        },

        {
            test: /\.(woff2?|ttf|eot|svg|otf)$/,
            loader: 'file-loader',
            options: {
                name: 'fonts/[name].[ext]?[hash]',
                publicPath: '/'
            }
        }
    ]
};

if (Mix.cssPreprocessor) {
    Mix[Mix.cssPreprocessor].forEach(toCompile => {
        let extractPlugin = new plugins.ExtractTextPlugin(
            Mix.cssOutput(toCompile)
        );

        module.exports.module.rules.push({
            test: new RegExp(toCompile.src.file),
            loader: extractPlugin.extract({
                fallbackLoader: 'style-loader',
                loader: [
                    'css-loader',
                    'postcss-loader',
                    'resolve-url-loader',
                    (Mix.cssPreprocessor == 'sass') ? 'sass-loader?sourceMap&precision=8' : 'less-loader'
                ]
            })
        });

        module.exports.plugins = (module.exports.plugins || []).concat(extractPlugin);
    });
}

/*
 |--------------------------------------------------------------------------
 | Resolve
 |--------------------------------------------------------------------------
 |
 | Here, we may set any options/aliases that affect Webpack's resolving
 | of modules. To begin, we will provide the necessary Vue alias to
 | load the Vue common library. You may delete this, if needed.
 |
 */

module.exports.resolve = {
    extensions: ['*', '.js', '.jsx', '.vue'],

    alias: {
        'vue$': 'vue/dist/vue.common.js'
    }
};

/*
 |--------------------------------------------------------------------------
 | Stats
 |--------------------------------------------------------------------------
 |
 | By default, Webpack spits a lot of information out to the terminal,
 | each you time you compile. Let's keep things a bit more minimal
 | and hide a few of those bits and pieces. Adjust as you wish.
 |
 */

module.exports.stats = {
    hash: false,
    version: false,
    timings: false,
    children: false,
    errors: false
};

module.exports.performance = { hints: false };

/*
 |--------------------------------------------------------------------------
 | Devtool
 |--------------------------------------------------------------------------
 |
 | Sourcemaps allow us to access our original source code within the
 | browser, even if we're serving a bundled script or stylesheet.
 | You may activate sourcemaps, by adding Mix.sourceMaps().
 |
 */

module.exports.devtool = Mix.sourcemaps;

/*
 |--------------------------------------------------------------------------
 | Webpack Dev Server Configuration
 |--------------------------------------------------------------------------
 |
 | If you want to use that flashy hot module replacement feature, then
 | we've got you covered. Here, we'll set some basic initial config
 | for the Node server. You very likely won't want to edit this.
 |
 */
module.exports.devServer = {
    historyApiFallback: true,
    noInfo: true,
    compress: true
};

/*
 |--------------------------------------------------------------------------
 | Plugins
 |--------------------------------------------------------------------------
 |
 | Lastly, we'll register a number of plugins to extend and configure
 | Webpack. To get you started, we've included a handful of useful
 | extensions, for versioning, OS notifications, and much more.
 |
 */

module.exports.plugins = (module.exports.plugins || []).concat([
    new webpack.ProvidePlugin(Mix.autoload || {
        jQuery: 'jquery',
        $: 'jquery',
        jquery: 'jquery',
        'window.jQuery': 'jquery'
    }),

    new plugins.FriendlyErrorsWebpackPlugin(),

    new plugins.StatsWriterPlugin({
        filename: "mix-manifest.json",
        transform: Mix.manifest.transform,
    }),

    new plugins.WebpackMd5HashPlugin(),

    new webpack.LoaderOptionsPlugin({
        minimize: Mix.inProduction,
        options: {
            postcss: [
                require('autoprefixer')
            ],
            context: __dirname,
            output: { path: './' }
        }
    })
]);

if (Mix.notifications) {
    module.exports.plugins.push(
        new plugins.WebpackNotifierPlugin({
            title: 'Laravel Mix',
            alwaysNotify: true,
            contentImage: Mix.Paths.root('node_modules/laravel-mix/icons/laravel.png')
        })
    );
}

if (Mix.versioning) {
    Mix.versioning.record();

    module.exports.plugins.push(
        new plugins.WebpackOnBuildPlugin(() => {
            Mix.versioning.prune(Mix.publicPath);
        })
    );
}

if (Mix.combine || Mix.minify) {
    module.exports.plugins.push(
        new plugins.WebpackOnBuildPlugin(() => {
            Mix.concatenateAll().minifyAll();
        })
    );
}

if (Mix.copy) {
    Mix.copy.forEach(copy => {
        module.exports.plugins.push(
            new plugins.CopyWebpackPlugin([copy])
        );
    });
}

if (Mix.js.vendor) {
    module.exports.plugins.push(
        new webpack.optimize.CommonsChunkPlugin({
            names: ['vendor', 'manifest']
        })
    );
}

if (Mix.inProduction) {
    module.exports.plugins = module.exports.plugins.concat([
        new webpack.DefinePlugin({
            'process.env': {
                NODE_ENV: '"production"'
            }
        }),

        new webpack.optimize.UglifyJsPlugin({
            sourceMap: true,
            compress: {
                warnings: false
            }
        })
    ]);
}

/*
 |--------------------------------------------------------------------------
 | Mix Finalizing
 |--------------------------------------------------------------------------
 |
 | Now that we've declared the entirety of our Webpack configuration, the
 | final step is to scan for any custom configuration in the Mix file.
 | If mix.webpackConfig() is called, we'll merge it in, and build!
 |
 */
Mix.finalize(module.exports);
<|endoftext|>


<commit_before>var path = require('path');
var webpack = require('webpack');
var Mix = require('laravel-mix').config;
var plugins = require('laravel-mix').plugins;

/*
 |--------------------------------------------------------------------------
 | Mix Initialization
 |--------------------------------------------------------------------------
 |
 | As our first step, we'll require the project's Laravel Mix file
 | and record the user's requested compilation and build steps.
 | Once those steps have been recorded, we may get to work.
 |
 */

Mix.initialize();

/*
 |--------------------------------------------------------------------------
 | Webpack Context
 |--------------------------------------------------------------------------
 |
 | This prop will determine the appropriate context, when running Webpack.
 | Since you have the option of publishing this webpack.config.js file
 | to your project root, we will dynamically set the path for you.
 |
 */

module.exports.context = Mix.Paths.root();

/*
 |--------------------------------------------------------------------------
 | Webpack Entry
 |--------------------------------------------------------------------------
 |
 | We'll first specify the entry point for Webpack. By default, we'll
 | assume a single bundled file, but you may call Mix.extract()
 | to make a separate bundle specifically for vendor libraries.
 |
 */

module.exports.entry = Mix.entry();

if (Mix.js.vendor) {
    module.exports.entry.vendor = Mix.js.vendor;
}

/*
 |--------------------------------------------------------------------------
 | Webpack Output
 |--------------------------------------------------------------------------
 |
 | Webpack naturally requires us to specify our desired output path and
 | file name. We'll simply echo what you passed to with Mix.js().
 | Note that, for Mix.version(), we'll properly hash the file.
 |
 */

module.exports.output = Mix.output();

/*
 |--------------------------------------------------------------------------
 | Rules
 |--------------------------------------------------------------------------
 |
 | Webpack rules allow us to register any number of loaders and options.
 | Out of the box, we'll provide a handful to get you up and running
 | as quickly as possible, though feel free to add to this list.
 |
 */

module.exports.module = {
    rules: [
        {
            test: /\.vue$/,
            loader: 'vue-loader',
            options: {
                loaders: {
                    js: 'babel-loader' + Mix.babelConfig(),
                    scss: 'vue-style-loader!css-loader!sass-loader',
                    sass: 'vue-style-loader!css-loader!sass-loader?indentedSyntax'
                },

                postcss: [
                    require('autoprefixer')
                ]
            }
        },

        {
            test: /\.js$/,
            exclude: /(node_modules|bower_components)/,
            loader: 'babel-loader' + Mix.babelConfig()
        },

        {
            test: /\.(png|jpg|gif)$/,
            loader: 'file-loader',
            options: {
                name: '[name].[ext]?[hash]'
            }
        },

        {
            test: /\.(woff2?|ttf|eot|svg|otf)$/,
            loader: 'file-loader',
            options: {
                name: 'fonts/[name].[ext]?[hash]',
                publicPath: '/'
            }
        }
    ]
};

if (Mix.cssPreprocessor) {
    Mix[Mix.cssPreprocessor].forEach(toCompile => {
        let extractPlugin = new plugins.ExtractTextPlugin(
            Mix.cssOutput(toCompile)
        );

        module.exports.module.rules.push({
            test: new RegExp(toCompile.src.file),
            loader: extractPlugin.extract({
                fallbackLoader: 'style-loader',
                loader: [
                    'css-loader',
                    'postcss-loader',
                    'resolve-url-loader',
                    (Mix.cssPreprocessor == 'sass') ? 'sass-loader?sourceMap&precision=8' : 'less-loader'
                ]
            })
        });

        module.exports.plugins = (module.exports.plugins || []).concat(extractPlugin);
    });
}

/*
 |--------------------------------------------------------------------------
 | Resolve
 |--------------------------------------------------------------------------
 |
 | Here, we may set any options/aliases that affect Webpack's resolving
 | of modules. To begin, we will provide the necessary Vue alias to
 | load the Vue common library. You may delete this, if needed.
 |
 */

module.exports.resolve = {
    extensions: ['*', '.js', '.jsx', '.vue'],

    alias: {
        'vue$': 'vue/dist/vue.common.js'
    }
};

/*
 |--------------------------------------------------------------------------
 | Stats
 |--------------------------------------------------------------------------
 |
 | By default, Webpack spits a lot of information out to the terminal,
 | each you time you compile. Let's keep things a bit more minimal
 | and hide a few of those bits and pieces. Adjust as you wish.
 |
 */

module.exports.stats = {
    hash: false,
    version: false,
    timings: false,
    children: false,
    errors: false
};

module.exports.performance = { hints: false };

/*
 |--------------------------------------------------------------------------
 | Devtool
 |--------------------------------------------------------------------------
 |
 | Sourcemaps allow us to access our original source code within the
 | browser, even if we're serving a bundled script or stylesheet.
 | You may activate sourcemaps, by adding Mix.sourceMaps().
 |
 */

module.exports.devtool = Mix.sourcemaps;

/*
 |--------------------------------------------------------------------------
 | Webpack Dev Server Configuration
 |--------------------------------------------------------------------------
 |
 | If you want to use that flashy hot module replacement feature, then
 | we've got you covered. Here, we'll set some basic initial config
 | for the Node server. You very likely won't want to edit this.
 |
 */
module.exports.devServer = {
    historyApiFallback: true,
    noInfo: true,
    compress: true
};

/*
 |--------------------------------------------------------------------------
 | Plugins
 |--------------------------------------------------------------------------
 |
 | Lastly, we'll register a number of plugins to extend and configure
 | Webpack. To get you started, we've included a handful of useful
 | extensions, for versioning, OS notifications, and much more.
 |
 */

module.exports.plugins = (module.exports.plugins || []).concat([
    new webpack.ProvidePlugin(Mix.autoload || {
        jQuery: 'jquery',
        $: 'jquery',
        jquery: 'jquery',
        'window.jQuery': 'jquery'
    }),

    new plugins.FriendlyErrorsWebpackPlugin(),

    new plugins.StatsWriterPlugin({
        filename: "mix-manifest.json",
        transform: Mix.manifest.transform,
    }),

    new plugins.WebpackMd5HashPlugin(),

    new webpack.LoaderOptionsPlugin({
        minimize: Mix.inProduction,
        options: {
            postcss: [
                require('autoprefixer')
            ],
            context: __dirname,
            output: { path: './' }
        }
    })
]);

if (Mix.notifications) {
    module.exports.plugins.push(
        new plugins.WebpackNotifierPlugin({
            title: 'Laravel Mix',
            alwaysNotify: true,
            contentImage: Mix.Paths.root('node_modules/laravel-mix/icons/laravel.png')
        })
    );
}

if (Mix.versioning) {
    Mix.versioning.record();

    module.exports.plugins.push(
        new plugins.WebpackOnBuildPlugin(() => {
            Mix.versioning.prune(Mix.publicPath);
        })
    );
}

if (Mix.combine || Mix.minify) {
    module.exports.plugins.push(
        new plugins.WebpackOnBuildPlugin(() => {
            Mix.concatenateAll().minifyAll();
        })
    );
}

if (Mix.copy) {
    Mix.copy.forEach(copy => {
        module.exports.plugins.push(
            new plugins.CopyWebpackPlugin([copy])
        );
    });
}

if (Mix.js.vendor) {
    module.exports.plugins.push(
        new webpack.optimize.CommonsChunkPlugin({
            names: ['vendor', 'manifest']
        })
    );
}

if (Mix.inProduction) {
    module.exports.plugins = module.exports.plugins.concat([
        new webpack.DefinePlugin({
            'process.env': {
                NODE_ENV: '"production"'
            }
        }),

        new webpack.optimize.UglifyJsPlugin({
            sourceMap: true,
            compress: {
                warnings: false
            }
        })
    ]);
}

/*
 |--------------------------------------------------------------------------
 | Mix Finalizing
 |--------------------------------------------------------------------------
 |
 | Now that we've declared the entirety of our Webpack configuration, the
 | final step is to scan for any custom configuration in the Mix file.
 | If mix.webpackConfig() is called, we'll merge it in, and build!
 |
 */
Mix.finalize(module.exports);
<commit_msg>source maps for less<commit_after>var path = require('path');
var webpack = require('webpack');
var Mix = require('laravel-mix').config;
var plugins = require('laravel-mix').plugins;

/*
 |--------------------------------------------------------------------------
 | Mix Initialization
 |--------------------------------------------------------------------------
 |
 | As our first step, we'll require the project's Laravel Mix file
 | and record the user's requested compilation and build steps.
 | Once those steps have been recorded, we may get to work.
 |
 */

Mix.initialize();

/*
 |--------------------------------------------------------------------------
 | Webpack Context
 |--------------------------------------------------------------------------
 |
 | This prop will determine the appropriate context, when running Webpack.
 | Since you have the option of publishing this webpack.config.js file
 | to your project root, we will dynamically set the path for you.
 |
 */

module.exports.context = Mix.Paths.root();

/*
 |--------------------------------------------------------------------------
 | Webpack Entry
 |--------------------------------------------------------------------------
 |
 | We'll first specify the entry point for Webpack. By default, we'll
 | assume a single bundled file, but you may call Mix.extract()
 | to make a separate bundle specifically for vendor libraries.
 |
 */

module.exports.entry = Mix.entry();

if (Mix.js.vendor) {
    module.exports.entry.vendor = Mix.js.vendor;
}

/*
 |--------------------------------------------------------------------------
 | Webpack Output
 |--------------------------------------------------------------------------
 |
 | Webpack naturally requires us to specify our desired output path and
 | file name. We'll simply echo what you passed to with Mix.js().
 | Note that, for Mix.version(), we'll properly hash the file.
 |
 */

module.exports.output = Mix.output();

/*
 |--------------------------------------------------------------------------
 | Rules
 |--------------------------------------------------------------------------
 |
 | Webpack rules allow us to register any number of loaders and options.
 | Out of the box, we'll provide a handful to get you up and running
 | as quickly as possible, though feel free to add to this list.
 |
 */

module.exports.module = {
    rules: [
        {
            test: /\.vue$/,
            loader: 'vue-loader',
            options: {
                loaders: {
                    js: 'babel-loader' + Mix.babelConfig(),
                    scss: 'vue-style-loader!css-loader!sass-loader',
                    sass: 'vue-style-loader!css-loader!sass-loader?indentedSyntax'
                },

                postcss: [
                    require('autoprefixer')
                ]
            }
        },

        {
            test: /\.js$/,
            exclude: /(node_modules|bower_components)/,
            loader: 'babel-loader' + Mix.babelConfig()
        },

        {
            test: /\.(png|jpg|gif)$/,
            loader: 'file-loader',
            options: {
                name: '[name].[ext]?[hash]'
            }
        },

        {
            test: /\.(woff2?|ttf|eot|svg|otf)$/,
            loader: 'file-loader',
            options: {
                name: 'fonts/[name].[ext]?[hash]',
                publicPath: '/'
            }
        }
    ]
};

if (Mix.cssPreprocessor) {
    Mix[Mix.cssPreprocessor].forEach(toCompile => {
        let extractPlugin = new plugins.ExtractTextPlugin(
            Mix.cssOutput(toCompile)
        );

        let sourceMap = Mix.sourcemaps ? '?sourceMap' : '';
        module.exports.module.rules.push({
            test: new RegExp(toCompile.src.file),
            loader: extractPlugin.extract({
                fallbackLoader: 'style-loader',
                loader: [
                    'css-loader' + sourceMap,
                    'postcss-loader' + sourceMap
                ].concat(Mix.cssPreprocessor == 'sass' ? [
                    'resolve-url-loader' + sourceMap,
                    'sass-loader?sourceMap&precision=8'
                ] : [
                    'less-loader' + sourceMap
                ])
            })
        });

        module.exports.plugins = (module.exports.plugins || []).concat(extractPlugin);
    });
}

/*
 |--------------------------------------------------------------------------
 | Resolve
 |--------------------------------------------------------------------------
 |
 | Here, we may set any options/aliases that affect Webpack's resolving
 | of modules. To begin, we will provide the necessary Vue alias to
 | load the Vue common library. You may delete this, if needed.
 |
 */

module.exports.resolve = {
    extensions: ['*', '.js', '.jsx', '.vue'],

    alias: {
        'vue$': 'vue/dist/vue.common.js'
    }
};

/*
 |--------------------------------------------------------------------------
 | Stats
 |--------------------------------------------------------------------------
 |
 | By default, Webpack spits a lot of information out to the terminal,
 | each you time you compile. Let's keep things a bit more minimal
 | and hide a few of those bits and pieces. Adjust as you wish.
 |
 */

module.exports.stats = {
    hash: false,
    version: false,
    timings: false,
    children: false,
    errors: false
};

module.exports.performance = { hints: false };

/*
 |--------------------------------------------------------------------------
 | Devtool
 |--------------------------------------------------------------------------
 |
 | Sourcemaps allow us to access our original source code within the
 | browser, even if we're serving a bundled script or stylesheet.
 | You may activate sourcemaps, by adding Mix.sourceMaps().
 |
 */

module.exports.devtool = Mix.sourcemaps;

/*
 |--------------------------------------------------------------------------
 | Webpack Dev Server Configuration
 |--------------------------------------------------------------------------
 |
 | If you want to use that flashy hot module replacement feature, then
 | we've got you covered. Here, we'll set some basic initial config
 | for the Node server. You very likely won't want to edit this.
 |
 */
module.exports.devServer = {
    historyApiFallback: true,
    noInfo: true,
    compress: true
};

/*
 |--------------------------------------------------------------------------
 | Plugins
 |--------------------------------------------------------------------------
 |
 | Lastly, we'll register a number of plugins to extend and configure
 | Webpack. To get you started, we've included a handful of useful
 | extensions, for versioning, OS notifications, and much more.
 |
 */

module.exports.plugins = (module.exports.plugins || []).concat([
    new webpack.ProvidePlugin(Mix.autoload || {
        jQuery: 'jquery',
        $: 'jquery',
        jquery: 'jquery',
        'window.jQuery': 'jquery'
    }),

    new plugins.FriendlyErrorsWebpackPlugin(),

    new plugins.StatsWriterPlugin({
        filename: "mix-manifest.json",
        transform: Mix.manifest.transform,
    }),

    new plugins.WebpackMd5HashPlugin(),

    new webpack.LoaderOptionsPlugin({
        minimize: Mix.inProduction,
        options: {
            postcss: [
                require('autoprefixer')
            ],
            context: __dirname,
            output: { path: './' }
        }
    })
]);

if (Mix.notifications) {
    module.exports.plugins.push(
        new plugins.WebpackNotifierPlugin({
            title: 'Laravel Mix',
            alwaysNotify: true,
            contentImage: Mix.Paths.root('node_modules/laravel-mix/icons/laravel.png')
        })
    );
}

if (Mix.versioning) {
    Mix.versioning.record();

    module.exports.plugins.push(
        new plugins.WebpackOnBuildPlugin(() => {
            Mix.versioning.prune(Mix.publicPath);
        })
    );
}

if (Mix.combine || Mix.minify) {
    module.exports.plugins.push(
        new plugins.WebpackOnBuildPlugin(() => {
            Mix.concatenateAll().minifyAll();
        })
    );
}

if (Mix.copy) {
    Mix.copy.forEach(copy => {
        module.exports.plugins.push(
            new plugins.CopyWebpackPlugin([copy])
        );
    });
}

if (Mix.js.vendor) {
    module.exports.plugins.push(
        new webpack.optimize.CommonsChunkPlugin({
            names: ['vendor', 'manifest']
        })
    );
}

if (Mix.inProduction) {
    module.exports.plugins = module.exports.plugins.concat([
        new webpack.DefinePlugin({
            'process.env': {
                NODE_ENV: '"production"'
            }
        }),

        new webpack.optimize.UglifyJsPlugin({
            sourceMap: true,
            compress: {
                warnings: false
            }
        })
    ]);
}

/*
 |--------------------------------------------------------------------------
 | Mix Finalizing
 |--------------------------------------------------------------------------
 |
 | Now that we've declared the entirety of our Webpack configuration, the
 | final step is to scan for any custom configuration in the Mix file.
 | If mix.webpackConfig() is called, we'll merge it in, and build!
 |
 */
Mix.finalize(module.exports);
<|endoftext|>


<commit_before>// Import all the objects we want to use from ReactBootstrap
var ListGroup = ReactBootstrap.ListGroup;
var ListGroupItem = ReactBootstrap.ListGroupItem;

var Grid = ReactBootstrap.Grid;
var Row = ReactBootstrap.Row;
var Col = ReactBootstrap.Col;

var Button = ReactBootstrap.Button;
var ButtonGroup = ReactBootstrap.ButtonGroup;
var Glyphicon = ReactBootstrap.Glyphicon;

var Modal = ReactBootstrap.Modal;

var Combobox = ReactWidgets.Combobox;

const recursiveAccountDisplayInfo = function(account, prefix) {
	var name = prefix + account.Name;
	var accounts = [{AccountId: account.AccountId, Name: name}];
	for (var i = 0; i < account.Children.length; i++)
		accounts = accounts.concat(recursiveAccountDisplayInfo(account.Children[i], name + "/"));
	return accounts
};
const getAccountDisplayList = function(account_list, includeRoot, rootName) {
	var accounts = []
	if (includeRoot)
		accounts.push({AccountId: -1, Name: rootName});
	for (var i = 0; i < account_list.length; i++) {
		if (account_list[i].ParentAccountId == -1)
			accounts = accounts.concat(recursiveAccountDisplayInfo(account_list[i], ""));
	}
	return accounts;
};

const AccountCombobox = React.createClass({
	handleAccountChange: function(account) {
		if (this.props.onSelect != null &&
				account.hasOwnProperty('AccountId') &&
				this.props.account_map.hasOwnProperty([account.AccountId])) {
			this.props.onSelect(this.props.account_map[account.AccountId])
		}
	},
	render: function() {
		var accounts = getAccountDisplayList(this.props.accounts, true, "New Root Account");
		return (
			<Combobox
				data={accounts}
				valueField='AccountId'
				textField='Name'
				value={this.props.value}
				onSelect={this.handleAccountChange}
				ref="account" />
	   );
	}
});

const NewAccountModal = React.createClass({
	getInitialState: function() {
		return {
			security: 1,
			parentaccountid: -1,
			type: 1,
			name: ""
		};
	},
	handleCancel: function() {
		if (this.props.onCancel != null)
			this.props.onCancel();
	},
	handleChange: function() {
		this.setState({
			name: this.refs.name.getValue(),
		});
	},
	handleSecurityChange: function(security) {
		if (security.hasOwnProperty('SecurityId'))
			this.setState({
				security: security.SecurityId
			});
	},
	handleTypeChange: function(type) {
		if (type.hasOwnProperty('TypeId'))
			this.setState({
				type: type.TypeId
			});
	},
	handleParentChange: function(parentAccount) {
		this.setState({parentaccountid: parentAccount.AccountId});
	},
	handleSubmit: function() {
		var a = new Account();

		a.Name = this.state.name;
		a.ParentAccountId = this.state.parentaccountid;
		a.SecurityId = this.state.security;
		a.Type = this.state.type;

		this.handleSaveSettings(a);
	},
	handleSaveSettings: function(account) {
		if (this.props.onSubmit != null)
			this.props.onSubmit(account);
	},
	render: function() {
		return (
			<Modal show={this.props.show} onHide={this.handleCancel}>
				<Modal.Header closeButton>
					<Modal.Title>Create New Account</Modal.Title>
				</Modal.Header>
				<Modal.Body>
				<form onSubmit={this.handleSubmit}
						className="form-horizontal">
					<Input type="text"
							label="Name"
							value={this.state.name}
							onChange={this.handleChange}
							ref="name"
							labelClassName="col-xs-2"
							wrapperClassName="col-xs-10"/>
					<Input wrapperClassName="wrapper"
							label="Parent Account"
							labelClassName="col-xs-2"
							wrapperClassName="col-xs-10">
					<AccountCombobox
							accounts={this.props.accounts}
							account_map={this.props.account_map}
							value={this.state.parentaccountid}
							onSelect={this.handleParentChange}
							ref="parent" />
					</Input>
					<Input wrapperClassName="wrapper"
							label="Security"
							labelClassName="col-xs-2"
							wrapperClassName="col-xs-10">
					<Combobox
							data={this.props.securities}
							valueField='SecurityId'
							textField='Name'
							value={this.state.security}
							onSelect={this.handleSecurityChange}
							ref="security" />
					</Input>
					<Input wrapperClassName="wrapper"
							label="Account Type"
							labelClassName="col-xs-2"
							wrapperClassName="col-xs-10">
					<Combobox
							data={AccountTypeList}
							valueField='TypeId'
							textField='Name'
							value={this.state.type}
							onSelect={this.handleTypeChange}
							ref="type" />
					</Input>
				</form>
				</Modal.Body>
				<Modal.Footer>
					<ButtonGroup className="pull-right">
						<Button onClick={this.handleCancel} bsStyle="warning">Cancel</Button>
						<Button onClick={this.handleSubmit} bsStyle="success">Create Account</Button>
					</ButtonGroup>
				</Modal.Footer>
			</Modal>
		);
	}
});

const AccountsTab = React.createClass({
	getInitialState: function() {
		return {
			creatingNewAccount: false
		};
	},
	handleNewAccount: function() {
		this.setState({creatingNewAccount: true});
	},
	handleEditAccount: function() {
		console.log("handleEditAccount");
	},
	handleDeleteAccount: function() {
		console.log("handleDeleteAccount");
	},
	handleCreationCancel: function() {
		this.setState({creatingNewAccount: false});
	},
	handleCreateAccount: function(account) {
		if (this.props.onCreateAccount != null)
			this.props.onCreateAccount(account);
		this.setState({creatingNewAccount: false});
	},
	render: function() {
		var accounts = this.props.accounts;
		var account_map = this.props.account_map;

		var listGroupItems = accounts.map(function(account) {
			return (
				<ListGroupItem>{account.Name}</ListGroupItem>
		   );
		});

		return (
			<Grid fluid><Row>
				<Col xs={2}>
					<NewAccountModal
						show={this.state.creatingNewAccount}
						accounts={this.props.accounts}
						account_map={this.props.account_map}
						onCancel={this.handleCreationCancel}
						onSubmit={this.handleCreateAccount}
						securities={this.props.securities}/>
					<ListGroup>
						{listGroupItems}
					</ListGroup>
					<ButtonGroup className="pull-right">
						<Button onClick={this.handleNewAccount} bsStyle="success">
							<Glyphicon glyph='plus-sign' /></Button>
						<Button onClick={this.handleEditAccount} bsStyle="primary">
							<Glyphicon glyph='cog' /></Button>
						<Button onClick={this.handleDeleteAccount} bsStyle="danger">
							<Glyphicon glyph='trash' /></Button>
					</ButtonGroup>
				</Col><Col xs={10}>
					blah
				</Col>
			</Row></Grid>
		);
	}
});
<commit_msg>Clear state on new account creation Modal when exited<commit_after>// Import all the objects we want to use from ReactBootstrap
var ListGroup = ReactBootstrap.ListGroup;
var ListGroupItem = ReactBootstrap.ListGroupItem;

var Grid = ReactBootstrap.Grid;
var Row = ReactBootstrap.Row;
var Col = ReactBootstrap.Col;

var Button = ReactBootstrap.Button;
var ButtonGroup = ReactBootstrap.ButtonGroup;
var Glyphicon = ReactBootstrap.Glyphicon;

var Modal = ReactBootstrap.Modal;

var Combobox = ReactWidgets.Combobox;

const recursiveAccountDisplayInfo = function(account, prefix) {
	var name = prefix + account.Name;
	var accounts = [{AccountId: account.AccountId, Name: name}];
	for (var i = 0; i < account.Children.length; i++)
		accounts = accounts.concat(recursiveAccountDisplayInfo(account.Children[i], name + "/"));
	return accounts
};
const getAccountDisplayList = function(account_list, includeRoot, rootName) {
	var accounts = []
	if (includeRoot)
		accounts.push({AccountId: -1, Name: rootName});
	for (var i = 0; i < account_list.length; i++) {
		if (account_list[i].ParentAccountId == -1)
			accounts = accounts.concat(recursiveAccountDisplayInfo(account_list[i], ""));
	}
	return accounts;
};

const AccountCombobox = React.createClass({
	handleAccountChange: function(account) {
		if (this.props.onSelect != null &&
				account.hasOwnProperty('AccountId') &&
				this.props.account_map.hasOwnProperty([account.AccountId])) {
			this.props.onSelect(this.props.account_map[account.AccountId])
		}
	},
	render: function() {
		var accounts = getAccountDisplayList(this.props.accounts, true, "New Root Account");
		return (
			<Combobox
				data={accounts}
				valueField='AccountId'
				textField='Name'
				value={this.props.value}
				onSelect={this.handleAccountChange}
				ref="account" />
	   );
	}
});

const NewAccountModal = React.createClass({
	getInitialState: function() {
		return {
			security: 1,
			parentaccountid: -1,
			type: 1,
			name: ""
		};
	},
	handleCancel: function() {
		if (this.props.onCancel != null)
			this.props.onCancel();
		this.setState(this.getInitialState());
	},
	handleChange: function() {
		this.setState({
			name: this.refs.name.getValue(),
		});
	},
	handleSecurityChange: function(security) {
		if (security.hasOwnProperty('SecurityId'))
			this.setState({
				security: security.SecurityId
			});
	},
	handleTypeChange: function(type) {
		if (type.hasOwnProperty('TypeId'))
			this.setState({
				type: type.TypeId
			});
	},
	handleParentChange: function(parentAccount) {
		this.setState({parentaccountid: parentAccount.AccountId});
	},
	handleSubmit: function() {
		var a = new Account();

		a.Name = this.state.name;
		a.ParentAccountId = this.state.parentaccountid;
		a.SecurityId = this.state.security;
		a.Type = this.state.type;

		this.handleSaveSettings(a);
		this.setState(this.getInitialState());
	},
	handleSaveSettings: function(account) {
		if (this.props.onSubmit != null)
			this.props.onSubmit(account);
	},
	render: function() {
		return (
			<Modal show={this.props.show} onHide={this.handleCancel}>
				<Modal.Header closeButton>
					<Modal.Title>Create New Account</Modal.Title>
				</Modal.Header>
				<Modal.Body>
				<form onSubmit={this.handleSubmit}
						className="form-horizontal">
					<Input type="text"
							label="Name"
							value={this.state.name}
							onChange={this.handleChange}
							ref="name"
							labelClassName="col-xs-2"
							wrapperClassName="col-xs-10"/>
					<Input wrapperClassName="wrapper"
							label="Parent Account"
							labelClassName="col-xs-2"
							wrapperClassName="col-xs-10">
					<AccountCombobox
							accounts={this.props.accounts}
							account_map={this.props.account_map}
							value={this.state.parentaccountid}
							onSelect={this.handleParentChange}
							ref="parent" />
					</Input>
					<Input wrapperClassName="wrapper"
							label="Security"
							labelClassName="col-xs-2"
							wrapperClassName="col-xs-10">
					<Combobox
							data={this.props.securities}
							valueField='SecurityId'
							textField='Name'
							value={this.state.security}
							onSelect={this.handleSecurityChange}
							ref="security" />
					</Input>
					<Input wrapperClassName="wrapper"
							label="Account Type"
							labelClassName="col-xs-2"
							wrapperClassName="col-xs-10">
					<Combobox
							data={AccountTypeList}
							valueField='TypeId'
							textField='Name'
							value={this.state.type}
							onSelect={this.handleTypeChange}
							ref="type" />
					</Input>
				</form>
				</Modal.Body>
				<Modal.Footer>
					<ButtonGroup className="pull-right">
						<Button onClick={this.handleCancel} bsStyle="warning">Cancel</Button>
						<Button onClick={this.handleSubmit} bsStyle="success">Create Account</Button>
					</ButtonGroup>
				</Modal.Footer>
			</Modal>
		);
	}
});

const AccountsTab = React.createClass({
	getInitialState: function() {
		return {
			creatingNewAccount: false
		};
	},
	handleNewAccount: function() {
		this.setState({creatingNewAccount: true});
	},
	handleEditAccount: function() {
		console.log("handleEditAccount");
	},
	handleDeleteAccount: function() {
		console.log("handleDeleteAccount");
	},
	handleCreationCancel: function() {
		this.setState({creatingNewAccount: false});
	},
	handleCreateAccount: function(account) {
		if (this.props.onCreateAccount != null)
			this.props.onCreateAccount(account);
		this.setState({creatingNewAccount: false});
	},
	render: function() {
		var accounts = this.props.accounts;
		var account_map = this.props.account_map;

		var listGroupItems = accounts.map(function(account) {
			return (
				<ListGroupItem>{account.Name}</ListGroupItem>
		   );
		});

		return (
			<Grid fluid><Row>
				<Col xs={2}>
					<NewAccountModal
						show={this.state.creatingNewAccount}
						accounts={this.props.accounts}
						account_map={this.props.account_map}
						onCancel={this.handleCreationCancel}
						onSubmit={this.handleCreateAccount}
						securities={this.props.securities}/>
					<ListGroup>
						{listGroupItems}
					</ListGroup>
					<ButtonGroup className="pull-right">
						<Button onClick={this.handleNewAccount} bsStyle="success">
							<Glyphicon glyph='plus-sign' /></Button>
						<Button onClick={this.handleEditAccount} bsStyle="primary">
							<Glyphicon glyph='cog' /></Button>
						<Button onClick={this.handleDeleteAccount} bsStyle="danger">
							<Glyphicon glyph='trash' /></Button>
					</ButtonGroup>
				</Col><Col xs={10}>
					blah
				</Col>
			</Row></Grid>
		);
	}
});
<|endoftext|>


<commit_before>define(['underscore', 'jquery', 'knockout', 'js/modules/dukecondb', 'js/modules/dukeconsettings', 'js/modules/dukecondateutils', 'js/modules/languageutils', 'js/modules/offline', 'js/modules/dukecloak', 'js/modules/synch'],
    function(_, $, ko, dukeconDb, dukeconSettings, dukeconDateUtils, languageUtils, offline, dukecloak, synch) {

    function Talk(data, speakers, metaData, isFavourite) {
        var self = this;

        this.id = data.id || '';
        this.startDate = data.start ? new Date(data.start) : null;
        this.day = ko.observable(dukeconDateUtils.getDisplayDate(data.start));
        this.dayshort = ko.observable(dukeconDateUtils.getDisplayDateShort(data.start));
        this.startDisplayed = dukeconDateUtils.getDisplayTime(data.start);
        this.duration = dukeconDateUtils.getDurationInMinutes(data.start, data.end);
        this.startSortable = data.start || '';
        this.trackDisplay = ko.observable(dukeconUtils.getTrack(metaData, data.trackId));
        this.track = data.trackId || '';
        this.talkIcon = dukeconUtils.getTalkIcon(data.trackId || '');
        this.isTrackVisible = ko.computed(function () {
            return self.trackDisplay() !== '';
        });
        this.locationDisplay = ko.observable(dukeconUtils.getLocation(metaData, data.locationId));
        this.location = data.locationId || '';
        this.locationOrder = dukeconUtils.getOrderById(metaData.locations, data.locationId);
        this.levelDisplay = ko.observable(dukeconUtils.getLevel(metaData, data.audienceId));
        this.level = data.audienceId || '';
        this.title = data.title || '';
        this.speakerString = dukeconUtils.getSpeakerNames(data.speakerIds, speakers).join(', ');
        this.speakersWithCompanies = dukeconUtils.getSpeakerInfo(data.speakerIds, speakers);
        this.languageDisplay = ko.observable(dukeconUtils.getLanguage(metaData, data.languageId));
        this.language = data.languageId || '';
        this.fullAbstract = dukeconUtils.getSaveAbstractHtml(data.abstractText || '');
        this.timeCategory = dukeconDateUtils.getTimeCategory(this.duration);
        this.timeClass = this.timeCategory == 'regular' ? 'time' : 'time-extra';
        this.favourite = ko.observable(isFavourite);
        this.favicon = ko.computed(function () {
            return this.favourite() ? "img/StarFilled.png" : "img/StarLine.png";
        }, this);
        this.showAlertWindow = function () {
            // requires scrollfix.js for cookie handling:
            var alreadySeen = readCookie('dukecon.favouriteAlertSeen');
            if (!dukecloak.dukecloak.auth.loggedIn() && !alreadySeen) {
                var alertWin = document.getElementById('alert-window');
                if (alertWin) {
                    var position = getScrollXY();
                    alertWin.className = 'shown';
                    alertWin.style.top = (position[1] + 150) + 'px';
                    alertWin.style.left = (position[0] + 40) + 'px';
                }
            }
        };
        this.toggleFavourite = function () {
            this.showAlertWindow();
            this.favourite(!this.favourite());
        };

        languageUtils.selectedLanguage.subscribe(function () {
            self.day(dukeconDateUtils.getDisplayDate(data.start));
            self.trackDisplay(dukeconUtils.getTrack(metaData, data.trackId));
            self.levelDisplay(dukeconUtils.getLevel(metaData, data.audienceId));
            self.languageDisplay(dukeconUtils.getLanguage(metaData, data.languageId));
            self.locationDisplay(dukeconUtils.getLocation(metaData, data.locationId));
        });

    }

    function Speaker(data, talks, speakers, metaData, favorites) {
        this.name = data.name || '';
        this.company = data.company || '';
        this.twitterHandle = '';
        this.twitterLink = '';
        if (data.twitter && data.twitter.length > 1) {
            this.twitterHandle = data.twitter;
            this.twitterLink = "http://www.twitter.com/" + data.twitter.substr(1);
        }

        this.talks = dukeconUtils.getTalks(data.eventIds, talks, speakers, metaData, favorites);
    }

    var cookiesConfirmed = ko.observable();

//not sure where else to put
    var dukeconUtils = {
        talkIcons: {
            "7": "img/track_architecture.jpg",
            "2": "img/track_jvm-languages.jpg",
            "3": "img/track_enterprise-java-cloud.jpg",
            "4": "img/track_frontend-mobile.jpg",
            "5": "img/track_ide-tools.jpg",
            "1": "img/track_microservices.jpg",
            "6": "img/track_internet-of-things.jpg",
            "8": "img/track_newcomer.jpg",
            "9": "img/track_community.jpg"
        },

        getTrack: function (metaData, trackId) {
            return dukeconUtils.getById(metaData.tracks, trackId);
        },

        getLanguage: function (metaData, languageId) {
            return dukeconUtils.getById(metaData.languages, languageId);
        },

        getLevel: function (metaData, levelId) {
            return dukeconUtils.getById(metaData.audiences, levelId);
        },

        getLocation: function (metaData, locationId) {
            return dukeconUtils.getById(metaData.locations, locationId);
        },

        getById: function (data, id) {
            var value = _.find(data, function (d) {
                return d.id === id;
            });
            return value ? value.names[languageUtils.selectedLanguage()] : '';
        },

        getOrderById: function (data, id) {
            var value = _.find(data, function (d) {
                return d.id === id;
            });
            return value ? value.order : 0;
        },

        getSpeakerInfo: function (speakerIds, speakers) {
            if (!speakerIds || speakerIds.length === 0) {
                return [];
            }
            var filteredSpeakers = _.filter(speakers, function (speaker) {
                return speaker && speaker.name;
            });
            return _.map(speakerIds, function (speakerId) {
                var speaker = _.find(speakers, function (s) {
                        return s.id === speakerId;
                    }
                ) || {};
                var twitterHandle = "", twitterLink = "";
                if (speaker.twitter && speaker.twitter.length > 1) {
                    twitterHandle = "(" + speaker.twitter + ")";
                    twitterLink = "http://www.twitter.com/" + speaker.twitter.substr(1);
                }
                return { name: speaker.name || "", company: (speaker.company ? ", " + speaker.company : ''), twitterHandle: twitterHandle, twitterLink: twitterLink };
            });
        },

        getSpeakerNames: function (speakerIds, speakers) {
            if (!speakerIds || speakerIds.length === 0) {
                return [];
            }
            var filteredSpeakers = _.filter(speakers, function (speaker) {
                return speaker && speaker.name;
            });
            return _.map(speakerIds, function (speakerId) {
                var speaker = _.find(speakers, function (s) {
                        return s.id === speakerId;
                    }
                ) || {};
                return speaker.name || "";
            });
        },

        getTalkIcon: function (typeId) {
            return dukeconUtils.talkIcons[typeId] || 'img/Unknown.png';
        },

        getTalks: function (talkIds, talks, speakers, metaData, favourites) {
            return _.map(talkIds, function (id) {
                var talk = _.find(talks, function (t) {
                    return t.id === id;
                });
                return talk ? new Talk(talk, speakers, metaData, favourites.indexOf(talk.id) !== -1) : null;
            });
        },

        toggleFavourite: function (talkObject) {
            var favourites = dukeconSettings.toggleFavourite(talkObject.talk.id);
            talkObject.talk.toggleFavourite();
            synch.push(dukecloak.dukecloak);
        },

        getSaveAbstractHtml: function(unsafe) {
            return unsafe
                .replace(/&/g, "&")
                .replace(/</g, "<")
                .replace(/>/g, ">")
                .replace(/"/g, """)
                .replace(/'/g, "'")
                .replace(/\n/g, "
");
        }
    };

    function initializeApp() {
        languageUtils.init();
        offline.init();
    }

    return {
        initializeApp : initializeApp,
        Talk : Talk,
        Speaker : Speaker,
        toggleFavourite : dukeconUtils.toggleFavourite,
        cookiesConfirmed : cookiesConfirmed
    };
});<commit_msg>fixed twitter handle stripping when twitter handle does not contain '@'<commit_after>define(['underscore', 'jquery', 'knockout', 'js/modules/dukecondb', 'js/modules/dukeconsettings', 'js/modules/dukecondateutils', 'js/modules/languageutils', 'js/modules/offline', 'js/modules/dukecloak', 'js/modules/synch'],
    function(_, $, ko, dukeconDb, dukeconSettings, dukeconDateUtils, languageUtils, offline, dukecloak, synch) {

    function Talk(data, speakers, metaData, isFavourite) {
        var self = this;

        this.id = data.id || '';
        this.startDate = data.start ? new Date(data.start) : null;
        this.day = ko.observable(dukeconDateUtils.getDisplayDate(data.start));
        this.dayshort = ko.observable(dukeconDateUtils.getDisplayDateShort(data.start));
        this.startDisplayed = dukeconDateUtils.getDisplayTime(data.start);
        this.duration = dukeconDateUtils.getDurationInMinutes(data.start, data.end);
        this.startSortable = data.start || '';
        this.trackDisplay = ko.observable(dukeconUtils.getTrack(metaData, data.trackId));
        this.track = data.trackId || '';
        this.talkIcon = dukeconUtils.getTalkIcon(data.trackId || '');
        this.isTrackVisible = ko.computed(function () {
            return self.trackDisplay() !== '';
        });
        this.locationDisplay = ko.observable(dukeconUtils.getLocation(metaData, data.locationId));
        this.location = data.locationId || '';
        this.locationOrder = dukeconUtils.getOrderById(metaData.locations, data.locationId);
        this.levelDisplay = ko.observable(dukeconUtils.getLevel(metaData, data.audienceId));
        this.level = data.audienceId || '';
        this.title = data.title || '';
        this.speakerString = dukeconUtils.getSpeakerNames(data.speakerIds, speakers).join(', ');
        this.speakersWithCompanies = dukeconUtils.getSpeakerInfo(data.speakerIds, speakers);
        this.languageDisplay = ko.observable(dukeconUtils.getLanguage(metaData, data.languageId));
        this.language = data.languageId || '';
        this.fullAbstract = dukeconUtils.getSaveAbstractHtml(data.abstractText || '');
        this.timeCategory = dukeconDateUtils.getTimeCategory(this.duration);
        this.timeClass = this.timeCategory == 'regular' ? 'time' : 'time-extra';
        this.favourite = ko.observable(isFavourite);
        this.favicon = ko.computed(function () {
            return this.favourite() ? "img/StarFilled.png" : "img/StarLine.png";
        }, this);
        this.showAlertWindow = function () {
            // requires scrollfix.js for cookie handling:
            var alreadySeen = readCookie('dukecon.favouriteAlertSeen');
            if (!dukecloak.dukecloak.auth.loggedIn() && !alreadySeen) {
                var alertWin = document.getElementById('alert-window');
                if (alertWin) {
                    var position = getScrollXY();
                    alertWin.className = 'shown';
                    alertWin.style.top = (position[1] + 150) + 'px';
                    alertWin.style.left = (position[0] + 40) + 'px';
                }
            }
        };
        this.toggleFavourite = function () {
            this.showAlertWindow();
            this.favourite(!this.favourite());
        };

        languageUtils.selectedLanguage.subscribe(function () {
            self.day(dukeconDateUtils.getDisplayDate(data.start));
            self.trackDisplay(dukeconUtils.getTrack(metaData, data.trackId));
            self.levelDisplay(dukeconUtils.getLevel(metaData, data.audienceId));
            self.languageDisplay(dukeconUtils.getLanguage(metaData, data.languageId));
            self.locationDisplay(dukeconUtils.getLocation(metaData, data.locationId));
        });

    }

    function Speaker(data, talks, speakers, metaData, favorites) {
        this.name = data.name || '';
        this.company = data.company || '';
        this.twitterHandle = '';
        this.twitterLink = '';
        if (data.twitter && data.twitter.length > 1) {
            this.twitterHandle = data.twitter;
            this.twitterLink = "http://www.twitter.com/" + data.twitter.startsWith('@') ? data.twitter.substr(1) : data.twitter;
        }

        this.talks = dukeconUtils.getTalks(data.eventIds, talks, speakers, metaData, favorites);
    }

    var cookiesConfirmed = ko.observable();

//not sure where else to put
    var dukeconUtils = {
        talkIcons: {
            "7": "img/track_architecture.jpg",
            "2": "img/track_jvm-languages.jpg",
            "3": "img/track_enterprise-java-cloud.jpg",
            "4": "img/track_frontend-mobile.jpg",
            "5": "img/track_ide-tools.jpg",
            "1": "img/track_microservices.jpg",
            "6": "img/track_internet-of-things.jpg",
            "8": "img/track_newcomer.jpg",
            "9": "img/track_community.jpg"
        },

        getTrack: function (metaData, trackId) {
            return dukeconUtils.getById(metaData.tracks, trackId);
        },

        getLanguage: function (metaData, languageId) {
            return dukeconUtils.getById(metaData.languages, languageId);
        },

        getLevel: function (metaData, levelId) {
            return dukeconUtils.getById(metaData.audiences, levelId);
        },

        getLocation: function (metaData, locationId) {
            return dukeconUtils.getById(metaData.locations, locationId);
        },

        getById: function (data, id) {
            var value = _.find(data, function (d) {
                return d.id === id;
            });
            return value ? value.names[languageUtils.selectedLanguage()] : '';
        },

        getOrderById: function (data, id) {
            var value = _.find(data, function (d) {
                return d.id === id;
            });
            return value ? value.order : 0;
        },

        getSpeakerInfo: function (speakerIds, speakers) {
            if (!speakerIds || speakerIds.length === 0) {
                return [];
            }
            var filteredSpeakers = _.filter(speakers, function (speaker) {
                return speaker && speaker.name;
            });
            return _.map(speakerIds, function (speakerId) {
                var speaker = _.find(speakers, function (s) {
                        return s.id === speakerId;
                    }
                ) || {};
                var twitterHandle = "", twitterLink = "";
                if (speaker.twitter && speaker.twitter.length > 1) {
                    twitterHandle = "(" + speaker.twitter + ")";
                    twitterLink = "http://www.twitter.com/" + speaker.twitter.startsWith('@') ? speaker.twitter.substr(1) : speaker.twitter;
                }
                return { name: speaker.name || "", company: (speaker.company ? ", " + speaker.company : ''), twitterHandle: twitterHandle, twitterLink: twitterLink };
            });
        },

        getSpeakerNames: function (speakerIds, speakers) {
            if (!speakerIds || speakerIds.length === 0) {
                return [];
            }
            var filteredSpeakers = _.filter(speakers, function (speaker) {
                return speaker && speaker.name;
            });
            return _.map(speakerIds, function (speakerId) {
                var speaker = _.find(speakers, function (s) {
                        return s.id === speakerId;
                    }
                ) || {};
                return speaker.name || "";
            });
        },

        getTalkIcon: function (typeId) {
            return dukeconUtils.talkIcons[typeId] || 'img/Unknown.png';
        },

        getTalks: function (talkIds, talks, speakers, metaData, favourites) {
            return _.map(talkIds, function (id) {
                var talk = _.find(talks, function (t) {
                    return t.id === id;
                });
                return talk ? new Talk(talk, speakers, metaData, favourites.indexOf(talk.id) !== -1) : null;
            });
        },

        toggleFavourite: function (talkObject) {
            var favourites = dukeconSettings.toggleFavourite(talkObject.talk.id);
            talkObject.talk.toggleFavourite();
            synch.push(dukecloak.dukecloak);
        },

        getSaveAbstractHtml: function(unsafe) {
            return unsafe
                .replace(/&/g, "&")
                .replace(/</g, "<")
                .replace(/>/g, ">")
                .replace(/"/g, """)
                .replace(/'/g, "'")
                .replace(/\n/g, "
");
        }
    };

    function initializeApp() {
        languageUtils.init();
        offline.init();
    }

    return {
        initializeApp : initializeApp,
        Talk : Talk,
        Speaker : Speaker,
        toggleFavourite : dukeconUtils.toggleFavourite,
        cookiesConfirmed : cookiesConfirmed
    };
});<|endoftext|>


<commit_before>var HealthChecker=function(){var b={},d=function(h,g,e){h in b||(b[h]=timedQueue(3E5));b[h].enqueue({instant:(new Date).getTime(),duration:e,success:g});k()},f=function(){var b=(new Date).getTime();$.ajax("/latency",{method:"GET",success:function(g){g=parseInt(g);var e=((new Date).getTime()-b-g)/2;d("serverResponse",!0,g);d("latency",!0,e);_.delay(f,2E4)},dataType:"text",error:function(){addMeasure("latency",!1,((new Date).getTime()-b)/2);_.delay(f,2E4)}})},k=_.throttle(function(){var b=l(1E3),g=
m();HealthCheckViewer.refreshDisplays(b,g)},500),n=function(){_.delay(f,2E4)},l=function(h){return _.mapValues(b,function(b){var e={};_.forEach(b.items(),function(b){var g=Math.floor(b.instant/h)*h,a=e[g],a=a?a:{count:0,avg:void 0,successCount:0,min:void 0,max:void 0,instant:g};a.count+=1;b.success&&(a.successCount+=1);if(void 0==a.min||a.min>b.duration)a.min=b.duration;if(void 0==a.max||a.max<b.duration)a.max=b.duration;a.avg=void 0==a.avg?b.duration:(b.duration-a.avg)/a.count+a.avg;e[g]=a});return _.values(e)})},
m=function(){return _.mapValues(b,function(b,g){var e=b.items(),d=e.length,f=_.map(e,"duration");if(0<d)return{name:g,count:d,max:_.max(f),min:_.min(f),average:_.mean(f),recent:_.mean(_.takeRight(f,10)),successRate:_.countBy(e,"success")[!0]/d}})};$(function(){n()});return{check:f,resumeHealthCheck:n,pauseHealthCheck:function(){},addMeasure:d,getMeasures:function(){return _.mapValues(b,function(b){return b.items()})},getAggregatedMeasures:l,describeHealth:m}}(),serverResponse=function(b){HealthChecker.addMeasure(b.command,
b.success,b.duration);if("instant"in b){var d=b.instant,d=((new Date).getTime()-d-b.duration)/2;HealthChecker.addMeasure("latency",b.success,d)}"success"in b&&0==b.success&&errorAlert(sprintf("error in %s",b.command),b.response||"error encountered")},HealthCheckViewer=function(){var b=!1,d={};$("#healthCheckListing");var f={},k={};$(function(){d=$("#healthCheckListing");f=d.find(".healthCheckItem").clone();d.empty()});var n=function(a){return _.filter(_.map(a,function(a){return{x:a.instant,y:a.count-
a.successCount}}),function(a){return 0<a.y})},l=function(a){return _.map(a,function(a){return{x:a.instant,y:a.avg}})},m=function(a){return _.map(a,function(a){return{x:a.instant,y:a.min}})},h=function(a){return _.map(a,function(a){return{x:a.instant,y:a.max}})},g=function(a){var b=(new Date).getTime();return _.map(a,function(a){a.instant=(a.instant-b)/1E3;return a})},e=function(a,b){if(!(a in k)){var c=g(b),e=f.clone(),p=$("<canvas />").addClass("healthCheckCanvas");e.html(p);d.append(e);e={title:{display:!0,
text:a},scales:{yAxes:[{id:"durationAxis",scaleLabel:{display:!0,labelString:"time taken (ms)"},type:"linear",stacked:!1,display:!0,position:"left",ticks:{},labels:{show:!0}},{id:"errorAxis",scaleLabel:{display:!0,labelString:"errors"},type:"linear",stacked:!0,display:!0,position:"right",ticks:{beginAtZero:!0,min:0,stepSize:1},labels:{show:!0}}],xAxes:[{type:"linear",position:"bottom",scaleLabel:{display:!0,labelString:"time (seconds)"},ticks:{beginAtZero:!0}}]},hover:{mode:"x-axis"},elements:{line:{fill:!1},
bar:{fill:!0}},legend:{display:!0}};c={type:"bar",data:{labels:_.map(c,"instant"),datasets:[{type:"line",label:"error count",data:n(c),fill:!0,borderColor:"rgba(0,0,0,0.5)",backgroundColor:"rgba(255,0,0,0.3)",borderWidth:1,pointRadius:0,pointHoverRadius:3,pointHitRadius:5,lineTension:0,stepped:!0,yAxisID:"errorAxis"},{label:"min",type:"line",data:m(c),fill:!0,pointRadius:0,pointHoverRadius:3,pointHitRadius:5,borderColor:"rgba(155,197,61,1)",backgroundColor:"rgba(155,197,61,0.3)",borderWidth:1,lineTension:.1,
yAxisID:"durationAxis"},{label:"avg",type:"line",data:l(c),fill:!0,pointRadius:0,pointHoverRadius:3,pointHitRadius:5,borderColor:"rgba(250,121,33,1)",backgroundColor:"rgba(250,121,33,0.3)",borderWidth:1,lineTension:.1,yAxisID:"durationAxis"},{label:"max",type:"line",data:h(c),fill:!0,pointRadius:0,pointHoverRadius:3,pointHitRadius:5,borderColor:"rgba(229,89,52,1)",backgroundColor:"rgba(229,89,52,0.3)",borderWidth:1,lineTension:.1,yAxisID:"durationAxis"}]},options:e};p=new Chart(p[0].getContext("2d"),
c);k[a]=p}},r=function(a){var b=10;a.latency&&(b-=Math.min(5,a.latency.recent/100));a.render&&(b-=Math.min(5,a.render.recent/20));$("#healthStatus").prop({max:10,min:0,value:b,low:0,optimum:8,high:6})},q=function(a,d){(new Date).getTime();var c=d.latency;void 0!=c?(r(d),$(".healthCheckSummaryLatencyContainer").show(),$(".latencyAverage").text(c.average),$(".worstLatency").text(c.min),$(".bestLatency").text(c.max),$(".successRate").text(100*c.successRate),200<c.average?$(".latencyHumanReadable").text("poor"):
50<c.average?$(".latencyHumanReadable").text("moderate"):20<c.average&&$(".latencyHumanReadable").text("good")):$(".healthCheckSummaryLatencyContainer").hide();c=d.serverResponse;void 0!=c?($(".heathCheckSummaryServerResponseContainer").show(),c=c.average,$(".serverResponseAverage").text(c),c=2<c?"poor":"good",$(".serverResponseHumanReadable").text(c)):$(".heathCheckSummaryServerResponseContainer").hide();_.forEach(a,function(a,c){var d=g(a);c in k||e(c,a);if(1==b){var f=k[c];f.data.datasets[0].data=
n(d);f.data.datasets[1].data=m(d);f.data.datasets[2].data=l(d);f.data.datasets[3].data=h(d);f.update()}})};return{resume:function(){b=!0;var a=HealthChecker.getAggregatedMeasures(1E3),d=HealthChecker.describeHealth();q(a,d);_.forEach(a,function(a,b){e(b,a)})},pause:function(){b=!1},refreshDisplays:q}}();
<commit_msg>changed healthcheck values<commit_after>var HealthChecker=function(){var b={},d=function(h,g,e){h in b||(b[h]=timedQueue(3E5));b[h].enqueue({instant:(new Date).getTime(),duration:e,success:g});k()},f=function(){var b=(new Date).getTime();$.ajax("/latency",{method:"GET",success:function(g){g=parseInt(g);var e=((new Date).getTime()-b-g)/2;d("serverResponse",!0,g);d("latency",!0,e);_.delay(f,2E4)},dataType:"text",error:function(){addMeasure("latency",!1,((new Date).getTime()-b)/2);_.delay(f,2E4)}})},k=_.throttle(function(){var b=l(1E3),g=
m();HealthCheckViewer.refreshDisplays(b,g)},500),n=function(){_.delay(f,2E4)},l=function(h){return _.mapValues(b,function(b){var e={};_.forEach(b.items(),function(b){var g=Math.floor(b.instant/h)*h,a=e[g],a=a?a:{count:0,avg:void 0,successCount:0,min:void 0,max:void 0,instant:g};a.count+=1;b.success&&(a.successCount+=1);if(void 0==a.min||a.min>b.duration)a.min=b.duration;if(void 0==a.max||a.max<b.duration)a.max=b.duration;a.avg=void 0==a.avg?b.duration:(b.duration-a.avg)/a.count+a.avg;e[g]=a});return _.values(e)})},
m=function(){return _.mapValues(b,function(b,g){var e=b.items(),d=e.length,f=_.map(e,"duration");if(0<d)return{name:g,count:d,max:_.max(f),min:_.min(f),average:_.mean(f),recent:_.mean(_.takeRight(f,10)),successRate:_.countBy(e,"success")[!0]/d}})};$(function(){n()});return{check:f,resumeHealthCheck:n,pauseHealthCheck:function(){},addMeasure:d,getMeasures:function(){return _.mapValues(b,function(b){return b.items()})},getAggregatedMeasures:l,describeHealth:m}}(),serverResponse=function(b){HealthChecker.addMeasure(b.command,
b.success,b.duration);if("instant"in b){var d=b.instant,d=((new Date).getTime()-d-b.duration)/2;HealthChecker.addMeasure("latency",b.success,d)}"success"in b&&0==b.success&&errorAlert(sprintf("error in %s",b.command),b.response||"error encountered")},HealthCheckViewer=function(){var b=!1,d={};$("#healthCheckListing");var f={},k={};$(function(){d=$("#healthCheckListing");f=d.find(".healthCheckItem").clone();d.empty()});var n=function(a){return _.filter(_.map(a,function(a){return{x:a.instant,y:a.count-
a.successCount}}),function(a){return 0<a.y})},l=function(a){return _.map(a,function(a){return{x:a.instant,y:a.avg}})},m=function(a){return _.map(a,function(a){return{x:a.instant,y:a.min}})},h=function(a){return _.map(a,function(a){return{x:a.instant,y:a.max}})},g=function(a){var b=(new Date).getTime();return _.map(a,function(a){a.instant=(a.instant-b)/1E3;return a})},e=function(a,b){if(!(a in k)){var c=g(b),e=f.clone(),p=$("<canvas />").addClass("healthCheckCanvas");e.html(p);d.append(e);e={title:{display:!0,
text:a},scales:{yAxes:[{id:"durationAxis",scaleLabel:{display:!0,labelString:"time taken (ms)"},type:"linear",stacked:!1,display:!0,position:"left",ticks:{},labels:{show:!0}},{id:"errorAxis",scaleLabel:{display:!0,labelString:"errors"},type:"linear",stacked:!0,display:!0,position:"right",ticks:{beginAtZero:!0,min:0,stepSize:1},labels:{show:!0}}],xAxes:[{type:"linear",position:"bottom",scaleLabel:{display:!0,labelString:"time (seconds)"},ticks:{beginAtZero:!0}}]},hover:{mode:"x-axis"},elements:{line:{fill:!1},
bar:{fill:!0}},legend:{display:!0}};c={type:"bar",data:{labels:_.map(c,"instant"),datasets:[{type:"line",label:"error count",data:n(c),fill:!0,borderColor:"rgba(0,0,0,0.5)",backgroundColor:"rgba(255,0,0,0.3)",borderWidth:1,pointRadius:0,pointHoverRadius:3,pointHitRadius:5,lineTension:0,stepped:!0,yAxisID:"errorAxis"},{label:"min",type:"line",data:m(c),fill:!0,pointRadius:0,pointHoverRadius:3,pointHitRadius:5,borderColor:"rgba(155,197,61,1)",backgroundColor:"rgba(155,197,61,0.3)",borderWidth:1,lineTension:.1,
yAxisID:"durationAxis"},{label:"avg",type:"line",data:l(c),fill:!0,pointRadius:0,pointHoverRadius:3,pointHitRadius:5,borderColor:"rgba(250,121,33,1)",backgroundColor:"rgba(250,121,33,0.3)",borderWidth:1,lineTension:.1,yAxisID:"durationAxis"},{label:"max",type:"line",data:h(c),fill:!0,pointRadius:0,pointHoverRadius:3,pointHitRadius:5,borderColor:"rgba(229,89,52,1)",backgroundColor:"rgba(229,89,52,0.3)",borderWidth:1,lineTension:.1,yAxisID:"durationAxis"}]},options:e};p=new Chart(p[0].getContext("2d"),
c);k[a]=p}},r=function(a){var b=10;a.latency&&(b-=Math.min(8,a.latency.recent/100));a.render&&(b-=Math.min(8,a.render.recent/20));$("#healthStatus").prop({max:10,min:0,value:b,low:0,optimum:8,high:6})},q=function(a,d){(new Date).getTime();var c=d.latency;void 0!=c?(r(d),$(".healthCheckSummaryLatencyContainer").show(),$(".latencyAverage").text(c.average),$(".worstLatency").text(c.min),$(".bestLatency").text(c.max),$(".successRate").text(100*c.successRate),200<c.average?$(".latencyHumanReadable").text("poor"):
50<c.average?$(".latencyHumanReadable").text("moderate"):20<c.average&&$(".latencyHumanReadable").text("good")):$(".healthCheckSummaryLatencyContainer").hide();c=d.serverResponse;void 0!=c?($(".heathCheckSummaryServerResponseContainer").show(),c=c.average,$(".serverResponseAverage").text(c),c=2<c?"poor":"good",$(".serverResponseHumanReadable").text(c)):$(".heathCheckSummaryServerResponseContainer").hide();_.forEach(a,function(a,c){var d=g(a);c in k||e(c,a);if(1==b){var f=k[c];f.data.datasets[0].data=
n(d);f.data.datasets[1].data=m(d);f.data.datasets[2].data=l(d);f.data.datasets[3].data=h(d);f.update()}})};return{resume:function(){b=!0;var a=HealthChecker.getAggregatedMeasures(1E3),d=HealthChecker.describeHealth();q(a,d);_.forEach(a,function(a,b){e(b,a)})},pause:function(){b=!1},refreshDisplays:q}}();
<|endoftext|>


<commit_before>function Character(_character) {
    Component.call(this, _character);
    try {
        this.setSpeed(_character.speed);
        this.setSpeedJump(_character.speedJump);
        this.setMaxHealth(_character.maxHealth);
        this.setHealth(_character.health); //percentage of maxHealth (0 to 100)
        this.setDamage(_character.damage);
        this.healBar;
        this.move = {
            right: false,
            left: false,
            up: false,
            down: false
        };
        this.isDead = false;
    } catch (e) {
        throw (e);
    }
    this.start();
}

Character.prototype = Object.create(Component.prototype);

Character.prototype.setMaxHealth = function (value = 100) {
    this.maxHealth = value;
    //CANNOT BE NEGATIVE
};

Character.prototype.setSpeed = function (value = 100) {
    this.speed = value;
    //CANNOT BE NEGATIVE
};

Character.prototype.setSpeedJump = function (value = 100) {
    this.speedJump = value;
    //CANNOT BE NEGATIVE
};

Character.prototype.setHealth = function (value = 100) {
    this.health = value;
    //CANNOT BE NEGATIVE
};

Character.prototype.setDamage = function (value = 0) {
    this.damage = value;
    //CANNOT BE NEGATIVE
};

Character.prototype.kill = function () {
    this.healBar.maxHealth.destroy();
    this.healBar.health.destroy();
    this.healBar.damage.destroy();
    this.figure.destroy();
    this.isDead = true;
    delete this.healBar;
};

Character.prototype.receiveDamage = function (damage) {
    this.damage = this.damage + damage;
    this.health = ((this.maxHealth - this.damage) * 100) / this.maxHealth;
    this.healBar.health.w = 96 * this.health / 100; //96 is the initial width of the healbar;
    if ((96 * this.health / 100) <= 0) {
        this.healBar.health.color('rgba (0,0,0,0)');
        this.kill();
    }
};

Character.prototype.start = function () {
    this.healBar = new HealBar(this);
    this.isDead = false;
    this.figure = Crafty.e(this.reference + ', 2D, Canvas' /*, Color,*/ + ', Gravity, Collision, balotelliRun, SpriteAnimation')
        .attr({
            x: this.posX,
            y: this.posY,
            w: this.width,
            h: this.height
        })
        /*.color(this.color)*/
        .gravity('Floor')
        .collision()
        .reel('running', 500, [
            [0, 0],
            [1, 0],
            [2, 0],
            [3, 0],
            [4, 0],
            [5, 0],
            [6, 0],
            [7, 0],
            [8, 0],
            [9, 0]
        ]) // setup animation
        .animate('running', -1).bind('KeyDown', (e) => {
            // Default movement booleans to false
            this.move.right = this.move.left = this.move.down = this.move.up = false;
            // If keys are down, set the direction
            if (e.key == Crafty.keys.RIGHT_ARROW || e.key == Crafty.keys.D) {
                this.move.right = true;
            }
            if (e.key == Crafty.keys.LEFT_ARROW || e.key == Crafty.keys.A) {
                this.move.left = true;
            }
            if (e.keyCode === Crafty.keys.UA) this.move.up = true;
            if (e.keyCode === Crafty.keys.DA) this.move.down = true;
        })
        .bind('Moved', (from) => {
            this.posX = this.figure.x;
            this.posY = this.figure.y;
            this.healBar.maxHealth.x = this.figure.x - this.figure.w / 2;
            this.healBar.maxHealth.y = this.figure.y - this.figure.h + 30;
            this.healBar.health.x = this.healBar.maxHealth.x + 2;
            this.healBar.health.y = this.healBar.maxHealth.y + 2;
            this.healBar.damage.x = this.healBar.maxHealth.x + 2;
            this.healBar.damage.y = this.healBar.maxHealth.y + 2;
            if (this.figure.hit("limitLeft")) {
                this.figure.attr({
                    x: 1,
                    y: this.figure.y
                });
            }
            if (this.figure.hit("limitRight")) {
                this.figure.attr({
                    x: 719,
                    y: this.figure.y
                });
            }
            if (this.figure.hit("LimitTop")) {
                this.figure.attr({
                    x: this.figure.x,
                    y: -1
                });
            }
            if (this.move.right) {
                this.figure.unflip("X");
            }
            if (this.move.left) {
                this.figure.flip("X");
            }
        });
};<commit_msg>Added new attr .animation<commit_after>function Character(_character) {
    Component.call(this, _character);
    try {
        this.setSpeed(_character.speed);
        this.setSpeedJump(_character.speedJump);
        this.setMaxHealth(_character.maxHealth);
        this.setHealth(_character.health); //percentage of maxHealth (0 to 100)
        this.setDamage(_character.damage);
        this.setAnimation(_character.animation);
        this.healBar;
        this.move = {
            right: false,
            left: false,
            up: false,
            down: false
        };
        this.isDead = false;
    } catch (e) {
        throw (e);
    }
    this.start();
}

Character.prototype = Object.create(Component.prototype);

Character.prototype.setMaxHealth = function (value = 100) {
    this.maxHealth = value;
    //CANNOT BE NEGATIVE
};

Character.prototype.setSpeed = function (value = 100) {
    this.speed = value;
    //CANNOT BE NEGATIVE
};

Character.prototype.setSpeedJump = function (value = 100) {
    this.speedJump = value;
    //CANNOT BE NEGATIVE
};

Character.prototype.setHealth = function (value = 100) {
    this.health = value;
    //CANNOT BE NEGATIVE
};

Character.prototype.setDamage = function (value = 0) {
    this.damage = value;
    //CANNOT BE NEGATIVE
};

Character.prototype.kill = function () {
    this.healBar.maxHealth.destroy();
    this.healBar.health.destroy();
    this.healBar.damage.destroy();
    this.figure.destroy();
    this.isDead = true;
    delete this.healBar;
};

Character.prototype.receiveDamage = function (damage) {
    this.damage = this.damage + damage;
    this.health = ((this.maxHealth - this.damage) * 100) / this.maxHealth;
    this.healBar.health.w = 96 * this.health / 100; //96 is the initial width of the healbar;
    if ((96 * this.health / 100) <= 0) {
        this.healBar.health.color('rgba (0,0,0,0)');
        this.kill();
    }
};

Character.prototype.setAnimation = function (value) {
    this.animation = value;
};

Character.prototype.start = function () {
    this.healBar = new HealBar(this);
    this.isDead = false;
    this.figure = Crafty.e(this.reference + ', 2D, Canvas' /*, Color,*/ + ', Gravity, Collision, balotelliRun, SpriteAnimation')
        .attr({
            x: this.posX,
            y: this.posY,
            w: this.width,
            h: this.height
        })
        /*.color(this.color)*/
        .gravity('Floor')
        .collision()
        .reel('running', 500, [
            [0, 0],
            [1, 0],
            [2, 0],
            [3, 0],
            [4, 0],
            [5, 0],
            [6, 0],
            [7, 0],
            [8, 0],
            [9, 0]
        ]) // setup animation
        .animate('running', -1).bind('KeyDown', (e) => {
            // Default movement booleans to false
            this.move.right = this.move.left = this.move.down = this.move.up = false;
            // If keys are down, set the direction
            if (e.key == Crafty.keys.RIGHT_ARROW || e.key == Crafty.keys.D) {
                this.move.right = true;
            }
            if (e.key == Crafty.keys.LEFT_ARROW || e.key == Crafty.keys.A) {
                this.move.left = true;
            }
            if (e.keyCode === Crafty.keys.UA) this.move.up = true;
            if (e.keyCode === Crafty.keys.DA) this.move.down = true;
        })
        .bind('Moved', (from) => {
            this.posX = this.figure.x;
            this.posY = this.figure.y;
            this.healBar.maxHealth.x = this.figure.x - this.figure.w / 2;
            this.healBar.maxHealth.y = this.figure.y - this.figure.h + 30;
            this.healBar.health.x = this.healBar.maxHealth.x + 2;
            this.healBar.health.y = this.healBar.maxHealth.y + 2;
            this.healBar.damage.x = this.healBar.maxHealth.x + 2;
            this.healBar.damage.y = this.healBar.maxHealth.y + 2;
            if (this.figure.hit("limitLeft")) {
                this.figure.attr({
                    x: 1,
                    y: this.figure.y
                });
            }
            if (this.figure.hit("limitRight")) {
                this.figure.attr({
                    x: 719,
                    y: this.figure.y
                });
            }
            if (this.figure.hit("LimitTop")) {
                this.figure.attr({
                    x: this.figure.x,
                    y: -1
                });
            }
            if (this.move.right) {
                this.figure.unflip("X");
            }
            if (this.move.left) {
                this.figure.flip("X");
            }
        });
};<|endoftext|>