<commit_before>/*
     Copyright 2011-2012 Jacob Beard, INFICON, and other SCION contributors

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

             http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
*/

"use strict";

var scxmlToScjson = require('../compiler/scxml-to-scjson'),
    scjsonToModule = require('../compiler/scjson-to-module'),
    scxmlAnalyzer = require('../compiler/static-analysis/scxml-analyzer'),
    inlineSrcs = require('./transform/inline-srcs'),
    pm = require('./platform-bootstrap/platform');

function documentStringToModel(url,docString,cb,context){

    scxmlAnalyzer.analyze(docString, url, context, function (scxmlAnalyzedResult) {
        //If there are errors in scxml content
        if (scxmlAnalyzedResult.errors.length) {
            //Log errors

            //Value --force is set
            if (true) {

            } else{
                //Throw error and kill process

            };
        };

        var scJson = scxmlToScjson(scxmlAnalyzedResult.newScxml);
    });

    createModule(url,scJson,context,cb);

    // try {

    //     //do whatever transforms
    //     //inline script tags
    //     //platformGet may be undefined, and we can continue without it, hence the guard
    //     if(pm.platform.getResourceFromUrl){
    //         inlineSrcs(url,scJson,context,function(errors){
    //             if(errors){
    //                 //treat script download errors as fatal
    //                 //pass through a single error - aggregate if there's more than one
    //                 cb(errors.length === 1 ?
    //                         errors[0].err :
    //                         new Error(
    //                             'Script download errors : \n' +
    //                                 errors.map(function(oErr){return oErr.url + ': ' + oErr.err.message;}).join('\n')));
    //             }else{
    //                 //otherwise, attempt to convert document to model object
    //                 createModule(url,scJson,context,cb);
    //             }
    //         });
    //     }else{
    //         createModule(url,scJson,context,cb);
    //     }
    // }catch(e){
    //     cb(e);
    // }
}

function createModule(url,scJson,context,cb){

    if(pm.platform.debug) console.log('scjson',JSON.stringify(scJson,4,4));

    var jsModule = scjsonToModule(scJson);

    if(pm.platform.debug) {
        console.log('scxmlName\n', jsModule.name);
        console.log('jsModuleString\n', jsModule.moduleString);
    }

    var model = pm.platform.module.eval(jsModule.moduleString,url,context);     //TODO: use a platform-native eval? this is where we would pass in require
    if(pm.platform.debug) console.log('model',model);

    cb(null, { model: model, name: jsModule.name });
}

module.exports = documentStringToModel;
<commit_msg>Removed old inliner<commit_after>/*
     Copyright 2011-2012 Jacob Beard, INFICON, and other SCION contributors

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

             http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
*/

"use strict";

var scxmlToScjson = require('../compiler/scxml-to-scjson'),
    scjsonToModule = require('../compiler/scjson-to-module'),
    scxmlAnalyzer = require('../compiler/static-analysis/scxml-analyzer'),
    inlineSrcs = require('./transform/inline-srcs'),
    pm = require('./platform-bootstrap/platform');

function documentStringToModel(url,docString,cb,context){
    scxmlAnalyzer.analyze(docString, url, context, function (scxmlAnalyzedResult) {

        //If there are errors in scxml content
        if (scxmlAnalyzedResult.errors.length) {
            //Log errors

            //TODO Value --force is set
            if (true) {

            } else{
                //TODO Throw error and kill process

            };
        };

        var scJson = scxmlToScjson(scxmlAnalyzedResult.newScxml);

        createModule(url,scJson,context,cb);
    });
}

function createModule(url,scJson,context,cb){

    if(pm.platform.debug) console.log('scjson',JSON.stringify(scJson,4,4));

    var jsModule = scjsonToModule(scJson);

    if(pm.platform.debug) {
        console.log('scxmlName\n', jsModule.name);
        console.log('jsModuleString\n', jsModule.moduleString);
    }

    var model = pm.platform.module.eval(jsModule.moduleString,url,context);     //TODO: use a platform-native eval? this is where we would pass in require
    if(pm.platform.debug) console.log('model',model);

    cb(null, { model: model, name: jsModule.name });
}

module.exports = documentStringToModel;
<|endoftext|>


<commit_before>#!/usr/bin/env node

/*
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements. See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership. The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License. You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied. See the License for the
    specific language governing permissions and limitations
    under the License.
*/

var shell = require('shelljs'),
    Q = require ('q'),
    path = require('path'),
    fs = require('fs'),
    ROOT = path.join(__dirname, '..', '..');

function createHelp() {
    console.log('Usage: $0 [--link] [--cli] <path_to_new_project> <package_name> <project_name> [<project_template_dir>]');
    console.log('   --link (optional): Link directly against the shared copy of the CordovaLib instead of a copy of it.');
    console.log('   --cli (optional): Use the CLI-project template.');
    console.log('   <path_to_new_project>: Path to your new Cordova iOS project');
    console.log('   <package_name>: Package name, following reverse-domain style convention');
    console.log('   <project_name>: Project name');
    console.log('   <project_template_dir>: Path to project template (override).');
}

function updateSubprojectHelp() {
    console.log('Updates the subproject path of the CordovaLib entry to point to this script\'s version of Cordova.');
    console.log('Usage: CordovaVersion/bin/update_cordova_project path/to/your/app.xcodeproj [path/to/CordovaLib.xcodeproj]');
}

function setShellFatal(value, func) {
    var oldVal = shell.config.fatal;
    shell.config.fatal = value;
    func();
    shell.config.fatal = oldVal;
}

function copyJsAndCordovaLib(projectPath, projectName, use_shared) {
    shell.cp('-f', path.join(ROOT, 'CordovaLib', 'cordova.js'), path.join(projectPath, 'www'));
    shell.rm('-rf', path.join(projectPath, 'CordovaLib'));

    if (use_shared) {
        update_cordova_subproject([path.join(projectPath, projectName +'.xcodeproj', 'project.pbxproj')]);
        // Symlink not used in project file, but is currently required for plugman because
        // it reads the VERSION file from it (instead of using the cordova/version script
        // like it should).
        fs.symlinkSync(path.join(ROOT, 'CordovaLib'), path.join(projectPath, 'CordovaLib'));
    } else {
        var r = path.join(projectPath, projectName);
        shell.mkdir('-p', path.join(projectPath, 'CordovaLib', 'CordovaLib.xcodeproj'));
        shell.cp('-f', path.join(r, '.gitignore'), projectPath);
        shell.cp('-rf',path.join(ROOT, 'CordovaLib', 'Classes'), path.join(projectPath, 'CordovaLib'));
        shell.cp('-f', path.join(ROOT, 'CordovaLib', 'VERSION'), path.join(projectPath, 'CordovaLib'));
        shell.cp('-f', path.join(ROOT, 'CordovaLib', 'cordova.js'), path.join(projectPath, 'CordovaLib'));
        shell.cp('-f', path.join(ROOT, 'CordovaLib', 'CordovaLib_Prefix.pch'), path.join(projectPath, 'CordovaLib'));
        shell.cp('-f', path.join(ROOT, 'CordovaLib', 'CordovaLib.xcodeproj', 'project.pbxproj'), path.join(projectPath, 'CordovaLib', 'CordovaLib.xcodeproj'));
        update_cordova_subproject([path.join(r+'.xcodeproj', 'project.pbxproj'), path.join(projectPath, 'CordovaLib', 'CordovaLib.xcodeproj', 'project.pbxproj')]);
    }
}

function copyScripts(projectPath) {
    var srcScriptsDir = path.join(ROOT, 'bin', 'templates', 'scripts', 'cordova');
    var destScriptsDir = path.join(projectPath, 'cordova');

    // Delete old scripts directory.
    shell.rm('-rf', destScriptsDir);

    // Copy in the new ones.
    var binDir = path.join(ROOT, 'bin');
    shell.cp('-r', srcScriptsDir, projectPath);
    shell.cp('-r', path.join(binDir, 'node_modules'), destScriptsDir);

    // Copy the check_reqs script
    shell.cp(path.join(binDir, 'check_reqs*'), destScriptsDir);
    shell.cp(path.join(binDir, 'lib', 'check_reqs.js'), path.join(destScriptsDir, 'lib'));

    // Copy the version scripts
    shell.cp(path.join(binDir, 'apple_ios_version'), destScriptsDir);
    shell.cp(path.join(binDir, 'apple_osx_version'), destScriptsDir);
    shell.cp(path.join(binDir, 'apple_xcode_version'), destScriptsDir);
    shell.cp(path.join(binDir, 'lib', 'versions.js'),  path.join(destScriptsDir, 'lib'));

    // Make sure they are executable (sometimes zipping them can remove executable bit)
    shell.find(destScriptsDir).forEach(function(entry) {
        shell.chmod(755, entry);
    });
}

function detectProjectName(projectDir) {
    var files = fs.readdirSync(projectDir);
    for (var i = 0; i < files.length; ++i) {
        var m = /(.*)\.xcodeproj$/.exec(files[i]);
        if (m) {
            return m[1];
        }
    }
    throw new Error('Could not find an .xcodeproj directory within ' + projectDir);
}

function AbsParentPath(_path) {
    return path.resolve(path.dirname(_path));
}

function AbsProjectPath(relative_path) {
    var absolute_path = path.resolve(relative_path);
    if (/.pbxproj$/.test(absolute_path)) {
        absolute_path = AbsParentPath(absolute_path);
    }
    else if (!(/.xcodeproj$/.test(absolute_path))) {
        throw new Error('The following is not a valid path to an Xcode project' + absolute_path);
    }
    return absolute_path;
}

function relpath(_path, start) {
    start = start || process.cwd();
    return path.relative(path.resolve(start), path.resolve(_path));
}

/*
 * Creates a new iOS project with the following options:
 *
 * - --link (optional): Link directly against the shared copy of the CordovaLib instead of a copy of it
 * - --cli (optional): Use the CLI-project template
 * - <path_to_new_project>: Path to your new Cordova iOS project
 * - <package_name>: Package name, following reverse-domain style convention
 * - <project_name>: Project name
 * - <project_template_dir>: Path to a project template (override)
 *
 */
exports.createProject = function(project_path, package_name, project_name, opts) {
    package_name = package_name || 'my.cordova.project';
    project_name = project_name || 'CordovaExample';
    var use_shared = !!opts.link;
    var use_cli = !!opts.cli;
    var bin_dir = path.join(ROOT, 'bin'),
        project_parent = path.dirname(project_path);
    var project_template_dir = opts.project_template_dir || path.join(bin_dir, 'templates', 'project');

    //check that project path doesn't exist
    if (fs.existsSync(project_path)) {
        return Q.reject('Project already exists');
    }

    //check that parent directory does exist so cp -r will not fail
    if (!fs.existsSync(project_parent)) {
        return Q.reject(project_parent + ' does not exist. Please specify an existing parent folder');
    }

    // create the project directory and copy over files
    shell.mkdir(project_path);
    shell.cp('-rf', path.join(project_template_dir, 'www'), project_path);
    if (use_cli) {
        shell.cp('-rf', path.join(project_template_dir, '__CLI__.xcodeproj'), project_path);
        shell.mv(path.join(project_path, '__CLI__.xcodeproj'), path.join(project_path, project_name+'.xcodeproj'));
    }
    else {
        shell.cp('-rf', path.join(project_template_dir, '__NON-CLI__.xcodeproj'), project_path);
        shell.mv(path.join(project_path, '__NON-CLI__.xcodeproj'), path.join(project_path, project_name+'.xcodeproj'));
    }
    shell.cp('-rf', path.join(project_template_dir, '__PROJECT_NAME__'), project_path);
    shell.mv(path.join(project_path, '__PROJECT_NAME__'), path.join(project_path, project_name));

    var r = path.join(project_path, project_name);
    shell.mv(path.join(r, '__PROJECT_NAME__-Info.plist'), path.join(r, project_name+'-Info.plist'));
    shell.mv(path.join(r, '__PROJECT_NAME__-Prefix.pch'), path.join(r, project_name+'-Prefix.pch'));
    shell.mv(path.join(r, 'gitignore'), path.join(r, '.gitignore'));

    /*replace __PROJECT_NAME__ and --ID-- with ACTIVITY and ID strings, respectively, in:
     *
     * - ./__PROJECT_NAME__.xcodeproj/project.pbxproj
     * - ./__PROJECT_NAME__/Classes/AppDelegate.h
     * - ./__PROJECT_NAME__/Classes/AppDelegate.m
     * - ./__PROJECT_NAME__/Resources/main.m
     * - ./__PROJECT_NAME__/Resources/__PROJECT_NAME__-info.plist
     * - ./__PROJECT_NAME__/Resources/__PROJECT_NAME__-Prefix.plist
     */
    var project_name_esc = project_name.replace(/&/g, '\\&');
    shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r+'.xcodeproj', 'project.pbxproj'));
    shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r, 'Classes', 'AppDelegate.h'));
    shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r, 'Classes', 'AppDelegate.m'));
    shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r, 'Classes', 'MainViewController.h'));
    shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r, 'Classes', 'MainViewController.m'));
    shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r, 'main.m'));
    shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r, project_name+'-Info.plist'));
    shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r, project_name+'-Prefix.pch'));
    shell.sed('-i', /--ID--/g, package_name, path.join(r, project_name+'-Info.plist'));

    //CordovaLib stuff
    copyJsAndCordovaLib(project_path, project_name, use_shared);
    copyScripts(project_path);

    console.log(generateDoneMessage('create', use_shared));
    return Q.resolve();
};

exports.updateProject = function(projectPath, opts) {
    var projectName = detectProjectName(projectPath);
    setShellFatal(true, function() {
        copyJsAndCordovaLib(projectPath, projectName, opts.link);
        copyScripts(projectPath);
        console.log(generateDoneMessage('update', opts.link));
    });
    return Q.resolve();
};

function generateDoneMessage(type, link) {
    var pkg = require('../../package');
    var msg = 'iOS project ' + (type == 'update' ? 'updated ' : 'created ') + 'with ' + pkg.name + '@' + pkg.version;
    if (link) {
        msg += ' and has a linked CordovaLib';
    }
    return msg;
}

function update_cordova_subproject(argv) {
    if (argv.length < 1 || argv.length > 2)
    {
        updateSubprojectHelp();
        throw new Error('Usage error for update_cordova_subproject');
    }

    var projectPath = AbsProjectPath(argv[0]),
        cordovaLibXcodePath;
    if (argv.length < 2) {
        cordovaLibXcodePath = path.join(ROOT, 'CordovaLib', 'CordovaLib.xcodeproj');
    }
    else {
        cordovaLibXcodePath = AbsProjectPath(argv[1]);
    }

    var parentProjectPath = AbsParentPath(projectPath),
        subprojectPath = relpath(cordovaLibXcodePath, parentProjectPath),
        REGEX = /(.+PBXFileReference.+wrapper.pb-project.+)(path = .+?;)(.*)(sourceTree.+;)(.+)/,
        newLine,
        lines = shell.grep('CordovaLib.xcodeproj', path.join(projectPath, 'project.pbxproj')),
        found = false;

    subprojectPath = subprojectPath.replace(/\\/g, '/');
    lines = lines.split('\n');
    for (var i = 0; i < lines.length; ++i) {
        if (lines[i].match(REGEX)) {
            found = true;
            newLine = lines[i].replace(/path = .+?;/, 'path = ' + subprojectPath + ';');
            newLine = newLine.replace(/sourceTree.+?;/, 'sourceTree = \"<group>\";');
            if (!newLine.match('name')) {
                newLine = newLine.replace('path = ', 'name = CordovaLib.xcodeproj; path = ');
            }
            shell.sed('-i', lines[i], newLine, path.join(projectPath, 'project.pbxproj'));
        }
    }

    if (!found) {
        throw new Error('Subproject: ' + subprojectPath + ' entry not found in project file');
    }
}

exports.createHelp = createHelp;
exports.updateSubprojectHelp = updateSubprojectHelp;
exports.update_cordova_subproject = update_cordova_subproject;
<commit_msg>CB-8965 Copy cordova-js-src directory to platform folder during create<commit_after>#!/usr/bin/env node

/*
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements. See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership. The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License. You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied. See the License for the
    specific language governing permissions and limitations
    under the License.
*/

var shell = require('shelljs'),
    Q = require ('q'),
    path = require('path'),
    fs = require('fs'),
    ROOT = path.join(__dirname, '..', '..');

function createHelp() {
    console.log('Usage: $0 [--link] [--cli] <path_to_new_project> <package_name> <project_name> [<project_template_dir>]');
    console.log('   --link (optional): Link directly against the shared copy of the CordovaLib instead of a copy of it.');
    console.log('   --cli (optional): Use the CLI-project template.');
    console.log('   <path_to_new_project>: Path to your new Cordova iOS project');
    console.log('   <package_name>: Package name, following reverse-domain style convention');
    console.log('   <project_name>: Project name');
    console.log('   <project_template_dir>: Path to project template (override).');
}

function updateSubprojectHelp() {
    console.log('Updates the subproject path of the CordovaLib entry to point to this script\'s version of Cordova.');
    console.log('Usage: CordovaVersion/bin/update_cordova_project path/to/your/app.xcodeproj [path/to/CordovaLib.xcodeproj]');
}

function setShellFatal(value, func) {
    var oldVal = shell.config.fatal;
    shell.config.fatal = value;
    func();
    shell.config.fatal = oldVal;
}

function copyJsAndCordovaLib(projectPath, projectName, use_shared) {
    shell.cp('-f', path.join(ROOT, 'CordovaLib', 'cordova.js'), path.join(projectPath, 'www'));
    shell.cp('-rf', path.join(ROOT, 'cordova-js-src'), path.join(projectPath, 'platform_www'));
    shell.rm('-rf', path.join(projectPath, 'CordovaLib'));

    if (use_shared) {
        update_cordova_subproject([path.join(projectPath, projectName +'.xcodeproj', 'project.pbxproj')]);
        // Symlink not used in project file, but is currently required for plugman because
        // it reads the VERSION file from it (instead of using the cordova/version script
        // like it should).
        fs.symlinkSync(path.join(ROOT, 'CordovaLib'), path.join(projectPath, 'CordovaLib'));
    } else {
        var r = path.join(projectPath, projectName);
        shell.mkdir('-p', path.join(projectPath, 'CordovaLib', 'CordovaLib.xcodeproj'));
        shell.cp('-f', path.join(r, '.gitignore'), projectPath);
        shell.cp('-rf',path.join(ROOT, 'CordovaLib', 'Classes'), path.join(projectPath, 'CordovaLib'));
        shell.cp('-f', path.join(ROOT, 'CordovaLib', 'VERSION'), path.join(projectPath, 'CordovaLib'));
        shell.cp('-f', path.join(ROOT, 'CordovaLib', 'cordova.js'), path.join(projectPath, 'CordovaLib'));
        shell.cp('-f', path.join(ROOT, 'CordovaLib', 'CordovaLib_Prefix.pch'), path.join(projectPath, 'CordovaLib'));
        shell.cp('-f', path.join(ROOT, 'CordovaLib', 'CordovaLib.xcodeproj', 'project.pbxproj'), path.join(projectPath, 'CordovaLib', 'CordovaLib.xcodeproj'));
        update_cordova_subproject([path.join(r+'.xcodeproj', 'project.pbxproj'), path.join(projectPath, 'CordovaLib', 'CordovaLib.xcodeproj', 'project.pbxproj')]);
    }
}

function copyScripts(projectPath) {
    var srcScriptsDir = path.join(ROOT, 'bin', 'templates', 'scripts', 'cordova');
    var destScriptsDir = path.join(projectPath, 'cordova');

    // Delete old scripts directory.
    shell.rm('-rf', destScriptsDir);

    // Copy in the new ones.
    var binDir = path.join(ROOT, 'bin');
    shell.cp('-r', srcScriptsDir, projectPath);
    shell.cp('-r', path.join(binDir, 'node_modules'), destScriptsDir);

    // Copy the check_reqs script
    shell.cp(path.join(binDir, 'check_reqs*'), destScriptsDir);
    shell.cp(path.join(binDir, 'lib', 'check_reqs.js'), path.join(destScriptsDir, 'lib'));

    // Copy the version scripts
    shell.cp(path.join(binDir, 'apple_ios_version'), destScriptsDir);
    shell.cp(path.join(binDir, 'apple_osx_version'), destScriptsDir);
    shell.cp(path.join(binDir, 'apple_xcode_version'), destScriptsDir);
    shell.cp(path.join(binDir, 'lib', 'versions.js'),  path.join(destScriptsDir, 'lib'));

    // Make sure they are executable (sometimes zipping them can remove executable bit)
    shell.find(destScriptsDir).forEach(function(entry) {
        shell.chmod(755, entry);
    });
}

function detectProjectName(projectDir) {
    var files = fs.readdirSync(projectDir);
    for (var i = 0; i < files.length; ++i) {
        var m = /(.*)\.xcodeproj$/.exec(files[i]);
        if (m) {
            return m[1];
        }
    }
    throw new Error('Could not find an .xcodeproj directory within ' + projectDir);
}

function AbsParentPath(_path) {
    return path.resolve(path.dirname(_path));
}

function AbsProjectPath(relative_path) {
    var absolute_path = path.resolve(relative_path);
    if (/.pbxproj$/.test(absolute_path)) {
        absolute_path = AbsParentPath(absolute_path);
    }
    else if (!(/.xcodeproj$/.test(absolute_path))) {
        throw new Error('The following is not a valid path to an Xcode project' + absolute_path);
    }
    return absolute_path;
}

function relpath(_path, start) {
    start = start || process.cwd();
    return path.relative(path.resolve(start), path.resolve(_path));
}

/*
 * Creates a new iOS project with the following options:
 *
 * - --link (optional): Link directly against the shared copy of the CordovaLib instead of a copy of it
 * - --cli (optional): Use the CLI-project template
 * - <path_to_new_project>: Path to your new Cordova iOS project
 * - <package_name>: Package name, following reverse-domain style convention
 * - <project_name>: Project name
 * - <project_template_dir>: Path to a project template (override)
 *
 */
exports.createProject = function(project_path, package_name, project_name, opts) {
    package_name = package_name || 'my.cordova.project';
    project_name = project_name || 'CordovaExample';
    var use_shared = !!opts.link;
    var use_cli = !!opts.cli;
    var bin_dir = path.join(ROOT, 'bin'),
        project_parent = path.dirname(project_path);
    var project_template_dir = opts.project_template_dir || path.join(bin_dir, 'templates', 'project');

    //check that project path doesn't exist
    if (fs.existsSync(project_path)) {
        return Q.reject('Project already exists');
    }

    //check that parent directory does exist so cp -r will not fail
    if (!fs.existsSync(project_parent)) {
        return Q.reject(project_parent + ' does not exist. Please specify an existing parent folder');
    }

    // create the project directory and copy over files
    shell.mkdir(project_path);
    shell.cp('-rf', path.join(project_template_dir, 'www'), project_path);
    if (use_cli) {
        shell.cp('-rf', path.join(project_template_dir, '__CLI__.xcodeproj'), project_path);
        shell.mv(path.join(project_path, '__CLI__.xcodeproj'), path.join(project_path, project_name+'.xcodeproj'));
    }
    else {
        shell.cp('-rf', path.join(project_template_dir, '__NON-CLI__.xcodeproj'), project_path);
        shell.mv(path.join(project_path, '__NON-CLI__.xcodeproj'), path.join(project_path, project_name+'.xcodeproj'));
    }
    shell.cp('-rf', path.join(project_template_dir, '__PROJECT_NAME__'), project_path);
    shell.mv(path.join(project_path, '__PROJECT_NAME__'), path.join(project_path, project_name));

    var r = path.join(project_path, project_name);
    shell.mv(path.join(r, '__PROJECT_NAME__-Info.plist'), path.join(r, project_name+'-Info.plist'));
    shell.mv(path.join(r, '__PROJECT_NAME__-Prefix.pch'), path.join(r, project_name+'-Prefix.pch'));
    shell.mv(path.join(r, 'gitignore'), path.join(r, '.gitignore'));

    /*replace __PROJECT_NAME__ and --ID-- with ACTIVITY and ID strings, respectively, in:
     *
     * - ./__PROJECT_NAME__.xcodeproj/project.pbxproj
     * - ./__PROJECT_NAME__/Classes/AppDelegate.h
     * - ./__PROJECT_NAME__/Classes/AppDelegate.m
     * - ./__PROJECT_NAME__/Resources/main.m
     * - ./__PROJECT_NAME__/Resources/__PROJECT_NAME__-info.plist
     * - ./__PROJECT_NAME__/Resources/__PROJECT_NAME__-Prefix.plist
     */
    var project_name_esc = project_name.replace(/&/g, '\\&');
    shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r+'.xcodeproj', 'project.pbxproj'));
    shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r, 'Classes', 'AppDelegate.h'));
    shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r, 'Classes', 'AppDelegate.m'));
    shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r, 'Classes', 'MainViewController.h'));
    shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r, 'Classes', 'MainViewController.m'));
    shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r, 'main.m'));
    shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r, project_name+'-Info.plist'));
    shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r, project_name+'-Prefix.pch'));
    shell.sed('-i', /--ID--/g, package_name, path.join(r, project_name+'-Info.plist'));

    //CordovaLib stuff
    copyJsAndCordovaLib(project_path, project_name, use_shared);
    copyScripts(project_path);

    console.log(generateDoneMessage('create', use_shared));
    return Q.resolve();
};

exports.updateProject = function(projectPath, opts) {
    var projectName = detectProjectName(projectPath);
    setShellFatal(true, function() {
        copyJsAndCordovaLib(projectPath, projectName, opts.link);
        copyScripts(projectPath);
        console.log(generateDoneMessage('update', opts.link));
    });
    return Q.resolve();
};

function generateDoneMessage(type, link) {
    var pkg = require('../../package');
    var msg = 'iOS project ' + (type == 'update' ? 'updated ' : 'created ') + 'with ' + pkg.name + '@' + pkg.version;
    if (link) {
        msg += ' and has a linked CordovaLib';
    }
    return msg;
}

function update_cordova_subproject(argv) {
    if (argv.length < 1 || argv.length > 2)
    {
        updateSubprojectHelp();
        throw new Error('Usage error for update_cordova_subproject');
    }

    var projectPath = AbsProjectPath(argv[0]),
        cordovaLibXcodePath;
    if (argv.length < 2) {
        cordovaLibXcodePath = path.join(ROOT, 'CordovaLib', 'CordovaLib.xcodeproj');
    }
    else {
        cordovaLibXcodePath = AbsProjectPath(argv[1]);
    }

    var parentProjectPath = AbsParentPath(projectPath),
        subprojectPath = relpath(cordovaLibXcodePath, parentProjectPath),
        REGEX = /(.+PBXFileReference.+wrapper.pb-project.+)(path = .+?;)(.*)(sourceTree.+;)(.+)/,
        newLine,
        lines = shell.grep('CordovaLib.xcodeproj', path.join(projectPath, 'project.pbxproj')),
        found = false;

    subprojectPath = subprojectPath.replace(/\\/g, '/');
    lines = lines.split('\n');
    for (var i = 0; i < lines.length; ++i) {
        if (lines[i].match(REGEX)) {
            found = true;
            newLine = lines[i].replace(/path = .+?;/, 'path = ' + subprojectPath + ';');
            newLine = newLine.replace(/sourceTree.+?;/, 'sourceTree = \"<group>\";');
            if (!newLine.match('name')) {
                newLine = newLine.replace('path = ', 'name = CordovaLib.xcodeproj; path = ');
            }
            shell.sed('-i', lines[i], newLine, path.join(projectPath, 'project.pbxproj'));
        }
    }

    if (!found) {
        throw new Error('Subproject: ' + subprojectPath + ' entry not found in project file');
    }
}

exports.createHelp = createHelp;
exports.updateSubprojectHelp = updateSubprojectHelp;
exports.update_cordova_subproject = update_cordova_subproject;
<|endoftext|>


<commit_before>var path = require('path'),
    fs = require('fs'),
    requirejs = require('requirejs'),
    _ = require('underscore');

module.exports = function (options, callback) {

    _.defaults(options, {
        config: "config.json",
        html: "index.html",
        serverFactoryClassName: "xaml!web/Server",

        environment: null,
        serverRoot: null,
        documentRoot: null,

        console: {
            log: function () {
            },
            error: function () {
            }
        }
    });

    var serverRoot = options.serverRoot,
        documentRoot = options.documentRoot,
        configPath = options.config,
        serverFactoryClassName = options.serverFactoryClassName,
        serverInstance;

    var serverModule = require(path.join(options.serverRoot, "..", "index.js"));

    if (path.resolve(configPath) !== configPath) {
        configPath = path.join(serverRoot, configPath);
    }

    var config = {},
        parameter = {},
        projectRequire = serverModule.require,
        rappidRequire = require;

    try {
        _.defaults(config, {
            nodeRequire: function () {
                try {
                    return rappidRequire.apply(rappidRequire, arguments);
                } catch (e) {
                    return projectRequire.apply(projectRequire, arguments);
                }
            },
            baseUrl: serverRoot,
            documentRoot: documentRoot,
            serverRoot: serverRoot
        }, JSON.parse(fs.readFileSync(configPath, 'utf8')));
    } catch (e) {
        console.error(e);
        callback(e);
        return;
    }

    config.suppress = {
        nodeShim: true
    };

    var rAppid = require(path.join(serverRoot, 'js/lib/rAppid.js')).rAppid;

    rAppid.createApplicationContext(null, config, function (err, applicationContext) {
        if (err) {
            callback(err);
        } else {
            var requirejsContext = applicationContext.$requirejsContext;
            applicationContext.$nodeRequire = require;

            requirejsContext([serverFactoryClassName, 'srv/core/Server', 'srv/core/ServerContext', 'js/core/Injection', 'js/core/Bindable'], function (ServerFactory, Server, ServerContext, Injection, Bindable) {

                try {
                    var serverContext = new ServerContext(requirejsContext, applicationContext);
                    serverContext.$environment = new Bindable();

                    var injection = serverContext.$injection = new Injection(null, null, serverContext);
                    injection.addInstance(serverContext.$bus);

                    var server = new ServerFactory(null, false, serverContext, null, null);

                    if (server instanceof Server) {
                        var environmentSetupComplete = function (err) {

                            if (!err) {
                                serverContext.$server = server;
                                server._initialize('auto');
                                server.start(parameter, function (err) {
                                    if (err) {
                                        callback(err);
                                    } else {
                                        console.log("server started");
                                        for (var i = 0; i < server.$endPoints.$endPoints.length; i++) {
                                            var endPoint = server.$endPoints.$endPoints[i];

                                            if (endPoint.uri instanceof Function) {
                                                console.log("open " + endPoint.uri() + " in your browser");
                                            }
                                        }
                                        serverInstance = server;
                                        callback(null, serverInstance);
                                    }
                                });
                            } else {
                                callback(err);
                            }

                        };

                        if (options.environment) {
                            Server.setupEnvironment(serverContext.$environment, options.environment, server.applicationDefaultNamespace, environmentSetupComplete);
                        } else if (server.supportEnvironments()) {
                            Server.setupEnvironment(serverContext.$environment, server._getEnvironment(), server.applicationDefaultNamespace, environmentSetupComplete);
                        } else {
                            environmentSetupComplete();
                        }

                    } else {
                        //noinspection ExceptionCaughtLocallyJS
                        throw new Error("Server '" + serverFactoryClassName + "' must be a Server");
                    }
                } catch (e) {
                    callback(e);
                }

            }, function (err) {
                console.error(err);
                callback(err);
            });
        }
    });
}<commit_msg>fixed server command if no index.js file is defined<commit_after>var path = require('path'),
    fs = require('fs'),
    requirejs = require('requirejs'),
    _ = require('underscore');

module.exports = function (options, callback) {

    _.defaults(options, {
        config: "config.json",
        html: "index.html",
        serverFactoryClassName: "xaml!web/Server",

        environment: null,
        serverRoot: null,
        documentRoot: null,

        console: {
            log: function () {
            },
            error: function () {
            }
        }
    });

    var serverRoot = options.serverRoot,
        documentRoot = options.documentRoot,
        configPath = options.config,
        serverFactoryClassName = options.serverFactoryClassName,
        serverInstance;

    var serverModule;
    try {
        serverModule = require(path.join(options.serverRoot, "..", "index.js"));
    } catch(e){
        console.warn("WARN: No index.js for server module defined. Please add a index.js file in the project directory");
    }

    if (path.resolve(configPath) !== configPath) {
        configPath = path.join(serverRoot, configPath);
    }

    var config = {},
        parameter = {},
        projectRequire = (serverModule ? serverModule.require : null),
        rappidRequire = require;

    try {
        _.defaults(config, {
            nodeRequire: function () {
                try {
                    return rappidRequire.apply(rappidRequire, arguments);
                } catch (e) {
                    return projectRequire.apply(projectRequire, arguments);
                }
            },
            baseUrl: serverRoot,
            documentRoot: documentRoot,
            serverRoot: serverRoot
        }, JSON.parse(fs.readFileSync(configPath, 'utf8')));
    } catch (e) {
        console.error(e);
        callback(e);
        return;
    }

    config.suppress = {
        nodeShim: true
    };

    var rAppid = require(path.join(serverRoot, 'js/lib/rAppid.js')).rAppid;

    rAppid.createApplicationContext(null, config, function (err, applicationContext) {
        if (err) {
            callback(err);
        } else {
            var requirejsContext = applicationContext.$requirejsContext;
            applicationContext.$nodeRequire = require;

            requirejsContext([serverFactoryClassName, 'srv/core/Server', 'srv/core/ServerContext', 'js/core/Injection', 'js/core/Bindable'], function (ServerFactory, Server, ServerContext, Injection, Bindable) {

                try {
                    var serverContext = new ServerContext(requirejsContext, applicationContext);
                    serverContext.$environment = new Bindable();

                    var injection = serverContext.$injection = new Injection(null, null, serverContext);
                    injection.addInstance(serverContext.$bus);

                    var server = new ServerFactory(null, false, serverContext, null, null);

                    if (server instanceof Server) {
                        var environmentSetupComplete = function (err) {

                            if (!err) {
                                serverContext.$server = server;
                                server._initialize('auto');
                                server.start(parameter, function (err) {
                                    if (err) {
                                        callback(err);
                                    } else {
                                        console.log("server started");
                                        for (var i = 0; i < server.$endPoints.$endPoints.length; i++) {
                                            var endPoint = server.$endPoints.$endPoints[i];

                                            if (endPoint.uri instanceof Function) {
                                                console.log("open " + endPoint.uri() + " in your browser");
                                            }
                                        }
                                        serverInstance = server;
                                        callback(null, serverInstance);
                                    }
                                });
                            } else {
                                callback(err);
                            }

                        };

                        if (options.environment) {
                            Server.setupEnvironment(serverContext.$environment, options.environment, server.applicationDefaultNamespace, environmentSetupComplete);
                        } else if (server.supportEnvironments()) {
                            Server.setupEnvironment(serverContext.$environment, server._getEnvironment(), server.applicationDefaultNamespace, environmentSetupComplete);
                        } else {
                            environmentSetupComplete();
                        }

                    } else {
                        //noinspection ExceptionCaughtLocallyJS
                        throw new Error("Server '" + serverFactoryClassName + "' must be a Server");
                    }
                } catch (e) {
                    callback(e);
                }

            }, function (err) {
                console.error(err);
                callback(err);
            });
        }
    });
}<|endoftext|>


<commit_before>'use strict';

/* Filters */

angular.module('myApp.filters', []).
  filter('interpolate', ['version', function(version) {
    return function(text) {
      return String(text).replace(/\%VERSION\%/mg, version);
    }
  }])

  .filter('shorten', function() {
    return function(str) {
      if (str.length >= 2) {
          str = str[0] + "-" + str[str.length-1]
      }
      return str;
    }
  })

  .filter('starters', function() {
    return function (places) {
        var starters = []
        var lastStarterCount = 8;
        angular.forEach(places , function(p, i) {
            var lastStarter = starters[starters.length -1] || '';
            var firstLetter = p.name[0]
            if (lastStarterCount > 7 && lastStarter.indexOf(firstLetter) == -1) {
                starters.push("");
                lastStarter = starters[starters.length -1];
                lastStarterCount = 0;
            }
            lastStarterCount++;
            var lastStarter = starters[starters.length -1];
            if (lastStarter.indexOf(firstLetter) == -1) {
                starters[starters.length -1] += firstLetter;
            }
        })
        return starters;
    }
  })

  .filter('starterLettersFilter', function() {
    return function(states, letetrs) {
        if (letetrs && letetrs != "") {
            states = states.filter(function(s) {
                return letetrs.indexOf(s.name[0]) != -1
            })
        }
        return states;
    }
  })

  .filter('percent', function() {
    return function(n) {
      var n = n || 0;
      return Math.round(100 * n) + '%';
    }
  })

  .filter('StatesFromPlaces', function() {
    return function(data) {
        var places = {};
        if (data && data[0] && data[0].places) {
            angular.forEach(data[0].places, function(place) {
                places[place.code] = place;
            });
        }
        return places;
    }
  });
<commit_msg>StatesFromPlaces js filter fixed in order to filter out continents<commit_after>'use strict';

/* Filters */

angular.module('myApp.filters', []).
  filter('interpolate', ['version', function(version) {
    return function(text) {
      return String(text).replace(/\%VERSION\%/mg, version);
    }
  }])

  .filter('shorten', function() {
    return function(str) {
      if (str.length >= 2) {
          str = str[0] + "-" + str[str.length-1]
      }
      return str;
    }
  })

  .filter('starters', function() {
    return function (places) {
        var starters = []
        var lastStarterCount = 8;
        angular.forEach(places , function(p, i) {
            var lastStarter = starters[starters.length -1] || '';
            var firstLetter = p.name[0]
            if (lastStarterCount > 7 && lastStarter.indexOf(firstLetter) == -1) {
                starters.push("");
                lastStarter = starters[starters.length -1];
                lastStarterCount = 0;
            }
            lastStarterCount++;
            var lastStarter = starters[starters.length -1];
            if (lastStarter.indexOf(firstLetter) == -1) {
                starters[starters.length -1] += firstLetter;
            }
        })
        return starters;
    }
  })

  .filter('starterLettersFilter', function() {
    return function(states, letetrs) {
        if (letetrs && letetrs != "") {
            states = states.filter(function(s) {
                return letetrs.indexOf(s.name[0]) != -1
            })
        }
        return states;
    }
  })

  .filter('percent', function() {
    return function(n) {
      var n = n || 0;
      return Math.round(100 * n) + '%';
    }
  })

  .filter('StatesFromPlaces', function() {
    return function(data) {
        var places = {};
        if (data && data[0]) {
            angular.forEach(data, function(category) {
                if (!category.haveMaps && category.places) {
                    angular.forEach(category.places, function(place) {
                        places[place.code] = place;
                    });
                }
            });
        }
        return places;
    }
  });
<|endoftext|>


<commit_before>/*
 *  TCPConnectedBridge.js
 *
 *  David Janes
 *  IOTDB.org
 *  2015-02-03
 *
 *  Copyright [2013-2015] [David P. Janes]
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

"use strict";

var homestar = require('homestar')
var _ = homestar._;
var bunyan = homestar.bunyan;

var TCPControlPoint = require('./tcp-connected');

var logger = bunyan.createLogger({
    name: 'homestar-tcp',
    module: 'TCPConnectedBridge',
});

/**
 *  See {iotdb.bridge.Bridge#Bridge} for documentation.
 *

 *  @param {object|undefined} native
 *  only used for instances, should be
 */
var TCPConnectedBridge = function(initd, native) {
    var self = this;

    self.initd = _.defaults(initd,
        iotdb.keystore().get("bridges/TCPConnectedBridge/initd"),
        {
            host: "lighting.local",
            poll: 30,
        }
    );
    self.native = native;
    self.stated = {};

    if (self.native) {
        self.queue = _.queue("TCPConnectedBridge");
    }
};

TCPConnectedBridge.prototype = new iotdb.Bridge();

TCPConnectedBridge.prototype.name = function () {
    return "TCPConnectedBridge";
};

/* --- lifecycle --- */

/**
 *  See {iotdb.bridge.Bridge#XXX} for documentation.
 */
TCPConnectedBridge.prototype.discover = function() {
    var self = this;

    var cp = new TCPControlPoint(self.initd.host);

    console.log("HERE:A");
    cp.GetState(function (error, rooms) {
        console.log("HERE:B");
        if (rooms === null) {
            console.log("# TCPConnectDriver.discover/GetState", "no rooms?");
            return;
        }

        for (var ri in rooms) {
            var room = rooms[ri];
            console.log("Room", room);
            /*
            discover_callback(new TCPConnectedDriver({
                room: room,
                name: room.name
            }));
            */

            /*
            tcp.GetRoomStateByName(room.name, function(error,state,level){
                console.log("State: " + state + " at Level: " + level);
                if(state === 0){
                    tcp.TurnOnRoomByName(room);
                }
            });
            tcp.SetRoomLevelByName(room.name, 100);
            */
        }
    });
};

/**
 *  See {iotdb.bridge.Bridge#XXX} for documentation.
 */
TCPConnectedBridge.prototype.connect = function(connectd) {
    var self = this;
    if (!self.native) {
        return;
    }

    return;
    self._setup_polling();
    self.pull();
};

TCPConnectedBridge.prototype._setup_polling = function() {
    var self = this;
    if (!self.initd.poll) {
        return;
    }

    var timer = setInterval(function() {
        if (!self.native) {
            clearInterval(timer);
            return;
        }

        self.pull();
    }, self.initd.poll * 1000);
};

TCPConnectedBridge.prototype._forget = function() {
    var self = this;
    if (!self.native) {
        return;
    }

    logger.info({
        method: "_forget"
    }, "called");

    self.native = null;
    self.pulled();
}

/**
 *  See {iotdb.bridge.Bridge#XXX} for documentation.
 */
TCPConnectedBridge.prototype.disconnect = function() {
    var self = this;
    if (!self.native || !self.native) {
        return;
    }

    self._forget();
};

/* --- data --- */

/**
 *  See {iotdb.bridge.Bridge#XXX} for documentation.
 */
TCPConnectedBridge.prototype.push = function(pushd) {
    var self = this;
    if (!self.native) {
        return;
    }
};

/**
 *  See {iotdb.bridge.Bridge#XXX} for documentation.
 */
TCPConnectedBridge.prototype.pull = function() {
    var self = this;
    if (!self.native) {
        return;
    }

};

/* --- state --- */

/**
 *  See {iotdb.bridge.Bridge#XXX} for documentation.
 */
TCPConnectedBridge.prototype.meta = function() {
    var self = this;
    if (!self.native) {
        return;
    }

    return {
        // "iot:thing": _.id.thing_urn.unique("TCPConnected", self.initd.name),
        // "iot:device": _.id.thing_urn.unique("TCPConnected", self.initd.name),
        "schema:manufacturer": "http://www.tcpi.com/",
        // "schema:name": self.initd.name || "Hue",
        // "iot:number": self.initd.number,
        // "schema:manufacturer": "http://philips.com/",
        // "schema:model": "http://meethue.com/",
    };
};

/**
 *  See {iotdb.bridge.Bridge#XXX} for documentation.
 */
TCPConnectedBridge.prototype.reachable = function() {
    return this.native !== null;
};

/**
 *  See {iotdb.bridge.Bridge#XXX} for documentation.
 */
TCPConnectedBridge.prototype.configure = function(app) {
};

/* --- injected: THIS CODE WILL BE REMOVED AT RUNTIME, DO NOT MODIFY  --- */
TCPConnectedBridge.prototype.discovered = function(bridge) {
    throw new Error("TCPConnectedBridge.discovered not implemented");
};

TCPConnectedBridge.prototype.pulled = function(pulld) {
    throw new Error("TCPConnectedBridge.pulled not implemented");
};

/*
 *  API
 */
exports.Bridge = TCPConnectedBridge;

<commit_msg>remove old injected code functions<commit_after>/*
 *  TCPConnectedBridge.js
 *
 *  David Janes
 *  IOTDB.org
 *  2015-02-03
 *
 *  Copyright [2013-2015] [David P. Janes]
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

"use strict";

var homestar = require('homestar')
var _ = homestar._;
var bunyan = homestar.bunyan;

var TCPControlPoint = require('./tcp-connected');

var logger = bunyan.createLogger({
    name: 'homestar-tcp',
    module: 'TCPConnectedBridge',
});

/**
 *  See {iotdb.bridge.Bridge#Bridge} for documentation.
 *

 *  @param {object|undefined} native
 *  only used for instances, should be
 */
var TCPConnectedBridge = function(initd, native) {
    var self = this;

    self.initd = _.defaults(initd,
        iotdb.keystore().get("bridges/TCPConnectedBridge/initd"),
        {
            host: "lighting.local",
            poll: 30,
        }
    );
    self.native = native;
    self.stated = {};

    if (self.native) {
        self.queue = _.queue("TCPConnectedBridge");
    }
};

TCPConnectedBridge.prototype = new iotdb.Bridge();

TCPConnectedBridge.prototype.name = function () {
    return "TCPConnectedBridge";
};

/* --- lifecycle --- */

/**
 *  See {iotdb.bridge.Bridge#XXX} for documentation.
 */
TCPConnectedBridge.prototype.discover = function() {
    var self = this;

    var cp = new TCPControlPoint(self.initd.host);

    console.log("HERE:A");
    cp.GetState(function (error, rooms) {
        console.log("HERE:B");
        if (rooms === null) {
            console.log("# TCPConnectDriver.discover/GetState", "no rooms?");
            return;
        }

        for (var ri in rooms) {
            var room = rooms[ri];
            console.log("Room", room);
            /*
            discover_callback(new TCPConnectedDriver({
                room: room,
                name: room.name
            }));
            */

            /*
            tcp.GetRoomStateByName(room.name, function(error,state,level){
                console.log("State: " + state + " at Level: " + level);
                if(state === 0){
                    tcp.TurnOnRoomByName(room);
                }
            });
            tcp.SetRoomLevelByName(room.name, 100);
            */
        }
    });
};

/**
 *  See {iotdb.bridge.Bridge#XXX} for documentation.
 */
TCPConnectedBridge.prototype.connect = function(connectd) {
    var self = this;
    if (!self.native) {
        return;
    }

    return;
    self._setup_polling();
    self.pull();
};

TCPConnectedBridge.prototype._setup_polling = function() {
    var self = this;
    if (!self.initd.poll) {
        return;
    }

    var timer = setInterval(function() {
        if (!self.native) {
            clearInterval(timer);
            return;
        }

        self.pull();
    }, self.initd.poll * 1000);
};

TCPConnectedBridge.prototype._forget = function() {
    var self = this;
    if (!self.native) {
        return;
    }

    logger.info({
        method: "_forget"
    }, "called");

    self.native = null;
    self.pulled();
}

/**
 *  See {iotdb.bridge.Bridge#XXX} for documentation.
 */
TCPConnectedBridge.prototype.disconnect = function() {
    var self = this;
    if (!self.native || !self.native) {
        return;
    }

    self._forget();
};

/* --- data --- */

/**
 *  See {iotdb.bridge.Bridge#XXX} for documentation.
 */
TCPConnectedBridge.prototype.push = function(pushd) {
    var self = this;
    if (!self.native) {
        return;
    }
};

/**
 *  See {iotdb.bridge.Bridge#XXX} for documentation.
 */
TCPConnectedBridge.prototype.pull = function() {
    var self = this;
    if (!self.native) {
        return;
    }

};

/* --- state --- */

/**
 *  See {iotdb.bridge.Bridge#XXX} for documentation.
 */
TCPConnectedBridge.prototype.meta = function() {
    var self = this;
    if (!self.native) {
        return;
    }

    return {
        // "iot:thing": _.id.thing_urn.unique("TCPConnected", self.initd.name),
        // "iot:device": _.id.thing_urn.unique("TCPConnected", self.initd.name),
        "schema:manufacturer": "http://www.tcpi.com/",
        // "schema:name": self.initd.name || "Hue",
        // "iot:number": self.initd.number,
        // "schema:manufacturer": "http://philips.com/",
        // "schema:model": "http://meethue.com/",
    };
};

/**
 *  See {iotdb.bridge.Bridge#XXX} for documentation.
 */
TCPConnectedBridge.prototype.reachable = function() {
    return this.native !== null;
};

/**
 *  See {iotdb.bridge.Bridge#XXX} for documentation.
 */
TCPConnectedBridge.prototype.configure = function(app) {
};

/*
 *  API
 */
exports.Bridge = TCPConnectedBridge;

<|endoftext|>


<commit_before>/*
 * Put any functions here which need to be included on every page to override
 * the Rice implementations.
 */

/**
 * Gets the value of an element with the given name.
 * When the element is an input field, we can directly retrieve its value using the name as the element ID;
 * otherwise when it's readOnly, we need to add ".div" to the name as the element ID.
 * This function also filters out white spaces as well as any URL links that might be associated with the field.
 * @param name the given field name.
 * @return the value of the element
 */
function getElementValue(name) {
	var value = null;

	// retrieve element using name as ID
	var el = kualiElements[name];
	//alert("overriden getElementValue: kualiElements el = " + el);

	// if the element exists, then it's an input field, get its value directly
	if ( el ) {
		value = el.value.toUpperCase().trim();
		//alert("input el value = " + value);
	}

	// otherwise the el is readOnly, retrieve the value using name.div as ID
	else {
		el = document.getElementById(name + ".div");
		//alert("getElementById el = " + el);

		if (el) {
			value = DWRUtil.getValue(name + ".div");
			//alert("DWR getValue = " + value);

			// trim html link if any
			value = value.replace(/(<([^>]+)>)/ig,"");
			//alert("After striping html, value = " + value);

			// trim &nbsp's and white spaces if any
			value = value.replace(" ", "").replace(/^\s+|\s+$/g,"");
			//alert("After striping spaces, value = " + value);

			// value most likely already in upper case, but just in case
			value = value.toUpperCase();
			//alert("After upper case, value = " + value);
		}
	}

	return value;
}<commit_msg>KFSMI-6428: added doToallTabs()<commit_after>/*
 * Put any functions here which need to be included on every page to override
 * the Rice implementations.
 */

/**
 * Gets the value of an element with the given name.
 * When the element is an input field, we can directly retrieve its value using the name as the element ID;
 * otherwise when it's readOnly, we need to add ".div" to the name as the element ID.
 * This function also filters out white spaces as well as any URL links that might be associated with the field.
 * @param name the given field name.
 * @return the value of the element
 */
function getElementValue(name) {
	var value = null;

	// retrieve element using name as ID
	var el = kualiElements[name];
	//alert("overriden getElementValue: kualiElements el = " + el);

	// if the element exists, then it's an input field, get its value directly
	if ( el ) {
		value = el.value.toUpperCase().trim();
		//alert("input el value = " + value);
	}

	// otherwise the el is readOnly, retrieve the value using name.div as ID
	else {
		el = document.getElementById(name + ".div");
		//alert("getElementById el = " + el);

		if (el) {
			value = DWRUtil.getValue(name + ".div");
			//alert("DWR getValue = " + value);

			// trim html link if any
			value = value.replace(/(<([^>]+)>)/ig,"");
			//alert("After striping html, value = " + value);

			// trim &nbsp's and white spaces if any
			value = value.replace(" ", "").replace(/^\s+|\s+$/g,"");
			//alert("After striping spaces, value = " + value);

			// value most likely already in upper case, but just in case
			value = value.toUpperCase();
			//alert("After upper case, value = " + value);
		}
	}

	return value;
}

/** executes a function on all tabs.  The function will be passed a document & partial tab name. */
function doToAllTabs(func) {
	// get the target node
	var targetElement = document.getElementsByTagName('body')[0];
	NodeIterator.iterate(func, targetElement);

	return false;
}

<|endoftext|>


<commit_before>angular.module('app.controllers')

.controller('optionsCtrl', function($scope, $location, OptionsService) {

	$scope.options = function(selectedOption){
		OptionsService.set(selectedOption);

		console.log('select option: ' + OptionsService.get());

		$location.url('/dishes');
	}

})
<commit_msg>Fix navigation was wrong when sharing equally<commit_after>angular.module('app.controllers')

.controller('optionsCtrl', function($scope, $location, OptionsService) {

	$scope.options = function(selectedOption){
		OptionsService.set(selectedOption);

		console.log('select option: ' + OptionsService.get());
	}

})
<|endoftext|>


<commit_before>/// <binding AfterBuild='watch' />
module.exports = function(grunt) {

    // CONFIGURATION
    grunt.initConfig({
        pkg: grunt.file.readJSON("package.json"),

        // Minimize JS
        uglify: {
            installWizard: {
                options: {
                    sourceMap: false,
                    output: { beautify: true },
                    mangle: false,
                    compress: false
                },
                src: [
                    "Scripts/jquery-3.6.0.js",
                    "Scripts/select2.js",
                    "Scripts/bootstrap.bundle.js",
                    "Scripts/forum/InstallWizard.js"
                ],
                dest: "Scripts/InstallWizard.comb.js"
            },

            fileUpload: {
                options: {
                    sourceMap: false,
                    output: { beautify: true },
                    mangle: false,
                    compress: false
                },
                src: [
                    "Scripts/jquery.FileUpload/vendor/jquery.ui.widget.js",
                    "Scripts/jquery.FileUpload/tmpl.js",
                    "Scripts/jquery.FileUpload/load-image.all.min.js",
                    "Scripts/jquery.FileUpload/canvas-to-blob.js",
                    "Scripts/jquery.FileUpload/jquery.iframe-transport.js",
                    "Scripts/jquery.FileUpload/jquery.fileupload.js",
                    "Scripts/jquery.FileUpload/jquery.fileupload-process.js",
                    "Scripts/jquery.FileUpload/jquery.fileupload-image.js",
                    "Scripts/jquery.FileUpload/jquery.fileupload-validate.js",
                    "Scripts/jquery.FileUpload/jquery.fileupload-ui.js"
                ],
                dest: "Scripts/jquery.fileupload.comb.js"
            },
            forumExtensions: {
                options: {
                    sourceMap: false,
                    output: { beautify: true },
                    mangle: false,
                    compress: false
                },
                src: [
                    "Scripts/moment-with-locales.js",
                    "Scripts/bootstrap.bundle.js",
                    "Scripts/bootbox.js",
                    "Scripts/bootstrap-notify.js",
                    "Scripts/jquery.bootstrap-touchspin.js",
                    "Scripts/select2.js",
                    "Scripts/bootstrap-tagsinput.js",
                    "Scripts/bootstrap-typeahead.js",
                    "Scripts/blueimp-gallery/blueimp-gallery.js",
                    "Scripts/blueimp-gallery/blueimp-gallery-indicator.js",
                    "Scripts/blueimp-gallery/jquery.blueimp-gallery.js",
                    "Scripts/jquery.hovercard.js",
                    "Scripts/prism.js",
                    "Scripts/tablesorter/jquery.tablesorter.combined.js",
                    "Scripts/tablesorter/extras/jquery.tablesorter.pager.js",
                    "Scripts/tablesorter/widgets/widget-reflow.js",
                    "Scripts/jsdifflib.js",
                    "Scripts/hammer.min.js",
                    "Scripts/forum/yaf.Utilities.js",
                    "Scripts/forum/yaf.MessageHistory.js",
                    "Scripts/forum/yaf.Albums.js",
                    "Scripts/forum/yaf.Attachments.js",
                    "Scripts/forum/yaf.Notify.js",
                    "Scripts/forum/yaf.SearchResults.js",
                    "Scripts/forum/yaf.SimilarTitles.js",
                    "Scripts/forum/yaf.Main.js",
                    "Scripts/forum/yaf.contextMenu.js"
                ],
                dest: "Scripts/jquery.ForumExtensions.js"
            },
            forumExtensionsDnn: {
                options: {
                    sourceMap: false,
                    output: { beautify: true },
                    mangle: false,
                    compress: false
                },
                src: [
                    "Scripts/moment-with-locales.js",
                    "Scripts/bootbox.js",
                    "Scripts/bootstrap-notify.js",
                    "Scripts/jquery.bootstrap-touchspin.js",
                    "Scripts/select2.js",
                    "Scripts/bootstrap-tagsinput.js",
                    "Scripts/bootstrap-typeahead.js",
                    "Scripts/blueimp-gallery/blueimp-gallery.js",
                    "Scripts/blueimp-gallery/blueimp-gallery-indicator.js",
                    "Scripts/blueimp-gallery/jquery.blueimp-gallery.js",
                    "Scripts/jquery.hovercard.js",
                    "Scripts/prism.js",
                    "Scripts/tablesorter/jquery.tablesorter.combined.js",
                    "Scripts/tablesorter/extras/jquery.tablesorter.pager.js",
                    "Scripts/tablesorter/widgets/widget-reflow.js",
                    "Scripts/jsdifflib.js",
                    "Scripts/hammer.min.js",
                    "Scripts/forum/yaf.Utilities.js",
                    "Scripts/forum/yaf.MessageHistory.js",
                    "Scripts/forum/yaf.Albums.js",
                    "Scripts/forum/yaf.Attachments.js",
                    "Scripts/forum/yaf.Notify.js",
                    "Scripts/forum/yaf.SearchResults.js",
                    "Scripts/forum/yaf.SimilarTitles.js",
                    "Scripts/forum/yaf.Main.js",
                    "Scripts/forum/yaf.contextMenu.js"
                ],
                dest: "Scripts/jquery.ForumExtensionsDnn.js"
            },
            forumAdminExtensions: {
                options: {
                    sourceMap: false,
                    output: { beautify: true },
                    mangle: false,
                    compress: false
                },
                src: [
                    "Scripts/moment-with-locales.js",
                    "Scripts/bootstrap.bundle.js",
                    "Scripts/bootbox.js",
                    "Scripts/bootstrap-datetimepicker.js",
                    "Scripts/bootstrap-notify.js",
                    "Scripts/jquery.bootstrap-touchspin.js",
                    "Scripts/select2.js",
                    "Scripts/blueimp-gallery/blueimp-gallery.js",
                    "Scripts/blueimp-gallery/jquery.blueimp-gallery.js",
                    "Scripts/jquery.blockUI.js",
                    "Scripts/jquery.hovercard.js",
                    "Scripts/prism.js",
                    "Scripts/hammer.min.js",
                    "Scripts/tablesorter/jquery.tablesorter.combined.js",
                    "Scripts/tablesorter/extras/jquery.tablesorter.pager.js",
                    "Scripts/tablesorter/widgets/widget-reflow.js",
                    "Scripts/forum/yaf.Utilities.js",
                    "Scripts/forum/yaf.Albums.js",
                    "Scripts/forum/yaf.Notify.js",
                    "Scripts/forum/yaf.Main.js",
                    "Scripts/forum/yaf.contextMenu.js"
                ],
                dest: "Scripts/jquery.ForumAdminExtensions.js"
            },
            forumAdminExtensionsDnn: {
                options: {
                    sourceMap: false,
                    output: { beautify: true },
                    mangle: false,
                    compress: false
                },
                src: [
                    "Scripts/moment-with-locales.js",
                    "Scripts/bootbox.js",
                    "Scripts/bootstrap-datetimepicker.js",
                    "Scripts/bootstrap-notify.js",
                    "Scripts/jquery.bootstrap-touchspin.js",
                    "Scripts/select2.js",
                    "Scripts/blueimp-gallery/blueimp-gallery.js",
                    "Scripts/blueimp-gallery/jquery.blueimp-gallery.js",
                    "Scripts/jquery.blockUI.js",
                    "Scripts/jquery.hovercard.js",
                    "Scripts/prism.js",
                    "Scripts/hammer.min.js",
                    "Scripts/tablesorter/jquery.tablesorter.combined.js",
                    "Scripts/tablesorter/extras/jquery.tablesorter.pager.js",
                    "Scripts/tablesorter/widgets/widget-reflow.js",
                    "Scripts/forum/yaf.Utilities.js",
                    "Scripts/forum/yaf.Albums.js",
                    "Scripts/forum/yaf.Notify.js",
                    "Scripts/forum/yaf.Main.js",
                    "Scripts/forum/yaf.contextMenu.js"
                ],
                dest: "Scripts/jquery.ForumAdminExtensionsDnn.js"
            },
            minify: {
                files: {
                    "Scripts/InstallWizard.comb.min.js": "Scripts/InstallWizard.comb.js",
                    "Scripts/jquery.fileupload.comb.min.js": "Scripts/jquery.fileupload.comb.js",
                    "Scripts/jquery.ForumExtensions.min.js": "Scripts/jquery.ForumExtensions.js",
                    "Scripts/jquery.ForumExtensionsDnn.min.js": "Scripts/jquery.ForumExtensionsDnn.js",
                    "Scripts/jquery.ForumAdminExtensions.min.js": "Scripts/jquery.ForumAdminExtensions.js",
                    "Scripts/jquery.ForumAdminExtensionsDnn.min.js": "Scripts/jquery.ForumAdminExtensionsDnn.js"

                }
            }
        },

        sass: {
            installWizard: {
                files: {
                    "Content/InstallWizard.css": "Content/InstallWizard.scss"
                }
            },
            forum: {
                files: {
                    "Content/forum.css": "Content/forum.scss"
                }
            },
            forumAdmin: {
                files: {
                    "Content/forum-admin.css": "Content/forum-admin.scss"
                }
            },
            bootstrap: {
                files: {
                    "Content/bootstrap/bootstrap.css": "Content/bootstrap/bootstrap.scss"
                }
            },
            themes: {
                files: {
                    "Content/Themes/zephyr/bootstrap-forum.css": "Content/Themes/zephyr/bootstrap-forum.scss",
                    "Content/Themes/yaf/bootstrap-forum.css": "Content/Themes/yaf/bootstrap-forum.scss",
                    "Content/Themes/yeti/bootstrap-forum.css": "Content/Themes/yeti/bootstrap-forum.scss",
                    "Content/Themes/vapor/bootstrap-forum.css": "Content/Themes/vapor/bootstrap-forum.scss",
                    "Content/Themes/united/bootstrap-forum.css": "Content/Themes/united/bootstrap-forum.scss",
                    "Content/Themes/superhero/bootstrap-forum.css": "Content/Themes/superhero/bootstrap-forum.scss",
                    "Content/Themes/spacelab/bootstrap-forum.css": "Content/Themes/spacelab/bootstrap-forum.scss",
                    "Content/Themes/solar/bootstrap-forum.css": "Content/Themes/solar/bootstrap-forum.scss",
                    "Content/Themes/slate/bootstrap-forum.css": "Content/Themes/slate/bootstrap-forum.scss",
                    "Content/Themes/sketchy/bootstrap-forum.css": "Content/Themes/sketchy/bootstrap-forum.scss",
                    "Content/Themes/simplex/bootstrap-forum.css": "Content/Themes/simplex/bootstrap-forum.scss",
                    "Content/Themes/sandstone/bootstrap-forum.css": "Content/Themes/sandstone/bootstrap-forum.scss",
                    "Content/Themes/quartz/bootstrap-forum.css": "Content/Themes/quartz/bootstrap-forum.scss",
                    "Content/Themes/pulse/bootstrap-forum.css": "Content/Themes/pulse/bootstrap-forum.scss",
                    "Content/Themes/morph/bootstrap-forum.css": "Content/Themes/morph/bootstrap-forum.scss",
                    "Content/Themes/minty/bootstrap-forum.css": "Content/Themes/minty/bootstrap-forum.scss",
                    "Content/Themes/materia/bootstrap-forum.css": "Content/Themes/materia/bootstrap-forum.scss",
                    "Content/Themes/lux/bootstrap-forum.css": "Content/Themes/lux/bootstrap-forum.scss",
                    "Content/Themes/lumen/bootstrap-forum.css": "Content/Themes/lumen/bootstrap-forum.scss",
                    "Content/Themes/litera/bootstrap-forum.css": "Content/Themes/litera/bootstrap-forum.scss",
                    "Content/Themes/journal/bootstrap-forum.css": "Content/Themes/journal/bootstrap-forum.scss",
                    "Content/Themes/flatly/bootstrap-forum.css": "Content/Themes/flatly/bootstrap-forum.scss",
                    "Content/Themes/darkly/bootstrap-forum.css": "Content/Themes/darkly/bootstrap-forum.scss",
                    "Content/Themes/cyborg/bootstrap-forum.css": "Content/Themes/cyborg/bootstrap-forum.scss",
                    "Content/Themes/cosmo/bootstrap-forum.css": "Content/Themes/cosmo/bootstrap-forum.scss",
                    "Content/Themes/cerulean/bootstrap-forum.css": "Content/Themes/cerulean/bootstrap-forum.scss"
                }
            }
        },

        postcss: {
            options: {
                map: false,
                processors: [
                    require("autoprefixer")({ overrideBrowserslist: "last 2 versions" })
                ]
            },
            installWizard: {
                src: "Content/InstallWizard.css"
            },
            themes: {
                src: "Content/Themes/**/bootstrap-forum.css"
            }

        },

        // CSS Minify
        cssmin: {
            fileUpload: {
                files: {
                    "Content/jquery.fileupload.comb.min.css": [
                        "Content/jQuery.FileUpload/jquery.fileupload-ui.css",
                        "Content/jQuery.FileUpload/jquery.fileupload.css"
                    ]
                }
            },
            other: {
                files: {
                    "Content/InstallWizard.min.css": "Content/InstallWizard.css",
                    "Content/forum.min.css": "Content/forum.css",
                    "Content/forum-admin.min.css": "Content/forum-admin.css"
                }
            },
            themes: {
                files: {
                    "Content/Themes/zephyr/bootstrap-forum.min.css": "Content/Themes/zephyr/bootstrap-forum.css",
                    "Content/Themes/yaf/bootstrap-forum.min.css": "Content/Themes/yaf/bootstrap-forum.css",
                    "Content/Themes/yeti/bootstrap-forum.min.css": "Content/Themes/yeti/bootstrap-forum.css",
                    "Content/Themes/vapor/bootstrap-forum.min.css": "Content/Themes/vapor/bootstrap-forum.css",
                    "Content/Themes/united/bootstrap-forum.min.css": "Content/Themes/united/bootstrap-forum.css",
                    "Content/Themes/superhero/bootstrap-forum.min.css": "Content/Themes/superhero/bootstrap-forum.css",
                    "Content/Themes/spacelab/bootstrap-forum.css": "Content/Themes/spacelab/bootstrap-forum.css",
                    "Content/Themes/solar/bootstrap-forum.min.css": "Content/Themes/solar/bootstrap-forum.css",
                    "Content/Themes/slate/bootstrap-forum.min.css": "Content/Themes/slate/bootstrap-forum.css",
                    "Content/Themes/sketchy/bootstrap-forum.min.css": "Content/Themes/sketchy/bootstrap-forum.css",
                    "Content/Themes/simplex/bootstrap-forum.min.css": "Content/Themes/simplex/bootstrap-forum.css",
                    "Content/Themes/sandstone/bootstrap-forum.min.css": "Content/Themes/sandstone/bootstrap-forum.css",
                    "Content/Themes/quartz/bootstrap-forum.min.css": "Content/Themes/quartz/bootstrap-forum.css",
                    "Content/Themes/pulse/bootstrap-forum.min.css": "Content/Themes/pulse/bootstrap-forum.css",
                    "Content/Themes/morph/bootstrap-forum.min.css": "Content/Themes/morph/bootstrap-forum.css",
                    "Content/Themes/minty/bootstrap-forum.min.css": "Content/Themes/minty/bootstrap-forum.css",
                    "Content/Themes/materia/bootstrap-forum.css": "Content/Themes/materia/bootstrap-forum.css",
                    "Content/Themes/lux/bootstrap-forum.min.css": "Content/Themes/lux/bootstrap-forum.css",
                    "Content/Themes/lumen/bootstrap-forum.min.css": "Content/Themes/lumen/bootstrap-forum.css",
                    "Content/Themes/litera/bootstrap-forum.min.css": "Content/Themes/litera/bootstrap-forum.css",
                    "Content/Themes/journal/bootstrap-forum.min.css": "Content/Themes/journal/bootstrap-forum.css",
                    "Content/Themes/flatly/bootstrap-forum.min.css": "Content/Themes/flatly/bootstrap-forum.css",
                    "Content/Themes/darkly/bootstrap-forum.min.css": "Content/Themes/darkly/bootstrap-forum.css",
                    "Content/Themes/cyborg/bootstrap-forum.min.css": "Content/Themes/cyborg/bootstrap-forum.css",
                    "Content/Themes/cosmo/bootstrap-forum.min.css": "Content/Themes/cosmo/bootstrap-forum.css",
                    "Content/Themes/cerulean/bootstrap-forum.min.css": "Content/Themes/cerulean/bootstrap-forum.css"
                }
            }
        }
    });

    // PLUGINS
    grunt.loadNpmTasks("grunt-contrib-sass");
    grunt.loadNpmTasks("grunt-postcss");
    grunt.loadNpmTasks("grunt-contrib-uglify");
    grunt.loadNpmTasks("grunt-contrib-cssmin");
    grunt.loadNpmTasks("grunt-contrib-watch");

    grunt.registerTask("watch",
        [
            "uglify", "postcss", "cssmin"
        ]);

    grunt.registerTask("default",
        [
            "uglify", "postcss", "cssmin"
        ]);

    grunt.registerTask("js",
        [
            "uglify"
        ]);

    grunt.registerTask("css",
        [
            "sass", "postcss", "cssmin"
        ]);
};
<commit_msg>Update Gruntfile.js<commit_after>/// <binding />
module.exports = function(grunt) {

    // CONFIGURATION
    grunt.initConfig({
        pkg: grunt.file.readJSON("package.json"),

        // Minimize JS
        uglify: {
            installWizard: {
                options: {
                    sourceMap: false,
                    output: { beautify: true },
                    mangle: false,
                    compress: false
                },
                src: [
                    "Scripts/jquery-3.6.0.js",
                    "Scripts/select2.js",
                    "Scripts/bootstrap.bundle.js",
                    "Scripts/forum/InstallWizard.js"
                ],
                dest: "Scripts/InstallWizard.comb.js"
            },

            fileUpload: {
                options: {
                    sourceMap: false,
                    output: { beautify: true },
                    mangle: false,
                    compress: false
                },
                src: [
                    "Scripts/jquery.FileUpload/vendor/jquery.ui.widget.js",
                    "Scripts/jquery.FileUpload/tmpl.js",
                    "Scripts/jquery.FileUpload/load-image.all.min.js",
                    "Scripts/jquery.FileUpload/canvas-to-blob.js",
                    "Scripts/jquery.FileUpload/jquery.iframe-transport.js",
                    "Scripts/jquery.FileUpload/jquery.fileupload.js",
                    "Scripts/jquery.FileUpload/jquery.fileupload-process.js",
                    "Scripts/jquery.FileUpload/jquery.fileupload-image.js",
                    "Scripts/jquery.FileUpload/jquery.fileupload-validate.js",
                    "Scripts/jquery.FileUpload/jquery.fileupload-ui.js"
                ],
                dest: "Scripts/jquery.fileupload.comb.js"
            },
            forumExtensions: {
                options: {
                    sourceMap: false,
                    output: { beautify: true },
                    mangle: false,
                    compress: false
                },
                src: [
                    "Scripts/moment-with-locales.js",
                    "Scripts/bootstrap.bundle.js",
                    "Scripts/bootbox.js",
                    "Scripts/bootstrap-notify.js",
                    "Scripts/jquery.bootstrap-touchspin.js",
                    "Scripts/select2.js",
                    "Scripts/bootstrap-tagsinput.js",
                    "Scripts/bootstrap-typeahead.js",
                    "Scripts/blueimp-gallery/blueimp-gallery.js",
                    "Scripts/blueimp-gallery/blueimp-gallery-indicator.js",
                    "Scripts/blueimp-gallery/jquery.blueimp-gallery.js",
                    "Scripts/jquery.hovercard.js",
                    "Scripts/prism.js",
                    "Scripts/tablesorter/jquery.tablesorter.combined.js",
                    "Scripts/tablesorter/extras/jquery.tablesorter.pager.js",
                    "Scripts/tablesorter/widgets/widget-reflow.js",
                    "Scripts/jsdifflib.js",
                    "Scripts/hammer.min.js",
                    "Scripts/forum/yaf.Utilities.js",
                    "Scripts/forum/yaf.MessageHistory.js",
                    "Scripts/forum/yaf.Albums.js",
                    "Scripts/forum/yaf.Attachments.js",
                    "Scripts/forum/yaf.Notify.js",
                    "Scripts/forum/yaf.SearchResults.js",
                    "Scripts/forum/yaf.SimilarTitles.js",
                    "Scripts/forum/yaf.Main.js",
                    "Scripts/forum/yaf.contextMenu.js"
                ],
                dest: "Scripts/jquery.ForumExtensions.js"
            },
            forumExtensionsDnn: {
                options: {
                    sourceMap: false,
                    output: { beautify: true },
                    mangle: false,
                    compress: false
                },
                src: [
                    "Scripts/moment-with-locales.js",
                    "Scripts/bootbox.js",
                    "Scripts/bootstrap-notify.js",
                    "Scripts/jquery.bootstrap-touchspin.js",
                    "Scripts/select2.js",
                    "Scripts/bootstrap-tagsinput.js",
                    "Scripts/bootstrap-typeahead.js",
                    "Scripts/blueimp-gallery/blueimp-gallery.js",
                    "Scripts/blueimp-gallery/blueimp-gallery-indicator.js",
                    "Scripts/blueimp-gallery/jquery.blueimp-gallery.js",
                    "Scripts/jquery.hovercard.js",
                    "Scripts/prism.js",
                    "Scripts/tablesorter/jquery.tablesorter.combined.js",
                    "Scripts/tablesorter/extras/jquery.tablesorter.pager.js",
                    "Scripts/tablesorter/widgets/widget-reflow.js",
                    "Scripts/jsdifflib.js",
                    "Scripts/hammer.min.js",
                    "Scripts/forum/yaf.Utilities.js",
                    "Scripts/forum/yaf.MessageHistory.js",
                    "Scripts/forum/yaf.Albums.js",
                    "Scripts/forum/yaf.Attachments.js",
                    "Scripts/forum/yaf.Notify.js",
                    "Scripts/forum/yaf.SearchResults.js",
                    "Scripts/forum/yaf.SimilarTitles.js",
                    "Scripts/forum/yaf.Main.js",
                    "Scripts/forum/yaf.contextMenu.js"
                ],
                dest: "Scripts/jquery.ForumExtensionsDnn.js"
            },
            forumAdminExtensions: {
                options: {
                    sourceMap: false,
                    output: { beautify: true },
                    mangle: false,
                    compress: false
                },
                src: [
                    "Scripts/moment-with-locales.js",
                    "Scripts/bootstrap.bundle.js",
                    "Scripts/bootbox.js",
                    "Scripts/bootstrap-datetimepicker.js",
                    "Scripts/bootstrap-notify.js",
                    "Scripts/jquery.bootstrap-touchspin.js",
                    "Scripts/select2.js",
                    "Scripts/blueimp-gallery/blueimp-gallery.js",
                    "Scripts/blueimp-gallery/jquery.blueimp-gallery.js",
                    "Scripts/jquery.blockUI.js",
                    "Scripts/jquery.hovercard.js",
                    "Scripts/prism.js",
                    "Scripts/hammer.min.js",
                    "Scripts/tablesorter/jquery.tablesorter.combined.js",
                    "Scripts/tablesorter/extras/jquery.tablesorter.pager.js",
                    "Scripts/tablesorter/widgets/widget-reflow.js",
                    "Scripts/forum/yaf.Utilities.js",
                    "Scripts/forum/yaf.Albums.js",
                    "Scripts/forum/yaf.Notify.js",
                    "Scripts/forum/yaf.Main.js",
                    "Scripts/forum/yaf.contextMenu.js"
                ],
                dest: "Scripts/jquery.ForumAdminExtensions.js"
            },
            forumAdminExtensionsDnn: {
                options: {
                    sourceMap: false,
                    output: { beautify: true },
                    mangle: false,
                    compress: false
                },
                src: [
                    "Scripts/moment-with-locales.js",
                    "Scripts/bootbox.js",
                    "Scripts/bootstrap-datetimepicker.js",
                    "Scripts/bootstrap-notify.js",
                    "Scripts/jquery.bootstrap-touchspin.js",
                    "Scripts/select2.js",
                    "Scripts/blueimp-gallery/blueimp-gallery.js",
                    "Scripts/blueimp-gallery/jquery.blueimp-gallery.js",
                    "Scripts/jquery.blockUI.js",
                    "Scripts/jquery.hovercard.js",
                    "Scripts/prism.js",
                    "Scripts/hammer.min.js",
                    "Scripts/tablesorter/jquery.tablesorter.combined.js",
                    "Scripts/tablesorter/extras/jquery.tablesorter.pager.js",
                    "Scripts/tablesorter/widgets/widget-reflow.js",
                    "Scripts/forum/yaf.Utilities.js",
                    "Scripts/forum/yaf.Albums.js",
                    "Scripts/forum/yaf.Notify.js",
                    "Scripts/forum/yaf.Main.js",
                    "Scripts/forum/yaf.contextMenu.js"
                ],
                dest: "Scripts/jquery.ForumAdminExtensionsDnn.js"
            },
            minify: {
                files: {
                    "Scripts/InstallWizard.comb.min.js": "Scripts/InstallWizard.comb.js",
                    "Scripts/jquery.fileupload.comb.min.js": "Scripts/jquery.fileupload.comb.js",
                    "Scripts/jquery.ForumExtensions.min.js": "Scripts/jquery.ForumExtensions.js",
                    "Scripts/jquery.ForumExtensionsDnn.min.js": "Scripts/jquery.ForumExtensionsDnn.js",
                    "Scripts/jquery.ForumAdminExtensions.min.js": "Scripts/jquery.ForumAdminExtensions.js",
                    "Scripts/jquery.ForumAdminExtensionsDnn.min.js": "Scripts/jquery.ForumAdminExtensionsDnn.js"

                }
            }
        },

        sass: {
            installWizard: {
                files: {
                    "Content/InstallWizard.css": "Content/InstallWizard.scss"
                }
            },
            forum: {
                files: {
                    "Content/forum.css": "Content/forum.scss"
                }
            },
            forumAdmin: {
                files: {
                    "Content/forum-admin.css": "Content/forum-admin.scss"
                }
            },
            bootstrap: {
                files: {
                    "Content/bootstrap/bootstrap.css": "Content/bootstrap/bootstrap.scss"
                }
            },
            themes: {
                files: {
                    "Content/Themes/zephyr/bootstrap-forum.css": "Content/Themes/zephyr/bootstrap-forum.scss",
                    "Content/Themes/yaf/bootstrap-forum.css": "Content/Themes/yaf/bootstrap-forum.scss",
                    "Content/Themes/yeti/bootstrap-forum.css": "Content/Themes/yeti/bootstrap-forum.scss",
                    "Content/Themes/vapor/bootstrap-forum.css": "Content/Themes/vapor/bootstrap-forum.scss",
                    "Content/Themes/united/bootstrap-forum.css": "Content/Themes/united/bootstrap-forum.scss",
                    "Content/Themes/superhero/bootstrap-forum.css": "Content/Themes/superhero/bootstrap-forum.scss",
                    "Content/Themes/spacelab/bootstrap-forum.css": "Content/Themes/spacelab/bootstrap-forum.scss",
                    "Content/Themes/solar/bootstrap-forum.css": "Content/Themes/solar/bootstrap-forum.scss",
                    "Content/Themes/slate/bootstrap-forum.css": "Content/Themes/slate/bootstrap-forum.scss",
                    "Content/Themes/sketchy/bootstrap-forum.css": "Content/Themes/sketchy/bootstrap-forum.scss",
                    "Content/Themes/simplex/bootstrap-forum.css": "Content/Themes/simplex/bootstrap-forum.scss",
                    "Content/Themes/sandstone/bootstrap-forum.css": "Content/Themes/sandstone/bootstrap-forum.scss",
                    "Content/Themes/quartz/bootstrap-forum.css": "Content/Themes/quartz/bootstrap-forum.scss",
                    "Content/Themes/pulse/bootstrap-forum.css": "Content/Themes/pulse/bootstrap-forum.scss",
                    "Content/Themes/morph/bootstrap-forum.css": "Content/Themes/morph/bootstrap-forum.scss",
                    "Content/Themes/minty/bootstrap-forum.css": "Content/Themes/minty/bootstrap-forum.scss",
                    "Content/Themes/materia/bootstrap-forum.css": "Content/Themes/materia/bootstrap-forum.scss",
                    "Content/Themes/lux/bootstrap-forum.css": "Content/Themes/lux/bootstrap-forum.scss",
                    "Content/Themes/lumen/bootstrap-forum.css": "Content/Themes/lumen/bootstrap-forum.scss",
                    "Content/Themes/litera/bootstrap-forum.css": "Content/Themes/litera/bootstrap-forum.scss",
                    "Content/Themes/journal/bootstrap-forum.css": "Content/Themes/journal/bootstrap-forum.scss",
                    "Content/Themes/flatly/bootstrap-forum.css": "Content/Themes/flatly/bootstrap-forum.scss",
                    "Content/Themes/darkly/bootstrap-forum.css": "Content/Themes/darkly/bootstrap-forum.scss",
                    "Content/Themes/cyborg/bootstrap-forum.css": "Content/Themes/cyborg/bootstrap-forum.scss",
                    "Content/Themes/cosmo/bootstrap-forum.css": "Content/Themes/cosmo/bootstrap-forum.scss",
                    "Content/Themes/cerulean/bootstrap-forum.css": "Content/Themes/cerulean/bootstrap-forum.scss"
                }
            }
        },

        postcss: {
            options: {
                map: false,
                processors: [
                    require("autoprefixer")({ overrideBrowserslist: "last 2 versions" })
                ]
            },
            installWizard: {
                src: "Content/InstallWizard.css"
            },
            themes: {
                src: "Content/Themes/**/bootstrap-forum.css"
            }

        },

        // CSS Minify
        cssmin: {
            fileUpload: {
                files: {
                    "Content/jquery.fileupload.comb.min.css": [
                        "Content/jQuery.FileUpload/jquery.fileupload-ui.css",
                        "Content/jQuery.FileUpload/jquery.fileupload.css"
                    ]
                }
            },
            other: {
                files: {
                    "Content/InstallWizard.min.css": "Content/InstallWizard.css",
                    "Content/forum.min.css": "Content/forum.css",
                    "Content/forum-admin.min.css": "Content/forum-admin.css"
                }
            },
            themes: {
                files: {
                    "Content/Themes/zephyr/bootstrap-forum.min.css": "Content/Themes/zephyr/bootstrap-forum.css",
                    "Content/Themes/yaf/bootstrap-forum.min.css": "Content/Themes/yaf/bootstrap-forum.css",
                    "Content/Themes/yeti/bootstrap-forum.min.css": "Content/Themes/yeti/bootstrap-forum.css",
                    "Content/Themes/vapor/bootstrap-forum.min.css": "Content/Themes/vapor/bootstrap-forum.css",
                    "Content/Themes/united/bootstrap-forum.min.css": "Content/Themes/united/bootstrap-forum.css",
                    "Content/Themes/superhero/bootstrap-forum.min.css": "Content/Themes/superhero/bootstrap-forum.css",
                    "Content/Themes/spacelab/bootstrap-forum.css": "Content/Themes/spacelab/bootstrap-forum.css",
                    "Content/Themes/solar/bootstrap-forum.min.css": "Content/Themes/solar/bootstrap-forum.css",
                    "Content/Themes/slate/bootstrap-forum.min.css": "Content/Themes/slate/bootstrap-forum.css",
                    "Content/Themes/sketchy/bootstrap-forum.min.css": "Content/Themes/sketchy/bootstrap-forum.css",
                    "Content/Themes/simplex/bootstrap-forum.min.css": "Content/Themes/simplex/bootstrap-forum.css",
                    "Content/Themes/sandstone/bootstrap-forum.min.css": "Content/Themes/sandstone/bootstrap-forum.css",
                    "Content/Themes/quartz/bootstrap-forum.min.css": "Content/Themes/quartz/bootstrap-forum.css",
                    "Content/Themes/pulse/bootstrap-forum.min.css": "Content/Themes/pulse/bootstrap-forum.css",
                    "Content/Themes/morph/bootstrap-forum.min.css": "Content/Themes/morph/bootstrap-forum.css",
                    "Content/Themes/minty/bootstrap-forum.min.css": "Content/Themes/minty/bootstrap-forum.css",
                    "Content/Themes/materia/bootstrap-forum.css": "Content/Themes/materia/bootstrap-forum.css",
                    "Content/Themes/lux/bootstrap-forum.min.css": "Content/Themes/lux/bootstrap-forum.css",
                    "Content/Themes/lumen/bootstrap-forum.min.css": "Content/Themes/lumen/bootstrap-forum.css",
                    "Content/Themes/litera/bootstrap-forum.min.css": "Content/Themes/litera/bootstrap-forum.css",
                    "Content/Themes/journal/bootstrap-forum.min.css": "Content/Themes/journal/bootstrap-forum.css",
                    "Content/Themes/flatly/bootstrap-forum.min.css": "Content/Themes/flatly/bootstrap-forum.css",
                    "Content/Themes/darkly/bootstrap-forum.min.css": "Content/Themes/darkly/bootstrap-forum.css",
                    "Content/Themes/cyborg/bootstrap-forum.min.css": "Content/Themes/cyborg/bootstrap-forum.css",
                    "Content/Themes/cosmo/bootstrap-forum.min.css": "Content/Themes/cosmo/bootstrap-forum.css",
                    "Content/Themes/cerulean/bootstrap-forum.min.css": "Content/Themes/cerulean/bootstrap-forum.css"
                }
            }
        }
    });

    // PLUGINS
    grunt.loadNpmTasks("grunt-contrib-sass");
    grunt.loadNpmTasks("grunt-postcss");
    grunt.loadNpmTasks("grunt-contrib-uglify");
    grunt.loadNpmTasks("grunt-contrib-cssmin");
    grunt.loadNpmTasks("grunt-contrib-watch");

    grunt.registerTask("watch",
        [
            "uglify", "sass", "postcss", "cssmin"
        ]);

    grunt.registerTask("default",
        [
            "uglify", "sass", "postcss", "cssmin"
        ]);

    grunt.registerTask("js",
        [
            "uglify"
        ]);

    grunt.registerTask("css",
        [
            "sass", "postcss", "cssmin"
        ]);
};
<|endoftext|>


<commit_before>/**
 * Created by Ursa on 16.11.2016.
 */

var webdriver = require('selenium-webdriver'),
    chrome = require('selenium-webdriver/chrome'),
    By = webdriver.By,
    until = webdriver.until,
    test = require('selenium-webdriver/testing');

test.describe('Task 3. Login admin panel', function() {
    var driver;

    test.before(function() {
        driver = new webdriver.Builder()
            .forBrowser('chrome')
            .build();
    });
    test.after(function() {
        driver.sleep('5000');  //Что бы успеть заметить конечное состояние
        driver.quit();
    });

    test.it('Открыть страницу авторизации', function() {
        driver.get('http://localhost/litecart/admin/');
        driver.findElement(By.name('username')).sendKeys('admin');  //.click().clear()
        driver.findElement(By.css('input[name="password"]')).sendKeys('admin');  //.click()
        driver.sleep('1000');  //Для визуальной отладки
        driver.findElement(By.name('login')).click();
        driver.wait(until.titleIs('My Store'), 1000); //Todo ожидать элемент
    });

});<commit_msg>Добавил ожидание менюшки , перевел элементы в переменные<commit_after>/**
 * Created by Ursa on 16.11.2016.
 */

var webdriver = require('selenium-webdriver'),
    chrome = require('selenium-webdriver/chrome'),
    By = webdriver.By,
    until = webdriver.until,
    test = require('selenium-webdriver/testing');

test.describe('Task 3. Login admin panel', function() {
    var driver;

    test.before(function() {
        driver = new webdriver.Builder()
            .forBrowser('chrome')
            .build();
    });
    test.after(function() {
        driver.sleep('5000');  //Что бы успеть заметить конечное состояние
        driver.quit();
    });

    test.it('Открыть страницу авторизации', function() {
        driver.get('http://localhost/litecart/admin/');
        var loginField = driver.findElement(By.name('username')),
            passField = driver.findElement(By.css('input[name="password"]')),
            submitButton = driver.findElement(By.name('login'));
        //Ввели логин
        loginField.click();
        loginField.clear();
        loginField.sendKeys('admin');
        //Ввели пароль
        passField.click();
        passField.clear();
        passField.sendKeys('admin');
        //Нажали кнопку вход
        submitButton.click();
        //
        driver.wait(driver.findElement(By.css('td#sidebar')).isDisplayed(), 10000);
    });

});<|endoftext|>