<commit_before>'use strict';
angular.module('formly.render')
.directive('formlyForm', function formlyForm() {
	return {
		restrict: 'AE',
		templateUrl: 'directives/formly-form.html',
		replace: true,
		scope: {
			fields: '=fields',
			options: '=options',
			result: '=result',
			formOnParentScope: '=name'
		},
		compile: function (scope, iElement, iAttrs, controller, transcludeFn) {
			return {
				post: function (scope, ele, attr, controller) {
					//Post gets called after angular has created the FormController
					//Now pass the FormController back up to the parent scope
					scope.formOnParentScope = scope[attr.name];
				}
			}
		},
		controller: function($scope, $element, $parse) {
			$scope.$watch('result', function(newValue) {
                angular.forEach($scope.fields, function(field, index) {
                    if (field.hideExpression) {
                        var getter = $parse(field.hideExpression);
                        field.hide = getter($scope.result);
                    }
                });
            }, true);
		}
	};
});<commit_msg>Fixing white space<commit_after>'use strict';
angular.module('formly.render')
.directive('formlyForm', function formlyForm() {
	return {
		restrict: 'AE',
		templateUrl: 'directives/formly-form.html',
		replace: true,
		scope: {
			fields: '=fields',
			options: '=options',
			result: '=result',
			formOnParentScope: '=name'
		},
		compile: function (scope, iElement, iAttrs, controller, transcludeFn) {
			return {
				post: function (scope, ele, attr, controller) {
					//Post gets called after angular has created the FormController
					//Now pass the FormController back up to the parent scope
					scope.formOnParentScope = scope[attr.name];
				}
			}
		},
		controller: function($scope, $element, $parse) {
			$scope.$watch('result', function(newValue) {
			angular.forEach($scope.fields, function(field, index) {
					if (field.hideExpression) {
						var getter = $parse(field.hideExpression);
						field.hide = getter($scope.result);
					}
				});
			}, true);
		}
	};
});<|endoftext|>


<commit_before>/*
 * Waltz - Enterprise Architecture
 * Copyright (C) 2016, 2017 Waltz open source project
 * See README.md for more information
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
import HomePage from './pages/home/person-home';
import PersonPage from './pages/view/person-view';
import {CORE_API} from "../common/services/core-api-utils";

function personEmployeeIdBouncer($state, $stateParams, serviceBroker) {
    const empId = $stateParams.empId;
    serviceBroker
        .loadViewData(
            CORE_API.PersonStore.getByEmployeeId,
            [ empId ])
        .then(r => r.data)
        .then(person => {
            if (person) {
                return $state.go("main.person.id", {id: person.id});
            } else {
                console.log(`Cannot find measure corresponding person: ${empId}`);
            }
        });
}

personEmployeeIdBouncer.$inject = [
    "$state",
    "$stateParams",
    "ServiceBroker"
];

// --- ROUTES ---

const personHome = {
    url: 'person',
    views: {'content@': HomePage }
};

const personViewByEmployeeId = {
    url: '/:empId',
    views: {'content@': PersonPage },
    resolve: {
        bouncer: personEmployeeIdBouncer
    }
};

const personViewByPersonId = {
    url: '/id/:id',
    views: {'content@': PersonPage },
};

// --- SETUP ---

function setup($stateProvider) {

    $stateProvider
        .state('main.person', personHome)
        .state('main.person.view', personViewByEmployeeId)
        .state('main.person.id', personViewByPersonId);
}

setup.$inject = ['$stateProvider'];

export default setup;<commit_msg>Update routes.js<commit_after>/*
 * Waltz - Enterprise Architecture
 * Copyright (C) 2016, 2017 Waltz open source project
 * See README.md for more information
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
import HomePage from './pages/home/person-home';
import PersonPage from './pages/view/person-view';
import {CORE_API} from "../common/services/core-api-utils";

function personEmployeeIdBouncer($state, $stateParams, serviceBroker) {
    const empId = $stateParams.empId;
    serviceBroker
        .loadViewData(
            CORE_API.PersonStore.getByEmployeeId,
            [ empId ])
        .then(r => r.data)
        .then(person => {
            if (person) {
                return $state.go("main.person.id", {id: person.id});
            } else {
                console.log(`Cannot find corresponding person: ${empId}`);
            }
        });
}

personEmployeeIdBouncer.$inject = [
    "$state",
    "$stateParams",
    "ServiceBroker"
];

// --- ROUTES ---

const personHome = {
    url: 'person',
    views: {'content@': HomePage }
};

const personViewByEmployeeId = {
    url: '/:empId',
    views: {'content@': PersonPage },
    resolve: {
        bouncer: personEmployeeIdBouncer
    }
};

const personViewByPersonId = {
    url: '/id/:id',
    views: {'content@': PersonPage },
};

// --- SETUP ---

function setup($stateProvider) {

    $stateProvider
        .state('main.person', personHome)
        .state('main.person.view', personViewByEmployeeId)
        .state('main.person.id', personViewByPersonId);
}

setup.$inject = ['$stateProvider'];

export default setup;
<|endoftext|>


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

/*!
 * clockdrift.js by Rich Trott, (c) 2012 Regents of University of California, MIT License
 */

var http = require("http"),
    https = require("https"),
    url = require("url"),
    before,
    tolerance,
    i,
    argvLength = process.argv.length;

function usage( errorMessage ) {
    if (errorMessage) {
        console.log("\nError: " + errorMessage + ".\n");
    }
    console.log("Usage: clockdrift.js tolerance url1 [url2 ...]");
    console.log("    tolerance: number of seconds a timestamp can be off without being reported");
    console.log("    url1 ...: URLs to inspect");
    console.log("\nExample: clockdrift.js 15 http://tycho.usno.navy.mil/ http://www.example.com/");
}

function checkTime( host ) {

    return function ( res ) {

        var clockTimestamp,
            diff;

        if (typeof res.headers.date !== "string") {
            console.log("No date header returned by " + host + ".");
            return;
        }

        clockTimestamp = new Date(res.headers.date).getTime();
        if (isNaN(clockTimestamp)) {
            console.log("Could not convert date header from " + host + " to timestamp. (Malformed?)");
            return;
        }

        diff = Math.round((clockTimestamp - before) / 1000);

        if (Math.abs(diff) > tolerance) {
            console.log("Clock at " + host + " is " + diff + "s off from local clock.");
        }
    };
}

function dispatchRequest( targetUrl ) {
    var reqObj = false,
        options,
        req;

    options = url.parse( targetUrl );
    options.method = "HEAD";

    switch (options.protocol) {
        case "http:":
            reqObj = http;
            break;
        case "https:":
            reqObj = https;
            break;
    }

    if ( reqObj ) {
        req = reqObj.request( options, checkTime( options.host ));
        req.on("error", function(e) {
            console.log("Error on " + options.host + ": " + e.message);
        });
        req.on("socket", function (socket) {
            socket.setTimeout(1000);
            socket.on("timeout", function() {
                console.log("Error: Timeout. Hanging up.");
                req.abort();
            });
        });
        req.end();
    } else {
        console.log("Could not determine protocol: " + options.protocol);
    }
}

if (argvLength < 4) {
    usage();
    return;
}

tolerance = parseInt(process.argv[2], 10);
if (isNaN(tolerance)) {
    usage("tolerance must be a number");
    return;
}

before = new Date().getTime();

for (i = 3; i<argvLength; i++) {
    dispatchRequest(process.argv[i]);
}<commit_msg>Use stderr for errors<commit_after>#!/usr/bin/env node

/*!
 * clockdrift.js by Rich Trott, (c) 2012 Regents of University of California, MIT License
 */

var http = require("http"),
    https = require("https"),
    url = require("url"),
    before,
    tolerance,
    i,
    argvLength = process.argv.length;

function usage( errorMessage ) {
    if (errorMessage) {
        console.error("\nError: " + errorMessage + ".\n");
    }
    console.error("Usage: clockdrift.js tolerance url1 [url2 ...]");
    console.error("    tolerance: number of seconds a timestamp can be off without being reported");
    console.error("    url1 ...: URLs to inspect");
    console.error("\nExample: clockdrift.js 15 http://tycho.usno.navy.mil/ http://www.example.com/");
}

function checkTime( host ) {

    return function ( res ) {

        var clockTimestamp,
            diff;

        if (typeof res.headers.date !== "string") {
            console.error("No date header returned by " + host + ".");
            return;
        }

        clockTimestamp = new Date(res.headers.date).getTime();
        if (isNaN(clockTimestamp)) {
            console.error("Could not convert date header from " + host + " to timestamp. (Malformed?)");
            return;
        }

        diff = Math.round((clockTimestamp - before) / 1000);

        if (Math.abs(diff) > tolerance) {
            console.log("Clock at " + host + " is " + diff + "s off from local clock.");
        }
    };
}

function dispatchRequest( targetUrl ) {
    var reqObj = false,
        options,
        req;

    options = url.parse( targetUrl );
    options.method = "HEAD";

    switch (options.protocol) {
        case "http:":
            reqObj = http;
            break;
        case "https:":
            reqObj = https;
            break;
    }

    if ( reqObj ) {
        req = reqObj.request( options, checkTime( options.host ));
        req.on("error", function(e) {
            console.error("Error on " + options.host + ": " + e.message);
        });
        req.on("socket", function (socket) {
            socket.setTimeout(1000);
            socket.on("timeout", function() {
                console.error("Socket timeout; hanging up.");
                req.abort();
            });
        });
        req.end();
    } else {
        console.error("Could not determine protocol: " + options.protocol);
    }
}

if (argvLength < 4) {
    usage();
    return;
}

tolerance = parseInt(process.argv[2], 10);
if (isNaN(tolerance)) {
    usage("tolerance must be a number");
    return;
}

before = new Date().getTime();

for (i = 3; i<argvLength; i++) {
    dispatchRequest(process.argv[i]);
}<|endoftext|>


<commit_before>'use strict';

/**
 * @ngdoc function
 * @name loopbackApp.controller:UsersCtrl
 * @description
 * # UsersCtrl
 * Controller of the loopbackApp
 */
angular.module('loopbackApp')
  .config(function ($stateProvider) {
    $stateProvider.state('app.users', {
      abstract: true,
      url: '/users',
      templateUrl: 'views/users/main.html',
      controller: 'UsersCtrl'
    }).state('app.users.profile', {
      url: '/users/profile',
      templateUrl: 'views/users/profile.html',
      controller: 'UsersCtrl'
    });
  })
  .controller('UsersCtrl', function ($scope, User, SweetAlert) {

    $scope.user = User.getCurrent(function(user) {
      console.log(user);
    }, function(err) {
      console.log(err);
    });

    $scope.formFields = [
      {
        key: 'username',
        type: 'text',
        label: 'Username',
        required: true
      },
      {
        key: 'email',
        type: 'email',
        label: 'E-mail',
        required: true
      },
      {
        key: 'firstName',
        type: 'text',
        label: 'First name',
        required: true
      },
      {
        key: 'lastName',
        type: 'text',
        label: 'Last name',
        required: true
      },
    ];

    $scope.formOptions = {
      uniqueFormId: true,
      hideSubmit: false,
      submitCopy: 'Save'
    };

    $scope.onSubmit = function () {
      SweetAlert.swal({
        title: 'Sorry!',
        text: 'Updating your profile is not yet implemented :(',
        type: 'warning',
        showCancelButton: false,
        confirmButtonColor: '#DD6B55'
      });

//      User.upsert($scope.user, function () {
//        toasty.pop.success({title: 'Profile saved', msg: 'Enjoy the new you!', sound: false});
////        $state.go('^.list');
//      }, function (err) {
//        console.log(err);
//      });
    };
  });
<commit_msg>Fix router url<commit_after>'use strict';

/**
 * @ngdoc function
 * @name loopbackApp.controller:UsersCtrl
 * @description
 * # UsersCtrl
 * Controller of the loopbackApp
 */
angular.module('loopbackApp')
  .config(function ($stateProvider) {
    $stateProvider.state('app.users', {
      abstract: true,
      url: '/users',
      templateUrl: 'views/users/main.html',
      controller: 'UsersCtrl'
    }).state('app.users.profile', {
      url: '/profile',
      templateUrl: 'views/users/profile.html',
      controller: 'UsersCtrl'
    });
  })
  .controller('UsersCtrl', function ($scope, User, SweetAlert) {

    $scope.user = User.getCurrent(function(user) {
      console.log(user);
    }, function(err) {
      console.log(err);
    });

    $scope.formFields = [
      {
        key: 'username',
        type: 'text',
        label: 'Username',
        required: true
      },
      {
        key: 'email',
        type: 'email',
        label: 'E-mail',
        required: true
      },
      {
        key: 'firstName',
        type: 'text',
        label: 'First name',
        required: true
      },
      {
        key: 'lastName',
        type: 'text',
        label: 'Last name',
        required: true
      },
    ];

    $scope.formOptions = {
      uniqueFormId: true,
      hideSubmit: false,
      submitCopy: 'Save'
    };

    $scope.onSubmit = function () {
      SweetAlert.swal({
        title: 'Sorry!',
        text: 'Updating your profile is not yet implemented :(',
        type: 'warning',
        showCancelButton: false,
        confirmButtonColor: '#DD6B55'
      });

//      User.upsert($scope.user, function () {
//        toasty.pop.success({title: 'Profile saved', msg: 'Enjoy the new you!', sound: false});
////        $state.go('^.list');
//      }, function (err) {
//        console.log(err);
//      });
    };
  });
<|endoftext|>


<commit_before>import React, {Component} from 'react';

import RaisedButton from 'src/RaisedButton';
import Popup from 'src/Popup';
import List from 'src/List';
import Theme from 'src/Theme';
import Widget from 'src/Widget';
import WidgetHeader from 'src/WidgetHeader';

import PropTypeDescTable from '../PropTypeDescTable';
import PopupDoc from 'assets/propTypes/PopupBody.json';

import 'sass/containers/app/modules/popup/PopupExamples.scss';

export default class PopupExamples extends Component {

    constructor(props) {

        super(props);

        this.state = {
            popupVisible1: false,
            popupVisible2: false,
            popupVisible3: false,
            popupVisible4: false,
            popupVisible5: false,
            popupVisible6: false,
            popupVisible7: false,
            popupVisible8: false,
            popupVisible9: false,
            popupVisible10: false,
            popupVisible11: false,
            popupVisible12: false,
            popupVisible13: false,
            popupVisible14: false,
            popupVisible15: false,
            triggerEl1: null,
            triggerEl2: null,
            triggerEl3: null,
            triggerEl4: null,
            triggerEl5: null,
            triggerEl6: null,
            triggerEl7: null,
            triggerEl8: null,
            triggerEl9: null,
            triggerEl10: null,
            triggerEl11: null,
            triggerEl12: null,
            triggerEl13: null,
            triggerEl14: null,
            triggerEl15: null
        };

        this.togglePopup = this::this.togglePopup;
        this.closePopup = this::this.closePopup;

    }

    togglePopup(e, id) {
        this.setState({
            [`popupVisible${id}`]: !this.state[`popupVisible${id}`],
            [`triggerEl${id}`]: e.target
        });
    }

    closePopup(id) {
        this.setState({
            [`popupVisible${id}`]: false
        });
    }

    render() {

        const {
                popupVisible1, popupVisible3, popupVisible4, popupVisible5, popupVisible6,
                popupVisible7, popupVisible8, popupVisible9, popupVisible10, popupVisible11, popupVisible12,
                popupVisible13, popupVisible14, popupVisible15,
                triggerEl1, triggerEl3, triggerEl4, triggerEl5, triggerEl6,
                triggerEl7, triggerEl8, triggerEl9, triggerEl10, triggerEl11, triggerEl12
                , triggerEl13, triggerEl14, triggerEl15
            } = this.state,
            items = [{
                iconCls: 'fa fa-facebook',
                text: 'Facebook'
            }, {
                iconCls: 'fa fa-twitter',
                text: 'Twitter'
            }, {
                iconCls: 'fa fa-google-plus',
                text: 'Google+'
            }];

        return (

Popup

                    A Popup can be used as an alternative to a Drop Down Menu that can contain elements
                    inside.

Examples

                <Widget>

                    <WidgetHeader className="example-header"
                                  title="Basic"/>

Popup simple example.

                                <RaisedButton className="trigger-button"
                                              value="Toggle Popup"
                                              onTouchTap={(e) => {
                                                  this.togglePopup(e, 1);
                                              }}/>

                                <Popup theme={Theme.PRIMARY}
                                       visible={popupVisible1}
                                       triggerEl={triggerEl1}
                                       isAutoClose={false}
                                       onRequestClose={() => {
                                           this.closePopup(1);
                                       }}>

                                        Menu

                                </Popup>

                </Widget>

                <Widget>

                    <WidgetHeader className="example-header"
                                  title="Without triangle"/>

                                    Set hasTriangle to false,the popover will have
                                    no triangle on the top of the DOM element.

                                <RaisedButton className="trigger-button"
                                              value="Toggle Popup"
                                              onTouchTap={(e) => {
                                                  this.togglePopup(e, 3);
                                              }}/>

                                <Popup visible={popupVisible3}
                                       triggerEl={triggerEl3}
                                       hasTriangle={false}
                                       onRequestClose={() => {
                                           this.closePopup(3);
                                       }}>
                                    <List items={items}/>
                                </Popup>

                </Widget>

                <Widget>

                    <WidgetHeader className="example-header"
                                  title="With value"/>

                                    Set the value property to show different position of Popup.

                                        <RaisedButton className="trigger-position-button"
                                                      value="Top Left"
                                                      onTouchTap={(e) => {
                                                          this.togglePopup(e, 7);
                                                      }}/>
                                        <RaisedButton className="trigger-position-button"
                                                      value="Top"
                                                      onTouchTap={(e) => {
                                                          this.togglePopup(e, 8);
                                                      }}/>
                                        <RaisedButton className="trigger-position-button"
                                                      value="Top right"
                                                      onTouchTap={(e) => {
                                                          this.togglePopup(e, 9);
                                                      }}/>

                                        <RaisedButton className="trigger-position-button"
                                                      value="Right Top"
                                                      onTouchTap={(e) => {
                                                          this.togglePopup(e, 13);
                                                      }}/>
                                        <RaisedButton className="trigger-position-button"
                                                      value="Right"
                                                      onTouchTap={(e) => {
                                                          this.togglePopup(e, 14);
                                                      }}/>
                                        <RaisedButton className="trigger-position-button"
                                                      value="Right Bottom"
                                                      onTouchTap={(e) => {
                                                          this.togglePopup(e, 15);
                                                      }}/>

                                        <RaisedButton className="trigger-position-button"
                                                      value="Bottom Left"
                                                      onTouchTap={(e) => {
                                                          this.togglePopup(e, 4);
                                                      }}/>
                                        <RaisedButton className="trigger-position-button"
                                                      value="Bottom"
                                                      onTouchTap={(e) => {
                                                          this.togglePopup(e, 5);
                                                      }}/>
                                        <RaisedButton className="trigger-position-button"
                                                      value="Bottom Right"
                                                      onTouchTap={(e) => {
                                                          this.togglePopup(e, 6);
                                                      }}/>

                                        <RaisedButton className="trigger-position-button"
                                                      value="Left Top"
                                                      onTouchTap={(e) => {
                                                          this.togglePopup(e, 10);
                                                      }}/>
                                        <RaisedButton className="trigger-position-button"
                                                      value="Left"
                                                      onTouchTap={(e) => {
                                                          this.togglePopup(e, 11);
                                                      }}/>
                                        <RaisedButton className="trigger-position-button"
                                                      value="Left Bottom"
                                                      onTouchTap={(e) => {
                                                          this.togglePopup(e, 12);
                                                      }}/>

                                <Popup visible={popupVisible4}
                                       triggerEl={triggerEl4}
                                       position={Popup.Position.BOTTOM_LEFT}
                                       onRequestClose={() => {
                                           this.closePopup(4);
                                       }}>
                                    <List items={items}/>
                                </Popup>
                                <Popup visible={popupVisible5}
                                       triggerEl={triggerEl5}
                                       position={Popup.Position.BOTTOM}
                                       onRequestClose={() => {
                                           this.closePopup(5);
                                       }}>
                                    <List items={items}/>
                                </Popup>
                                <Popup visible={popupVisible6}
                                       triggerEl={triggerEl6}
                                       position={Popup.Position.BOTTOM_RIGHT}
                                       onRequestClose={() => {
                                           this.closePopup(6);
                                       }}>
                                    <List items={items}/>
                                </Popup>

                                <Popup visible={popupVisible7}
                                       triggerEl={triggerEl7}
                                       position={Popup.Position.TOP_LEFT}
                                       onRequestClose={() => {
                                           this.closePopup(7);
                                       }}>
                                    <List items={items}/>
                                </Popup>
                                <Popup visible={popupVisible8}
                                       triggerEl={triggerEl8}
                                       position={Popup.Position.TOP}
                                       onRequestClose={() => {
                                           this.closePopup(8);
                                       }}>
                                    <List items={items}/>
                                </Popup>
                                <Popup visible={popupVisible9}
                                       triggerEl={triggerEl9}
                                       position={Popup.Position.TOP_RIGHT}
                                       onRequestClose={() => {
                                           this.closePopup(9);
                                       }}>
                                    <List items={items}/>
                                </Popup>

                                <Popup visible={popupVisible10}
                                       triggerEl={triggerEl10}
                                       position={Popup.Position.LEFT_TOP}
                                       onRequestClose={() => {
                                           this.closePopup(10);
                                       }}>
                                    <List items={items}/>
                                </Popup>
                                <Popup visible={popupVisible11}
                                       triggerEl={triggerEl11}
                                       position={Popup.Position.LEFT}
                                       onRequestClose={() => {
                                           this.closePopup(11);
                                       }}>
                                    <List items={items}/>
                                </Popup>
                                <Popup visible={popupVisible12}
                                       triggerEl={triggerEl12}
                                       position={Popup.Position.LEFT_BOTTOM}
                                       onRequestClose={() => {
                                           this.closePopup(12);
                                       }}>
                                    <List items={items}/>
                                </Popup>

                                <Popup visible={popupVisible13}
                                       triggerEl={triggerEl13}
                                       position={Popup.Position.RIGHT_TOP}
                                       onRequestClose={() => {
                                           this.closePopup(13);
                                       }}>
                                    <List items={items}/>
                                </Popup>
                                <Popup visible={popupVisible14}
                                       triggerEl={triggerEl14}
                                       position={Popup.Position.RIGHT}
                                       onRequestClose={() => {
                                           this.closePopup(14);
                                       }}>
                                    <List items={items}/>
                                </Popup>
                                <Popup visible={popupVisible15}
                                       triggerEl={triggerEl15}
                                       position={Popup.Position.RIGHT_BOTTOM}
                                       onRequestClose={() => {
                                           this.closePopup(15);
                                       }}>
                                    <List items={items}/>
                                </Popup>

                </Widget>

Properties

                <PropTypeDescTable data={PopupDoc}/>

        );
    }
};<commit_msg>update Popup examples<commit_after>import React, {Component} from 'react';

import RaisedButton from 'src/RaisedButton';
import Popup from 'src/Popup';
import List from 'src/List';
import Theme from 'src/Theme';
import Widget from 'src/Widget';
import WidgetHeader from 'src/WidgetHeader';

import PropTypeDescTable from '../PropTypeDescTable';
import PopupDoc from 'assets/propTypes/PopupBody.json';

import 'sass/containers/app/modules/popup/PopupExamples.scss';

export default class PopupExamples extends Component {

    constructor(props) {

        super(props);

        this.state = {
            popupVisible1: false,
            popupVisible2: false,
            popupVisible3: false,
            popupVisible4: false,
            popupVisible5: false,
            popupVisible6: false,
            popupVisible7: false,
            popupVisible8: false,
            popupVisible9: false,
            popupVisible10: false,
            popupVisible11: false,
            popupVisible12: false,
            popupVisible13: false,
            popupVisible14: false,
            popupVisible15: false,
            triggerEl1: null,
            triggerEl2: null,
            triggerEl3: null,
            triggerEl4: null,
            triggerEl5: null,
            triggerEl6: null,
            triggerEl7: null,
            triggerEl8: null,
            triggerEl9: null,
            triggerEl10: null,
            triggerEl11: null,
            triggerEl12: null,
            triggerEl13: null,
            triggerEl14: null,
            triggerEl15: null
        };

        this.togglePopup = this::this.togglePopup;
        this.closePopup = this::this.closePopup;

    }

    togglePopup(e, id) {
        this.setState({
            [`popupVisible${id}`]: !this.state[`popupVisible${id}`],
            [`triggerEl${id}`]: e.target
        });
    }

    closePopup(id) {
        this.setState({
            [`popupVisible${id}`]: false
        });
    }

    render() {

        const {
                popupVisible1, popupVisible3, popupVisible4, popupVisible5, popupVisible6,
                popupVisible7, popupVisible8, popupVisible9, popupVisible10, popupVisible11, popupVisible12,
                popupVisible13, popupVisible14, popupVisible15,
                triggerEl1, triggerEl3, triggerEl4, triggerEl5, triggerEl6,
                triggerEl7, triggerEl8, triggerEl9, triggerEl10, triggerEl11, triggerEl12
                , triggerEl13, triggerEl14, triggerEl15
            } = this.state,
            items = [{
                iconCls: 'fa fa-facebook',
                text: 'Facebook'
            }, {
                iconCls: 'fa fa-twitter',
                text: 'Twitter'
            }, {
                iconCls: 'fa fa-google-plus',
                text: 'Google+'
            }];

        return (

Popup

                    A Popup can be used as an alternative to a Drop Down Menu that can contain elements
                    inside.

Examples

                <Widget>

                    <WidgetHeader className="example-header"
                                  title="Basic"/>

Popup simple example.

                                <RaisedButton className="trigger-button"
                                              value="Toggle Popup"
                                              onTouchTap={(e) => {
                                                  this.togglePopup(e, 1);
                                              }}/>

                                <Popup theme={Theme.PRIMARY}
                                       visible={popupVisible1}
                                       triggerEl={triggerEl1}
                                       onRequestClose={() => {
                                           this.closePopup(1);
                                       }}>

                                        Menu

                                </Popup>

                </Widget>

                <Widget>

                    <WidgetHeader className="example-header"
                                  title="Without triangle"/>

                                    Set hasTriangle to false,the popover will have
                                    no triangle on the top of the DOM element.

                                <RaisedButton className="trigger-button"
                                              value="Toggle Popup"
                                              onTouchTap={(e) => {
                                                  this.togglePopup(e, 3);
                                              }}/>

                                <Popup visible={popupVisible3}
                                       triggerEl={triggerEl3}
                                       hasTriangle={false}
                                       onRequestClose={() => {
                                           this.closePopup(3);
                                       }}>
                                    <List items={items}/>
                                </Popup>

                </Widget>

                <Widget>

                    <WidgetHeader className="example-header"
                                  title="With value"/>

                                    Set the value property to show different position of Popup.

                                        <RaisedButton className="trigger-position-button"
                                                      value="Top Left"
                                                      onTouchTap={(e) => {
                                                          this.togglePopup(e, 7);
                                                      }}/>
                                        <RaisedButton className="trigger-position-button"
                                                      value="Top"
                                                      onTouchTap={(e) => {
                                                          this.togglePopup(e, 8);
                                                      }}/>
                                        <RaisedButton className="trigger-position-button"
                                                      value="Top right"
                                                      onTouchTap={(e) => {
                                                          this.togglePopup(e, 9);
                                                      }}/>

                                        <RaisedButton className="trigger-position-button"
                                                      value="Right Top"
                                                      onTouchTap={(e) => {
                                                          this.togglePopup(e, 13);
                                                      }}/>
                                        <RaisedButton className="trigger-position-button"
                                                      value="Right"
                                                      onTouchTap={(e) => {
                                                          this.togglePopup(e, 14);
                                                      }}/>
                                        <RaisedButton className="trigger-position-button"
                                                      value="Right Bottom"
                                                      onTouchTap={(e) => {
                                                          this.togglePopup(e, 15);
                                                      }}/>

                                        <RaisedButton className="trigger-position-button"
                                                      value="Bottom Left"
                                                      onTouchTap={(e) => {
                                                          this.togglePopup(e, 4);
                                                      }}/>
                                        <RaisedButton className="trigger-position-button"
                                                      value="Bottom"
                                                      onTouchTap={(e) => {
                                                          this.togglePopup(e, 5);
                                                      }}/>
                                        <RaisedButton className="trigger-position-button"
                                                      value="Bottom Right"
                                                      onTouchTap={(e) => {
                                                          this.togglePopup(e, 6);
                                                      }}/>

                                        <RaisedButton className="trigger-position-button"
                                                      value="Left Top"
                                                      onTouchTap={(e) => {
                                                          this.togglePopup(e, 10);
                                                      }}/>
                                        <RaisedButton className="trigger-position-button"
                                                      value="Left"
                                                      onTouchTap={(e) => {
                                                          this.togglePopup(e, 11);
                                                      }}/>
                                        <RaisedButton className="trigger-position-button"
                                                      value="Left Bottom"
                                                      onTouchTap={(e) => {
                                                          this.togglePopup(e, 12);
                                                      }}/>

                                <Popup visible={popupVisible4}
                                       triggerEl={triggerEl4}
                                       position={Popup.Position.BOTTOM_LEFT}
                                       onRequestClose={() => {
                                           this.closePopup(4);
                                       }}>
                                    <List items={items}/>
                                </Popup>
                                <Popup visible={popupVisible5}
                                       triggerEl={triggerEl5}
                                       position={Popup.Position.BOTTOM}
                                       onRequestClose={() => {
                                           this.closePopup(5);
                                       }}>
                                    <List items={items}/>
                                </Popup>
                                <Popup visible={popupVisible6}
                                       triggerEl={triggerEl6}
                                       position={Popup.Position.BOTTOM_RIGHT}
                                       onRequestClose={() => {
                                           this.closePopup(6);
                                       }}>
                                    <List items={items}/>
                                </Popup>

                                <Popup visible={popupVisible7}
                                       triggerEl={triggerEl7}
                                       position={Popup.Position.TOP_LEFT}
                                       onRequestClose={() => {
                                           this.closePopup(7);
                                       }}>
                                    <List items={items}/>
                                </Popup>
                                <Popup visible={popupVisible8}
                                       triggerEl={triggerEl8}
                                       position={Popup.Position.TOP}
                                       onRequestClose={() => {
                                           this.closePopup(8);
                                       }}>
                                    <List items={items}/>
                                </Popup>
                                <Popup visible={popupVisible9}
                                       triggerEl={triggerEl9}
                                       position={Popup.Position.TOP_RIGHT}
                                       onRequestClose={() => {
                                           this.closePopup(9);
                                       }}>
                                    <List items={items}/>
                                </Popup>

                                <Popup visible={popupVisible10}
                                       triggerEl={triggerEl10}
                                       position={Popup.Position.LEFT_TOP}
                                       onRequestClose={() => {
                                           this.closePopup(10);
                                       }}>
                                    <List items={items}/>
                                </Popup>
                                <Popup visible={popupVisible11}
                                       triggerEl={triggerEl11}
                                       position={Popup.Position.LEFT}
                                       onRequestClose={() => {
                                           this.closePopup(11);
                                       }}>
                                    <List items={items}/>
                                </Popup>
                                <Popup visible={popupVisible12}
                                       triggerEl={triggerEl12}
                                       position={Popup.Position.LEFT_BOTTOM}
                                       onRequestClose={() => {
                                           this.closePopup(12);
                                       }}>
                                    <List items={items}/>
                                </Popup>

                                <Popup visible={popupVisible13}
                                       triggerEl={triggerEl13}
                                       position={Popup.Position.RIGHT_TOP}
                                       onRequestClose={() => {
                                           this.closePopup(13);
                                       }}>
                                    <List items={items}/>
                                </Popup>
                                <Popup visible={popupVisible14}
                                       triggerEl={triggerEl14}
                                       position={Popup.Position.RIGHT}
                                       onRequestClose={() => {
                                           this.closePopup(14);
                                       }}>
                                    <List items={items}/>
                                </Popup>
                                <Popup visible={popupVisible15}
                                       triggerEl={triggerEl15}
                                       position={Popup.Position.RIGHT_BOTTOM}
                                       onRequestClose={() => {
                                           this.closePopup(15);
                                       }}>
                                    <List items={items}/>
                                </Popup>

                </Widget>

Properties

                <PropTypeDescTable data={PopupDoc}/>

        );
    }
};<|endoftext|>


<commit_before>/*
 * Copyright (C) 2018 con terra GmbH (info@conterra.de)
 *
 * 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.
 */
import ct_when from "ct/_when";
import ServiceResolver from "apprt/ServiceResolver";
import Promise from "apprt-core/Promise";
import QueryTask from "esri/tasks/QueryTask";
import Query from "esri/tasks/support/Query";

class MetadataAnalyzer {
    activate(componentContext) {
        let serviceResolver = this.serviceResolver = new ServiceResolver();
        let bundleCtx = componentContext.getBundleContext();
        serviceResolver.setBundleCtx(bundleCtx);
    }

    getFields(store) {
        return new Promise((resolve) => {
            try {
                let metadata = store.getMetadata();
                ct_when(metadata, (metadata) => {
                    let fields = metadata.fields;
                    let storeData = [];
                    fields.forEach((field) => {
                        let codedValues = [];
                        let codedValueString = "";
                        if (field.domain && field.domain.codedValues) {
                            codedValues = field.domain.codedValues;
                            codedValueString = "[CV]";
                        }
                        if (field.type !== "geometry") {
                            storeData.push({
                                id: field.name,
                                text: field.title + " (" + field.type + ") " + codedValueString,
                                type: field.type,
                                codedValues: codedValues
                            });
                        }
                    });
                    if (this._queryBuilderProperties.enableDistinctValues) {
                        this.getDistinctValues(store, storeData).then((storeData) => {
                            resolve(storeData);
                        });
                    } else {
                        resolve(storeData);
                    }
                }, this);
            }
            catch (e) {
                this._logService.error({
                    id: 0,
                    message: e
                });
            }
        });
    }

    getDistinctValues(store, storeData) {
        let metadata = store.getMetadata();
        return ct_when(metadata, (metadata) => {
            let supportsDistincts = metadata.advancedQueryCapabilities && metadata.advancedQueryCapabilities.supportsDistinct;
            if (supportsDistincts) {
                let promises = storeData.map((data) => {
                    return new Promise((resolve) => {
                        let queryTask = new QueryTask({
                            url: store.target
                        });
                        let query = new Query();
                        query.where = "1=1";
                        query.outFields = [data.id];
                        query.orderByFields = [data.id];
                        query.returnGeometry = false;
                        query.returnDistinctValues = true;
                        queryTask.execute(query).then((result) => {
                            let distinctValues = [];
                            result.features.forEach((feature) => {
                                let value = feature.attributes[data.id];
                                if (value !== "") {
                                    distinctValues.push(value);
                                }
                            });
                            data.distinctValues = distinctValues;
                            resolve(data);
                        }, (error) => {
                            data.distinctValues = [];
                            resolve(data);
                        });
                    });
                });
                return Promise.all(promises);
            } else {
                return storeData;
            }
        });
    }

    getStoreData(stores) {
        let storeIds = [];
        stores.forEach((store) => {
            storeIds.push(store.id);
        });
        return this.getStoreDataByIds(storeIds);
    }

    getStoreDataByIds(storeIds) {
        let storeData = [];
        storeIds.forEach((storeId) => {
            let storeProperties = this.getStoreProperties(storeId);
            if (storeProperties) {
                storeData.push(
                    {
                        text: storeProperties.title || storeProperties.id,
                        id: storeId
                    }
                );
            }
        }, this);
        storeData.sort((a, b) => {
            return a.text.localeCompare(b.text);
        });
        return storeData;
    }

    getStoreProperties(idOrStore) {
        let resolver = this.serviceResolver;
        if (typeof (idOrStore) === "string") {
            return resolver.getServiceProperties("ct.api.Store", "(id=" + idOrStore + ")");
        }
        return resolver.getServiceProperties(idOrStore);
    }
}

module.exports = MetadataAnalyzer;
<commit_msg>Fix distinct value bug in case of disabled distinct values<commit_after>/*
 * Copyright (C) 2018 con terra GmbH (info@conterra.de)
 *
 * 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.
 */
import ct_when from "ct/_when";
import ServiceResolver from "apprt/ServiceResolver";
import Promise from "apprt-core/Promise";
import QueryTask from "esri/tasks/QueryTask";
import Query from "esri/tasks/support/Query";

class MetadataAnalyzer {
    activate(componentContext) {
        let serviceResolver = this.serviceResolver = new ServiceResolver();
        let bundleCtx = componentContext.getBundleContext();
        serviceResolver.setBundleCtx(bundleCtx);
    }

    getFields(store) {
        return new Promise((resolve) => {
            try {
                let metadata = store.getMetadata();
                ct_when(metadata, (metadata) => {
                    let fields = metadata.fields;
                    let storeData = [];
                    fields.forEach((field) => {
                        let codedValues = [];
                        let codedValueString = "";
                        if (field.domain && field.domain.codedValues) {
                            codedValues = field.domain.codedValues;
                            codedValueString = "[CV]";
                        }
                        if (field.type !== "geometry") {
                            storeData.push({
                                id: field.name,
                                text: field.title + " (" + field.type + ") " + codedValueString,
                                type: field.type,
                                codedValues: codedValues,
                                distinctValues: []
                            });
                        }
                    });
                    if (this._queryBuilderProperties.enableDistinctValues) {
                        this.getDistinctValues(store, storeData).then((storeData) => {
                            resolve(storeData);
                        });
                    } else {
                        resolve(storeData);
                    }
                }, this);
            }
            catch (e) {
                this._logService.error({
                    id: 0,
                    message: e
                });
            }
        });
    }

    getDistinctValues(store, storeData) {
        let metadata = store.getMetadata();
        return ct_when(metadata, (metadata) => {
            let supportsDistincts = metadata.advancedQueryCapabilities && metadata.advancedQueryCapabilities.supportsDistinct;
            if (supportsDistincts) {
                let promises = storeData.map((data) => {
                    return new Promise((resolve) => {
                        let queryTask = new QueryTask({
                            url: store.target
                        });
                        let query = new Query();
                        query.where = "1=1";
                        query.outFields = [data.id];
                        query.orderByFields = [data.id];
                        query.returnGeometry = false;
                        query.returnDistinctValues = true;
                        queryTask.execute(query).then((result) => {
                            let distinctValues = [];
                            result.features.forEach((feature) => {
                                let value = feature.attributes[data.id];
                                if (value !== "") {
                                    distinctValues.push(value);
                                }
                            });
                            data.distinctValues = distinctValues;
                            resolve(data);
                        }, (error) => {
                            data.distinctValues = [];
                            resolve(data);
                        });
                    });
                });
                return Promise.all(promises);
            } else {
                return storeData;
            }
        });
    }

    getStoreData(stores) {
        let storeIds = [];
        stores.forEach((store) => {
            storeIds.push(store.id);
        });
        return this.getStoreDataByIds(storeIds);
    }

    getStoreDataByIds(storeIds) {
        let storeData = [];
        storeIds.forEach((storeId) => {
            let storeProperties = this.getStoreProperties(storeId);
            if (storeProperties) {
                storeData.push(
                    {
                        text: storeProperties.title || storeProperties.id,
                        id: storeId
                    }
                );
            }
        }, this);
        storeData.sort((a, b) => {
            return a.text.localeCompare(b.text);
        });
        return storeData;
    }

    getStoreProperties(idOrStore) {
        let resolver = this.serviceResolver;
        if (typeof (idOrStore) === "string") {
            return resolver.getServiceProperties("ct.api.Store", "(id=" + idOrStore + ")");
        }
        return resolver.getServiceProperties(idOrStore);
    }
}

module.exports = MetadataAnalyzer;
<|endoftext|>


<commit_before>// processor.js
var redisclient = require('redis').createClient(process.env.REDIS_URL || { host: '127.0.0.1', port: 6379 });
// redisclient.on('ready', function() {
//     console.log("Redis is ready");
// });

// redisclient.on('error', function() {
//     console.log("Error in Redis");
// });
var tools = require('./3Dprocessor/tools');
module.exports = function(job) {
    // Do some heavy work
    const synthesisid =job.data.synthesisid;
    // var existingroads = job.data.rfc;

    var constraintedDesigns = job.data.gj;

    const systems = job.data.sys;

    // if (existingroads.features.length > 0) {
    //     existingroads = tools.bufferExistingRoads(existingroads);
    // }

    var curFeats = constraintedDesigns.features;
    var flen = curFeats.length;
    var fullproc = flen;
    var counter = 0;
    var finalGJFeats = [];

    for (var h = 0; h < flen; h++) {

        // for every feature , create a point grid.
        var curFeat = curFeats[h];
        const cur3DGeom = tools.generateFinal3DGeoms(curFeat, 0);
        finalGJFeats.push.apply(finalGJFeats, cur3DGeom);
        counter += 1;
        job.progress({'percent': parseInt((100 * counter) / fullproc),'synthesisid':synthesisid} );

    }

    var final3DGeoms = {
        "type": "FeatureCollection",
        "features": finalGJFeats
    };
    // const final3DGeoms = tools.generateFinal3DGeoms(constraintedDesigns, 1, existingroads);

    // job.progress(50);

    var center = tools.generateCenter(constraintedDesigns);

    // console.log(center, unitCounts);
    // job.progress(100);
    console.log('Computation Complete..');
    redisclient.set(synthesisid, JSON.stringify({ "finalGeoms": final3DGeoms, "center": center }));

    return Promise.resolve(synthesisid);
}<commit_msg>Update processor.js<commit_after>// processor.js
var redisclient = require('redis').createClient(process.env.REDIS_URL || {
    host: '127.0.0.1',
    port: 6379
});
// redisclient.on('ready', function() {
//     console.log("Redis is ready");
// });

// redisclient.on('error', function() {
//     console.log("Error in Redis");
// });
var tools = require('./3Dprocessor/tools');
module.exports = function (job) {
    // Do some heavy work
    const synthesisid = job.data.synthesisid;
    // var existingroads = job.data.rfc;

    var constraintedDesigns = job.data.gj;

    const systems = job.data.sys;

    // if (existingroads.features.length > 0) {
    //     existingroads = tools.bufferExistingRoads(existingroads);
    // }

    var curFeats = constraintedDesigns.features;
    var flen = curFeats.length;
    var fullproc = flen;
    var counter = 0;
    var finalGJFeats = [];

    for (var h = 0; h < flen; h++) {
        var cur3DGeom = [];
        // for every feature , create a point grid.
        var curFeat = curFeats[h];
        try {
            cur3DGeom = tools.generateFinal3DGeoms(curFeat, 0);
        } catch (error) {
            console.log(error);
        }
        if (cur3DGeom) {
            finalGJFeats.push.apply(finalGJFeats, cur3DGeom);
        }
        counter += 1;
        job.progress({
            'percent': parseInt((100 * counter) / fullproc),
            'synthesisid': synthesisid
        });

    }

    var final3DGeoms = {
        "type": "FeatureCollection",
        "features": finalGJFeats
    };
    // const final3DGeoms = tools.generateFinal3DGeoms(constraintedDesigns, 1, existingroads);

    // job.progress(50);

    var center = tools.generateCenter(constraintedDesigns);

    // console.log(center, unitCounts);
    // job.progress(100);
    console.log('Computation Complete..');
    redisclient.set(synthesisid, JSON.stringify({
        "finalGeoms": final3DGeoms,
        "center": center
    }));

    return Promise.resolve(synthesisid);
}<|endoftext|>


<commit_before>/*@pjs preload="data/images/logo1.png";*/

var sketchProc=function(processingInstance){ with (processingInstance){

//Setup
var wi = window.innerWidth ||
        document.documentElement.clientWidth ||
        document.body.clientWidth;
var he = window.innerHeight ||
         document.documentElement.clientHeight ||
         document.body.clientHeight;
size(wi*0.9,he*0.9);
frameRate(60);

setup = function() {
	mainfont = createFont("Times New Roman");
	logo = loadImage("data/images/logo1.png");

	keys = [];
	page = 0;
	chapter1 = [];

	m = false;
	md = false;
	flevel = 255;
	bw = width/8;
	bh = width/16;
	prim = color(15,15,15);
	sec = color(100,30,30);
	tert = color(150,150,150);
	backg = color(55,55,55);

	fade = function() {
		flevel -= 10;
		fill(55,55,55,flevel);
		noStroke();
		rectMode(CORNER);
		rect(-1,-1,width+1,height+1);
	};

	loadpanels = function(name,number,target) {
		for (i = 0; i < number;) {
			target[i] = loadImage("data/images/panels/"+name+i+".png");
			i ++;
		}
	};

	buttons = {
		start:{x:width*(3/4),y:height/2,w:bw,h:bh,text:"Enter"},
		next:{x:width*(6/7),y:height*(1/2),w:bw,h:bh,text:"Next"},
		prev:{x:width*(1/7),y:height*(1/2),w:bw,h:bh,text:"Previous"},
	};

	displaypanel = function(img,x,y) {
		imageMode(CENTER);
		pushMatrix();
		translate(x,y);
		scale(0.001*height,0.001*height);
			image(img,0,0);
		popMatrix();
	};

	button = function(con) {
		bux = con.x
		buy = con.y
		buw = con.w
		buh = con.h
		butext = con.text
		con.pressed = false;

		rectMode(CENTER);

		if (mouseX>bux-buw/2&&mouseX<bux+buw/2 && mouseY>buy-buh/2&&mouseY<buy+buh/2) {
			fill(prim);
		} else {
			fill(sec);
		}
		stroke(prim);
		strokeWeight(buh/10);
		rect(bux,buy,buw,buh,buh/3);

		if (mouseX>bux-buw/2&&mouseX<bux+buw/2 && mouseY>buy-buh/2&&mouseY<buy+buh/2) {
			fill(sec);
		} else {
			fill(prim);
		}
		textFont(mainfont,buh/2);
		textAlign(CENTER,CENTER);
		text(butext,bux,buy);

		if ((mouseX>bux-buw/2&&mouseX<bux+buw/2 && mouseY>buy-buh/2&&mouseY<buy+buh/2 && m) || (mouseX>bux-buw/2&&mouseX<bux+buw/2 && mouseY>buy-buh/2&&mouseY<buy+buh/2 && md)) {
			con.pressed = true;
			return con.pressed;
		}
		return con.pressed;
	};

	loadpanels("chap1/",1,chapter1);
	standardbuttons = function() {
		button(buttons.next);
		if (buttons.next.pressed) {
			page += 1;
			flevel = 255;
		};

		button(buttons.prev);
		if (buttons.prev.pressed) {
			page -= 1;
			flevel = 255;
		};
	};

	pages = [
		function() {
			background(backg)

			displaypanel(logo,width/4,height/2)

			button(buttons.start)
			if (buttons.start.pressed==true) {
				page += 1
			}
		},
		function() {
			background(backg)

			displaypanel(chapter1[0],width/2,height/2);

			standardbuttons();

			fade();
		},

	];

};

draw = function() {
	pages[page]();
	fill(0,0,0);
	text(m+" "+md+" "+buttons.start.pressed,width/2,height/2);
};

keyPressed = function() {
	keys[keyCode] = true;
};
keyReleased = function() {
	keys[keyCode] = false;
};
mousePressed = function() {
	m = true;
};
mouseDragged = function() {
	md = true;
};
mouseClicked = function() {
	md = true;
};
mouseReleased = function() {
	m = false;
	md = false;
};

}};
<commit_msg>Update main.js<commit_after>/*@pjs preload="data/images/logo1.png";*/

var sketchProc=function(processingInstance){ with (processingInstance){

//Setup
var wi = window.innerWidth ||
        document.documentElement.clientWidth ||
        document.body.clientWidth;
var he = window.innerHeight ||
         document.documentElement.clientHeight ||
         document.body.clientHeight;
size(wi*0.9,he*0.9);
frameRate(60);

setup = function() {
	mainfont = createFont("Times New Roman");
	logo = loadImage("data/images/logo1.png");

	keys = [];
	page = 0;
	chapter1 = [];

	m = false;
	md = false;
	flevel = 255;
	bw = width/8;
	bh = width/16;
	prim = color(15,15,15);
	sec = color(100,30,30);
	tert = color(150,150,150);
	backg = color(55,55,55);

	fade = function() {
		flevel -= 10;
		fill(55,55,55,flevel);
		noStroke();
		rectMode(CORNER);
		rect(-1,-1,width+1,height+1);
	};

	loadpanels = function(name,number,target) {
		for (i = 0; i < number;) {
			target[i] = loadImage("data/images/panels/"+name+i+".png");
			i ++;
		}
	};

	buttons = {
		start:{x:width*(3/4),y:height/2,w:bw,h:bh,text:"Enter"},
		next:{x:width*(6/7),y:height*(1/2),w:bw,h:bh,text:"Next"},
		prev:{x:width*(1/7),y:height*(1/2),w:bw,h:bh,text:"Previous"},
	};

	displaypanel = function(img,x,y) {
		imageMode(CENTER);
		pushMatrix();
		translate(x,y);
		scale(0.001*height,0.001*height);
			image(img,0,0);
		popMatrix();
	};

	button = function(con) {
		bux = con.x
		buy = con.y
		buw = con.w
		buh = con.h
		butext = con.text
		con.pressed = false;

		rectMode(CENTER);

		if (mouseX>bux-buw/2&&mouseX<bux+buw/2 && mouseY>buy-buh/2&&mouseY<buy+buh/2) {
			fill(prim);
		} else {
			fill(sec);
		}
		stroke(prim);
		strokeWeight(buh/10);
		rect(bux,buy,buw,buh,buh/3);

		if (mouseX>bux-buw/2&&mouseX<bux+buw/2 && mouseY>buy-buh/2&&mouseY<buy+buh/2) {
			fill(sec);
		} else {
			fill(prim);
		}
		textFont(mainfont,buh/2);
		textAlign(CENTER,CENTER);
		text(butext,bux,buy);

		if ((mouseX>bux-buw/2&&mouseX<bux+buw/2 && mouseY>buy-buh/2&&mouseY<buy+buh/2 && m) || (mouseX>bux-buw/2&&mouseX<bux+buw/2 && mouseY>buy-buh/2&&mouseY<buy+buh/2 && mousePressed == true)) {
			con.pressed = true;
			return con.pressed;
		}
		return con.pressed;
	};

	loadpanels("chap1/",1,chapter1);
	standardbuttons = function() {
		button(buttons.next);
		if (buttons.next.pressed) {
			page += 1;
			flevel = 255;
		};

		button(buttons.prev);
		if (buttons.prev.pressed) {
			page -= 1;
			flevel = 255;
		};
	};

	pages = [
		function() {
			background(backg)

			displaypanel(logo,width/4,height/2)

			button(buttons.start)
			if (buttons.start.pressed==true) {
				page += 1
			}
		},
		function() {
			background(backg)

			displaypanel(chapter1[0],width/2,height/2);

			standardbuttons();

			fade();
		},

	];

};

draw = function() {
	pages[page]();
	fill(0,0,0);
	text(m+" "+mousePressed,width/2,height/2);
};

keyPressed = function() {
	keys[keyCode] = true;
};
keyReleased = function() {
	keys[keyCode] = false;
};
mousePressed = function() {
	m = true;
};
mouseDragged = function() {
	md = true;
};
mouseClicked = function() {
	md = true;
};
mouseReleased = function() {
	m = false;
	md = false;
};

}};
<|endoftext|>


<commit_before>require('dotenv').config({ silent: true });
const Crawler = require('simplecrawler');
const jsdom = require('jsdom');
const colors = require('colors');
const string = require('string');
const jquery = require('jquery');
const fs = require('fs');
const path = require('path');

class Results {
  constructor(onlyErrors, params) {
    this.onlyErrors = onlyErrors;
    this.params = params;
    this.results = [];
  }

  saveResult(result) {
    this.results.push(result);
  }

  printResults() {
    const results = this.results.filter(result => (!this.onlyErrors || result.isError));

    if (!this.onlyErrors || results.length > 0) {
      // eslint-disable-next-line prefer-template
      console.log(`Results for ${this.params.url}`
        + colors.dim(` (${this.params.bufferLength} bytes, type ${this.params.contentType})`));

      results.forEach(result => {
        const printWithColor = result.isError ? colors.red : colors.green;
        console.log(printWithColor(result.message));
      });
    }
  }
}

function downloadSite(initialUrl, rules) {
  const myCrawler = new Crawler(initialUrl);

  myCrawler.interval = 500;
  myCrawler.maxConcurrency = 3;
  myCrawler.decodeResponses = true;

  myCrawler.on('fetchcomplete', (queueItem, responseBuffer, response) => {
    if (!string(response.headers['content-type']).startsWith('text/html')) {
      return;
    }

    jsdom.env(
      responseBuffer,
      ['http://code.jquery.com/jquery.js'],
      (err, window) => {
        const $ = jquery(window);
        const params = {
          url: queueItem.url,
          bufferLength: responseBuffer.length,
          contentType: response.headers['content-type'],
        };
        const results = new Results(true, params);

        const rulePromises = [];
        rules.forEach(rule => {
          const rulePromise = rule.run($, results, params);
          if (rulePromise instanceof Promise) {
            rulePromises.push(rulePromise);
          }
        });

        Promise.all(rulePromises).then(() => {
          results.printResults();
        });
      }
    );
  });

  myCrawler.on('complete', () => console.log('Done!'));

  myCrawler.start();
}

if (process.argv.length < 3) {
  console.error('Usage: node seotest.js http://testsite.com [enabled-rules, ...]');
  process.exit(1);
}

const enabledRules = process.argv.splice(3).map(rule => (
  string(rule).chompRight('.js').toString()
));

const rulesDir = 'rules';
const normalizedPath = path.join(__dirname, rulesDir);
const loadedRules = [];
fs.readdirSync(normalizedPath).forEach(file => {
  loadedRules.push({
    name: string(file).chompRight('.js').toString(),
    run: require(`./${rulesDir}/${file}`), // eslint-disable-line global-require
  });
});

const rules = [];
console.log(colors.green('Rules'));
loadedRules.forEach(rule => {
  const isEnabled = enabledRules.length === 0 || enabledRules.includes(rule.name);
  console.log(
    `* ${rule.name.toString()} [${isEnabled ? colors.green('enabled') : colors.red('disabled')}]`);
  if (isEnabled) {
    rules.push(rule);
  }
});

downloadSite(process.argv[2], rules);
<commit_msg>Renamed myCrawler to crawler<commit_after>require('dotenv').config({ silent: true });
const Crawler = require('simplecrawler');
const jsdom = require('jsdom');
const colors = require('colors');
const string = require('string');
const jquery = require('jquery');
const fs = require('fs');
const path = require('path');

class Results {
  constructor(onlyErrors, params) {
    this.onlyErrors = onlyErrors;
    this.params = params;
    this.results = [];
  }

  saveResult(result) {
    this.results.push(result);
  }

  printResults() {
    const results = this.results.filter(result => (!this.onlyErrors || result.isError));

    if (!this.onlyErrors || results.length > 0) {
      // eslint-disable-next-line prefer-template
      console.log(`Results for ${this.params.url}`
        + colors.dim(` (${this.params.bufferLength} bytes, type ${this.params.contentType})`));

      results.forEach(result => {
        const printWithColor = result.isError ? colors.red : colors.green;
        console.log(printWithColor(result.message));
      });
    }
  }
}

function downloadSite(initialUrl, rules) {
  const crawler = new Crawler(initialUrl);

  crawler.interval = 500;
  crawler.maxConcurrency = 3;
  crawler.decodeResponses = true;

  crawler.on('fetchcomplete', (queueItem, responseBuffer, response) => {
    if (!string(response.headers['content-type']).startsWith('text/html')) {
      return;
    }

    jsdom.env(
      responseBuffer,
      ['http://code.jquery.com/jquery.js'],
      (err, window) => {
        const $ = jquery(window);
        const params = {
          url: queueItem.url,
          bufferLength: responseBuffer.length,
          contentType: response.headers['content-type'],
        };
        const results = new Results(true, params);

        const rulePromises = [];
        rules.forEach(rule => {
          const rulePromise = rule.run($, results, params);
          if (rulePromise instanceof Promise) {
            rulePromises.push(rulePromise);
          }
        });

        Promise.all(rulePromises).then(() => {
          results.printResults();
        });
      }
    );
  });

  crawler.on('complete', () => console.log('Done!'));

  crawler.start();
}

if (process.argv.length < 3) {
  console.error('Usage: node seotest.js http://testsite.com [enabled-rules, ...]');
  process.exit(1);
}

const enabledRules = process.argv.splice(3).map(rule => (
  string(rule).chompRight('.js').toString()
));

const rulesDir = 'rules';
const normalizedPath = path.join(__dirname, rulesDir);
const loadedRules = [];
fs.readdirSync(normalizedPath).forEach(file => {
  loadedRules.push({
    name: string(file).chompRight('.js').toString(),
    run: require(`./${rulesDir}/${file}`), // eslint-disable-line global-require
  });
});

const rules = [];
console.log(colors.green('Rules'));
loadedRules.forEach(rule => {
  const isEnabled = enabledRules.length === 0 || enabledRules.includes(rule.name);
  console.log(
    `* ${rule.name.toString()} [${isEnabled ? colors.green('enabled') : colors.red('disabled')}]`);
  if (isEnabled) {
    rules.push(rule);
  }
});

downloadSite(process.argv[2], rules);
<|endoftext|>


<commit_before>cmapi.channel["cmapi.appendix.b"] = {
  schema: {
    "$schema": "http://json-schema.org/draft-04/schema#",
    "id": "http://json-schema.org/geojson/geojson.json#",
    "title": "Appendix B - GeoJSON Support",
    "description": "The GeoJSON specification can be found at http://geojson.org/geojson-spec.html.  The Common Map Widget API specification extends the GeoJSON specification by adding the “style”, “name”, “id”, “description“, and “timePrimitive“ objects to the “Properties” object of the GeoJSON specification.  These extended objects ONLY apply to the GeoJSON Feature object.",
    "type": "object",
    "properties": {
      "name": {
        "type": "string",
        "description": "name of the specific GeoJSON feature.  Generally used when the GeoJSON parent object is a featureCollection or feature objects."
      },
      "id": {
        "type": "string",
        "description": "a unique identifier for the feature object.  Though not required, it is RECOMMENDED. If the id of the GeoJSON Feature.properties.id is omitted, and part of a FeatureCollection, selection may not work for these features as they cannot be uniquely identified. "
      },
      "description": {
        "type": "string",
        "description": "user supplied content that appears in a pop-up balloon associated with the feature.  Can be plain text, or HTML formatted."
      },
      "timePrimitive": {
        "type": "object",
        "description": "",
        "properties": {
          "timeSpan": {
            "type": "object",
            "description": "",
            "properties": {
              "begin": {
                "type": "string",
                "format": "date-time",
                "description": "time stamp identifying the beginning of the time span (see timeStamp definition for format info). "
              },
              "end": {
                "type": "string",
                "format": "date-time",
                "description": "time stamp identifying the end of the time span (see timeStamp definition for format info)."
              }
            },
            "required": ["begin", "end"]
          },
          "timeStamp": {
            "type": "string",
            "format": "date-time",
            "description": "time stamp value expressed as yyyy-mm-ddThh:mm:ss.ssszzzzzz, where T is the separator between the date and the time, and the time zone is either Z (for UTC) or zzzzzz, which represents ±hh:mm in relation to UTC. Additionally, the value can be expressed as a date only."
          }
        }
      },
      "style": {
        "type": "object",
        "description": "",
        "properties": {
          "lineStyle": {
            "type": "object",
            "description": "",
            "properties": {
              "color": {
                "description": "Object representing CSS3 RGBA.  See Note 1 below for more info",
                "type": "object",
                "default": "No value sent results in default settings on the map.",
                "properties": {
                  "r": {
                    "description": "Integer value between 0 and 255 for red.",
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 255
                  },
                  "g": {
                    "description": "Integer value between 0 and 255 for green.",
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 255
                  },
                  "b": {
                    "description": "Integer value between 0 and 255 for green.",
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 255
                  },
                  "a": {
                    "description": "Number value between 0.0 (fully transparent) to 1.0 (fully opaque).",
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  }
                },
                "required": [
                  "r",
                  "g",
                  "b",
                  "a"
                ]
              }
            },
            "required": ["color"]
          },
          "polyStyle": {
            "type": "object",
            "description": "",
            "properties": {
              "color": {
                "description": "Object representing CSS3 RGBA.  See Note 1 below for more info. ",
                "type": "object",
                "default": "No value sent results in default settings on the map.",
                "properties": {
                  "r": {
                    "description": "Integer value between 0 and 255 for red.",
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 255
                  },
                  "g": {
                    "description": "Integer value between 0 and 255 for green.",
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 255
                  },
                  "b": {
                    "description": "Integer value between 0 and 255 for blue.",
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 255
                  },
                  "a": {
                    "description": "Number value between 0.0 (fully transparent) to 1.0 (fully opaque).",
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  }
                },
                "required": [
                  "r",
                  "g",
                  "b",
                  "a"
                ]
              }
            },
            "required": ["color"]
          },
          "iconStyle": {
            "type": "object",
            "description": "",
            "properties": {
              "url": {
                "type": "uri",
                "description": "URL to an image file that will be used for the icon for a point.",
                "default": "If no URL is provided, result will be map’s default icon."
              }
            },
            "required": ["url"]
          }
        }
      }
    }
  },
  notes: [
    'See http://www.w3.org/wiki/CSS3/Color/RGBA for more info on RGBA.'
  ]
};<commit_msg>Fixed blue color annotation.<commit_after>cmapi.channel["cmapi.appendix.b"] = {
  schema: {
    "$schema": "http://json-schema.org/draft-04/schema#",
    "id": "http://json-schema.org/geojson/geojson.json#",
    "title": "Appendix B - GeoJSON Support",
    "description": "The GeoJSON specification can be found at http://geojson.org/geojson-spec.html.  The Common Map Widget API specification extends the GeoJSON specification by adding the “style”, “name”, “id”, “description“, and “timePrimitive“ objects to the “Properties” object of the GeoJSON specification.  These extended objects ONLY apply to the GeoJSON Feature object.",
    "type": "object",
    "properties": {
      "name": {
        "type": "string",
        "description": "name of the specific GeoJSON feature.  Generally used when the GeoJSON parent object is a featureCollection or feature objects."
      },
      "id": {
        "type": "string",
        "description": "a unique identifier for the feature object.  Though not required, it is RECOMMENDED. If the id of the GeoJSON Feature.properties.id is omitted, and part of a FeatureCollection, selection may not work for these features as they cannot be uniquely identified. "
      },
      "description": {
        "type": "string",
        "description": "user supplied content that appears in a pop-up balloon associated with the feature.  Can be plain text, or HTML formatted."
      },
      "timePrimitive": {
        "type": "object",
        "description": "",
        "properties": {
          "timeSpan": {
            "type": "object",
            "description": "",
            "properties": {
              "begin": {
                "type": "string",
                "format": "date-time",
                "description": "time stamp identifying the beginning of the time span (see timeStamp definition for format info). "
              },
              "end": {
                "type": "string",
                "format": "date-time",
                "description": "time stamp identifying the end of the time span (see timeStamp definition for format info)."
              }
            },
            "required": ["begin", "end"]
          },
          "timeStamp": {
            "type": "string",
            "format": "date-time",
            "description": "time stamp value expressed as yyyy-mm-ddThh:mm:ss.ssszzzzzz, where T is the separator between the date and the time, and the time zone is either Z (for UTC) or zzzzzz, which represents ±hh:mm in relation to UTC. Additionally, the value can be expressed as a date only."
          }
        }
      },
      "style": {
        "type": "object",
        "description": "",
        "properties": {
          "lineStyle": {
            "type": "object",
            "description": "",
            "properties": {
              "color": {
                "description": "Object representing CSS3 RGBA.  See Note 1 below for more info",
                "type": "object",
                "default": "No value sent results in default settings on the map.",
                "properties": {
                  "r": {
                    "description": "Integer value between 0 and 255 for red.",
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 255
                  },
                  "g": {
                    "description": "Integer value between 0 and 255 for green.",
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 255
                  },
                  "b": {
                    "description": "Integer value between 0 and 255 for blue.",
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 255
                  },
                  "a": {
                    "description": "Number value between 0.0 (fully transparent) to 1.0 (fully opaque).",
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  }
                },
                "required": [
                  "r",
                  "g",
                  "b",
                  "a"
                ]
              }
            },
            "required": ["color"]
          },
          "polyStyle": {
            "type": "object",
            "description": "",
            "properties": {
              "color": {
                "description": "Object representing CSS3 RGBA.  See Note 1 below for more info. ",
                "type": "object",
                "default": "No value sent results in default settings on the map.",
                "properties": {
                  "r": {
                    "description": "Integer value between 0 and 255 for red.",
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 255
                  },
                  "g": {
                    "description": "Integer value between 0 and 255 for green.",
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 255
                  },
                  "b": {
                    "description": "Integer value between 0 and 255 for blue.",
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 255
                  },
                  "a": {
                    "description": "Number value between 0.0 (fully transparent) to 1.0 (fully opaque).",
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  }
                },
                "required": [
                  "r",
                  "g",
                  "b",
                  "a"
                ]
              }
            },
            "required": ["color"]
          },
          "iconStyle": {
            "type": "object",
            "description": "",
            "properties": {
              "url": {
                "type": "uri",
                "description": "URL to an image file that will be used for the icon for a point.",
                "default": "If no URL is provided, result will be map’s default icon."
              }
            },
            "required": ["url"]
          }
        }
      }
    }
  },
  notes: [
    'See http://www.w3.org/wiki/CSS3/Color/RGBA for more info on RGBA.'
  ]
};
<|endoftext|>


<commit_before>(function(window, undefined){
  'use strict';

  window.visLine = flight.component(function(){
    this.attributes({
      'containerId': '#lines_chart',
      'legendId': '#lines_tooltip'
    });

    this.after('initialize', function() {
      var visLineasJ = new VisLineasJ(this.attr.containerId, this.attr.legendId, this.$node.data('line-widget-type'), this.$node.data('line-widget-series'));
      visLineasJ.render(this.$node.data('line-widget-url'));

      $('[data-line-widget-url]').on('click', function(e){
        e.preventDefault();
        visLineasJ.measure = $(this).data('line-widget-type');
        visLineasJ.render($(this).data('line-widget-url'));
        $('#lines_char_wrapper [data-line-widget-url]').removeClass('active');
        $('#lines_char_wrapper [data-line-widget-url]').attr({
          'tabindex': -1,
          'aria-selected': false
        });

        $(this).addClass('active');
        $(this).attr({
          'tabindex': 0,
          'aria-selected': true
        });
      });
    });
  });

  window.visLineComparison = flight.component(function(){
    this.attributes({
      'containerId': '#lines_chart_comparison',
      'legendId': '#lines_tooltip_comparison'
    });

    this.after('initialize', function() {
      var visLineasJ = new VisLineasJ(this.attr.containerId, this.attr.legendId, this.$node.data('line-widget-type'), this.$node.data('line-widget-series'));
      visLineasJ.render(this.$node.data('line-widget-url'));

      $('[data-line-widget-url]').on('click', function(e){
        e.preventDefault();
        visLineasJ.measure = $(this).data('line-widget-type');
        visLineasJ.render($(this).data('line-widget-url'));
        $('#lines_chart_comparison_wrapper [data-line-widget-url]').removeClass('active');
        $('#lines_chart_comparison_wrapper [data-line-widget-url]').attr({
          'tabindex': -1,
          'aria-selected': false
        });

        $(this).addClass('active');
        $(this).attr({
          'tabindex': 0,
          'aria-selected': true
        });
      });
    });
  });

  $( document ).on('turbolinks:load', function() {
    window.visLine.attachTo('#lines_chart_wrapper [data-line-widget-url].active');
    window.visLineComparison.attachTo('#lines_chart_comparison_wrapper [data-line-widget-url].active');
  });

})(window);
<commit_msg>Various fixes on line chart<commit_after>(function(window, undefined){
  'use strict';

  window.visLine = flight.component(function(){
    this.attributes({
      'containerId': '#lines_chart',
      'legendId': '#lines_tooltip'
    });

    this.after('initialize', function() {
      var visLineasJ = new VisLineasJ(this.attr.containerId, this.attr.legendId, this.$node.data('line-widget-type'), this.$node.data('line-widget-series'));
      visLineasJ.render(this.$node.data('line-widget-url'));

      $('#lines_chart_wrapper [data-line-widget-url]').on('click', function(e){
        e.preventDefault();
        visLineasJ.measure = $(this).data('line-widget-type');
        visLineasJ.render($(this).data('line-widget-url'));
        $('#lines_chart_wrapper [data-line-widget-url]').removeClass('active');
        $('#lines_chart_wrapper [data-line-widget-url]').attr({
          'tabindex': -1,
          'aria-selected': false
        });

        $(this).addClass('active');
        $(this).attr({
          'tabindex': 0,
          'aria-selected': true
        });
      });
    });
  });

  window.visLineComparison = flight.component(function(){
    this.attributes({
      'containerId': '#lines_chart_comparison',
      'legendId': '#lines_tooltip_comparison'
    });

    this.after('initialize', function() {
      var visLineasJ = new VisLineasJ(this.attr.containerId, this.attr.legendId, this.$node.data('line-widget-type'), this.$node.data('line-widget-series'));
      visLineasJ.render(this.$node.data('line-widget-url'));

      $('#lines_chart_comparison_wrapper [data-line-widget-url]').on('click', function(e){
        e.preventDefault();
        $(visLineasJ.container+"_wrapper").removeProp('hidden');
        visLineasJ.measure = $(this).data('line-widget-type');
        visLineasJ.render($(this).data('line-widget-url'));
        $('#lines_chart_comparison_wrapper [data-line-widget-url]').removeClass('active');
        $('#lines_chart_comparison_wrapper [data-line-widget-url]').attr({
          'tabindex': -1,
          'aria-selected': false
        });

        $(this).addClass('active');
        $(this).attr({
          'tabindex': 0,
          'aria-selected': true
        });
      });
    });
  });

  $( document ).on('turbolinks:load', function() {
    window.visLine.attachTo('#lines_chart_wrapper [data-line-widget-url].active');
    window.visLineComparison.attachTo('#lines_chart_comparison_wrapper [data-line-widget-url].active');
  });

})(window);
<|endoftext|>