<commit_before>import React from "react";
import "../App.css";
import FilterWidget from "../containers/FilterWidget";
import { NavBar } from "../components/NavBar";
import { connectBackend } from "../actions/index";
import { fetchDailyPoints } from "../actions/index";
import { connect } from 'react-redux';

class App extends React.Component {

  componentDidMount() {
    this.props.connectBackend();
  }

  componentWillUpdate(nextProps) {
    console.log("componentWillUpdate" + nextProps);
    if(nextProps.dashboard_token) {
      this.props.fetchDailyPoints(nextProps.dashboard_token);
    }
  }

  render() {
    return (

        <NavBar />

          <FilterWidget />

    )
  }
}

const mapStateToProps = state => {
  return {
    dashboard_token: state.APIcalls.dashboard_token
  }
}

const mapDispatchToProps = dispatch => {
  return {
    connectBackend: () => dispatch(connectBackend()),
    fetchDailyPoints: (token) => dispatch(fetchDailyPoints(token))
  }
}

export default connect(mapStateToProps, mapDispatchToProps)(App);
<commit_msg>removed console.log statement<commit_after>import React from "react";
import "../App.css";
import FilterWidget from "../containers/FilterWidget";
import { NavBar } from "../components/NavBar";
import { connectBackend } from "../actions/index";
import { fetchDailyPoints } from "../actions/index";
import { connect } from 'react-redux';

class App extends React.Component {

  componentDidMount() {
    this.props.connectBackend();
  }

  componentWillUpdate(nextProps) {
    if(nextProps.dashboard_token) {
      this.props.fetchDailyPoints(nextProps.dashboard_token);
    }
  }

  render() {
    return (

        <NavBar />

          <FilterWidget />

    )
  }
}

const mapStateToProps = state => {
  return {
    dashboard_token: state.APIcalls.dashboard_token
  }
}

const mapDispatchToProps = dispatch => {
  return {
    connectBackend: () => dispatch(connectBackend()),
    fetchDailyPoints: (token) => dispatch(fetchDailyPoints(token))
  }
}

export default connect(mapStateToProps, mapDispatchToProps)(App);
<|endoftext|>


<commit_before>import React, { Component } from "react";
import api from "../utils/api";
import coordinates from "parse-dms";
import defaultMapStyles from "./mapstyle.js";

const defaultMarkerLayout = {
  "text-line-height": 1,
  "text-padding": 0,
  "text-anchor": "bottom",
  "text-allow-overlap": true,
  "text-field": String.fromCharCode("0xe55f"), // see https://github.com/mapbox/mapbox-gl-js/issues/3605#issuecomment-296486123 for the why.
  "icon-optional": true,
  "text-font": ["Material Icons Regular"], // ["FontAwesome Regular"] is also available
  "text-size": 18
};

// Quiet Jest down (Unnecessary as soon as we upgrade to react-apps 0.10)
if (process.env.NODE_ENV === "test") {
  require.ensure = (deps, cb) => cb(require);
}

function extractData(data) {
  if (!data) {
    return [];
  }
  let newdata = data.map(function(obj) {
    let coords;
    if (obj.location && obj.location.latitude && obj.location.longitude) {
      coords = coordinates(
        obj.location.latitude + " " + obj.location.longitude
      );
      coords = [coords["lon"], coords["lat"]];
    } else {
      coords = [0, 0];
    }
    return {
      id: obj.id,
      type: obj.type,
      featured: obj.featured,
      searchmatched: obj.searchmatched,
      position: coords,
      url: `/${obj.type}/${obj.id}`,
      title: obj.title,
      images: obj.images
    };
  });
  newdata = newdata.filter(c => c.position[0] !== 0);
  return newdata;
}

export default class Map extends Component {
  state = {
    cases: [],
    organizations: [],
    MapVisualization: null
  };
  componentDidMount() {
    // There is probably a cleaner way to do this, but it seems to work
    let component = this;
    require.ensure(
      ["../components/MapVisualization/MapVisualization"],
      function(require) {
        let MapVisualization = require("../components/MapVisualization/MapVisualization")
          .default;
        component.setState({
          MapVisualization
        });
      }
    );
  }
  componentWillMount() {
    let component = this;

    api.searchMapTokens(this.props.location.search).then(function(results) {
      let items = extractData(results);
      component.setState({
        items: items
      });
    });
  }

  render() {
    let { items } = this.state;
    let styles = this.props.styles || defaultMapStyles;
    let markerLayout = this.props.markerLayout || defaultMarkerLayout;
    let center = this.props.center;

    if (this.state.MapVisualization) {
      return (
        <this.state.MapVisualization
          items={items}
          styles={styles}
          markerLayout={markerLayout}
          center={center}
        />
      );
    } else {
      return <div />;
    }
  }
}
<commit_msg>Update map when props change (as in when a search query changes for example)<commit_after>import React, { Component } from "react";
import api from "../utils/api";
import coordinates from "parse-dms";
import defaultMapStyles from "./mapstyle.js";

const defaultMarkerLayout = {
  "text-line-height": 1,
  "text-padding": 0,
  "text-anchor": "bottom",
  "text-allow-overlap": true,
  "text-field": String.fromCharCode("0xe55f"), // see https://github.com/mapbox/mapbox-gl-js/issues/3605#issuecomment-296486123 for the why.
  "icon-optional": true,
  "text-font": ["Material Icons Regular"], // ["FontAwesome Regular"] is also available
  "text-size": 18
};

// Quiet Jest down (Unnecessary as soon as we upgrade to react-apps 0.10)
if (process.env.NODE_ENV === "test") {
  require.ensure = (deps, cb) => cb(require);
}

function extractData(data) {
  if (!data) {
    return [];
  }
  let newdata = data.map(function(obj) {
    let coords;
    if (obj.location && obj.location.latitude && obj.location.longitude) {
      coords = coordinates(
        obj.location.latitude + " " + obj.location.longitude
      );
      coords = [coords["lon"], coords["lat"]];
    } else {
      coords = [0, 0];
    }
    return {
      id: obj.id,
      type: obj.type,
      featured: obj.featured,
      searchmatched: obj.searchmatched,
      position: coords,
      url: `/${obj.type}/${obj.id}`,
      title: obj.title,
      images: obj.images
    };
  });
  newdata = newdata.filter(c => c.position[0] !== 0);
  return newdata;
}

export default class Map extends Component {
  state = {
    cases: [],
    organizations: [],
    MapVisualization: null
  };
  componentDidMount() {
    // There is probably a cleaner way to do this, but it seems to work
    let component = this;
    require.ensure(
      ["../components/MapVisualization/MapVisualization"],
      function(require) {
        let MapVisualization = require("../components/MapVisualization/MapVisualization")
          .default;
        component.setState({
          MapVisualization
        });
      }
    );
  }

  componentWillMount() {
    let component = this;

    api.searchMapTokens(this.props.location.search).then(function(results) {
      let items = extractData(results);
      component.setState({
        items: items
      });
    });
  }
  componentWillReceiveProps(newProps) {
    let component = this;

    api.searchMapTokens(newProps.location.search).then(function(results) {
      let items = extractData(results);
      component.setState({
        items: items
      });
    });
  }

  render() {
    let { items } = this.state;
    let styles = this.props.styles || defaultMapStyles;
    let markerLayout = this.props.markerLayout || defaultMarkerLayout;
    let center = this.props.center;

    if (this.state.MapVisualization) {
      return (
        <this.state.MapVisualization
          items={items}
          styles={styles}
          markerLayout={markerLayout}
          center={center}
        />
      );
    } else {
      return <div />;
    }
  }
}
<|endoftext|>


<commit_before>'use strict';

angular.module('createContainer', ['ngRoute'])
    .config(['$routeProvider', function ($routeProvider) {
        $routeProvider.when('/createContainer', {
            templateUrl: 'app/createContainer/createContainer.html',
            controller: 'CreateContainerCtrl'
        });
    }])
    .controller('CreateContainerCtrl', ['$rootScope', '$scope', '$location', 'Helpers', 'Docker', function ($rootScope, $scope, $location, Helpers, Docker) {
        if (Helpers.isEmpty($rootScope.hostUrl)) {
            $location.path('/hosts');
        } else {
            $scope.imageName = 'ubuntu';
            $scope.imageName = 'lexandro/echo-repeat';
            $scope.rm = false;
            $scope.detach = true;
            $scope.tty = true;
            $scope.interactive = true;
            $scope.privileged = false;
            $scope.validation = {};
            $scope.environmentVariables = [{}];
            $scope.entryPoints = [{value: ""}];
            $scope.workDir = "";
            $scope.publishAllPorts = false;
            $scope.publishedPorts = [{port: "", protocol: 'tcp', port2: ""}];
            $scope.exposedPorts = [{value: "", protocol: "tcp", status: ""}];
            $scope.portBindings = [{port: "", protocol: "tcp", hostIp: "0.0.0.0", hostPort: "", status: ""}];
            $scope.hostVolumeBindings = [{value: "", writable: true, status: ""}];
            $scope.volumeBindings = [{value: "", writable: true, status: ""}];
            $scope.volumesFrom = [{containerId: "", writable: true, status: ""}];
            // !!!!!!!!!!!!
            $scope.containerListing = true;

            //
            var containers = Docker.containers().query({all: 1}, function () {
                $scope.containerListing = false;
                $scope.containers = containers;
            });
            //
            $scope.createContainer = function (startFlag) {
                // TODO add name format check
                var validation = {};
                var newContainerParameters = {};
                if (!isEmpty($scope.imageName)) {
                    newContainerParameters.Image = $scope.imageName;
                } else {
                    validation.imageNameRequired = true;
                }

                if (!isEmpty($scope.command)) {
                    newContainerParameters.Cmd = $scope.command.split(' ');
                }

                if (!isEmpty($scope.tty)) {
                    newContainerParameters.Tty = $scope.tty;
                }

                // converting env variables
                if ($scope.environmentVariables.length > 1) {
                    var envs = [];
                    $scope.environmentVariables.forEach(function (envVar) {
                        envs.push(envVar.name + '=' + envVar.value);
                    });
                    envs.splice(envs.length - 1, 1);
                    //
                    newContainerParameters.Env = envs;
                }

                // generating entrypoint entry
                if ($scope.entryPoints.length > 1) {
                    var entryPointStrings = [];
                    $scope.entryPoints.forEach(function (entryPoint) {
                        entryPointStrings.push(entryPoint.value);
                    });
                    entryPointStrings.splice(entryPointStrings.length - 1, 1);
                    newContainerParameters.Entrypoint = entryPointStrings;
                }

                if (!isEmpty($scope.workDir)) {
                    newContainerParameters.WorkingDir = $scope.workDir;
                }
                //
                newContainerParameters.HostConfig = {};
                if ($scope.privileged == true) {
                    newContainerParameters.HostConfig.Privileged = true;
                }

                if ($scope.publishAllPorts) {
                    newContainerParameters.HostConfig.PublishAllPorts = true;
                }
                //
                if ($scope.exposedPorts.length > 1) {
                    var exposedPortsData = $scope.exposedPorts;
                    var ExposedPorts = {};
                    var newExposedPortsData = [];
                    exposedPortsData.forEach(function (exposedPort) {
                        if (!isEmpty(exposedPort.value)) {
                            if (isPositiveInteger(exposedPort.value) && !isPortDuplicated(newExposedPortsData, exposedPort)) {
                                newExposedPortsData.push(exposedPort);
                                ExposedPorts[exposedPort.value + "/" + exposedPort.protocol] = {};
                            }
                        }
                    });
                    newContainerParameters.ExposedPorts = ExposedPorts;
                }
                //
                if ($scope.portBindings.length > 1) {
                    var portBindingsData = $scope.portBindings;
                    var newBindings = [];
                    var PortBindings = {};
                    portBindingsData.forEach(function (portBinding) {

                        if (!isEmpty(portBinding.port) || !isEmpty(portBinding.hostPort)) {
                            if (isPositiveInteger(portBinding.port) && !isBindingDuplicated(newBindings, portBinding) && isPositiveInteger(portBinding.hostPort)) {
                                PortBindings[portBinding.port + "/" + portBinding.protocol] =
                                    [{hostIp: portBinding.hostIp, hostPort: portBinding.hostPort}];
                                newBindings.push(portBinding);
                            }
                        }
                    });
                    newContainerParameters.HostConfig.PortBindings = PortBindings;
                }
                //
                newContainerParameters.HostConfig.Binds = [];
                if ($scope.hostVolumeBindings.length > 1) {
                    var hostVolumeBindingsData = $scope.hostVolumeBindings;
                    var newHostVolumeBindingsData = [];
                    var Binds = [];
                    hostVolumeBindingsData.forEach(function (hostVolumeBinding) {
                        if (!isEmpty(hostVolumeBinding.value) && !isHostVolumeBindingDuplicated(newHostVolumeBindingsData, hostVolumeBinding)) {
                            var hostVolumeBindingString = hostVolumeBinding.value;
                            if (hostVolumeBinding["writable"] == true) {
                                hostVolumeBindingString += ":ro";
                            }
                            Binds.push(hostVolumeBindingString);
                            newHostVolumeBindingsData.push(hostVolumeBinding);
                        }
                    });
                    newContainerParameters.HostConfig.Binds = Binds;
                }
                //
                console.log(JSON.stringify(newContainerParameters));
                //
                $scope.validation = validation;

                var createdContainer = Docker.containers().create($scope.newContainerName ? {name: $scope.newContainerName} : null, newContainerParameters,

                    function () {
                        console.log(JSON.stringify(createdContainer));
                        if (startFlag == true) {
                            Docker.containers().start({containerId: createdContainer.Id}, {}, function () {
                                $location.path('/containers');
                            });
                        } else {
                            $location.path('/containers');
                        }
                    }
                )
            };

            $scope.createAndStartContainer = function () {
                $scope.createContainer(true);
                console.log('and start');
            };
            //
            $scope.generateContainerName = function () {
                $scope.newContainerName = 'random_container';
            };

            $scope.envVarValidator = function () {
                var envVars = $scope.environmentVariables;
                var newEnvVars = [];
                envVars.forEach(function (env) {
                    if (!isEmpty(env.name) || !isEmpty(env.value)) {
                        newEnvVars.push(env);
                    }
                });
                newEnvVars.push({name: "", value: ""});
                $scope.environmentVariables = newEnvVars;

            };

            $scope.entryPointValidator = function () {
                var entryPoints = $scope.entryPoints;
                var newEntryPoints = [];
                entryPoints.forEach(function (entryPoint) {
                    if (!isEmpty(entryPoint.value)) {
                        newEntryPoints.push(entryPoint);
                    }
                });

                newEntryPoints.push({value: ""});
                $scope.entryPoints = newEntryPoints;
            }

        }

        $scope.exposedPortValidator = function () {
            var exposedPorts = $scope.exposedPorts;
            var newExposedPorts = [];
            exposedPorts.forEach(function (port) {
                if (!isEmpty(port.value)) {
                    if (isPositiveInteger(port.value) && !isPortDuplicated(newExposedPorts, port)) {
                        port.status = "valid";
                    } else {
                        port.status = "invalid";
                    }
                    newExposedPorts.push(port);
                }
            });
            newExposedPorts.push({value: "", protocol: "tcp", status: ""});
            $scope.exposedPorts = newExposedPorts;
        };

        $scope.portBindingValidator = function () {
            var portBindings = $scope.portBindings;
            var newBindings = [];
            portBindings.forEach(function (portBinding) {
                if (!isEmpty(portBinding.port) || !isEmpty(portBinding.hostPort)) {
                    if (isPositiveInteger(portBinding.port) && !isBindingDuplicated(newBindings, portBinding) && isPositiveInteger(portBinding.hostPort)) {
                        portBinding.status = "valid";
                    } else {
                        portBinding.status = "invalid";
                    }
                    newBindings.push(portBinding);
                }
            });
            newBindings.push({port: "", protocol: "tcp", hostIp: "0.0.0.0", hostPort: "", status: ""});
            $scope.portBindings = newBindings;
        };

        $scope.hostVolumeBindingValidator = function () {
            var hostVolumeBindings = $scope.hostVolumeBindings;
            var newHostVolumeBindings = [];
            hostVolumeBindings.forEach(function (hostVolumeBinding) {
                if (!isEmpty(hostVolumeBinding.value)) {
                    newHostVolumeBindings.push(hostVolumeBinding);
                }
            });
            newHostVolumeBindings.push({value: "", writable: true, status: ""});
            $scope.hostVolumeBindings = newHostVolumeBindings;
        };

        $scope.volumeBindingValidator = function () {
            var volumeBindings = $scope.volumeBindings;
            var newVolumeBindings = [];
            volumeBindings.forEach(function (volumeBinding) {
                if (!isEmpty(volumeBinding.value)) {
                    newVolumeBindings.push(volumeBinding);
                }
            });
            newVolumeBindings.push({value: "", writable: true, status: ""});
            $scope.volumeBindings = newVolumeBindings;
        };
        $scope.volumeFromValidator = function () {
            var volumesFrom = $scope.volumesFrom;
            var newVolumesFrom = [];
            volumesFrom.forEach(function (volumeFrom) {
                if (!isEmpty(volumeFrom.containerId)) {
                    newVolumesFrom.push(volumeFrom);
                }
            });
            newVolumesFrom.push({containerId: "", writable: true, status: ""});
            $scope.volumesFrom = newVolumesFrom;
        };

        $scope.deleteEnvVarEntry = function (index) {
            $scope.deleteFromArray($scope.environmentVariables, index);
        };

        $scope.deleteEntryPointEntry = function (index) {
            $scope.deleteFromArray($scope.entryPoints, index);
        };

        $scope.deleteExposedPortEntry = function (index) {
            $scope.deleteFromArray($scope.exposedPorts, index);
        };

        $scope.deletePortBinding = function (index) {
            $scope.deleteFromArray($scope.portBindings, index);
        };

        $scope.deleteHostVolumeBinding = function (index) {
            $scope.deleteFromArray($scope.hostVolumeBindings, index);
        };

        $scope.deleteVolumeBinding = function (index) {
            $scope.deleteFromArray($scope.volumeBindings, index);
        };

        $scope.deleteVolumeFrom = function (index) {
            if ($scope.volumesFrom.length == 1) {
                $scope.volumesFrom[0].containerId = "";

            } else {
                $scope.deleteFromArray($scope.volumesFrom, index);
            }
        };

        $scope.deleteFromArray = function (array, index) {
            var arrayLength = array.length;
            if (arrayLength > 1 && index < arrayLength - 1) {
                array.splice(index, 1);
            }
        };

        function isPortDuplicated(newExposedPorts, port) {
            var result = false;
            newExposedPorts.forEach(function (newPort) {
                if (parseInt(newPort.value) == parseInt(port.value)) {
                    result = true;
                }
            });
            return result;
        }

        function isBindingDuplicated(newBindings, portBinding) {
            var result = false;
            newBindings.forEach(function (newPortBinding) {
                if ((parseInt(newPortBinding.port) == parseInt(portBinding.port))
                    ||
                    (parseInt(newPortBinding.hostPort) == parseInt(portBinding.hostPort))) {
                    result = true;
                }
            });
            return result;
        }

        function isHostVolumeBindingDuplicated(newHostVolumeBindingsData, hostVolumeBinding) {
            var result = false;
            newHostVolumeBindingsData.forEach(function (newHostVolumeBinding) {
                if (newHostVolumeBinding.value == hostVolumeBinding.value) {
                    result = true;
                }
            });
            return result;
        }

        function isEmpty(obj) {
            return Helpers.isEmpty(obj);
        }

        function isPositiveInteger(obj) {
            return Helpers.isPositiveInteger(obj);
        }
    }]
);<commit_msg>Adding data volume option<commit_after>'use strict';

angular.module('createContainer', ['ngRoute'])
    .config(['$routeProvider', function ($routeProvider) {
        $routeProvider.when('/createContainer', {
            templateUrl: 'app/createContainer/createContainer.html',
            controller: 'CreateContainerCtrl'
        });
    }])
    .controller('CreateContainerCtrl', ['$rootScope', '$scope', '$location', 'Helpers', 'Docker', function ($rootScope, $scope, $location, Helpers, Docker) {
        if (Helpers.isEmpty($rootScope.hostUrl)) {
            $location.path('/hosts');
        } else {
            $scope.imageName = 'ubuntu';
            $scope.imageName = 'lexandro/echo-repeat';
            $scope.rm = false;
            $scope.detach = true;
            $scope.tty = true;
            $scope.interactive = true;
            $scope.privileged = false;
            $scope.validation = {};
            $scope.environmentVariables = [{}];
            $scope.entryPoints = [{value: ""}];
            $scope.workDir = "";
            $scope.publishAllPorts = false;
            $scope.publishedPorts = [{port: "", protocol: 'tcp', port2: ""}];
            $scope.exposedPorts = [{value: "", protocol: "tcp", status: ""}];
            $scope.portBindings = [{port: "", protocol: "tcp", hostIp: "0.0.0.0", hostPort: "", status: ""}];
            $scope.hostVolumeBindings = [{value: "", writable: true, status: ""}];
            $scope.volumeBindings = [{value: "", writable: true, status: ""}];
            $scope.volumesFrom = [{containerId: "", writable: true, status: ""}];
            // !!!!!!!!!!!!
            $scope.containerListing = true;

            //
            var containers = Docker.containers().query({all: 1}, function () {
                $scope.containerListing = false;
                $scope.containers = containers;
            });
            //
            $scope.createContainer = function (startFlag) {
                // TODO add name format check
                var validation = {};
                var newContainerParameters = {};
                if (!isEmpty($scope.imageName)) {
                    newContainerParameters.Image = $scope.imageName;
                } else {
                    validation.imageNameRequired = true;
                }

                if (!isEmpty($scope.command)) {
                    newContainerParameters.Cmd = $scope.command.split(' ');
                }

                if (!isEmpty($scope.tty)) {
                    newContainerParameters.Tty = $scope.tty;
                }

                // converting env variables
                if ($scope.environmentVariables.length > 1) {
                    var envs = [];
                    $scope.environmentVariables.forEach(function (envVar) {
                        envs.push(envVar.name + '=' + envVar.value);
                    });
                    envs.splice(envs.length - 1, 1);
                    //
                    newContainerParameters.Env = envs;
                }

                // generating entrypoint entry
                if ($scope.entryPoints.length > 1) {
                    var entryPointStrings = [];
                    $scope.entryPoints.forEach(function (entryPoint) {
                        entryPointStrings.push(entryPoint.value);
                    });
                    entryPointStrings.splice(entryPointStrings.length - 1, 1);
                    newContainerParameters.Entrypoint = entryPointStrings;
                }

                if (!isEmpty($scope.workDir)) {
                    newContainerParameters.WorkingDir = $scope.workDir;
                }
                //
                newContainerParameters.HostConfig = {};
                if ($scope.privileged == true) {
                    newContainerParameters.HostConfig.Privileged = true;
                }

                if ($scope.publishAllPorts) {
                    newContainerParameters.HostConfig.PublishAllPorts = true;
                }
                //
                if ($scope.exposedPorts.length > 1) {
                    var exposedPortsData = $scope.exposedPorts;
                    var ExposedPorts = {};
                    var newExposedPortsData = [];
                    exposedPortsData.forEach(function (exposedPort) {
                        if (!isEmpty(exposedPort.value)) {
                            if (isPositiveInteger(exposedPort.value) && !isPortDuplicated(newExposedPortsData, exposedPort)) {
                                newExposedPortsData.push(exposedPort);
                                ExposedPorts[exposedPort.value + "/" + exposedPort.protocol] = {};
                            }
                        }
                    });
                    newContainerParameters.ExposedPorts = ExposedPorts;
                }
                //
                if ($scope.portBindings.length > 1) {
                    var portBindingsData = $scope.portBindings;
                    var newBindings = [];
                    var PortBindings = {};
                    portBindingsData.forEach(function (portBinding) {

                        if (!isEmpty(portBinding.port) || !isEmpty(portBinding.hostPort)) {
                            if (isPositiveInteger(portBinding.port) && !isBindingDuplicated(newBindings, portBinding) && isPositiveInteger(portBinding.hostPort)) {
                                PortBindings[portBinding.port + "/" + portBinding.protocol] =
                                    [{hostIp: portBinding.hostIp, hostPort: portBinding.hostPort}];
                                newBindings.push(portBinding);
                            }
                        }
                    });
                    newContainerParameters.HostConfig.PortBindings = PortBindings;
                }
                //
                newContainerParameters.HostConfig.Binds = [];
                if ($scope.hostVolumeBindings.length > 1) {
                    var hostVolumeBindingsData = $scope.hostVolumeBindings;
                    var newHostVolumeBindingsData = [];
                    var Binds = [];
                    hostVolumeBindingsData.forEach(function (hostVolumeBinding) {
                        if (!isEmpty(hostVolumeBinding.value) && !isHostVolumeBindingDuplicated(newHostVolumeBindingsData, hostVolumeBinding)) {
                            var hostVolumeBindingString = hostVolumeBinding.value;
                            if (hostVolumeBinding["writable"] != true) {
                                hostVolumeBindingString += ":ro";
                            }
                            Binds.push(hostVolumeBindingString);
                            newHostVolumeBindingsData.push(hostVolumeBinding);
                        }
                    });
                    newContainerParameters.HostConfig.Binds = Binds;
                }

                if ($scope.volumeBindings.length > 1) {
                    var volumeBindingsData = $scope.volumeBindings;
                    var newVolumeBindingsData = [];
                    var Volumes = {};
                    volumeBindingsData.forEach(function (volumeBinding) {
                        if (!isEmpty(volumeBinding.value) && !isHostVolumeBindingDuplicated(newVolumeBindingsData, volumeBinding)) {
                            var volumeBindingString = volumeBinding.value;
                            if (volumeBinding["writable"] != true) {
                                volumeBindingString += ":ro";
                            }
                            Volumes[volumeBindingString] = {};
                            newVolumeBindingsData.push(volumeBinding);
                        }
                    });
                    newContainerParameters.Volumes = Volumes;
                }

                //
                console.log(JSON.stringify(newContainerParameters));
                //
                $scope.validation = validation;

                var createdContainer = Docker.containers().create($scope.newContainerName ? {name: $scope.newContainerName} : null, newContainerParameters,

                    function () {
                        console.log(JSON.stringify(createdContainer));
                        if (startFlag == true) {
                            Docker.containers().start({containerId: createdContainer.Id}, {}, function () {
                                $location.path('/containers');
                            });
                        } else {
                            $location.path('/containers');
                        }
                    }
                )
            };

            $scope.createAndStartContainer = function () {
                $scope.createContainer(true);
                console.log('and start');
            };
            //
            $scope.generateContainerName = function () {
                $scope.newContainerName = 'random_container';
            };

            $scope.envVarValidator = function () {
                var envVars = $scope.environmentVariables;
                var newEnvVars = [];
                envVars.forEach(function (env) {
                    if (!isEmpty(env.name) || !isEmpty(env.value)) {
                        newEnvVars.push(env);
                    }
                });
                newEnvVars.push({name: "", value: ""});
                $scope.environmentVariables = newEnvVars;

            };

            $scope.entryPointValidator = function () {
                var entryPoints = $scope.entryPoints;
                var newEntryPoints = [];
                entryPoints.forEach(function (entryPoint) {
                    if (!isEmpty(entryPoint.value)) {
                        newEntryPoints.push(entryPoint);
                    }
                });

                newEntryPoints.push({value: ""});
                $scope.entryPoints = newEntryPoints;
            }

        }

        $scope.exposedPortValidator = function () {
            var exposedPorts = $scope.exposedPorts;
            var newExposedPorts = [];
            exposedPorts.forEach(function (port) {
                if (!isEmpty(port.value)) {
                    if (isPositiveInteger(port.value) && !isPortDuplicated(newExposedPorts, port)) {
                        port.status = "valid";
                    } else {
                        port.status = "invalid";
                    }
                    newExposedPorts.push(port);
                }
            });
            newExposedPorts.push({value: "", protocol: "tcp", status: ""});
            $scope.exposedPorts = newExposedPorts;
        };

        $scope.portBindingValidator = function () {
            var portBindings = $scope.portBindings;
            var newBindings = [];
            portBindings.forEach(function (portBinding) {
                if (!isEmpty(portBinding.port) || !isEmpty(portBinding.hostPort)) {
                    if (isPositiveInteger(portBinding.port) && !isBindingDuplicated(newBindings, portBinding) && isPositiveInteger(portBinding.hostPort)) {
                        portBinding.status = "valid";
                    } else {
                        portBinding.status = "invalid";
                    }
                    newBindings.push(portBinding);
                }
            });
            newBindings.push({port: "", protocol: "tcp", hostIp: "0.0.0.0", hostPort: "", status: ""});
            $scope.portBindings = newBindings;
        };

        $scope.hostVolumeBindingValidator = function () {
            var hostVolumeBindings = $scope.hostVolumeBindings;
            var newHostVolumeBindings = [];
            hostVolumeBindings.forEach(function (hostVolumeBinding) {
                if (!isEmpty(hostVolumeBinding.value)) {
                    newHostVolumeBindings.push(hostVolumeBinding);
                }
            });
            newHostVolumeBindings.push({value: "", writable: true, status: ""});
            $scope.hostVolumeBindings = newHostVolumeBindings;
        };

        $scope.volumeBindingValidator = function () {
            var volumeBindings = $scope.volumeBindings;
            var newVolumeBindings = [];
            volumeBindings.forEach(function (volumeBinding) {
                if (!isEmpty(volumeBinding.value)) {
                    newVolumeBindings.push(volumeBinding);
                }
            });
            newVolumeBindings.push({value: "", writable: true, status: ""});
            $scope.volumeBindings = newVolumeBindings;
        };
        $scope.volumeFromValidator = function () {
            var volumesFrom = $scope.volumesFrom;
            var newVolumesFrom = [];
            volumesFrom.forEach(function (volumeFrom) {
                if (!isEmpty(volumeFrom.containerId)) {
                    newVolumesFrom.push(volumeFrom);
                }
            });
            newVolumesFrom.push({containerId: "", writable: true, status: ""});
            $scope.volumesFrom = newVolumesFrom;
        };

        $scope.deleteEnvVarEntry = function (index) {
            $scope.deleteFromArray($scope.environmentVariables, index);
        };

        $scope.deleteEntryPointEntry = function (index) {
            $scope.deleteFromArray($scope.entryPoints, index);
        };

        $scope.deleteExposedPortEntry = function (index) {
            $scope.deleteFromArray($scope.exposedPorts, index);
        };

        $scope.deletePortBinding = function (index) {
            $scope.deleteFromArray($scope.portBindings, index);
        };

        $scope.deleteHostVolumeBinding = function (index) {
            $scope.deleteFromArray($scope.hostVolumeBindings, index);
        };

        $scope.deleteVolumeBinding = function (index) {
            $scope.deleteFromArray($scope.volumeBindings, index);
        };

        $scope.deleteVolumeFrom = function (index) {
            if ($scope.volumesFrom.length == 1) {
                $scope.volumesFrom[0].containerId = "";

            } else {
                $scope.deleteFromArray($scope.volumesFrom, index);
            }
        };

        $scope.deleteFromArray = function (array, index) {
            var arrayLength = array.length;
            if (arrayLength > 1 && index < arrayLength - 1) {
                array.splice(index, 1);
            }
        };

        function isPortDuplicated(newExposedPorts, port) {
            var result = false;
            newExposedPorts.forEach(function (newPort) {
                if (parseInt(newPort.value) == parseInt(port.value)) {
                    result = true;
                }
            });
            return result;
        }

        function isBindingDuplicated(newBindings, portBinding) {
            var result = false;
            newBindings.forEach(function (newPortBinding) {
                if ((parseInt(newPortBinding.port) == parseInt(portBinding.port))
                    ||
                    (parseInt(newPortBinding.hostPort) == parseInt(portBinding.hostPort))) {
                    result = true;
                }
            });
            return result;
        }

        function isHostVolumeBindingDuplicated(newHostVolumeBindingsData, hostVolumeBinding) {
            var result = false;
            newHostVolumeBindingsData.forEach(function (newHostVolumeBinding) {
                if (newHostVolumeBinding.value == hostVolumeBinding.value) {
                    result = true;
                }
            });
            return result;
        }

        function isEmpty(obj) {
            return Helpers.isEmpty(obj);
        }

        function isPositiveInteger(obj) {
            return Helpers.isPositiveInteger(obj);
        }
    }]
);<|endoftext|>


<commit_before>/**
 * (description)
 *
 * @author yourname
 */

export default class EditController {
    constructor(Api, $http, storeSvc, $state,templateSvc) {
        "ngInject";
        this.name = 'edit';
        this.storeSvc = storeSvc;
        this.templateSvc = templateSvc;
        this.api = Api;
        this.$state = $state;
        this.d = {}
        this.init();
    }
    init() {
        let self = this;
        self.loading = true;
        self.loadPromise = this.api.get('/Organization/detail', { id: this.$state.params.id })

        self.loadPromise.then(res => {
            self.loading = false;
            self.d = res.datas;
            self.getTempList().then((result) => {
                self.d.templateData = result.datas;
                self.d.templateData.map((template)=>{
                    if(self.d.role_ids && self.d.role_ids.indexOf(template.rid)>-1){
                        template.checked = true ;
                    }
                })
            });
        });
    }
    save() {
        let self = this;
        let roleIdList = []

        this.d.templateData.forEach((template)=>{
            template.checked && roleIdList.push(template.rid);
        });

        this.api.post('/Organization/inputAjax', {
            organization_id: this.d.organization_id,
            name: this.d.name,
            contact: this.d.contact,
            principal: this.d.principal,
            remark: this.d.remark,
            role_info: JSON.stringify(roleIdList)

        }).then(res => { alert('提交成功'); this.back() }, err => { alert('提交错误') })

    }

    getTempList() {
        this.loadPromise = this.templateSvc.getPageAllTempList({
            limit: 999999,
            status: 1
        });
        return this.loadPromise;
    }

    back() {
        this.$state.go('storelist');
    }

}<commit_msg>fix 显示全部功能模板状态 liyn<commit_after>/**
 * (description)
 *
 * @author yourname
 */

export default class EditController {
    constructor(Api, $http, storeSvc, $state,templateSvc) {
        "ngInject";
        this.name = 'edit';
        this.storeSvc = storeSvc;
        this.templateSvc = templateSvc;
        this.api = Api;
        this.$state = $state;
        this.d = {}
        this.init();
    }
    init() {
        let self = this;
        self.loading = true;
        self.loadPromise = this.api.get('/Organization/detail', { id: this.$state.params.id })

        self.loadPromise.then(res => {
            self.loading = false;
            self.d = res.datas;
            self.getTempList().then((result) => {
                self.d.templateData = result.datas;
                self.d.templateData.map((template)=>{
                    if(self.d.role_ids && self.d.role_ids.indexOf(template.rid)>-1){
                        template.checked = true ;
                    }
                })
            });
        });
    }
    save() {
        let self = this;
        let roleIdList = []

        this.d.templateData.forEach((template)=>{
            template.checked && roleIdList.push(template.rid);
        });

        this.api.post('/Organization/inputAjax', {
            organization_id: this.d.organization_id,
            name: this.d.name,
            contact: this.d.contact,
            principal: this.d.principal,
            remark: this.d.remark,
            role_info: JSON.stringify(roleIdList)

        }).then(res => { alert('提交成功'); this.back() }, err => { alert('提交错误') })

    }

    getTempList() {
        this.loadPromise = this.templateSvc.getPageAllTempList({
            limit: 999999,
            status:0
        });
        return this.loadPromise;
    }

    back() {
        this.$state.go('storelist');
    }

}<|endoftext|>


<commit_before>import React, { PropTypes, Component } from 'react'
import * as d3 from 'd3'
import ReactFauxDOM from 'react-faux-dom'
import { connect } from 'react-redux'

class BarChart extends Component {
  constructor(props) {
    super(props)
    this.state = {
      chart: null
    }
  }

  componentDidMount() {
    this.buildChart(this.props.pollData)
  }

  buildChart({ entries }) {
    const pollEntries = entries
    const that = this
    const fauxDOM = ReactFauxDOM.createElement('div')
    const padding = { left: 30, top: 10, right: 10, bottom: 20 }
    const chartWidth = (600 - (padding.left + padding.right))
    const chartHeight = (400 - (padding.top + padding.bottom))

    const xScale = d3.scaleBand()
        .rangeRound([0, chartWidth])
        .domain(pollEntries.map(entry => entry.title))
        .paddingOuter(0.05)
        .padding(0.05)
    const yScale = d3.scaleLinear()
        .range([chartHeight, 0])
        .domain(getYScaleDomain())

    const xAxis = d3.axisBottom(xScale)
    const yAxis = d3.axisLeft(yScale)

    const chart = d3.select(fauxDOM).append('svg')
        .attr('width', (chartWidth + padding.left + padding.right))
        .attr('height', (chartHeight + padding.top + padding.bottom))
        .style('background-color', 'lightblue')
      .append('g')
        .classed('inner-chart', true)
        .attr('transform', `translate(${padding.left}, ${padding.top})`)
        .attr('width', chartWidth)
        .attr('height', chartHeight)

    const bars = chart.selectAll('rect')
        .data(pollEntries).enter()
      .append('rect')
        .attr('fill', 'orange')
        .attr('width', xScale.bandwidth())
        .attr('height', getBarHeight)
        .attr('x', entry => xScale(entry.title))
        .attr('y', entry => yScale(entry.votes.length))
        .on('click', callOnBarClickEvent)

    chart.append('g')
        .classed('x axis', true)
        .attr('transform', `translate(0, ${chartHeight})`)
        .call(xAxis)

    const yAxisElement = chart.append('g')
        .classed('y axis', true)
        .attr('transform', 'translate(0, 0)')
        .call(yAxis)

    function getYScaleDomain() {
      const lowestVotedBar = d3.min(pollEntries, entry => entry.votes.length)
      const heighestVotedBar = d3.max(pollEntries, entry => entry.votes.length)
      return [
        lowestVotedBar > 0 ? 0 : -1,
        heighestVotedBar > 0 ? heighestVotedBar : 1
      ]
    }

    function getBarHeight(entry) {
      return chartHeight - yScale(entry.votes.length)
    }

    function callOnBarClickEvent(bar) {
      const eventCallback = that.props.barClickedEvent
      if (eventCallback) {
        eventCallback(bar, updateVotedOnBars.bind(this))
      }
    }

    function updateVotedOnBars() {
      const transitionDuration = 500

      xScale.domain(pollEntries.map(entry => entry.title))
      yScale.domain(getYScaleDomain())

      bars
          .data(that.props.pollData.entries)
          .transition()
          .duration(transitionDuration)
          .attr('height', (entry) => chartHeight - yScale(entry.votes.length))
          .attr('y', entry => (yScale(entry.votes.length)))
          .ease((frame) => {
            that.updateChartState(fauxDOM)
            return ease(frame)
          })

      yAxisElement
          .transition()
          .duration(transitionDuration)
          .ease(ease)
          .call(yAxis)

      function ease(frame) {
        /* make these in the options when setting up the chart */
        // return d3.easeBounceInOut(frame)
        // return d3.easeCubicInOut(frame)
        return d3.easeExpOut(frame)
      }
    }

    this.updateChartState(fauxDOM)

    that.props.setTriggerUpdate(() => {
      this.updateChartState(fauxDOM)
    })
  }

  updateChartState(fauxDOM) {
    this.setState({ chart: fauxDOM.toReact() })
  }

  render() {
    return
{this.state.chart}

  }
}

BarChart.propTypes = {
  pollData: PropTypes.shape({
    title: PropTypes.string.isRequired,
    author: PropTypes.string.isRequired,
    authorID: PropTypes.string.isRequired,
    entries: PropTypes.array.isRequired,
    cuid: PropTypes.string.isRequired,
    dateCreated: PropTypes.number.isRequired
  }),
  dispatch: PropTypes.func.isRequired,
  barClickedEvent: PropTypes.func,
  setTriggerUpdate: PropTypes.func
}

export default connect()(BarChart)
<commit_msg>fixed an the BarChart trying to call the setTriggerUpdate when its not assigned<commit_after>import React, { PropTypes, Component } from 'react'
import * as d3 from 'd3'
import ReactFauxDOM from 'react-faux-dom'
import { connect } from 'react-redux'

class BarChart extends Component {
  constructor(props) {
    super(props)
    this.state = {
      chart: null
    }
  }

  componentDidMount() {
    this.buildChart(this.props.pollData)
  }

  buildChart({ entries }) {
    const pollEntries = entries
    const that = this
    const fauxDOM = ReactFauxDOM.createElement('div')
    const padding = { left: 30, top: 10, right: 10, bottom: 20 }
    const chartWidth = (600 - (padding.left + padding.right))
    const chartHeight = (400 - (padding.top + padding.bottom))

    const xScale = d3.scaleBand()
        .rangeRound([0, chartWidth])
        .domain(pollEntries.map(entry => entry.title))
        .paddingOuter(0.05)
        .padding(0.05)
    const yScale = d3.scaleLinear()
        .range([chartHeight, 0])
        .domain(getYScaleDomain())

    const xAxis = d3.axisBottom(xScale)
    const yAxis = d3.axisLeft(yScale)

    const chart = d3.select(fauxDOM).append('svg')
        .attr('width', (chartWidth + padding.left + padding.right))
        .attr('height', (chartHeight + padding.top + padding.bottom))
        .style('background-color', 'lightblue')
      .append('g')
        .classed('inner-chart', true)
        .attr('transform', `translate(${padding.left}, ${padding.top})`)
        .attr('width', chartWidth)
        .attr('height', chartHeight)

    const bars = chart.selectAll('rect')
        .data(pollEntries).enter()
      .append('rect')
        .attr('fill', 'orange')
        .attr('width', xScale.bandwidth())
        .attr('height', getBarHeight)
        .attr('x', entry => xScale(entry.title))
        .attr('y', entry => yScale(entry.votes.length))
        .on('click', callOnBarClickEvent)

    chart.append('g')
        .classed('x axis', true)
        .attr('transform', `translate(0, ${chartHeight})`)
        .call(xAxis)

    const yAxisElement = chart.append('g')
        .classed('y axis', true)
        .attr('transform', 'translate(0, 0)')
        .call(yAxis)

    function getYScaleDomain() {
      const lowestVotedBar = d3.min(pollEntries, entry => entry.votes.length)
      const heighestVotedBar = d3.max(pollEntries, entry => entry.votes.length)
      return [
        lowestVotedBar > 0 ? 0 : -1,
        heighestVotedBar > 0 ? heighestVotedBar : 1
      ]
    }

    function getBarHeight(entry) {
      return chartHeight - yScale(entry.votes.length)
    }

    function callOnBarClickEvent(bar) {
      const eventCallback = that.props.barClickedEvent
      if (eventCallback) {
        eventCallback(bar, updateVotedOnBars.bind(this))
      }
    }

    function updateVotedOnBars() {
      const transitionDuration = 500

      xScale.domain(pollEntries.map(entry => entry.title))
      yScale.domain(getYScaleDomain())

      bars
          .data(that.props.pollData.entries)
          .transition()
          .duration(transitionDuration)
          .attr('height', (entry) => chartHeight - yScale(entry.votes.length))
          .attr('y', entry => (yScale(entry.votes.length)))
          .ease((frame) => {
            that.updateChartState(fauxDOM)
            return ease(frame)
          })

      yAxisElement
          .transition()
          .duration(transitionDuration)
          .ease(ease)
          .call(yAxis)

      function ease(frame) {
        /* make these in the options when setting up the chart */
        // return d3.easeBounceInOut(frame)
        // return d3.easeCubicInOut(frame)
        return d3.easeExpOut(frame)
      }
    }

    this.updateChartState(fauxDOM)

    if (that.props.setTriggerUpdate) {
      that.props.setTriggerUpdate(() => {
        this.updateChartState(fauxDOM)
      })
    }
  }

  updateChartState(fauxDOM) {
    this.setState({ chart: fauxDOM.toReact() })
  }

  render() {
    return
{this.state.chart}

  }
}

BarChart.propTypes = {
  pollData: PropTypes.shape({
    title: PropTypes.string.isRequired,
    author: PropTypes.string.isRequired,
    authorID: PropTypes.string.isRequired,
    entries: PropTypes.array.isRequired,
    cuid: PropTypes.string.isRequired,
    dateCreated: PropTypes.number.isRequired
  }),
  dispatch: PropTypes.func.isRequired,
  barClickedEvent: PropTypes.func,
  setTriggerUpdate: PropTypes.func
}

export default connect()(BarChart)
<|endoftext|>


<commit_before>{
	// IMPORTANT
	//
	// Internet Explorer can't parse dictionaries as:
	//  {
	//        'foo' : 'bar',
	//  }
	//
	// Due to the last ',' after 'bar'. Same for lists
	//   [
	//      1,
	//      2,
	//      //3
	//   ]
	// Would produce an error since there is a ',' and then a ']'.
	//
	// "weblab.service.fileupload.post.url" : "/weblab/fileUpload.php",
	"development"                    : true, // To see the latest features, although they might not be working
	"admin.email"                    : "weblab@deusto.es",
	"demo.available"                 : true,
	"google.analytics.tracking.code" : "UA-12576838-6",
	"sound.enabled"					 : false,
	"experiments.default_picture"	 : "/img/experiments/default.jpg",
	"host.entity.image"              : "/img/udeusto-logo.jpg",
	"experiments" : {
					// Experiments not developed in GWT (such as those developed in Flash or Java) don't require
					// recompiling the client to be loaded. Adding them to this configuration file is enough.
					// Also those experiments that are inherently reusable for different classes, such as
					// those based in Virtual Machines (that will need to handle different experiment names
					// and categories) can be added here.
					"flash" : [
					           {
					        	   "experiment.name"     : "flashdummy",
					        	   "experiment.category" : "Dummy experiments",
					        	   "experiment.picture"	 : "/img/experiments/flash.jpg",
					        	   "page.footer"	 : "",
					        	   "flash.timeout"       : 20,
					        	   "width"               : 500,
					        	   "height"              : 350,
					        	   "swf.file"            : "WeblabFlashSample.swf",
					        	   "message"             : "Note: This is not a real experiment, it's just a demo so as to show that WebLab-Deusto can integrate different web technologies (such as Adobe Flash in this experiment). This demostrates that developing experiments in WebLab-Deusto is really flexible."
	                       		}
	                       		// Other flash experiments could be added here
	                       ],
	                "java" : [
	                          {
	                        	  "experiment.name"      : "javadummy",
	                        	  "experiment.category"  : "Dummy experiments",
	                        	  "experiment.picture"   : "/img/experiments/java.jpg",
	                        	  "width"                : 500,
	                        	  "height"               : 350,
	                        	  "jar.file"             : "WeblabJavaSample.jar",
	                        	  "code"                 : "es.deusto.weblab.client.experiment.plugins.es.deusto.weblab.javadummy.JavaDummyApplet",
	                        	  "message"             : "Note: This is not a real experiment, it's just a demo so as to show that WebLab-Deusto can integrate different web technologies (such as Java Applets in this experiment). This demostrates that developing experiments in WebLab-Deusto is really flexible."
	                          }
	                          // Other java experiments could be added here
	                       ],
	                "vm"    : [
	                           {
	                        	   "experiment.picture"	 : "/img/experiments/virtualbox.jpg",
	                        	   "experiment.name"     : "vm",
	                        	   "experiment.category" : "Dummy experiments"
	                           },
	                           {
	                        	   "experiment.picture"	 : "/img/experiments/virtualbox.jpg",
	                        	   "experiment.name"     : "ud-linux-vm",
	                        	   "experiment.category" : "VM experiments"
	                           },
	                           {
	                        	   "experiment.picture"	 : "/img/experiments/virtualbox.jpg",
	                        	   "experiment.name"     : "ud-win-vm",
	                        	   "experiment.category" : "VM experiments"
	                           },
	                           {
	                        	   "experiment.picture"	 : "/img/experiments/virtualbox.jpg",
	                        	   "experiment.name"	 : "vm-win",
	                               "experiment.category" : "Dummy experiments"
	                           }
	                       ],
	                "labview": [
	                            {
		                        	"experiment.picture"  : "/img/experiments/labview.jpg",
	                            	"experiment.name"     : "testone",
	                            	"experiment.category" : "LabVIEW experiments"
	                            },
	                            {
		                        	"experiment.picture"  : "/img/experiments/labview.jpg",
	                            	"experiment.name"     : "blink-led",
	                            	"experiment.category" : "LabVIEW experiments"
	                            },
	                            {
		                        	"experiment.picture"  : "/img/experiments/labview.jpg",
	                            	"experiment.name"     : "prototyping-board-01",
	                            	"experiment.category" : "LabVIEW experiments"
	                            },
	                            {
		                        	"experiment.picture"  : "/img/experiments/labview.jpg",
	                            	"experiment.name"     : "fpga-board-config",
	                            	"experiment.category" : "LabVIEW experiments"
	                            },
	                            {
		                        	"experiment.picture"  : "/img/experiments/labview.jpg",
	                            	"experiment.name"     : "fpga-board-experiment",
	                            	"experiment.category" : "LabVIEW experiments",
	                            	"send.file"           : true
	                            },
	                            {
		                        	"experiment.picture"  : "/img/experiments/labview.jpg",
	                            	"experiment.name"     : "fpga-board-bit",
	                            	"experiment.category" : "LabVIEW experiments"
	                            }
	                       ],
	                "xilinx" : [
							  {
								   "experiment.name"     : "ud-test-pld1",
								   "experiment.category" : "PLD experiments",
	                        	   "experiment.picture"   : "/img/experiments/xilinx.jpg",
								   "is.demo"             : true
							  },
							  {
								   "experiment.name"     : "ud-test-pld2",
								   "experiment.category" : "PLD experiments",
	                        	   "experiment.picture"   : "/img/experiments/xilinx.jpg",
								   "is.demo"             : true
							  },
							  {
								   "experiment.name"     : "ud-demo-pld",
								   "experiment.category" : "PLD experiments",
	                        	   "experiment.picture"   : "/img/experiments/xilinx.jpg",
								   "is.demo"             : true
							  },
							  {
								   "experiment.name"     : "ud-demo-fpga",
								   "experiment.category" : "FPGA experiments",
	                        	   "experiment.picture"   : "/img/experiments/xilinx.jpg",
								   "is.demo"             : true
						      },
						      {
							       "experiment.name"     : "ud-demo-xilinx",
							       "experiment.category" : "Xilinx experiments",
	                        	   "experiment.picture"   : "/img/experiments/xilinx.jpg",
							       "is.demo"             : true,
							       "is.multiresource.demo" : true
						      },
							  {
								   "experiment.name"     : "ud-fpga",
								   "experiment.category" : "FPGA experiments",
	                        	   "experiment.picture"   : "/img/experiments/xilinx.jpg",
	                        	   "experiment.info.link" : "http://code.google.com/p/weblabdeusto/wiki/Latest_Exp_Fpga",
	                        	   "experiment.info.description" : "wiki"
							  },
	                          {
	                        	  "experiment.name"      : "ud-pld",
	                        	  "experiment.category"  : "PLD experiments",
	                        	  "experiment.picture"   : "/img/experiments/xilinx.jpg"
	                          }
	                       ],
	                "dummy" : [
	                           {
	                        	   "experiment.name"     : "ud-dummy",
	                        	   "experiment.category" : "Dummy experiments"
	                           }
	                       ],
	   	        "dummybatch" : [
		                           {
		                        	   "experiment.name"     : "ud-dummy-batch",
		                        	   "experiment.category" : "Dummy experiments"
		                           }
		                ],
	                "robot-standard" : [
	                			{
	                			   "experiment.name" : "robot-standard",
	                			   "experiment.category" : "Robot experiments",
					        	   "experiment.picture"	 : "/img/experiments/robot.jpg",
					        	   "experiment.info.link" : "http://code.google.com/p/weblabdeusto/wiki/Latest_Exp_Robot_Standard",
	                        	   "experiment.info.description" : "wiki"
	                			}
	                		],

	                "robot-movement" : [
	                			{
	                				"experiment.name" : "robot-movement",
						        	"experiment.picture" : "/img/experiments/robot.jpg",
	                				"experiment.category" : "Robot experiments",
	                				"experiment.info.link" : "http://code.google.com/p/weblabdeusto/wiki/Latest_Exp_Robot_Movement",
	                        	    "experiment.info.description" : "wiki"
	                			}
	                		],
	                "robot-proglist" : [
	                			{
	                				"experiment.name" : "robot-proglist",
						        	"experiment.picture"  : "/img/experiments/robot.jpg",
	                				"experiment.category" : "Robot experiments",
	                				"experiment.info.link" : "http://code.google.com/p/weblabdeusto/wiki/Latest_Exp_Robot_Proglist",
	                        	    "experiment.info.description" : "wiki"
	                			}
	                		],
	                "visir" : [
	                           {
	                        	   "experiment.name"     : "visirtest",
	                        	   "experiment.category" : "Dummy experiments",
	                        	   "experiment.picture"  : "/img/experiments/visir.jpg",
	                        	   "page.timer"          : true,
	                        	   "page.footer"         : "Powered by the wonderful VISIR Open Source project developed at the BTH"
	                           },
	                           {
	                        	   "experiment.name"     : "lxi_visir",
	                        	   "experiment.category" : "Visir experiments",
	                        	   "experiment.picture"  : "/img/experiments/visir.jpg",
	                        	   "page.timer"          : true,
	                        	   "page.footer"         : "Powered by the wonderful VISIR Open Source project developed at the BTH"
	                           },
                                   {
	                        	   "experiment.name"     : "visir",
	                        	   "experiment.category" : "Visir experiments",
	                        	   "experiment.picture"  : "/img/experiments/visir.jpg",
	                        	   "page.timer"          : true,
	                        	   "page.footer"         : "Powered by the wonderful VISIR Open Source project developed at the BTH"
	                           }
	                       ],
	                "logic" : [
	                           {
	                        	   "experiment.name"     : "ud-logic",
	                        	   "experiment.category" : "PIC experiments",
	                        	   "experiment.picture"   : "/img/experiments/logic.jpg",
	                        	   "experiment.info.link" : "http://code.google.com/p/weblabdeusto/wiki/Latest_Exp_Logic",
	                        	   "experiment.info.description" : "wiki"
	                           }
	                       ],
	                "binary" : [
	                            {
	                               "experiment.name"     : "ud-binary",
	                               "experiment.category" : "PLD experiments"
	                            }
	                       ],
	                "gpib"   : [
	                            {
	                               "experiment.name"     : "ud-gpib",
	                               "experiment.category" : "GPIB experiments"
	                            }
	                       ],
	                "gpib1" : [
	                            {
	                               "experiment.name"     : "ud-gpib1",
	                               "experiment.category" : "GPIB experiments"
	                            }
	                        ],
	                "gpib2" : [
	                           {
	                        	   "experiment.name"     : "ud-gpib2",
	                        	   "experiment.category" : "GPIB experiments"
	                           }
	                        ],
	                "pic"   : [
	                           {
	                        	   "experiment.name"     : "ud-pic",
	                        	   "experiment.category" : "PIC experiments",
	                        	   "experiment.picture"  : "/img/experiments/microchip.jpg"
	                           }
	                        ],
	                "pic2"  : [
	                           {
	                        	   "experiment.name"     : "ud-pic2",
	                        	   "experiment.category" : "PIC experiments",
	                        	   "experiment.picture"  : "/img/experiments/microchip.jpg"
	                           }
	                        ]
		}
}
<commit_msg>[wiki]: Added links to teh recently created exp pages.<commit_after>{
	// IMPORTANT
	//
	// Internet Explorer can't parse dictionaries as:
	//  {
	//        'foo' : 'bar',
	//  }
	//
	// Due to the last ',' after 'bar'. Same for lists
	//   [
	//      1,
	//      2,
	//      //3
	//   ]
	// Would produce an error since there is a ',' and then a ']'.
	//
	// "weblab.service.fileupload.post.url" : "/weblab/fileUpload.php",
	"development"                    : true, // To see the latest features, although they might not be working
	"admin.email"                    : "weblab@deusto.es",
	"demo.available"                 : true,
	"google.analytics.tracking.code" : "UA-12576838-6",
	"sound.enabled"					 : false,
	"experiments.default_picture"	 : "/img/experiments/default.jpg",
	"host.entity.image"              : "/img/udeusto-logo.jpg",
	"experiments" : {
					// Experiments not developed in GWT (such as those developed in Flash or Java) don't require
					// recompiling the client to be loaded. Adding them to this configuration file is enough.
					// Also those experiments that are inherently reusable for different classes, such as
					// those based in Virtual Machines (that will need to handle different experiment names
					// and categories) can be added here.
					"flash" : [
					           {
					        	   "experiment.name"     : "flashdummy",
					        	   "experiment.category" : "Dummy experiments",
					        	   "experiment.picture"	 : "/img/experiments/flash.jpg",
					        	   "page.footer"	 : "",
					        	   "flash.timeout"       : 20,
					        	   "width"               : 500,
					        	   "height"              : 350,
					        	   "swf.file"            : "WeblabFlashSample.swf",
					        	   "message"             : "Note: This is not a real experiment, it's just a demo so as to show that WebLab-Deusto can integrate different web technologies (such as Adobe Flash in this experiment). This demostrates that developing experiments in WebLab-Deusto is really flexible.",
	                       		   "experiment.info.link" : "http://code.google.com/p/weblabdeusto/wiki/Latest_Exp_Flash_Dummy",
	                        	   "experiment.info.description" : "wiki"
	                       		}
	                       		// Other flash experiments could be added here
	                       ],
	                "java" : [
	                          {
	                        	  "experiment.name"      : "javadummy",
	                        	  "experiment.category"  : "Dummy experiments",
	                        	  "experiment.picture"   : "/img/experiments/java.jpg",
	                        	  "width"                : 500,
	                        	  "height"               : 350,
	                        	  "jar.file"             : "WeblabJavaSample.jar",
	                        	  "code"                 : "es.deusto.weblab.client.experiment.plugins.es.deusto.weblab.javadummy.JavaDummyApplet",
	                        	  "message"             : "Note: This is not a real experiment, it's just a demo so as to show that WebLab-Deusto can integrate different web technologies (such as Java Applets in this experiment). This demostrates that developing experiments in WebLab-Deusto is really flexible.",
	                          	  "experiment.info.link" : "http://code.google.com/p/weblabdeusto/wiki/Latest_Exp_Java_Dummy",
	                        	  "experiment.info.description" : "wiki"
	                          }
	                          // Other java experiments could be added here
	                       ],
	                "vm"    : [
	                           {
	                        	   "experiment.picture"	 : "/img/experiments/virtualbox.jpg",
	                        	   "experiment.name"     : "vm",
	                        	   "experiment.category" : "Dummy experiments"
	                           },
	                           {
	                        	   "experiment.picture"	 : "/img/experiments/virtualbox.jpg",
	                        	   "experiment.name"     : "ud-linux-vm",
	                        	   "experiment.category" : "VM experiments",
	                        	   "experiment.info.link" : "http://code.google.com/p/weblabdeusto/wiki/Latest_Exp_Linux_VM",
	                        	   "experiment.info.description" : "wiki"
	                           },
	                           {
	                        	   "experiment.picture"	 : "/img/experiments/virtualbox.jpg",
	                        	   "experiment.name"     : "ud-win-vm",
	                        	   "experiment.category" : "VM experiments"
	                           },
	                           {
	                        	   "experiment.picture"	 : "/img/experiments/virtualbox.jpg",
	                        	   "experiment.name"	 : "vm-win",
	                               "experiment.category" : "Dummy experiments"
	                           }
	                       ],
	                "labview": [
	                            {
		                        	"experiment.picture"  : "/img/experiments/labview.jpg",
	                            	"experiment.name"     : "testone",
	                            	"experiment.category" : "LabVIEW experiments"
	                            },
	                            {
		                        	"experiment.picture"  : "/img/experiments/labview.jpg",
	                            	"experiment.name"     : "blink-led",
	                            	"experiment.category" : "LabVIEW experiments"
	                            },
	                            {
		                        	"experiment.picture"  : "/img/experiments/labview.jpg",
	                            	"experiment.name"     : "prototyping-board-01",
	                            	"experiment.category" : "LabVIEW experiments"
	                            },
	                            {
		                        	"experiment.picture"  : "/img/experiments/labview.jpg",
	                            	"experiment.name"     : "fpga-board-config",
	                            	"experiment.category" : "LabVIEW experiments"
	                            },
	                            {
		                        	"experiment.picture"  : "/img/experiments/labview.jpg",
	                            	"experiment.name"     : "fpga-board-experiment",
	                            	"experiment.category" : "LabVIEW experiments",
	                            	"send.file"           : true
	                            },
	                            {
		                        	"experiment.picture"  : "/img/experiments/labview.jpg",
	                            	"experiment.name"     : "fpga-board-bit",
	                            	"experiment.category" : "LabVIEW experiments"
	                            }
	                       ],
	                "xilinx" : [
							  {
								   "experiment.name"     : "ud-test-pld1",
								   "experiment.category" : "PLD experiments",
	                        	   "experiment.picture"   : "/img/experiments/xilinx.jpg",
								   "is.demo"             : true
							  },
							  {
								   "experiment.name"     : "ud-test-pld2",
								   "experiment.category" : "PLD experiments",
	                        	   "experiment.picture"   : "/img/experiments/xilinx.jpg",
								   "is.demo"             : true
							  },
							  {
								   "experiment.name"     : "ud-demo-pld",
								   "experiment.category" : "PLD experiments",
	                        	   "experiment.picture"   : "/img/experiments/xilinx.jpg",
								   "is.demo"             : true
							  },
							  {
								   "experiment.name"     : "ud-demo-fpga",
								   "experiment.category" : "FPGA experiments",
	                        	   "experiment.picture"   : "/img/experiments/xilinx.jpg",
								   "is.demo"             : true,
								   "experiment.info.link" : "http://code.google.com/p/weblabdeusto/wiki/Latest_Exp_Fpga",
	                        	   "experiment.info.description" : "wiki"
						      },
						      {
							       "experiment.name"     : "ud-demo-xilinx",
							       "experiment.category" : "Xilinx experiments",
	                        	   "experiment.picture"   : "/img/experiments/xilinx.jpg",
							       "is.demo"             : true,
							       "is.multiresource.demo" : true,
							       "experiment.info.link" : "http://code.google.com/p/weblabdeusto/wiki/Latest_Exp_Demo_Xilinx",
	                        	   "experiment.info.description" : "wiki"
						      },
							  {
								   "experiment.name"     : "ud-fpga",
								   "experiment.category" : "FPGA experiments",
	                        	   "experiment.picture"   : "/img/experiments/xilinx.jpg",
	                        	   "experiment.info.link" : "http://code.google.com/p/weblabdeusto/wiki/Latest_Exp_Fpga",
	                        	   "experiment.info.description" : "wiki"
							  },
	                          {
	                        	  "experiment.name"      : "ud-pld",
	                        	  "experiment.category"  : "PLD experiments",
	                        	  "experiment.picture"   : "/img/experiments/xilinx.jpg"
	                          }
	                       ],
	                "dummy" : [
	                           {
	                        	   "experiment.name"     : "ud-dummy",
	                        	   "experiment.category" : "Dummy experiments"
	                           }
	                       ],
	   	        "dummybatch" : [
		                           {
		                        	   "experiment.name"     : "ud-dummy-batch",
		                        	   "experiment.category" : "Dummy experiments"
		                           }
		                ],
	                "robot-standard" : [
	                			{
	                			   "experiment.name" : "robot-standard",
	                			   "experiment.category" : "Robot experiments",
					        	   "experiment.picture"	 : "/img/experiments/robot.jpg",
					        	   "experiment.info.link" : "http://code.google.com/p/weblabdeusto/wiki/Latest_Exp_Robot_Standard",
	                        	   "experiment.info.description" : "wiki"
	                			}
	                		],

	                "robot-movement" : [
	                			{
	                				"experiment.name" : "robot-movement",
						        	"experiment.picture" : "/img/experiments/robot.jpg",
	                				"experiment.category" : "Robot experiments",
	                				"experiment.info.link" : "http://code.google.com/p/weblabdeusto/wiki/Latest_Exp_Robot_Movement",
	                        	    "experiment.info.description" : "wiki"
	                			}
	                		],
	                "robot-proglist" : [
	                			{
	                				"experiment.name" : "robot-proglist",
						        	"experiment.picture"  : "/img/experiments/robot.jpg",
	                				"experiment.category" : "Robot experiments",
	                				"experiment.info.link" : "http://code.google.com/p/weblabdeusto/wiki/Latest_Exp_Robot_Proglist",
	                        	    "experiment.info.description" : "wiki"
	                			}
	                		],
	                "visir" : [
	                           {
	                        	   "experiment.name"     : "visirtest",
	                        	   "experiment.category" : "Dummy experiments",
	                        	   "experiment.picture"  : "/img/experiments/visir.jpg",
	                        	   "page.timer"          : true,
	                        	   "page.footer"         : "Powered by the wonderful VISIR Open Source project developed at the BTH",
	                           	   "experiment.info.link" : "http://code.google.com/p/weblabdeusto/wiki/Latest_Exp_Visir",
	                        	   "experiment.info.description" : "wiki"
	                           },
	                           {
	                        	   "experiment.name"     : "lxi_visir",
	                        	   "experiment.category" : "Visir experiments",
	                        	   "experiment.picture"  : "/img/experiments/visir.jpg",
	                        	   "page.timer"          : true,
	                        	   "page.footer"         : "Powered by the wonderful VISIR Open Source project developed at the BTH",
	                           	   "experiment.info.link" : "http://code.google.com/p/weblabdeusto/wiki/Latest_Exp_Visir",
	                        	   "experiment.info.description" : "wiki"
	                           },
                                   {
	                        	   "experiment.name"     : "visir",
	                        	   "experiment.category" : "Visir experiments",
	                        	   "experiment.picture"  : "/img/experiments/visir.jpg",
	                        	   "page.timer"          : true,
	                        	   "page.footer"         : "Powered by the wonderful VISIR Open Source project developed at the BTH",
	                           	   "experiment.info.link" : "http://code.google.com/p/weblabdeusto/wiki/Latest_Exp_Visir",
	                        	   "experiment.info.description" : "wiki"
	                           }
	                       ],
	                "logic" : [
	                           {
	                        	   "experiment.name"     : "ud-logic",
	                        	   "experiment.category" : "PIC experiments",
	                        	   "experiment.picture"   : "/img/experiments/logic.jpg",
	                        	   "experiment.info.link" : "http://code.google.com/p/weblabdeusto/wiki/Latest_Exp_Logic",
	                        	   "experiment.info.description" : "wiki"
	                           }
	                       ],
	                "binary" : [
	                            {
	                               "experiment.name"     : "ud-binary",
	                               "experiment.category" : "PLD experiments"
	                            }
	                       ],
	                "gpib"   : [
	                            {
	                               "experiment.name"     : "ud-gpib",
	                               "experiment.category" : "GPIB experiments"
	                            }
	                       ],
	                "gpib1" : [
	                            {
	                               "experiment.name"     : "ud-gpib1",
	                               "experiment.category" : "GPIB experiments"
	                            }
	                        ],
	                "gpib2" : [
	                           {
	                        	   "experiment.name"     : "ud-gpib2",
	                        	   "experiment.category" : "GPIB experiments"
	                           }
	                        ],
	                "pic"   : [
	                           {
	                        	   "experiment.name"     : "ud-pic",
	                        	   "experiment.category" : "PIC experiments",
	                        	   "experiment.picture"  : "/img/experiments/microchip.jpg"
	                           }
	                        ],
	                "pic2"  : [
	                           {
	                        	   "experiment.name"     : "ud-pic2",
	                        	   "experiment.category" : "PIC experiments",
	                        	   "experiment.picture"  : "/img/experiments/microchip.jpg"
	                           }
	                        ]
		}
}
<|endoftext|>


<commit_before><commit_msg>Correct the piechart colors too<commit_after><|endoftext|>


<commit_before>// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//

//= require ./app/lib/core/jquery-2.1.4.js
//= require ./app/lib/core/jquery-ui-1.11.2.js
//= require ./app/lib/core/underscore-1.8.3.js

//= require ./app/lib/animations/velocity.min.js
//= require ./app/lib/animations/velocity.ui.js

//not_used= require_tree ./app/lib/spine
//= require ./app/lib/spine/spine.coffee
//= require ./app/lib/spine/ajax.coffee
//= require ./app/lib/spine/local.coffee
//= require ./app/lib/spine/route.coffee

//= require ./app/lib/flot/jquery.flot.js
//= require ./app/lib/flot/jquery.flot.selection.js

//not_used= require_tree ./app/lib/bootstrap
//= require ./app/lib/bootstrap/dropdown.js
//= require ./app/lib/bootstrap/tooltip.js
//= require ./app/lib/bootstrap/popover.js
//= require ./app/lib/bootstrap/popover-enhance.js

// modified by Felix Jan-2014
//= require ./app/lib/bootstrap/modal.js

//= require ./app/lib/bootstrap/tab.js
//= require ./app/lib/bootstrap/transition.js
//= require ./app/lib/bootstrap/button.js
//= require ./app/lib/bootstrap/collapse.js

//= require ./app/lib/rangy/rangy-core.js
//= require ./app/lib/rangy/rangy-classapplier.js
//= require ./app/lib/rangy/rangy-textrange.js
//= require ./app/lib/rangy/rangy-highlighter.js

//= require_tree ./app/lib/base

//= require ./app/index.js.coffee

// IE8 workaround for missing console.log
if (!window.console) {
  window.console = {}
}
if (!console.log) {
  console.log = function(){}
}

function escapeRegExp(str) {
  return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
}

Date.prototype.getWeek = function() {
  var onejan = new Date(this.getFullYear(),0,1);
  return Math.ceil((((this - onejan) / 86400000) + onejan.getDay()+1)/7);
}

function difference(object1, object2) {
  var changes = {};
  for ( var name in object1 ) {
    if ( name in object2 ) {
      if ( _.isObject( object2[name] ) && !_.isArray( object2[name] ) ) {
        var diff = difference( object1[name], object2[name] );
        if ( !_.isEmpty( diff ) ) {
            changes[name] = diff;
        }
      } else if ( !_.isEqual( object1[name], object2[name] ) ) {
        changes[name] = object2[name];
      }
    }
  }
  return changes;
}

// clone, just data, no instances of objects
function clone(item, full) {
  if (!item) { return item }

  // ignore certain objects
  var acceptedInstances = [ 'Object', 'Number', 'String', 'Boolean', 'Array' ]
  if (full) {
    acceptedInstances.push( 'Function' )
  }
  if (item && item.constructor) {
    if (!_.contains(acceptedInstances, item.constructor.name)) {
      return
    }
  }

  // copy array
  var result;
  if ( _.isArray(item) )  {
    result = []
    item.forEach(function(child, index, array) {
      result[index] = clone( child, full )
    });
  }

  // copy function
  else if ( _.isFunction(item) ) {
    result = item.bind({})
  }

  // copy object
  else if ( _.isObject(item) ) {
    result = {}
    for(var key in item) {
      if (item.hasOwnProperty(key)) {
        result[key] = clone( item[key], full )
      }
    }
  }

  // copy others
  else {
    result = item
  }
  return result
}

// taken from http://stackoverflow.com/questions/4459928/how-to-deep-clone-in-javascript
function clone2(item) {
    if (!item) { return item; } // null, undefined values check

    var types = [ Number, String, Boolean ],
        result;

    // normalizing primitives if someone did new String('aaa'), or new Number('444');
    types.forEach(function(type) {
        if (item instanceof type) {
            result = type( item );
        }
    });

    if (typeof result == "undefined") {
        if (Object.prototype.toString.call( item ) === "[object Array]") {
            result = [];
            item.forEach(function(child, index, array) {
                result[index] = clone( child );
            });
        } else if (typeof item == "object") {
            // testing that this is DOM
            if (item.nodeType && typeof item.cloneNode == "function") {
                var result = item.cloneNode( true );
            } else if (!item.prototype) { // check that this is a literal
                if (item instanceof Date) {
                    result = new Date(item);
                } else {
                    // it is an object literal
                    result = {};
                    for (var i in item) {
                        result[i] = clone( item[i] );
                    }
                }
            } else {
                // depending what you would like here,
                // just keep the reference, or create new object
                if (false && item.constructor) {
                    // would not advice to do that, reason? Read below
                    result = new item.constructor();
                } else {
                    result = item;
                }
            }
        } else {
            result = item;
        }
    }

    return result;
}

jQuery.event.special.remove = {
  remove: function(e) {
    if (e.handler) e.handler();
  }
};

// start application
jQuery(function(){
  new App.Run();
});<commit_msg>clone() is now IE comparable.<commit_after>// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//

//= require ./app/lib/core/jquery-2.1.4.js
//= require ./app/lib/core/jquery-ui-1.11.2.js
//= require ./app/lib/core/underscore-1.8.3.js

//= require ./app/lib/animations/velocity.min.js
//= require ./app/lib/animations/velocity.ui.js

//not_used= require_tree ./app/lib/spine
//= require ./app/lib/spine/spine.coffee
//= require ./app/lib/spine/ajax.coffee
//= require ./app/lib/spine/local.coffee
//= require ./app/lib/spine/route.coffee

//= require ./app/lib/flot/jquery.flot.js
//= require ./app/lib/flot/jquery.flot.selection.js

//not_used= require_tree ./app/lib/bootstrap
//= require ./app/lib/bootstrap/dropdown.js
//= require ./app/lib/bootstrap/tooltip.js
//= require ./app/lib/bootstrap/popover.js
//= require ./app/lib/bootstrap/popover-enhance.js

// modified by Felix Jan-2014
//= require ./app/lib/bootstrap/modal.js

//= require ./app/lib/bootstrap/tab.js
//= require ./app/lib/bootstrap/transition.js
//= require ./app/lib/bootstrap/button.js
//= require ./app/lib/bootstrap/collapse.js

//= require ./app/lib/rangy/rangy-core.js
//= require ./app/lib/rangy/rangy-classapplier.js
//= require ./app/lib/rangy/rangy-textrange.js
//= require ./app/lib/rangy/rangy-highlighter.js

//= require_tree ./app/lib/base

//= require ./app/index.js.coffee

// IE8 workaround for missing console.log
if (!window.console) {
  window.console = {}
}
if (!console.log) {
  console.log = function(){}
}

function escapeRegExp(str) {
  return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
}

Date.prototype.getWeek = function() {
  var onejan = new Date(this.getFullYear(),0,1);
  return Math.ceil((((this - onejan) / 86400000) + onejan.getDay()+1)/7);
}

function difference(object1, object2) {
  var changes = {};
  for ( var name in object1 ) {
    if ( name in object2 ) {
      if ( _.isObject( object2[name] ) && !_.isArray( object2[name] ) ) {
        var diff = difference( object1[name], object2[name] );
        if ( !_.isEmpty( diff ) ) {
            changes[name] = diff;
        }
      } else if ( !_.isEqual( object1[name], object2[name] ) ) {
        changes[name] = object2[name];
      }
    }
  }
  return changes;
}

// clone, just data, no instances of objects
function clone(item, full) {

  // just return/clone false conditions
  if (!item) { return item }

  var itemType = item.constructor.name

  // IE behavior // doesn't know item.constructor.name, detect it by underscore
  if (itemType === undefined) {
    if (_.isArray(item)) {
      itemType = 'Array'
    }
    else if (_.isNumber(item)) {
      itemType = 'Number'
    }
    else if (_.isString(item)) {
      itemType = 'String'
    }
    else if (_.isBoolean(item)) {
      itemType = 'Boolean'
    }
    else if (_.isFunction(item)) {
      itemType = 'Function'
    }
    else if (_.isObject(item)) {
      itemType = 'Object'
    }
  }

  // ignore certain objects
  var acceptedInstances = [ 'Object', 'Number', 'String', 'Boolean', 'Array' ]
  if (full) {
    acceptedInstances.push( 'Function' )
  }

  // check if item is accepted to get cloned
  if (itemType && !_.contains(acceptedInstances, itemType)) {
    console.log('no acceptedInstances', itemType)
    return
  }

  // copy array
  var result;
  if (itemType == 'Array')  {
    result = []
    item.forEach(function(child, index, array) {
      result[index] = clone( child, full )
    });
  }

  // copy function
  else if (itemType == 'Function') {
    result = item.bind({})
  }

  // copy object
  else if (itemType == 'Object') {
    result = {}
    for(var key in item) {
      if (item.hasOwnProperty(key)) {
        result[key] = clone( item[key], full )
      }
    }
  }
  // copy others
  else {
    result = item
  }
  return result
}

// taken from http://stackoverflow.com/questions/4459928/how-to-deep-clone-in-javascript
function clone2(item) {
    if (!item) { return item; } // null, undefined values check

    var types = [ Number, String, Boolean ],
        result;

    // normalizing primitives if someone did new String('aaa'), or new Number('444');
    types.forEach(function(type) {
        if (item instanceof type) {
            result = type( item );
        }
    });

    if (typeof result == "undefined") {
        if (Object.prototype.toString.call( item ) === "[object Array]") {
            result = [];
            item.forEach(function(child, index, array) {
                result[index] = clone( child );
            });
        } else if (typeof item == "object") {
            // testing that this is DOM
            if (item.nodeType && typeof item.cloneNode == "function") {
                var result = item.cloneNode( true );
            } else if (!item.prototype) { // check that this is a literal
                if (item instanceof Date) {
                    result = new Date(item);
                } else {
                    // it is an object literal
                    result = {};
                    for (var i in item) {
                        result[i] = clone( item[i] );
                    }
                }
            } else {
                // depending what you would like here,
                // just keep the reference, or create new object
                if (false && item.constructor) {
                    // would not advice to do that, reason? Read below
                    result = new item.constructor();
                } else {
                    result = item;
                }
            }
        } else {
            result = item;
        }
    }

    return result;
}

jQuery.event.special.remove = {
  remove: function(e) {
    if (e.handler) e.handler();
  }
};

// start application
jQuery(function(){
  new App.Run();
});<|endoftext|>


<commit_before>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require d3-v3-min
//= require jquery
//= require jquery_ujs
//= require jquery-ui-touch-punch-min
//= require bootstrap-custom
//= require_tree .

<commit_msg>Fixed js load order problem<commit_after>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require d3-v3-min
//= require jquery
//= require jquery_ujs
//= require bootstrap-custom
//= require_tree .
//= require jquery-ui-touch-punch-min
<|endoftext|>