<commit_before>(function () {
    'use strict';

    var gulp, minifyHTML, concat, stripDebug, uglify, jshint, changed, imagemin, autoprefix, sass, rjs, minifyCSS,
        browserSync, pngquant, del, paths, host, themes, fs, request, recursive, configs, FOUNDATION_URI, THEME_AS_DEFAULT;

    gulp = require('gulp');
    minifyHTML = require('gulp-minify-html');
    concat = require('gulp-concat');
    stripDebug = require('gulp-strip-debug');
    uglify = require('gulp-uglify');
    jshint = require('gulp-jshint');
    changed = require('gulp-changed');
    imagemin = require('gulp-imagemin');
    autoprefix = require('gulp-autoprefixer');
    sass = require('gulp-sass');
    rjs = require('gulp-requirejs');
    minifyCSS = require('gulp-minify-css');
    browserSync = require('browser-sync');
    pngquant = require('imagemin-pngquant');
    del = require('del');
    fs = require('fs');
    request = require('request');
    recursive = require('recursive-readdir');
    paths = {
        "app": require('./bower.json').appPath || 'app',
        "dist": 'dist',
        "themes": 'themes',
        "js": ['app/scripts/*.js', 'app/scripts/**/*.js'],
        "vendor": 'app/lib/**/*.js',
        "vendorTheme": 'app/themes/**/lib/*',
        "sass": 'app/styles/sass/**/*.scss',
        "css": 'app/themes/**/styles/**/*.css',
        "images": ['app/themes/**/images/**/*', 'app/themes/**/styles/**/*.{png,jpg,jpec,ico}'],
        "fonts": ['app/themes/**/styles/fonts/**/*', 'app/themes/**/fonts/**/*'],
        "html": 'app/**/*.html',
        "misc": 'app/*.{txt,htaccess,ico}',
        "themeDest": "dist/themes",
        "themesDir": "./app/themes"

    };
    host = {
        port: '8080',
        lrPort: '35729'
    };

    themes = [];
    FOUNDATION_URI = 'http://dev.ottemo.io:3000';
    THEME_AS_DEFAULT = 'blitz';

    configs = [
        {
            "path": "general.app.foundation_url",
            "value": FOUNDATION_URI,
            "type": "varchar(255)",
            "editor": "text",
            "options": "",
            "label": "Foundation host URL",
            "description": "URL application will use to generate foundation resources links"
        },
        {
            "path": "themes",
            "value": "",
            "type": "group",
            "editor": "",
            "options": "",
            "label": "Themes",
            "description": ""
        },
        {
            "path": "themes.list",
            "value": "",
            "type": "group",
            "editor": "themes_manager",
            "options": "",
            "label": "Themes",
            "description": ""
        },
        {
            "path": "themes.list.active",
            "value": THEME_AS_DEFAULT,
            "type": "",
            "editor": "themes_manager",
            "options": "",
            "label": "Active theme",
            "description": "Active theme on storefront"
        },
        {
            "path": "general.app.login.facebook.appId",
            "value": "483159925160897",
            "type": "varchar(255)",
            "editor": "text",
            "options": "",
            "label": "Facebook: App ID",
            "description": "Facebook: Application ID"
        },
        {
            "path": "general.app.login.facebook.secretKey",
            "value": "9a362f8b5cd91dbdd908bff472468c7e",
            "type": "varchar(255)",
            "editor": "text",
            "options": "",
            "label": "Facebook: App Secret",
            "description": "Facebook: Application secret key"
        },
        {
            "path": "general.app.login.google.clientId",
            "value": "1074763412644-qq25glj3tb87bq7bk5m8793da11ddheh.apps.googleusercontent.com",
            "type": "varchar(255)",
            "editor": "text",
            "options": "",
            "label": "Google: Client ID",
            "description": ""
        },
        {
            "path": "general.app.category.itemsPerPage",
            "value": 10,
            "type": "int",
            "editor": "text",
            "options": "",
            "label": "Items on page",
            "description": ""
        }
    ];

    var setConfigOption = function (path, option) {
        for (var i = 0; i < configs.length; i += 1) {
            if (configs[i].path === path) {
                configs[i].options = option;
                break;
            }
        }
    };

    var setConfig = function (config) {
        request({
            uri: FOUNDATION_URI + '/config/unregister/' + config.path,
            method: 'DELETE'
        }, function () {
            var r = request.post(FOUNDATION_URI + '/config/register');
            var form = r.form();

            form.append('path', config.path);
            form.append('value', config.value);
            form.append('type', config.type);
            form.append('editor', config.editor);
            form.append('options', config.options);
            form.append('label', config.label);
            form.append('description', config.description);
        });
    };

    var initConfigs = function () {
        for (var i = 0; i < configs.length; i += 1) {
            setConfig(configs[i]);
        }
    };

    // Empties folders to start fresh
    gulp.task('clean', function (cb) {
        del(['dist/*', '!dist/media'], cb);
    });

    // Actions with js-files from theme
    gulp.task('vendorTheme', ['clean'], function () {
        /**
         * Minify and uglify the custom scripts in folder 'scripts' in each theme
         */
        gulp.src('app/themes/**/scripts/**/*.js')
            .pipe(stripDebug())
            .pipe(uglify({mangle: false}))
            .pipe(gulp.dest(paths.themeDest));

        /**
         * copy vendor js from theme folder
         */
        return gulp.src(paths.vendorTheme)
            .pipe(gulp.dest(paths.themeDest));
    });

    // copy vendor js
    gulp.task('vendor', ['clean', 'vendorTheme'], function () {
        return gulp.src(paths.vendor)
            .pipe(gulp.dest(paths.dist + '/lib'));
    });

    // copy misc assets
    gulp.task('misc', ['clean'], function () {
        return gulp.src(paths.misc)
            .pipe(gulp.dest(paths.dist));
    });

    // Run JSHint
    gulp.task('jshint', function () {
        gulp.src(paths.js)
            .pipe(jshint())
            .pipe(jshint.reporter(require('jshint-stylish')));
    });

    gulp.task('requirejs', ['clean', 'jshint'], function () {
        rjs({
            out: 'main.js',
            name: 'main',
            preserveLicenseComments: false, // remove all comments
            removeCombined: true,
            baseUrl: paths.app + '/scripts',
            mainConfigFile: 'app/scripts/main.js',
            "paths": {
                // Don't attempt to include dependencies whose path begins with webapp/
                "config": "config"
            },
            "shim": {
                "config": {exports: "config"}
            }
        })
            .pipe(stripDebug())
            .pipe(uglify({mangle: false}))
            .pipe(gulp.dest(paths.dist + '/scripts/'));
    });

    // Sass task, will run when any SCSS files change & BrowserSync
    // will auto-update browsers
    gulp.task('sass', function () {
        return gulp.src(paths.sass)
            .pipe(sass({imagePath: '../../images'}))
            .pipe(autoprefix('last 1 version'))
            .pipe(gulp.dest(paths.dist + '/styles'))
            .pipe(gulp.dest(paths.app + '/styles'));
    });

    // minify new images
    gulp.task('imagemin', ['clean'], function () {
        return gulp.src(paths.images)
            .pipe(changed(paths.themeDest))
            .pipe(imagemin())
            .pipe(gulp.dest(paths.themeDest));
    });

    // minify new or changed HTML pages
    gulp.task('html', ['clean'], function () {
        return gulp.src(paths.html)
            .pipe(changed(paths.dist))
            .pipe(minifyHTML({
                collapseWhitespace: true,
                collapseBooleanAttributes: true,
                removeCommentsFromCDATA: true,
                removeOptionalTags: true,
                conditionals: true,
                quotes: true,
                empty: true
            }))
            .pipe(gulp.dest(paths.dist));
    });

    // CSS auto-prefix and minify
    gulp.task('autoprefixer', ['clean', 'sass'], function () {
        gulp.src(paths.css)
            .pipe(autoprefix('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
            .pipe(minifyCSS())
            .pipe(gulp.dest(paths.themeDest));
        gulp.src(paths.fonts)
            .pipe(gulp.dest(paths.themeDest));
    });

    // Protractor tests
    // gulp.task('protractorUpdate', protractor.webdriverUpdate);
    // gulp.task('protractor', ['protractorUpdate'], function (cb) {
    //     gulp.src(['tests/e2e/**/*.js']).pipe(protractor.protractor({
    //         configFile: 'protractor.conf.js'
    //     })).on('error', function (e) {
    //         console.log(e);
    //     }).on('end', cb);
    // });
    //
    // // Jasmine test
    // gulp.task('jasmine', function() {
    //     gulp.src('spec/**/*.js')
    //         .pipe(jasmine({verbose:true, includeStackTrace: true}));
    // });
    //
    // gulp.task('test', ['protractor', 'jasmine'], function () {});

    // browser-sync task for starting server
    gulp.task('browser-sync', function () {
        browserSync({
            server: {
                baseDir: './app'
            },
            port: host.port
        });
    });

    gulp.task('bs-reload', function () {
        browserSync.reload();
    });

    // run in development mode with easy browser reloading
    gulp.task('dev', ['browser-sync'], function () {

        gulp.watch('app/views/**/*.html', [browserSync.reload]);
        gulp.watch('app/styles/**/*.css', [browserSync.reload]);
        gulp.watch('app/styles/**/*.scss', ['sass', browserSync.reload]);
        gulp.watch('app/scripts/**/*.js', ['jshint', browserSync.reload]);
    });

    gulp.task('serve', ['dev', 'retrieve-files']);

    gulp.task('build', function () {
        var jsCode, themesData;
        themesData = '';

        recursive(paths.themesDir, function (err, files) {
            var i, theme, filePath, parts, regExp;
            theme = null;
            regExp = new RegExp('app[/\\\\]themes[/\\\\](\\w+)[/\\\\](.+)', 'i');

            jsCode = '/* jshint ignore:start */\n' +
                '(function (define) {\n' +
                '"use strict";\n' +
                'define(function () {\n' +
                'return {\n';

            for (i = 0; i < files.length; i += 1) {
                filePath = files[i];
                parts = filePath.match(regExp);
                if (parts instanceof Array) {
                    if (theme !== parts[1] && theme === null) {
                        themes.push(parts[1]);
                        jsCode += '\'' + parts[1] + '\' : [\n';
                    }
                    if (theme !== parts[1] && theme !== null) {
                        themes.push(parts[1]);
                        jsCode += '],\n\'' + parts[1] + '\' : [\n';
                    }
                    jsCode += '\'/' + parts[2] + '\',\n';
                    theme = parts[1];
                }
            }

            jsCode += ']\n};\n' +
                '});\n' +
                '})(window.define);\n' +
                '/* jshint ignore:end */';

            fs.writeFile('./app/scripts/design/themeFiles.js', jsCode, function (err) {
                if (err) {
                    return console.log(err);
                }
            });

            themesData = '{';
            for (i = 0; i < themes.length; i += 1) {
                themesData += '"' + themes[i] + '":"' + themes[i] + '"';
                if (i < themes.length - 1) {
                    themesData += ',';
                }
            }
            themesData += '}';

            setConfigOption("themes.list.active", themesData);
            initConfigs();

            gulp.start('requirejs');
            gulp.start('vendor');
            gulp.start('misc');
            gulp.start('html');
            gulp.start('autoprefixer');
            gulp.start('imagemin');
        });
    });

    gulp.task('default', ['build']);

    gulp.task('retrieve-files', function () {
        var jsCode, themesData;
        themesData = '';

        recursive(paths.themesDir, function (err, files) {
            var i, theme, filePath, parts, regExp;
            theme = null;
            regExp = new RegExp('app[/\\\\]themes[/\\\\](\\w+)[/\\\\](.+)', 'i');

            jsCode = '/* jshint ignore:start */\n' +
                '(function (define) {\n' +
                '"use strict";\n' +
                'define(function () {\n' +
                'return {\n';

            for (i = 0; i < files.length; i += 1) {
                filePath = files[i];
                parts = filePath.match(regExp);
                if (parts instanceof Array) {
                    if (theme !== parts[1] && theme === null) {
                        themes.push(parts[1]);
                        jsCode += '\'' + parts[1] + '\' : [\n';
                    }
                    if (theme !== parts[1] && theme !== null) {
                        themes.push(parts[1]);
                        jsCode += '],\n\'' + parts[1] + '\' : [\n';
                    }
                    jsCode += '\'/' + parts[2] + '\',\n';
                    theme = parts[1];
                }
            }

            jsCode += ']\n};\n' +
                '});\n' +
                '})(window.define);\n' +
                '/* jshint ignore:end */';

            fs.writeFile('./app/scripts/design/themeFiles.js', jsCode, function (err) {
                if (err) {
                    return console.log(err);
                }
            });
            themesData = '{';
            for (i = 0; i < themes.length; i += 1) {
                themesData += '"' + themes[i] + '":"' + themes[i] + '"';
                if (i < themes.length - 1) {
                    themesData += ',';
                }
            }
            themesData += '}';

            setConfigOption("themes.list.active", themesData);
            initConfigs();
        });

    });

})();
<commit_msg>Fixed bug in gulpfile<commit_after>(function () {
    'use strict';

    var gulp, minifyHTML, concat, stripDebug, uglify, jshint, changed, imagemin, autoprefix, sass, rjs, minifyCSS,
        browserSync, pngquant, del, paths, host, themes, fs, request, recursive, configs, FOUNDATION_URI, THEME_AS_DEFAULT;

    gulp = require('gulp');
    minifyHTML = require('gulp-minify-html');
    concat = require('gulp-concat');
    stripDebug = require('gulp-strip-debug');
    uglify = require('gulp-uglify');
    jshint = require('gulp-jshint');
    changed = require('gulp-changed');
    imagemin = require('gulp-imagemin');
    autoprefix = require('gulp-autoprefixer');
    sass = require('gulp-sass');
    rjs = require('gulp-requirejs');
    minifyCSS = require('gulp-minify-css');
    browserSync = require('browser-sync');
    pngquant = require('imagemin-pngquant');
    del = require('del');
    fs = require('fs');
    request = require('request');
    recursive = require('recursive-readdir');
    paths = {
        "app": require('./bower.json').appPath || 'app',
        "dist": 'dist',
        "themes": 'themes',
        "js": ['app/scripts/*.js', 'app/scripts/**/*.js'],
        "vendor": 'app/lib/**/*.js',
        "vendorTheme": 'app/themes/**/lib/**/*',
        "sass": 'app/styles/sass/**/*.scss',
        "css": 'app/themes/**/styles/**/*.css',
        "images": ['app/themes/**/images/**/*', 'app/themes/**/styles/**/*.{png,jpg,jpec,ico}'],
        "fonts": ['app/themes/**/styles/fonts/**/*', 'app/themes/**/fonts/**/*'],
        "html": 'app/**/*.html',
        "misc": 'app/*.{txt,htaccess,ico}',
        "themeDest": "dist/themes",
        "themesDir": "./app/themes"

    };
    host = {
        port: '8080',
        lrPort: '35729'
    };

    themes = [];
    FOUNDATION_URI = 'http://dev.ottemo.io:3000';
    THEME_AS_DEFAULT = 'blitz';

    configs = [
        {
            "path": "general.app.foundation_url",
            "value": FOUNDATION_URI,
            "type": "varchar(255)",
            "editor": "text",
            "options": "",
            "label": "Foundation host URL",
            "description": "URL application will use to generate foundation resources links"
        },
        {
            "path": "themes",
            "value": "",
            "type": "group",
            "editor": "",
            "options": "",
            "label": "Themes",
            "description": ""
        },
        {
            "path": "themes.list",
            "value": "",
            "type": "group",
            "editor": "themes_manager",
            "options": "",
            "label": "Themes",
            "description": ""
        },
        {
            "path": "themes.list.active",
            "value": THEME_AS_DEFAULT,
            "type": "",
            "editor": "themes_manager",
            "options": "",
            "label": "Active theme",
            "description": "Active theme on storefront"
        },
        {
            "path": "general.app.login.facebook.appId",
            "value": "483159925160897",
            "type": "varchar(255)",
            "editor": "text",
            "options": "",
            "label": "Facebook: App ID",
            "description": "Facebook: Application ID"
        },
        {
            "path": "general.app.login.facebook.secretKey",
            "value": "9a362f8b5cd91dbdd908bff472468c7e",
            "type": "varchar(255)",
            "editor": "text",
            "options": "",
            "label": "Facebook: App Secret",
            "description": "Facebook: Application secret key"
        },
        {
            "path": "general.app.login.google.clientId",
            "value": "1074763412644-qq25glj3tb87bq7bk5m8793da11ddheh.apps.googleusercontent.com",
            "type": "varchar(255)",
            "editor": "text",
            "options": "",
            "label": "Google: Client ID",
            "description": ""
        },
        {
            "path": "general.app.category.itemsPerPage",
            "value": 10,
            "type": "int",
            "editor": "text",
            "options": "",
            "label": "Items on page",
            "description": ""
        }
    ];

    var setConfigOption = function (path, option) {
        for (var i = 0; i < configs.length; i += 1) {
            if (configs[i].path === path) {
                configs[i].options = option;
                break;
            }
        }
    };

    var setConfig = function (config) {
        request({
            uri: FOUNDATION_URI + '/config/unregister/' + config.path,
            method: 'DELETE'
        }, function () {
            var r = request.post(FOUNDATION_URI + '/config/register');
            var form = r.form();

            form.append('path', config.path);
            form.append('value', config.value);
            form.append('type', config.type);
            form.append('editor', config.editor);
            form.append('options', config.options);
            form.append('label', config.label);
            form.append('description', config.description);
        });
    };

    var initConfigs = function () {
        for (var i = 0; i < configs.length; i += 1) {
            setConfig(configs[i]);
        }
    };

    // Empties folders to start fresh
    gulp.task('clean', function (cb) {
        del(['dist/*', '!dist/media'], cb);
    });

    // Actions with js-files from theme
    gulp.task('vendorTheme', ['clean'], function () {
        /**
         * Minify and uglify the custom scripts in folder 'scripts' in each theme
         */
        gulp.src('app/themes/**/scripts/**/*.js')
            .pipe(stripDebug())
            .pipe(uglify({mangle: false}))
            .pipe(gulp.dest(paths.themeDest));

        /**
         * copy vendor js from theme folder
         */
        return gulp.src(paths.vendorTheme)
            .pipe(gulp.dest(paths.themeDest));
    });

    // copy vendor js
    gulp.task('vendor', ['clean', 'vendorTheme'], function () {
        return gulp.src(paths.vendor)
            .pipe(gulp.dest(paths.dist + '/lib'));
    });

    // copy misc assets
    gulp.task('misc', ['clean'], function () {
        return gulp.src(paths.misc)
            .pipe(gulp.dest(paths.dist));
    });

    // Run JSHint
    gulp.task('jshint', function () {
        gulp.src(paths.js)
            .pipe(jshint())
            .pipe(jshint.reporter(require('jshint-stylish')));
    });

    gulp.task('requirejs', ['clean', 'jshint'], function () {
        rjs({
            out: 'main.js',
            name: 'main',
            preserveLicenseComments: false, // remove all comments
            removeCombined: true,
            baseUrl: paths.app + '/scripts',
            mainConfigFile: 'app/scripts/main.js',
            "paths": {
                // Don't attempt to include dependencies whose path begins with webapp/
                "config": "config"
            },
            "shim": {
                "config": {exports: "config"}
            }
        })
            .pipe(stripDebug())
            .pipe(uglify({mangle: false}))
            .pipe(gulp.dest(paths.dist + '/scripts/'));
    });

    // Sass task, will run when any SCSS files change & BrowserSync
    // will auto-update browsers
    gulp.task('sass', function () {
        return gulp.src(paths.sass)
            .pipe(sass({imagePath: '../../images'}))
            .pipe(autoprefix('last 1 version'))
            .pipe(gulp.dest(paths.dist + '/styles'))
            .pipe(gulp.dest(paths.app + '/styles'));
    });

    // minify new images
    gulp.task('imagemin', ['clean'], function () {
        return gulp.src(paths.images)
            .pipe(changed(paths.themeDest))
            .pipe(imagemin())
            .pipe(gulp.dest(paths.themeDest));
    });

    // minify new or changed HTML pages
    gulp.task('html', ['clean'], function () {
        return gulp.src(paths.html)
            .pipe(changed(paths.dist))
            .pipe(minifyHTML({
                collapseWhitespace: true,
                collapseBooleanAttributes: true,
                removeCommentsFromCDATA: true,
                removeOptionalTags: true,
                conditionals: true,
                quotes: true,
                empty: true
            }))
            .pipe(gulp.dest(paths.dist));
    });

    // CSS auto-prefix and minify
    gulp.task('autoprefixer', ['clean', 'sass'], function () {
        gulp.src(paths.css)
            .pipe(autoprefix('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
            .pipe(minifyCSS())
            .pipe(gulp.dest(paths.themeDest));
        gulp.src(paths.fonts)
            .pipe(gulp.dest(paths.themeDest));
    });

    // Protractor tests
    // gulp.task('protractorUpdate', protractor.webdriverUpdate);
    // gulp.task('protractor', ['protractorUpdate'], function (cb) {
    //     gulp.src(['tests/e2e/**/*.js']).pipe(protractor.protractor({
    //         configFile: 'protractor.conf.js'
    //     })).on('error', function (e) {
    //         console.log(e);
    //     }).on('end', cb);
    // });
    //
    // // Jasmine test
    // gulp.task('jasmine', function() {
    //     gulp.src('spec/**/*.js')
    //         .pipe(jasmine({verbose:true, includeStackTrace: true}));
    // });
    //
    // gulp.task('test', ['protractor', 'jasmine'], function () {});

    // browser-sync task for starting server
    gulp.task('browser-sync', function () {
        browserSync({
            server: {
                baseDir: './app'
            },
            port: host.port
        });
    });

    gulp.task('bs-reload', function () {
        browserSync.reload();
    });

    // run in development mode with easy browser reloading
    gulp.task('dev', ['browser-sync'], function () {

        gulp.watch('app/views/**/*.html', [browserSync.reload]);
        gulp.watch('app/styles/**/*.css', [browserSync.reload]);
        gulp.watch('app/styles/**/*.scss', ['sass', browserSync.reload]);
        gulp.watch('app/scripts/**/*.js', ['jshint', browserSync.reload]);
    });

    gulp.task('serve', ['dev', 'retrieve-files']);

    gulp.task('build', function () {
        var jsCode, themesData;
        themesData = '';

        recursive(paths.themesDir, function (err, files) {
            var i, theme, filePath, parts, regExp;
            theme = null;
            regExp = new RegExp('app[/\\\\]themes[/\\\\](\\w+)[/\\\\](.+)', 'i');

            jsCode = '/* jshint ignore:start */\n' +
                '(function (define) {\n' +
                '"use strict";\n' +
                'define(function () {\n' +
                'return {\n';

            for (i = 0; i < files.length; i += 1) {
                filePath = files[i];
                parts = filePath.match(regExp);
                if (parts instanceof Array) {
                    if (theme !== parts[1] && theme === null) {
                        themes.push(parts[1]);
                        jsCode += '\'' + parts[1] + '\' : [\n';
                    }
                    if (theme !== parts[1] && theme !== null) {
                        themes.push(parts[1]);
                        jsCode += '],\n\'' + parts[1] + '\' : [\n';
                    }
                    jsCode += '\'/' + parts[2] + '\',\n';
                    theme = parts[1];
                }
            }

            jsCode += ']\n};\n' +
                '});\n' +
                '})(window.define);\n' +
                '/* jshint ignore:end */';

            fs.writeFile('./app/scripts/design/themeFiles.js', jsCode, function (err) {
                if (err) {
                    return console.log(err);
                }
            });

            themesData = '{';
            for (i = 0; i < themes.length; i += 1) {
                themesData += '"' + themes[i] + '":"' + themes[i] + '"';
                if (i < themes.length - 1) {
                    themesData += ',';
                }
            }
            themesData += '}';

            setConfigOption("themes.list.active", themesData);
            initConfigs();

            gulp.start('requirejs');
            gulp.start('vendor');
            gulp.start('misc');
            gulp.start('html');
            gulp.start('autoprefixer');
            gulp.start('imagemin');
        });
    });

    gulp.task('default', ['build']);

    gulp.task('retrieve-files', function () {
        var jsCode, themesData;
        themesData = '';

        recursive(paths.themesDir, function (err, files) {
            var i, theme, filePath, parts, regExp;
            theme = null;
            regExp = new RegExp('app[/\\\\]themes[/\\\\](\\w+)[/\\\\](.+)', 'i');

            jsCode = '/* jshint ignore:start */\n' +
                '(function (define) {\n' +
                '"use strict";\n' +
                'define(function () {\n' +
                'return {\n';

            for (i = 0; i < files.length; i += 1) {
                filePath = files[i];
                parts = filePath.match(regExp);
                if (parts instanceof Array) {
                    if (theme !== parts[1] && theme === null) {
                        themes.push(parts[1]);
                        jsCode += '\'' + parts[1] + '\' : [\n';
                    }
                    if (theme !== parts[1] && theme !== null) {
                        themes.push(parts[1]);
                        jsCode += '],\n\'' + parts[1] + '\' : [\n';
                    }
                    jsCode += '\'/' + parts[2] + '\',\n';
                    theme = parts[1];
                }
            }

            jsCode += ']\n};\n' +
                '});\n' +
                '})(window.define);\n' +
                '/* jshint ignore:end */';

            fs.writeFile('./app/scripts/design/themeFiles.js', jsCode, function (err) {
                if (err) {
                    return console.log(err);
                }
            });
            themesData = '{';
            for (i = 0; i < themes.length; i += 1) {
                themesData += '"' + themes[i] + '":"' + themes[i] + '"';
                if (i < themes.length - 1) {
                    themesData += ',';
                }
            }
            themesData += '}';

            setConfigOption("themes.list.active", themesData);
            initConfigs();
        });

    });

})();
<|endoftext|>


<commit_before>'use strict';

const
    config = require('config'),

    Command = require('../Command'),
    CommandParam = require('../CommandParam'),
    CommandError = require('../../errors/CommandError'),
    CacheMiddleware = require('../../middleware/CacheMiddleware'),
    ReplyMethodMiddleware = require('../../middleware/ReplyMethodMiddleware'),
    RestrictPermissionMiddleware = require('../../middleware/internal/RestrictPermissionsMiddleware');

class CommandHelp extends Command {
    constructor(module) {
        super(module);

        this.helpText = 'Shows information about how to use commands, with optionally a command as argument to get more detailed information.';
        this.shortHelpText = 'Shows information about how to use commands';
        this.params = new CommandParam('command', 'The command', true);

        this.middleware = [
            new ReplyMethodMiddleware({ method: 'dm' }),
            new CacheMiddleware()
        ];
    }

    onCommand(response) {
        const modules = this.module.bot.getModules();
        const commandPrefix = config.get('discord.command_prefix');

        if (response.params.length > 0) {
            // Reply with help for a specific command
            const commandTrigger = response.params[0].replace(new RegExp(`^${commandPrefix}?(.*)$`), '$1');
            let command;
            for (module of modules) {
                const foundCommand = module.commands.find(command => command.trigger == commandTrigger);
                if (foundCommand) {
                    command = foundCommand;
                    break;
                }
            }

            if (!command) {
                throw new CommandError(`The command \`${command}\` is not recognized. ` +
                    `Type \`${this}\` to see the list of commands.`);
            }
            return `\n${this.formatCommandHelp(response.message, command)}`;
        } else {
            // Reply with general help
            const help = [];
            modules.forEach(module => {
                const moduleHelp = this.formatModuleHelp(response.message, module);
                if (moduleHelp) {
                    help.push(moduleHelp);
                }
            });
            return `\n${help.join('\n\n')}\n\nCommands marked with an asterisk might be restricted.`;
        }
    }

    formatCommandChannelFilter(command) {
        let text = [];

        let middleware = command.allMiddleware.find(m => m.name === 'RestrictChannelsMiddleware');
        if (middleware) {
            // Restricted channels is applied
            if (middleware.options.types.length === 1) {
                switch (middleware.options.types[0]) {
                    case 'dm':
                        text.push('DM only');
                        break;
                    case 'text':
                        if (middleware.options.channels.length > 0) {
                            text.push('specific server channels only');
                        } else {
                            text.push('server channels only');
                        }
                        break;
                }
            }
        }

        middleware = command.allMiddleware.find(m => m.name === 'MentionsMiddleware');
        if (middleware) {
            // Mentions are allowed
            if (middleware.options.types.includes('mention')) {
                if (middleware.options.types.length === 1) {
                    text.push('strictly mentionable');
                } else {
                    text.push('mentionable');
                }
            }
        }
        return text.join(', ');
    }

    formatModuleHelp(message, module) {
        const commands = [];
        module.commands.forEach(command => {
            const commandText = `\`${command}\``;
            const helpText = command.shortHelpText;
            if (!helpText) {
                return;
            }

            let extraText = this.formatCommandChannelFilter(command);
            // TODO: Find a better way to detect server role assignments in a DM
            if (!RestrictPermissionMiddleware.isCommandAllowed(message, command)) {
                extraText += '*';
            }

            const text = extraText ? `${commandText} - ${helpText} *(${extraText})*` : `${commandText} - ${helpText}`;
            commands.push(text);
        });
        if (commands.length === 0) {
            return;
        }
        return `__**${module.name}**__\n${commands.join('\n')}`;
    }

    formatCommandHelp(message, command) {
        let invocation = `${command} `;
        const helpText = command.helpText;
        const params = [];

        command.params.forEach(param => {
            const paramText = `\`${param.name}\``;
            const helpText = param.helpText;
            const text = param.isOptional ? `${paramText} - ${helpText} *(optional)*` : `${paramText} - ${helpText}`;
            params.push(text);
            invocation += (param.isOptional ? '[' : '') + param.name + (param.isOptional ? ']' : '') + ' ';
        });
        let extraText = this.formatCommandChannelFilter(command);
        // TODO: Find a better way to detect server role assignments in a DM
        if (!RestrictPermissionMiddleware.isCommandAllowed(message, command)) {
            extraText += (extraText ? ', ' : '') + 'might be restricted';
        }

        if (extraText) {
            return `\`\`\`${invocation}\`\`\`\n**(${extraText})**\n${helpText}\n\n${params.join('\n')}`;
        }
        return `\`\`\`${invocation}\`\`\`\n${helpText}\n\n${params.join('\n')}`;
    }
}

module.exports = CommandHelp;
<commit_msg>Fix missing command name while doing !help if command was not found<commit_after>'use strict';

const
    config = require('config'),

    Command = require('../Command'),
    CommandParam = require('../CommandParam'),
    CommandError = require('../../errors/CommandError'),
    CacheMiddleware = require('../../middleware/CacheMiddleware'),
    ReplyMethodMiddleware = require('../../middleware/ReplyMethodMiddleware'),
    RestrictPermissionMiddleware = require('../../middleware/internal/RestrictPermissionsMiddleware');

class CommandHelp extends Command {
    constructor(module) {
        super(module);

        this.helpText = 'Shows information about how to use commands, with optionally a command as argument to get more detailed information.';
        this.shortHelpText = 'Shows information about how to use commands';
        this.params = new CommandParam('command', 'The command', true);

        this.middleware = [
            new ReplyMethodMiddleware({ method: 'dm' }),
            new CacheMiddleware()
        ];
    }

    onCommand(response) {
        const modules = this.module.bot.getModules();
        const commandPrefix = config.get('discord.command_prefix');

        if (response.params.length > 0) {
            // Reply with help for a specific command
            const commandTrigger = response.params[0].replace(new RegExp(`^${commandPrefix}?(.*)$`), '$1');
            let command;
            for (module of modules) {
                const foundCommand = module.commands.find(command => command.trigger == commandTrigger);
                if (foundCommand) {
                    command = foundCommand;
                    break;
                }
            }

            if (!command) {
                throw new CommandError(`The command \`${commandTrigger}\` is not recognized. ` +
                    `Type \`${this}\` to see the list of commands.`);
            }
            return `\n${this.formatCommandHelp(response.message, command)}`;
        } else {
            // Reply with general help
            const help = [];
            modules.forEach(module => {
                const moduleHelp = this.formatModuleHelp(response.message, module);
                if (moduleHelp) {
                    help.push(moduleHelp);
                }
            });
            return `\n${help.join('\n\n')}\n\nCommands marked with an asterisk might be restricted.`;
        }
    }

    formatCommandChannelFilter(command) {
        let text = [];

        let middleware = command.allMiddleware.find(m => m.name === 'RestrictChannelsMiddleware');
        if (middleware) {
            // Restricted channels is applied
            if (middleware.options.types.length === 1) {
                switch (middleware.options.types[0]) {
                    case 'dm':
                        text.push('DM only');
                        break;
                    case 'text':
                        if (middleware.options.channels.length > 0) {
                            text.push('specific server channels only');
                        } else {
                            text.push('server channels only');
                        }
                        break;
                }
            }
        }

        middleware = command.allMiddleware.find(m => m.name === 'MentionsMiddleware');
        if (middleware) {
            // Mentions are allowed
            if (middleware.options.types.includes('mention')) {
                if (middleware.options.types.length === 1) {
                    text.push('strictly mentionable');
                } else {
                    text.push('mentionable');
                }
            }
        }
        return text.join(', ');
    }

    formatModuleHelp(message, module) {
        const commands = [];
        module.commands.forEach(command => {
            const commandText = `\`${command}\``;
            const helpText = command.shortHelpText;
            if (!helpText) {
                return;
            }

            let extraText = this.formatCommandChannelFilter(command);
            // TODO: Find a better way to detect server role assignments in a DM
            if (!RestrictPermissionMiddleware.isCommandAllowed(message, command)) {
                extraText += '*';
            }

            const text = extraText ? `${commandText} - ${helpText} *(${extraText})*` : `${commandText} - ${helpText}`;
            commands.push(text);
        });
        if (commands.length === 0) {
            return;
        }
        return `__**${module.name}**__\n${commands.join('\n')}`;
    }

    formatCommandHelp(message, command) {
        let invocation = `${command} `;
        const helpText = command.helpText;
        const params = [];

        command.params.forEach(param => {
            const paramText = `\`${param.name}\``;
            const helpText = param.helpText;
            const text = param.isOptional ? `${paramText} - ${helpText} *(optional)*` : `${paramText} - ${helpText}`;
            params.push(text);
            invocation += (param.isOptional ? '[' : '') + param.name + (param.isOptional ? ']' : '') + ' ';
        });
        let extraText = this.formatCommandChannelFilter(command);
        // TODO: Find a better way to detect server role assignments in a DM
        if (!RestrictPermissionMiddleware.isCommandAllowed(message, command)) {
            extraText += (extraText ? ', ' : '') + 'might be restricted';
        }

        if (extraText) {
            return `\`\`\`${invocation}\`\`\`\n**(${extraText})**\n${helpText}\n\n${params.join('\n')}`;
        }
        return `\`\`\`${invocation}\`\`\`\n${helpText}\n\n${params.join('\n')}`;
    }
}

module.exports = CommandHelp;
<|endoftext|>


<commit_before>/* jshint node: true */

var gulp = require('gulp');
var yargs = require('yargs');
var mocha = require('gulp-mocha');
var jshint = require('gulp-jshint');

function buildArgs(args) {
  var argName, skipArgs = { _: true, '$0': true };

  for (argName in yargs.argv) {
    if (yargs.argv.hasOwnProperty(argName) && !skipArgs[argName]) {
      args[argName] = yargs.argv[argName];
    }
  }
  return args;
}

gulp.task('test', function() {
  return gulp.src(['./test/*.js', './test/*.coffee'], {read: false})
    // Reporters:
    // https://github.com/mochajs/mocha/blob/master/lib/reporters/index.js
    .pipe(mocha(buildArgs({ reporter: 'spec' })));
});

gulp.task('lint', function() {
  return gulp.src(['*.js', 'lib/**/*.js', 'src/**/*.js', 'test/**/*.js'])
    .pipe(jshint())
    .pipe(jshint.reporter('default'));
});
<commit_msg>Remove vestigal `test/*.coffee` gulpfile pattern<commit_after>/* jshint node: true */

var gulp = require('gulp');
var yargs = require('yargs');
var mocha = require('gulp-mocha');
var jshint = require('gulp-jshint');

function buildArgs(args) {
  var argName, skipArgs = { _: true, '$0': true };

  for (argName in yargs.argv) {
    if (yargs.argv.hasOwnProperty(argName) && !skipArgs[argName]) {
      args[argName] = yargs.argv[argName];
    }
  }
  return args;
}

gulp.task('test', function() {
  return gulp.src(['./test/*.js'], {read: false})
    // Reporters:
    // https://github.com/mochajs/mocha/blob/master/lib/reporters/index.js
    .pipe(mocha(buildArgs({ reporter: 'spec' })));
});

gulp.task('lint', function() {
  return gulp.src(['*.js', 'lib/**/*.js', 'src/**/*.js', 'test/**/*.js'])
    .pipe(jshint())
    .pipe(jshint.reporter('default'));
});
<|endoftext|>


<commit_before>var lineCharts = [];
var doughnutCharts = [];

$(document).ready(function(){

  	// Chart Data

    var lineChartData = [];

    lineChartData[0] = {
        labels: [""],
        datasets: [
          {
            label: "CPU-Auslastung",
            fillColor: "rgba(220,220,220,0.2)",
            strokeColor: "rgba(220,220,220,1)",
            pointColor: "rgba(220,220,220,1)",
            pointStrokeColor: "#fff",
            pointHighlightFill: "#fff",
            pointHighlightStroke: "rgba(220,220,220,1)",
            data: [0]
          }
        ]
    };

    var dChartData = [];

    dChartData[0] = {
        labels: [
            "Red",
            "Green",
            "Yellow"
        ],
        datasets: [
            {
                data: [300, 50, 100],
                backgroundColor: [
                    "#FF6384",
                    "#36A2EB",
                    "#FFCE56"
                ],
                hoverBackgroundColor: [
                    "#FF6384",
                    "#36A2EB",
                    "#FFCE56"
                ]
            }]
    };

    dChartData[1] = {
        labels: [""],
        datasets: [
            {
                data: [300, 50, 100],
                backgroundColor: [
                    "#FF6384",
                    "#36A2EB",
                    "#FFCE56"
                ],
                hoverBackgroundColor: [
                    "#FF6384",
                    "#36A2EB",
                    "#FFCE56"
                ]
            }]
    };

    // Genereate Charts

    lineCharts[0] = new Chart($('#lChart1').get(0).getContext('2d'), {
        type: 'line',
        data: lineChartData[0],
        options: {
            title: {
                display: true,
                position: "top",
                text: "CPU-Auslastung"
            }
        }
    });

    doughnutCharts[0] = new Chart($('#dChart' + (0 + 1) ).get(0).getContext("2d"),{ type: 'doughnut', data: dChartData[0] });
    doughnutCharts[1] = new Chart($('#dChart' + (1 + 1) ).get(0).getContext("2d"),{ type: 'doughnut', data: dChartData[1] });

 	// Functions

    var toBottom = true;
	function scroll(){
        var speed = 200; // px/s
        var duration = ($(document).height()/speed)*1000
        var h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
        var verticalCoordinate = toBottom ? $(document).height() - h: 0; //(-1 * $(document).height());

        toBottom = !toBottom;

		$('body').animate({ scrollTop: verticalCoordinate}, duration, "linear", function(){
			setTimeout(scroll, 2000);
		});
 	}

    function getCPU(origin, count){
        $.ajax({
            url: 'localhost:5000/metrics/api/v1.0/get?origin=' + origin + '&key=cpu_usage&count=' + count,
            type: 'GET',
        }).done(function(response){
                var data = JSON.parse(response);
                console.log(lineCharts[0]);
                var currentData = lineCharts[0].getChartData();

                $.each(data.results, function(){
                    if(currentData._labels.contains(this.Id)){
                        lineCharts[0].addChartData(0, { label: this.Id, value: parseInt(this.Value) });
                    }
                });

                chartObj.update();

                window.setTimeout(function(){
                    getCPU(origin, count);
                }, 1000);
        });
    }

    // Prototypes

    Object.prototype.contains = function(x){
        for(var i in this){
            if(x == this[i]) return true;
        }

        return false;
    };

    // Activate Functions

    getCPU('laptop', '20');

    setTimeout(scroll, 2000); // fix issue with website not populated with data

});<commit_msg>Removed unnecessary lines<commit_after>var lineCharts = [];
var doughnutCharts = [];

$(document).ready(function(){

  	// Chart Data

    var lineChartData = [];

    lineChartData[0] = {
        labels: [""],
        datasets: [
          {
            label: "CPU-Auslastung",
            fillColor: "rgba(220,220,220,0.2)",
            strokeColor: "rgba(220,220,220,1)",
            pointColor: "rgba(220,220,220,1)",
            pointStrokeColor: "#fff",
            pointHighlightFill: "#fff",
            pointHighlightStroke: "rgba(220,220,220,1)",
            data: [0]
          }
        ]
    };

    var dChartData = [];

    dChartData[0] = {
        labels: [
            "Red",
            "Green",
            "Yellow"
        ],
        datasets: [
            {
                data: [300, 50, 100],
                backgroundColor: [
                    "#FF6384",
                    "#36A2EB",
                    "#FFCE56"
                ],
                hoverBackgroundColor: [
                    "#FF6384",
                    "#36A2EB",
                    "#FFCE56"
                ]
            }]
    };

    dChartData[1] = {
        labels: [""],
        datasets: [
            {
                data: [300, 50, 100],
                backgroundColor: [
                    "#FF6384",
                    "#36A2EB",
                    "#FFCE56"
                ],
                hoverBackgroundColor: [
                    "#FF6384",
                    "#36A2EB",
                    "#FFCE56"
                ]
            }]
    };

    // Genereate Charts

    lineCharts[0] = new Chart($('#lChart1').get(0).getContext('2d'), {
        type: 'line',
        data: lineChartData[0],
        options: {
            title: {
                display: true,
                position: "top",
                text: "CPU-Auslastung"
            }
        }
    });

    doughnutCharts[0] = new Chart($('#dChart' + (0 + 1) ).get(0).getContext("2d"),{ type: 'doughnut', data: dChartData[0] });
    doughnutCharts[1] = new Chart($('#dChart' + (1 + 1) ).get(0).getContext("2d"),{ type: 'doughnut', data: dChartData[1] });

 	// Functions

    var toBottom = true;
	function scroll(){
        var speed = 200; // px/s
        var duration = ($(document).height()/speed)*1000
        var h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
        var verticalCoordinate = toBottom ? $(document).height() - h: 0; //(-1 * $(document).height());

        toBottom = !toBottom;

		$('body').animate({ scrollTop: verticalCoordinate}, duration, "linear", function(){
			setTimeout(scroll, 2000);
		});
 	}

    function getCPU(origin, count){
        $.ajax({
            url: 'localhost:5000/metrics/api/v1.0/get?origin=' + origin + '&key=cpu_usage&count=' + count,
            type: 'GET',
        }).done(function(response){
                var data = JSON.parse(response);
                var currentData = lineCharts[0].getChartData();

                $.each(data.results, function(){
                    if(currentData._labels.contains(this.Id)){
                        lineCharts[0].addChartData(0, { label: this.Id, value: parseInt(this.Value) });
                    }
                });

                window.setTimeout(function(){
                    getCPU(origin, count);
                }, 1000);
        });
    }

    // Prototypes

    Object.prototype.contains = function(x){
        for(var i in this){
            if(x == this[i]) return true;
        }

        return false;
    };

    // Activate Functions

    getCPU('laptop', '20');

    setTimeout(scroll, 2000); // fix issue with website not populated with data

});<|endoftext|>


<commit_before>const gulp = require('gulp');
const jshint = require('gulp-jshint');
const browserify = require('browserify');
const watchify = require('watchify');
const source = require('vinyl-source-stream');
const gutil = require('gulp-util');
const assign = require('lodash.assign');
const mocha = require('gulp-mocha');
const istanbul = require('gulp-istanbul');

const src = [ 'index.js', './lib/**/*.js' ];
const bundleTarget = 'benzene.js';

const opts = assign({}, watchify.args, {
  entries: [ 'index.js' ]
});
const b = watchify(browserify(opts));

gulp.task('js', bundle);
b.on('update', bundle);
b.on('log', gutil.log);

function bundle() {
  return b.bundle()
    .on('error', gutil.log.bind(gutil, 'Browserify error'))
    .pipe(source(bundleTarget))
    .pipe(gulp.dest('./sample/'));
}

gulp.task('jshint', () => {
  return gulp.src(src)
             .pipe(jshint())
             .pipe(jshint.reporter('default'))
             .pipe(jshint.reporter('fail'))
});

gulp.task('pre-test', () => {
  return gulp.src(src)
    .pipe(istanbul())
    .pipe(istanbul.hookRequire());
})

gulp.task('test', ['pre-test'], () => {
  return gulp.src(['test/**/*.js'])
    .pipe(mocha())
    .pipe(istanbul.writeReports());
});
<commit_msg>Make default gulp task the js task<commit_after>const gulp = require('gulp');
const jshint = require('gulp-jshint');
const browserify = require('browserify');
const watchify = require('watchify');
const source = require('vinyl-source-stream');
const gutil = require('gulp-util');
const assign = require('lodash.assign');
const mocha = require('gulp-mocha');
const istanbul = require('gulp-istanbul');

const src = [ 'index.js', './lib/**/*.js' ];
const bundleTarget = 'benzene.js';

const opts = assign({}, watchify.args, {
  entries: [ 'index.js' ]
});
const b = watchify(browserify(opts));

gulp.task('default', bundle);
b.on('update', bundle);
b.on('log', gutil.log);

function bundle() {
  return b.bundle()
    .on('error', gutil.log.bind(gutil, 'Browserify error'))
    .pipe(source(bundleTarget))
    .pipe(gulp.dest('./sample/'));
}

gulp.task('jshint', () => {
  return gulp.src(src)
             .pipe(jshint())
             .pipe(jshint.reporter('default'))
             .pipe(jshint.reporter('fail'))
});

gulp.task('pre-test', () => {
  return gulp.src(src)
    .pipe(istanbul())
    .pipe(istanbul.hookRequire());
})

gulp.task('test', ['pre-test'], () => {
  return gulp.src(['test/**/*.js'])
    .pipe(mocha())
    .pipe(istanbul.writeReports());
});
<|endoftext|>


<commit_before>// Usar "gulp" para iniciar la tarea watch.
// Agregar la bandera "--prod" para guardar el build.

// @todo: crear una tarea para eliminar carpetas de ../../plugins/ que coincidan con ./plugins/

var gulp = require('gulp'),
    argv = require('yargs').argv,
    autoprefixer = require('gulp-autoprefixer'),
    concat = require('gulp-concat'),
    del = require('del'),
    favicons = require('gulp-favicons'),
    gulpif = require('gulp-if'),
    gulpIgnore = require('gulp-ignore'),
    gutil = require('gulp-util'),
    imagemin = require('gulp-imagemin'),
    livereload = require('gulp-livereload'),
    newer = require('gulp-newer'),
    rename = require("gulp-rename"),
    sass = require('gulp-sass'),
    sourcemaps = require('gulp-sourcemaps'),
    svgSprite = require('gulp-svg-sprite'),
    runSequence = require('run-sequence'),
    uglify = require('gulp-uglify')

var dir = {
    root: './',
    assets: './assets/',
}

if (argv.prod) {
    var rootDir = __dirname.split('\\').pop() + '/'
    dir.root = './build/' + rootDir
    dir.assets = './build/' + rootDir + 'assets/'
}

gulp.task('clean', function() {
    return del(['assets/', 'build/'])
})

gulp.task('images', function(cb) {
    gulp.src('./source/img/**/*')
    .pipe(newer(dir.assets + 'img/'))
    .pipe(imagemin())
    .pipe(gulp.dest(dir.assets + 'img/'))
    .pipe(gulpif(!argv.prod, livereload()))
    .on('end', cb).on('error', cb);
})

gulp.task('favicon', function() {
    return gulp.src('./source/favicon.png')
        .pipe(newer(dir.root + ''))
        .pipe(favicons({
            logging: false,
            online: false,
            html: false,
            replace: true,
            icons: {
                android: false,
                appleIcon: false,
                appleStartup: false,
                coast: false,
                favicons: true,
                firefox: false,
                windows: false,
                yandex: false
            },
        }))
        .on("error", gutil.log)
        .pipe(gulpIgnore.include('*.ico'))
        .pipe(gulp.dest(dir.root + ''))
})

gulp.task('js', function() {
    return gulp.src(['./source/js/includes/*', './source/js/app.js'])
        .pipe(newer(dir.assets + 'js/'))
        .pipe(gulpif(!argv.prod, sourcemaps.init()))
        .pipe(concat('app.min.js'))
        .pipe(uglify())
        .pipe(gulpif(!argv.prod, sourcemaps.write()))
        .pipe(gulp.dest(dir.assets + 'js/'))
        .pipe(gulpif(!argv.prod, livereload()))
})

gulp.task('foundation-js', function() {
    return gulp.src([
            'foundation.core.js',
            'foundation.util.mediaQuery.js',

            'foundation.util.box.js', // reveal
            'foundation.util.keyboard.js', // reveal
            'foundation.util.motion.js', // offcanvas, toggler
            // 'foundation.util.nest.js',
            'foundation.util.timerAndImageLoader.js', // equalizer
            // 'foundation.util.touch.js',
            'foundation.util.triggers.js', // offcanvas, reveal, toggler

            // 'foundation.abide.js',
            // 'foundation.accordion.js',
            // 'foundation.accordionMenu.js',
            // 'foundation.drilldown.js',
            // 'foundation.dropdown.js',
            // 'foundation.dropdownMenu.js',
            'foundation.equalizer.js',
            // 'foundation.interchange.js',
            // 'foundation.magellan.js',
            'foundation.offcanvas.js',
            // 'foundation.orbit.js',
            // 'foundation.responsiveMenu.js',
            // 'foundation.responsiveToggle.js',
            'foundation.reveal.js',
            // 'foundation.slider.js',
            // 'foundation.sticky.js',
            // 'foundation.tabs.js',
            'foundation.toggler.js',
            // 'foundation.tooltip.js',
        ], {cwd: './node_modules/foundation-sites/dist/plugins/'})
        .pipe(newer('./source/js/vendor/foundation.min.js'))
        .pipe(concat('foundation.min.js'))
        .pipe(uglify())
        .pipe(gulp.dest('./source/js/vendor'))
})

gulp.task('sass', function(cb) {
    return gulp.src('./source/sass/*.scss')
        .pipe(newer({dest: dir.assets + 'css/', ext: '.min.css'}))
        .pipe(gulpif(!argv.prod, sourcemaps.init()))
        .pipe(sass({
            includePaths: [
                './node_modules/foundation-sites/scss',
                './node_modules/motion-ui/src',
            ],
            outputStyle: 'compressed'
        }).on('error', sass.logError))
        .pipe(autoprefixer({
            browsers: ['last 5 versions'],
            cascade: false
        }))
        .pipe(rename({suffix: '.min'}))
        .pipe(gulpif(!argv.prod, sourcemaps.write()))
        .pipe(gulp.dest(dir.assets + 'css/'))
        .pipe(gulpif(!argv.prod, livereload()))
})

gulp.task('svg', function(cb) {
    gulp.src('./source/svg/*.svg')
        .pipe(newer(dir.assets + 'svg/'))
        .pipe(imagemin())
        .pipe(gulp.dest(dir.assets + 'svg/'))
        .pipe(gulpif(!argv.prod, livereload()))
        .on('end', cb).on('error', cb);
})

gulp.task('svg-sprite', function(cb) {
    var options = {
        shape: {
            dimension: {
                maxWidth: 100,
                maxHeight: 100
            },
            id: {
                whitespace: '_',
            },
        },
        svg: {
            namespaceClassnames: false,
        },
        mode: {
            symbol: {
                dest: '',
                prefix: '',
                bust: false,
                sprite: 'sprite.svg'
            }
        }
    }

    return gulp.src('./source/svg/sprite/*.svg')
        .pipe(newer(dir.assets + 'svg/sprite.svg'))
        .pipe(svgSprite(options))
        .pipe(gulp.dest(dir.assets + 'svg/'))
        .pipe(gulpif(!argv.prod, livereload()))
})

gulp.task('copiar-plugins', function() {
    return gulp.src('./plugins/**/*.*')
        .pipe(gulp.dest('../../plugins/'))
})

gulp.task('copiar-assets', function() {
    return gulp.src([
        './source/**/*',
        // favicon se genera
        '!./source/favicon.png',
        // img se optimiza
        '!./source/img',
        '!./source/img/**/',
        // js se uglifica
        '!./source/js/app.js',
        '!./source/js/includes',
        '!./source/js/includes/**/',
        '!./source/js/snippets',
        '!./source/js/snippets/**/',
        // sass se compila
        '!./source/sass',
        '!./source/sass/**/',
        // svg se optimizan o arman en un sprite
        '!./source/svg',
        '!./source/svg/**/',
        ])
        .pipe(newer(dir.assets))
        .pipe(gulp.dest(dir.assets))
})

gulp.task('watch', function() {
    livereload.listen()
    gulp.watch('./source/img/**/*', ['images'])
    gulp.watch('./source/favicon.png', ['favicon'])
    gulp.watch(['./source/js/app.js', './source/js/includes/*'], ['js'])
    gulp.watch('./source/sass/**/*.scss', ['sass'])
    gulp.watch('./source/svg/*.svg', ['svg'])
    gulp.watch('./source/svg/sprite/*.svg', ['svg-sprite'])
    gulp.watch('./plugins/**/*', ['copiar-plugins'])
    gulp.watch([
        './source/**/*',
        '!./source/favicon.png',
        '!./source/img',
        '!./source/img/**/',
        '!./source/js/app.js',
        '!./source/js/includes',
        '!./source/js/includes/**/',
        '!./source/js/snippets',
        '!./source/js/snippets/**/',
        '!./source/sass',
        '!./source/sass/**/',
        '!./source/svg/',
        '!./source/svg/**/',
        ], ['copiar-assets'])
})

gulp.task('default', function() {
    runSequence(
        'foundation-js',
        [
            'copiar-assets',
            // 'copiar-plugins', -> rara vez se usa
            'sass',
            'js',
            'images',
            'svg',
            'svg-sprite',
            'favicon'
        ],
        'watch'
    );
})

gulp.task('build', function() {
    runSequence('clean', 'default', function() {
        gulp.src([
            './includes/',
            './page-templates/',
            './plugins/',
            './templates/',
            './woocommerce/',
            '!*.{map,md}',
            '!package.json',
            '!LICENSE',
            '!gulpfile.js',
            '.htaccess',
            '*.php',
            'config.ini',
            'favicon.ico',
            'screenshot.png',
            'style.css',
        ]).pipe(gulp.dest(dir.root))
    })
})
<commit_msg>Correcciones y TOC<commit_after>// Usar "gulp" para iniciar la tarea watch.
// Agregar la bandera "--prod" para guardar el build.

// @todo: crear una tarea para eliminar carpetas de ../../plugins/ que coincidan con ./plugins/

var gulp         = require('gulp'),
    argv         = require('yargs').argv,
    autoprefixer = require('gulp-autoprefixer'),
    concat       = require('gulp-concat'),
    del          = require('del'),
    favicons     = require('gulp-favicons'),
    gulpIgnore   = require('gulp-ignore'),
    gulpif       = require('gulp-if'),
    gutil        = require('gulp-util'),
    imagemin     = require('gulp-imagemin'),
    livereload   = require('gulp-livereload'),
    newer        = require('gulp-newer'),
    rename       = require("gulp-rename"),
    runSequence  = require('run-sequence'),
    sass         = require('gulp-sass'),
    sourcemaps   = require('gulp-sourcemaps'),
    svgSprite    = require('gulp-svg-sprite'),
    uglify       = require('gulp-uglify')

var dir = {
    root: './',
    assets: './assets/',
}

if (argv.prod) {
    var rootDir = __dirname.split('\\').pop() + '/'
    dir.root = './build/' + rootDir
    dir.assets = './build/' + rootDir + 'assets/'
}

gulp.task('clean', function() {
    return del(['assets/', 'build/'])
})

gulp.task('images', function(cb) {
    gulp.src('./source/img/**/*')
        .pipe(newer(dir.assets + 'img/'))
        .pipe(imagemin())
        .pipe(gulp.dest(dir.assets + 'img/'))
        .pipe(gulpif(!argv.prod, livereload()))
        .on('end', cb).on('error', cb);
})

gulp.task('favicon', function() {
    return gulp.src('./source/favicon.png')
        .pipe(newer(dir.root + ''))
        .pipe(favicons({
            logging: false,
            online: false,
            html: false,
            replace: true,
            icons: {
                android: false,
                appleIcon: false,
                appleStartup: false,
                coast: false,
                favicons: true,
                firefox: false,
                windows: false,
                yandex: false
            },
        }))
        .on("error", gutil.log)
        .pipe(gulpIgnore.include('*.ico'))
        .pipe(gulp.dest(dir.root + ''))
})

gulp.task('js', function() {
    return gulp.src(['./temp/js/foundation.js', './source/js/includes/*', './source/js/app.js'])
        .pipe(newer(dir.assets + 'js/'))
        .pipe(gulpif(!argv.prod, sourcemaps.init()))
        .pipe(concat('app.min.js'))
        .pipe(uglify())
        .pipe(gulpif(!argv.prod, sourcemaps.write()))
        .pipe(gulp.dest(dir.assets + 'js/'))
        .pipe(gulpif(!argv.prod, livereload()))
})

gulp.task('foundation-js', function() {
    return gulp.src([
            'foundation.core.js',
            'foundation.util.mediaQuery.js',

            'foundation.util.box.js',      // reveal
            'foundation.util.keyboard.js', // reveal
            'foundation.util.motion.js',   // offcanvas, toggler
            // 'foundation.util.nest.js',
            'foundation.util.timerAndImageLoader.js', // equalizer
            // 'foundation.util.touch.js',
            'foundation.util.triggers.js',  // offcanvas, reveal, toggler

            // 'foundation.abide.js',
            // 'foundation.accordion.js',
            // 'foundation.accordionMenu.js',
            // 'foundation.drilldown.js',
            // 'foundation.dropdown.js',
            // 'foundation.dropdownMenu.js',
            'foundation.equalizer.js',
            // 'foundation.interchange.js',
            // 'foundation.magellan.js',
            'foundation.offcanvas.js',
            // 'foundation.orbit.js',
            // 'foundation.responsiveMenu.js',
            // 'foundation.responsiveToggle.js',
            'foundation.reveal.js',
            // 'foundation.slider.js',
            // 'foundation.sticky.js',
            // 'foundation.tabs.js',
            'foundation.toggler.js',
            // 'foundation.tooltip.js',
        ], {cwd: './node_modules/foundation-sites/dist/js/plugins/'})
        .pipe(concat('foundation.js'))
        .pipe(gulp.dest('./temp/js/'))
})

gulp.task('sass', function(cb) {
    return gulp.src('./source/sass/*.scss')
        .pipe(newer({dest: dir.assets + 'css/', ext: '.min.css'}))
        .pipe(gulpif(!argv.prod, sourcemaps.init()))
        .pipe(sass({
            includePaths: [
                './node_modules/foundation-sites/scss',
                './node_modules/motion-ui/src',
            ],
            outputStyle: 'compressed'
        }).on('error', sass.logError))
        .pipe(autoprefixer({
            browsers: ['last 5 versions'],
            cascade: false
        }))
        .pipe(rename({suffix: '.min'}))
        .pipe(gulpif(!argv.prod, sourcemaps.write()))
        .pipe(gulp.dest(dir.assets + 'css/'))
        .pipe(gulpif(!argv.prod, livereload()))
})

gulp.task('svg', function(cb) {
    gulp.src('./source/svg/*.svg')
        .pipe(newer(dir.assets + 'svg/'))
        .pipe(imagemin())
        .pipe(gulp.dest(dir.assets + 'svg/'))
        .pipe(gulpif(!argv.prod, livereload()))
        .on('end', cb).on('error', cb);
})

gulp.task('svg-sprite', function(cb) {
    var options = {
        shape: {
            dimension: {
                maxWidth: 100,
                maxHeight: 100
            },
            id: {
                whitespace: '_',
            },
        },
        svg: {
            namespaceClassnames: false,
        },
        mode: {
            symbol: {
                dest: '',
                prefix: '',
                bust: false,
                sprite: 'sprite.svg'
            }
        }
    }

    return gulp.src('./source/svg/sprite/*.svg')
        .pipe(newer(dir.assets + 'svg/sprite.svg'))
        .pipe(svgSprite(options))
        .pipe(gulp.dest(dir.assets + 'svg/'))
        .pipe(gulpif(!argv.prod, livereload()))
})

gulp.task('actualizar-plugins', function() {
    return gulp.src('./plugins/**/*.*')
        .pipe(gulp.dest('../../plugins/'))
})

gulp.task('actualizar-assets', function() {
    return gulp.src([
        './source/**/*',
        // favicon se genera
        '!./source/favicon.png',
        // img se optimiza
        '!./source/img',
        '!./source/img/**/',
        // js se uglifica
        '!./source/js/app.js',
        '!./source/js/includes',
        '!./source/js/includes/**/',
        '!./source/js/snippets',
        '!./source/js/snippets/**/',
        // sass se compila
        '!./source/sass',
        '!./source/sass/**/',
        // svg se optimizan o arman en un sprite
        '!./source/svg',
        '!./source/svg/**/',
        ])
        .pipe(newer(dir.assets))
        .pipe(gulp.dest(dir.assets))
})

gulp.task('actualizar-carpetas', function() {
    if (argv.prod) {
        return gulp.src([
                './includes/**',
                './page-templates/**',
                './plugins/**',
                './templates/**',
                './woocommerce/**',
                './vendor/**',
                '!*.map',
                '!*.md',
                '!package.json',
                '!LICENSE',
                '.htaccess',
                '*.php',
                './config.ini',
                './favicon.ico',
                './style.css',
            ], {base: '.'}).pipe(gulp.dest(dir.root))
    }
})

gulp.task('comprimir-screenshot', function() {
    if (argv.prod) {
        return gulp.src('./screenshot.png')
                .pipe(imagemin())
                .pipe(gulp.dest(dir.root))
    }
})

gulp.task('watch', function() {
    livereload.listen()
    gulp.watch('./source/img/**/*', ['images'])
    gulp.watch('./source/favicon.png', ['favicon'])
    gulp.watch(['./source/js/app.js', './source/js/includes/*'], ['js'])
    gulp.watch('./source/sass/**/*.scss', ['sass'])
    gulp.watch('./source/svg/*.svg', ['svg'])
    gulp.watch('./source/svg/sprite/*.svg', ['svg-sprite'])
    gulp.watch('./plugins/**/*', ['actualizar-plugins'])
    gulp.watch([
        './source/**/*',
        '!./source/favicon.png',
        '!./source/img',
        '!./source/img/**/',
        '!./source/js/app.js',
        '!./source/js/includes',
        '!./source/js/includes/**/',
        '!./source/js/snippets',
        '!./source/js/snippets/**/',
        '!./source/sass',
        '!./source/sass/**/',
        '!./source/svg/',
        '!./source/svg/**/',
        ], ['actualizar-assets'])
})

gulp.task('default', function() {
    runSequence('foundation-js', [
            'actualizar-assets',
            // 'actualizar-plugins', -> rara vez se usa
            'actualizar-carpetas',
            'sass',
            'js',
            'images',
            'svg',
            'svg-sprite',
            'favicon',
        ], 'watch'
    );
})

gulp.task('build', function() {
    runSequence('clean', 'foundation-js', 'default')
})
<|endoftext|>


<commit_before>var webdriver = require('selenium-webdriver'),
    By = require('selenium-webdriver').By,
    until = require('selenium-webdriver').until;

var test = require('selenium-webdriver/testing');
var assert = require('selenium-webdriver/testing/assert');

var driver = new webdriver.Builder()
    .forBrowser('firefox')
    .build();

var $ = function (selector, context) {
    if (context) {
        return context.findElement(By.css(selector));
    }
    return driver.findElement(By.css(selector));
};

var helper = {

    setTab: function (selector) {
        this.tab_selector = selector;
        this.tab = $(selector);
    },

    assertScreenValue: function (element, expected) {
        driver.wait(until.elementTextIs(element, expected));
    },

    assertResult: function (url) {
        var urlScreen = $('.here-text-screen textarea', this.tab);
        var markupScreen = $('.markup-screen textarea', this.tab);

        // Url in the textarea is correct
        this.assertScreenValue(urlScreen, url);

        // Markup is correct
        this.assertScreenValue(markupScreen, 'Your text here');

        // Link is there with correct href
        $('a', this.tab).getAttribute('href').then(function (value) {
            return assert(value).equals(url);
        });

        // Copy button is there
        driver.wait(until.elementLocated(By.css(this.tab_selector + ' .url-screen button')));
        // Copy button is there
        driver.wait(until.elementLocated(By.css(this.tab_selector + ' .markup-screen button')));
    },

    selectOption: function (text) {
        var listitem = driver.wait(until.elementLocated(By.xpath('//li[normalize-space(.)="' + text + '"]')));
        driver.wait(until.elementIsVisible(listitem));
        // Although element is visible, because of the transition it is not yet fully there, so we sleep a bit.
        driver.sleep(300);
        listitem.click();
    },

    sendKeysSelectOption: function (selector, keys, text) {
        $(selector + ' input[type="text"]', this.tab).sendKeys(keys);
        this.selectOption(text);
    },

    selectMyLocation: function (selector) {
        $(selector + ' input[type="text"]', this.tab).click();
        this.selectOption('Use user\'s location');
    }

};

test.describe('Link Builder', function () {

    // Default 2000 ms is not enough for most tests.
    this.timeout(10000);

    test.before(function () {

    });

    test.after(function () {
        driver.quit();
    });

    test.beforeEach(function () {
        driver.get('http:127.0.0.1:5000');
        driver.executeScript('window.scroll(0, 400)');
    });

    test.describe('Route panel', function () {

        test.beforeEach(function () {
            helper.setTab('.here-tabs-body>div:nth-child(1)');
        });

        test.it('should generate route from a to b', function () {
            helper.sendKeysSelectOption('.row-route-from', 'Bremen', 'Bremen, Germany');
            helper.sendKeysSelectOption('.row-route-to', 'Berlin', 'Berlin, Germany');
            helper.assertResult('https://share.here.com/r/53.0751,8.80469,Bremen%2C%20Germany/52.51607,13.37699,Berlin%2C%20Germany?m=d&t=normal');
        });

        test.it('should generate route from mylocation to b', function () {
            helper.selectMyLocation('.row-route-from');
            helper.sendKeysSelectOption('.row-route-to', 'Berlin', 'Berlin, Germany');
            helper.assertResult('https://share.here.com/r/mylocation/52.51607,13.37699,Berlin%2C%20Germany?m=d&t=normal');
        });

        test.it('should generate route from a to mylocation', function () {
            helper.sendKeysSelectOption('.row-route-from', 'Berlin', 'Berlin, Germany');
            helper.selectMyLocation('.row-route-to');
            helper.assertResult('https://share.here.com/r/52.51607,13.37699,Berlin%2C%20Germany/mylocation?m=d&t=normal');
        });

        test.describe('Options', function () {

            test.beforeEach(function () {
                helper.selectMyLocation('.row-route-from');
                helper.sendKeysSelectOption('.row-route-to', 'Berlin', 'Berlin, Germany');
            });

            test.it('should set route mode', function () {
                $('select option:nth-child(2)', helper.tab).click();
                helper.assertResult('https://share.here.com/r/mylocation/52.51607,13.37699,Berlin%2C%20Germany?m=pt&t=normal');
                $('select option:nth-child(3)', helper.tab).click();
                helper.assertResult('https://share.here.com/r/mylocation/52.51607,13.37699,Berlin%2C%20Germany?m=w&t=normal');
            });

            test.it('should set map type', function () {
                $('.builder-row:nth-of-type(2) select option:nth-child(2)', helper.tab).click();
                helper.assertResult('https://share.here.com/r/mylocation/52.51607,13.37699,Berlin%2C%20Germany?m=d&t=terrain');
            });

        });
    });

    test.describe('Location panel', function () {

        test.beforeEach(function () {
            $('.here-tabs-controls li:nth-child(2)').click();
            helper.setTab('.here-tabs-body>div:nth-child(2)');
            helper.sendKeysSelectOption('.location-box', 'Berlin', 'Berlin, Germany');
        });

        test.it('should generate location link', function () {
            helper.assertResult('https://share.here.com/l/52.51607,13.37699,Berlin%2C%20Germany?t=normal');
        });

        test.it('should set map type', function () {
            $('select option:nth-child(2)', helper.tab).click();
            helper.assertResult('https://share.here.com/l/52.51607,13.37699,Berlin%2C%20Germany?t=terrain');
        });

    });

    test.describe('Place panel', function () {

        test.it('should generate place link', function () {
            $('.here-tabs-controls li:nth-child(3)').click();
            helper.setTab('.here-tabs-body>div:nth-child(3)');
            helper.sendKeysSelectOption('.location-box', 'Berlin', 'Berlin, Germany');
            helper.assertResult('https://share.here.com/p/s-YmI9MTMuMTE5MzclMkM1Mi4zNzYxNSUyQzEzLjY1ODAxJTJDNTIuNjYwNTg7Yz1jaXR5LXRvd24tdmlsbGFnZTtpZD0yNzZ1MzNkYi1mYmNmZmQyZTUyZjk0ZjU2YjZmNTU0YzBiYWEzM2YwNjtsYXQ9NTIuNTE2MDc7bG9uPTEzLjM3Njk4O249QmVybGluO25sYXQ9NTIuNTE2MDc7bmxvbj0xMy4zNzY5ODtoPTYwMTQzNw');
        });
    });
});
<commit_msg>Add missing // in the local URL in beforeEach<commit_after>var webdriver = require('selenium-webdriver'),
    By = require('selenium-webdriver').By,
    until = require('selenium-webdriver').until;

var test = require('selenium-webdriver/testing');
var assert = require('selenium-webdriver/testing/assert');

var driver = new webdriver.Builder()
    .forBrowser('firefox')
    .build();

var $ = function (selector, context) {
    if (context) {
        return context.findElement(By.css(selector));
    }
    return driver.findElement(By.css(selector));
};

var helper = {

    setTab: function (selector) {
        this.tab_selector = selector;
        this.tab = $(selector);
    },

    assertScreenValue: function (element, expected) {
        driver.wait(until.elementTextIs(element, expected));
    },

    assertResult: function (url) {
        var urlScreen = $('.here-text-screen textarea', this.tab);
        var markupScreen = $('.markup-screen textarea', this.tab);

        // Url in the textarea is correct
        this.assertScreenValue(urlScreen, url);

        // Markup is correct
        this.assertScreenValue(markupScreen, 'Your text here');

        // Link is there with correct href
        $('a', this.tab).getAttribute('href').then(function (value) {
            return assert(value).equals(url);
        });

        // Copy button is there
        driver.wait(until.elementLocated(By.css(this.tab_selector + ' .url-screen button')));
        // Copy button is there
        driver.wait(until.elementLocated(By.css(this.tab_selector + ' .markup-screen button')));
    },

    selectOption: function (text) {
        var listitem = driver.wait(until.elementLocated(By.xpath('//li[normalize-space(.)="' + text + '"]')));
        driver.wait(until.elementIsVisible(listitem));
        // Although element is visible, because of the transition it is not yet fully there, so we sleep a bit.
        driver.sleep(300);
        listitem.click();
    },

    sendKeysSelectOption: function (selector, keys, text) {
        $(selector + ' input[type="text"]', this.tab).sendKeys(keys);
        this.selectOption(text);
    },

    selectMyLocation: function (selector) {
        $(selector + ' input[type="text"]', this.tab).click();
        this.selectOption('Use user\'s location');
    }

};

test.describe('Link Builder', function () {

    // Default 2000 ms is not enough for most tests.
    this.timeout(10000);

    test.before(function () {

    });

    test.after(function () {
        driver.quit();
    });

    test.beforeEach(function () {
        driver.get('http://127.0.0.1:5000');
        driver.executeScript('window.scroll(0, 400)');
    });

    test.describe('Route panel', function () {

        test.beforeEach(function () {
            helper.setTab('.here-tabs-body>div:nth-child(1)');
        });

        test.it('should generate route from a to b', function () {
            helper.sendKeysSelectOption('.row-route-from', 'Bremen', 'Bremen, Germany');
            helper.sendKeysSelectOption('.row-route-to', 'Berlin', 'Berlin, Germany');
            helper.assertResult('https://share.here.com/r/53.0751,8.80469,Bremen%2C%20Germany/52.51607,13.37699,Berlin%2C%20Germany?m=d&t=normal');
        });

        test.it('should generate route from mylocation to b', function () {
            helper.selectMyLocation('.row-route-from');
            helper.sendKeysSelectOption('.row-route-to', 'Berlin', 'Berlin, Germany');
            helper.assertResult('https://share.here.com/r/mylocation/52.51607,13.37699,Berlin%2C%20Germany?m=d&t=normal');
        });

        test.it('should generate route from a to mylocation', function () {
            helper.sendKeysSelectOption('.row-route-from', 'Berlin', 'Berlin, Germany');
            helper.selectMyLocation('.row-route-to');
            helper.assertResult('https://share.here.com/r/52.51607,13.37699,Berlin%2C%20Germany/mylocation?m=d&t=normal');
        });

        test.describe('Options', function () {

            test.beforeEach(function () {
                helper.selectMyLocation('.row-route-from');
                helper.sendKeysSelectOption('.row-route-to', 'Berlin', 'Berlin, Germany');
            });

            test.it('should set route mode', function () {
                $('select option:nth-child(2)', helper.tab).click();
                helper.assertResult('https://share.here.com/r/mylocation/52.51607,13.37699,Berlin%2C%20Germany?m=pt&t=normal');
                $('select option:nth-child(3)', helper.tab).click();
                helper.assertResult('https://share.here.com/r/mylocation/52.51607,13.37699,Berlin%2C%20Germany?m=w&t=normal');
            });

            test.it('should set map type', function () {
                $('.builder-row:nth-of-type(2) select option:nth-child(2)', helper.tab).click();
                helper.assertResult('https://share.here.com/r/mylocation/52.51607,13.37699,Berlin%2C%20Germany?m=d&t=terrain');
            });

        });
    });

    test.describe('Location panel', function () {

        test.beforeEach(function () {
            $('.here-tabs-controls li:nth-child(2)').click();
            helper.setTab('.here-tabs-body>div:nth-child(2)');
            helper.sendKeysSelectOption('.location-box', 'Berlin', 'Berlin, Germany');
        });

        test.it('should generate location link', function () {
            helper.assertResult('https://share.here.com/l/52.51607,13.37699,Berlin%2C%20Germany?t=normal');
        });

        test.it('should set map type', function () {
            $('select option:nth-child(2)', helper.tab).click();
            helper.assertResult('https://share.here.com/l/52.51607,13.37699,Berlin%2C%20Germany?t=terrain');
        });

    });

    test.describe('Place panel', function () {

        test.it('should generate place link', function () {
            $('.here-tabs-controls li:nth-child(3)').click();
            helper.setTab('.here-tabs-body>div:nth-child(3)');
            helper.sendKeysSelectOption('.location-box', 'Berlin', 'Berlin, Germany');
            helper.assertResult('https://share.here.com/p/s-YmI9MTMuMTE5MzclMkM1Mi4zNzYxNSUyQzEzLjY1ODAxJTJDNTIuNjYwNTg7Yz1jaXR5LXRvd24tdmlsbGFnZTtpZD0yNzZ1MzNkYi1mYmNmZmQyZTUyZjk0ZjU2YjZmNTU0YzBiYWEzM2YwNjtsYXQ9NTIuNTE2MDc7bG9uPTEzLjM3Njk4O249QmVybGluO25sYXQ9NTIuNTE2MDc7bmxvbj0xMy4zNzY5ODtoPTYwMTQzNw');
        });
    });
});
<|endoftext|>