<commit_before>  var camera, scene, renderer;
  var mesh;

  var lastVelocity = 0,
      lastTime = false,
      lastPosition = 0;

  init();
  animate();
  initGyro();

  function init() {
    var geometry = new THREE.BoxGeometry( 200, 200, 400 );

    var material = new THREE.MeshBasicMaterial({
      color: 0xaff00,
      wireframe: true
    });

    mesh = new THREE.Mesh( geometry, material );

    //

    renderer = new THREE.WebGLRenderer();
    renderer.setPixelRatio( window.devicePixelRatio );
    renderer.setSize( window.innerWidth, window.innerHeight );
    document.body.appendChild( renderer.domElement );

    //

    camera = new THREE.PerspectiveCamera( 70, window.innerWidth /
        window.innerHeight, 1, 1000 );

    camera.position.z = 800;

    //

    scene = new THREE.Scene();
    scene.add( mesh );

    //

    window.addEventListener( 'resize', onWindowResize, false );

  }

  // acceleration is in (meters/second)^2
  // timestep is in seconds
  function velocity (lastVelocity, acceleration, timeStep) {
    return lastVelocity + (acceleration * timeStep);
  }

  function position (lastPosition, lastVelocity, acceleration, timeStep) {
    return lastPosition + lastVelocity * timeStep +
        (0.5 * acceleration * timeStep * timeStep);
  }

  function initGyro() {
    var listYAccelerations = [];
    var noise = false;
    console.log("start tracking");
    gyro.frequency = 10000;

    function trackAxis(axis) {

    }

    function calibrateNoise(axis) {

    }

    // some comments
    gyro.startTracking(function(o) {
      var yAcceleration = o.y.toFixed(3),
        needsRender = false,
        currentTime = new Date(),
        sum;

      if (listYAccelerations.length <= 100) {
        listYAccelerations.push(yAcceleration);

      } else if (listYAccelerations.length > 100) {

        if (noise === false) {
          sum = 0;

          for (var i = 0; i < listYAccelerations.length; i++) {
            sum += parseFloat(listYAccelerations[i]);
          }

          noise = sum / 100;
          // calibration done
        }

        // dividing by 1000 to decrease velocity by 1000 and position by
        // 100000
        // time is in seconds
        // if there is no last time
        // or if last time is greater than frequency
        if (lastTime && lastTime <= (gyro.frequency * 2) / 1000) {
          timeStep = (currentTime - lastTime) / 1000;
          lastTime = currentTime;

        } else {
          lastTime = currentTime;
          timeStep = (currentTime - lastTime) / 1000;
        }

        yAcceleration -= noise;

        if (yAcceleration <= 0.05 &&
            yAcceleration >= -0.05) {

          yAcceleration = 0;
        }
        console.log("lastPosition: " + lastPosition);
        console.log("lastVelocity: " + lastVelocity);
        console.log("timeStep: " + timeStep);
        console.log("acceleration: " + yAcceleration);

        lastVelocity = velocity(lastVelocity, yAcceleration, timeStep);
        lastPosition = position(lastPosition, lastVelocity, yAcceleration,
            timeStep);

        // if (newY <= 400 && newY >= -400) {
        //   mesh.position.y = newY;
        //   needsRender = true;
        // }
        // if (needsRender) {
        //   renderer.render( scene, camera );
        //   console.log(mesh.position.y);
        // }

      }

      if (parseFloat(o.x.toFixed(1)) >= 0.5) {
        console.log("x-acceleration: "  + o.x.toFixed(3));
      }

      if (parseFloat(o.z.toFixed(1)) >= 9.8) {
        console.log("z-acceleration: "  + o.z.toFixed(3));
      }
    });
  }

  function onWindowResize() {

    camera.aspect = window.innerWidth / window.innerHeight;
    camera.updateProjectionMatrix();

    renderer.setSize( window.innerWidth, window.innerHeight );

  }

  function animate() {

    requestAnimationFrame( animate );

    renderer.render( scene, camera );

  }
<commit_msg>cleaning up<commit_after>  var camera, scene, renderer;
  var mesh;

  var lastVelocity = 0,
      lastTime = false,
      lastPosition = 0;

  init();
  animate();
  initGyro();

  function init() {
    var geometry = new THREE.BoxGeometry( 200, 200, 400 );

    var material = new THREE.MeshBasicMaterial({
      color: 0xaff00,
      wireframe: true
    });

    mesh = new THREE.Mesh( geometry, material );

    //

    renderer = new THREE.WebGLRenderer();
    renderer.setPixelRatio( window.devicePixelRatio );
    renderer.setSize( window.innerWidth, window.innerHeight );
    document.body.appendChild( renderer.domElement );

    //

    camera = new THREE.PerspectiveCamera( 70, window.innerWidth /
        window.innerHeight, 1, 1000 );

    camera.position.z = 800;

    //

    scene = new THREE.Scene();
    scene.add( mesh );

    //

    window.addEventListener( 'resize', onWindowResize, false );

  }

  // acceleration is in (meters/second)^2
  // timestep is in seconds
  function velocity (lastVelocity, acceleration, timeStep) {
    return lastVelocity + (acceleration * timeStep);
  }

  function position (lastPosition, lastVelocity, acceleration, timeStep) {
    return lastPosition + lastVelocity * timeStep +
        (0.5 * acceleration * timeStep * timeStep);
  }

  function initGyro() {
    var listYAccelerations = [],
      noise = false;

    gyro.frequency = 1000;

    function trackAxis(axis) {
    }

    function calibrateNoise(axis) {
    }

    // some comments
    gyro.startTracking(function(o) {
      var yAcceleration = o.y.toFixed(3),
        needsRender = false,
        currentTime = new Date(),
        sum;

      console.log("gyro");

      if (listYAccelerations.length <= 100) {
        listYAccelerations.push(yAcceleration);

      } else if (listYAccelerations.length > 100) {

        if (noise === false) {
          sum = 0;

          for (var i = 0; i < listYAccelerations.length; i++) {
            sum += parseFloat(listYAccelerations[i]);
          }

          noise = sum / 100;
          // calibration done
        }

        // dividing by 1000 to decrease velocity by 1000 and position by
        // 100000
        // time is in seconds
        // if there is no last time
        // or if last time is greater than frequency
        if (lastTime && lastTime <= (gyro.frequency * 2) / 1000) {
          timeStep = (currentTime - lastTime) / 1000;
          lastTime = currentTime;

        } else {
          lastTime = currentTime;
          timeStep = (currentTime - lastTime) / 1000;
        }

        yAcceleration -= noise;

        if (yAcceleration <= 0.05 &&
            yAcceleration >= -0.05) {

          yAcceleration = 0;
        }
        console.log("lastPosition: " + lastPosition);
        console.log("lastVelocity: " + lastVelocity);
        console.log("timeStep: " + timeStep);
        console.log("acceleration: " + yAcceleration);

        lastVelocity = velocity(lastVelocity, yAcceleration, timeStep);
        lastPosition = position(lastPosition, lastVelocity, yAcceleration,
            timeStep);

        // if (newY <= 400 && newY >= -400) {
        //   mesh.position.y = newY;
        //   needsRender = true;
        // }
        // if (needsRender) {
        //   renderer.render( scene, camera );
        //   console.log(mesh.position.y);
        // }

      }

      if (parseFloat(o.x.toFixed(1)) >= 0.5) {
        console.log("x-acceleration: "  + o.x.toFixed(3));
      }

      if (parseFloat(o.z.toFixed(1)) >= 9.8) {
        console.log("z-acceleration: "  + o.z.toFixed(3));
      }
    });
  }

  function onWindowResize() {

    camera.aspect = window.innerWidth / window.innerHeight;
    camera.updateProjectionMatrix();

    renderer.setSize( window.innerWidth, window.innerHeight );

  }

  function animate() {

    requestAnimationFrame( animate );

    renderer.render( scene, camera );

  }
<|endoftext|>


<commit_before>

  var camera, scene, renderer;
  var mesh;

  var lastVelocity = 0,
      lastTime = new Date(),
      lastPosition = 0;

  init();
  animate();
  initGyro();

  function init() {

    renderer = new THREE.WebGLRenderer();
    renderer.setPixelRatio( window.devicePixelRatio );
    renderer.setSize( window.innerWidth, window.innerHeight );
    document.body.appendChild( renderer.domElement );

    //

    camera = new THREE.PerspectiveCamera( 70, window.innerWidth /
      window.innerHeight, 1, 1000 );
      camera.position.z = 600;

      scene = new THREE.Scene();

      var geometry = new THREE.BoxGeometry( 200, 200, 200 );

      var texture = THREE.ImageUtils.loadTexture( 'textures/crate.gif' );
      texture.anisotropy = renderer.getMaxAnisotropy();

      var material = new THREE.MeshBasicMaterial( { map: texture } );

      mesh = new THREE.Mesh( geometry, material );
      scene.add( mesh );

      //

      window.addEventListener( 'resize', onWindowResize, false );

    }

    function velocity (lastVelocity, acceleration, timeStep) {
      return lastVelocity + (acceleration * timeStep);
    }

    function position (lastPosition, lastVelocity, acceleration, timeStep) {
      return lastPosition + lastVelocity * timeStep +
          (0.5 * acceleration * timeStep * timeStep);
    }

    // some comments
    function initGyro() {
      console.log("start tracking");
      gyro.frequency = 100;

      gyro.startTracking(function(o) {
        var yNoiseUpper = 0.2,
          yNoiseLower = -0.13;

        if (parseFloat(o.y.toFixed(2)) >= yNoiseUpper ||
            parseFloat(o.y.toFixed(2)) <= yNoiseLower) {

          if (parseFloat(o.y.toFixed(2)) >= yNoiseUpper) {

          }
          var yAcceleration = o.y.toFixed(3),
          needsRender = false,
          currentTime = new Date(),

          // dividing by 1000 to decrease velocity by 1000 and position by
          // 100000
          timeStep = (currentTime - lastTime) / 1000;

          console.log("y-acceleration: "  + o.y.toFixed(3));

          lastVelocity = velocity(lastVelocity, yAcceleration, timeStep);
          lastPosition = position(lastPosition, lastVelocity, yAcceleration, timeStep);
          console.log("Velocity: " + lastVelocity);
          console.log("Position: " + lastPosition);
          lastTime = currentTime;

          // if (newY <= 400 && newY >= -400) {
          //   mesh.position.y = newY;
          //   needsRender = true;
          // }

          if (needsRender) {
            renderer.render( scene, camera );
            console.log(mesh.position.y);
          }

          // o.z
          // o.alpha
          // o.beta
          // o.gamma
        }

        if (parseFloat(o.x.toFixed(1)) >= 0.5) {
          console.log("x-acceleration: "  + o.x.toFixed(3));
        }

        if (parseFloat(o.z.toFixed(1)) >= 9.8) {
          console.log("z-acceleration: "  + o.z.toFixed(3));
        }
      });
    }

    function onWindowResize() {

      camera.aspect = window.innerWidth / window.innerHeight;
      camera.updateProjectionMatrix();

      renderer.setSize( window.innerWidth, window.innerHeight );

    }

    function animate() {

      requestAnimationFrame( animate );

      renderer.render( scene, camera );

    }
<commit_msg>increasing frequency<commit_after>

  var camera, scene, renderer;
  var mesh;

  var lastVelocity = 0,
      lastTime = new Date(),
      lastPosition = 0;

  init();
  animate();
  initGyro();

  function init() {

    renderer = new THREE.WebGLRenderer();
    renderer.setPixelRatio( window.devicePixelRatio );
    renderer.setSize( window.innerWidth, window.innerHeight );
    document.body.appendChild( renderer.domElement );

    //

    camera = new THREE.PerspectiveCamera( 70, window.innerWidth /
      window.innerHeight, 1, 1000 );
      camera.position.z = 600;

      scene = new THREE.Scene();

      var geometry = new THREE.BoxGeometry( 200, 200, 200 );

      var texture = THREE.ImageUtils.loadTexture( 'textures/crate.gif' );
      texture.anisotropy = renderer.getMaxAnisotropy();

      var material = new THREE.MeshBasicMaterial( { map: texture } );

      mesh = new THREE.Mesh( geometry, material );
      scene.add( mesh );

      //

      window.addEventListener( 'resize', onWindowResize, false );

    }

    function velocity (lastVelocity, acceleration, timeStep) {
      return lastVelocity + (acceleration * timeStep);
    }

    function position (lastPosition, lastVelocity, acceleration, timeStep) {
      return lastPosition + lastVelocity * timeStep +
          (0.5 * acceleration * timeStep * timeStep);
    }

    // some comments
    function initGyro() {
      console.log("start tracking");
      gyro.frequency = 10;

      gyro.startTracking(function(o) {
        var yNoiseUpper = 0.2,
          yNoiseLower = -0.13;

        if (parseFloat(o.y.toFixed(2)) >= yNoiseUpper ||
            parseFloat(o.y.toFixed(2)) <= yNoiseLower) {

          if (parseFloat(o.y.toFixed(2)) >= yNoiseUpper) {

          }
          var yAcceleration = o.y.toFixed(3),
          needsRender = false,
          currentTime = new Date(),

          // dividing by 1000 to decrease velocity by 1000 and position by
          // 100000
          timeStep = (currentTime - lastTime) / 1000;

          console.log("y-acceleration: "  + o.y.toFixed(3));

          lastVelocity = velocity(lastVelocity, yAcceleration, timeStep);
          lastPosition = position(lastPosition, lastVelocity, yAcceleration, timeStep);
          console.log("Velocity: " + lastVelocity);
          console.log("Position: " + lastPosition);
          lastTime = currentTime;

          // if (newY <= 400 && newY >= -400) {
          //   mesh.position.y = newY;
          //   needsRender = true;
          // }

          if (needsRender) {
            renderer.render( scene, camera );
            console.log(mesh.position.y);
          }

          // o.z
          // o.alpha
          // o.beta
          // o.gamma
        }

        if (parseFloat(o.x.toFixed(1)) >= 0.5) {
          console.log("x-acceleration: "  + o.x.toFixed(3));
        }

        if (parseFloat(o.z.toFixed(1)) >= 9.8) {
          console.log("z-acceleration: "  + o.z.toFixed(3));
        }
      });
    }

    function onWindowResize() {

      camera.aspect = window.innerWidth / window.innerHeight;
      camera.updateProjectionMatrix();

      renderer.setSize( window.innerWidth, window.innerHeight );

    }

    function animate() {

      requestAnimationFrame( animate );

      renderer.render( scene, camera );

    }
<|endoftext|>


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

'use strict'

import <%= appNameCamel %> from '../'
import yargs from 'yargs'

const argv = yargs.usage('Usage: $0 [options] command')
  .showHelpOnFail(false, 'Specify --help for available options')
  .version(() => {
    return require('../../package.json').version
  })
  .help('help')
  .argv

console.log(`Executing ${argv.$0}`);
<commit_msg>style(cli): Remove extra semicolon<commit_after>#!/usr/bin/env node

'use strict'

import <%= appNameCamel %> from '../'
import yargs from 'yargs'

const argv = yargs.usage('Usage: $0 [options] command')
  .showHelpOnFail(false, 'Specify --help for available options')
  .version(() => {
    return require('../../package.json').version
  })
  .help('help')
  .argv

console.log(`Executing ${argv.$0}`)
<|endoftext|>


<commit_before>var download = require('./download').download;
var spawn = require('child_process').spawn;
var path = require('path');
var fs = require('fs');

var ZMQ;
var ZMQ_REPO;
if (process.platform == 'linux') {
  ZMQ = '4.1.6';
  ZMQ_REPO = 'zeromq4-1';
} else {
  ZMQ = '4.2.0';
  ZMQ_REPO = 'libzmq';
}

function buildZMQ(scriptPath, zmqDir) {
  console.log('Building libzmq for ' + process.platform);

  var child = spawn(scriptPath, [ZMQ]);

  child.stdout.pipe(process.stdout);
  child.stderr.pipe(process.stderr);
  child.on('error', function(err) {
    console.error('Failed to start child process.');
  });
  child.on('close', function(code) {
    if (code !== 0) {
      return console.error('child process exited with code ' + code);
    }
    var message = 'Succesfully build libzmq on ' + Date();
    fs.writeFile(path.join(zmqDir, 'BUILD_SUCCESS'), message, function(err) {
      if (err) {
        return console.error(err.message);
      }
      console.log(message);
    });
});
}

if (process.platform === 'win32') {
  var LIB_URL = 'https://github.com/nteract/libzmq-win/releases/download/v2.0.0/libzmq-' + ZMQ + '-' + process.arch + '.lib';
  var DIR_NAME = path.join(__dirname, '..', 'windows', 'lib');
  var FILE_NAME = path.join(DIR_NAME, 'libzmq.lib');

  if (!fs.existsSync(DIR_NAME)) {
    fs.mkdirSync(DIR_NAME);
  }

  if (!fs.existsSync(FILE_NAME)) {
    console.log('Downloading libzmq for Windows');
    download(LIB_URL, FILE_NAME, function() {
      console.log('Download finished');
    });
  }

} else {
  var SCRIPT_PATH = path.join(__dirname, 'build_libzmq.sh');
  var TAR_URL = 'https://github.com/zeromq/' + ZMQ_REPO + '/releases/download/v' + ZMQ + '/zeromq-' + ZMQ + '.tar.gz';
  var DIR_NAME = path.join(__dirname, '..', 'zmq');
  var FILE_NAME = path.join(DIR_NAME, 'zeromq-' + ZMQ + '.tar.gz');

  if (!fs.existsSync(DIR_NAME)) {
    fs.mkdirSync(DIR_NAME);
  }

  if (fs.existsSync(path.join(DIR_NAME, 'BUILD_SUCCESS'))) {
    return console.log('Libzmq found, skipping rebuild.');
  }

  if (fs.existsSync(FILE_NAME)) {
    return buildZMQ(SCRIPT_PATH, DIR_NAME);
  }

  download(TAR_URL, FILE_NAME, function() {
    buildZMQ(SCRIPT_PATH, DIR_NAME);
  });

}
<commit_msg>run prettier on preinstall, fix errant return<commit_after>var download = require("./download").download;
var spawn = require("child_process").spawn;
var path = require("path");
var fs = require("fs");

var ZMQ;
var ZMQ_REPO;
if (process.platform == "linux") {
  ZMQ = "4.1.6";
  ZMQ_REPO = "zeromq4-1";
} else {
  ZMQ = "4.2.0";
  ZMQ_REPO = "libzmq";
}

function buildZMQ(scriptPath, zmqDir) {
  console.log("Building libzmq for " + process.platform);

  var child = spawn(scriptPath, [ZMQ]);

  child.stdout.pipe(process.stdout);
  child.stderr.pipe(process.stderr);
  child.on("error", function(err) {
    console.error("Failed to start child process.");
  });
  child.on("close", function(code) {
    if (code !== 0) {
      return console.error("child process exited with code " + code);
    }
    var message = "Succesfully build libzmq on " + Date();
    fs.writeFile(path.join(zmqDir, "BUILD_SUCCESS"), message, function(err) {
      if (err) {
        return console.error(err.message);
      }
      console.log(message);
    });
  });
}

if (process.platform === "win32") {
  var LIB_URL =
    "https://github.com/nteract/libzmq-win/releases/download/v2.0.0/libzmq-" +
    ZMQ +
    "-" +
    process.arch +
    ".lib";
  var DIR_NAME = path.join(__dirname, "..", "windows", "lib");
  var FILE_NAME = path.join(DIR_NAME, "libzmq.lib");

  if (!fs.existsSync(DIR_NAME)) {
    fs.mkdirSync(DIR_NAME);
  }

  if (!fs.existsSync(FILE_NAME)) {
    console.log("Downloading libzmq for Windows");
    download(LIB_URL, FILE_NAME, function() {
      console.log("Download finished");
    });
  }
} else {
  var SCRIPT_PATH = path.join(__dirname, "build_libzmq.sh");
  var TAR_URL =
    "https://github.com/zeromq/" +
    ZMQ_REPO +
    "/releases/download/v" +
    ZMQ +
    "/zeromq-" +
    ZMQ +
    ".tar.gz";
  var DIR_NAME = path.join(__dirname, "..", "zmq");
  var FILE_NAME = path.join(DIR_NAME, "zeromq-" + ZMQ + ".tar.gz");

  if (!fs.existsSync(DIR_NAME)) {
    fs.mkdirSync(DIR_NAME);
  }

  if (fs.existsSync(path.join(DIR_NAME, "BUILD_SUCCESS"))) {
    console.log("Libzmq found, skipping rebuild.");
    process.exit(0);
  }

  if (fs.existsSync(FILE_NAME)) {
    buildZMQ(SCRIPT_PATH, DIR_NAME);
    process.exit(0);
  }

  download(TAR_URL, FILE_NAME, function() {
    buildZMQ(SCRIPT_PATH, DIR_NAME);
  });
}
<|endoftext|>


<commit_before>import React, { PropTypes } from 'react'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import * as courseActions from '../../actions/courseActions'
import CourseList from './CourseList'

class CoursesPage extends React.Component {
	constructor (props, context) {
	  super(props, context)
	}
	render() {
		const { courses } = this.props;
		return (

Courses

				<CourseList courses={ courses } />

		)
	}
}

CoursesPage.propTypes = {
	courses: PropTypes.array.isRequired,
	actions: PropTypes.object.isRequired
}

function mapStateToProps (state, ownProps) {
	return {
		courses: state.courses
	}
}

function mapDispatchToProps (dispatch) {
	return {
		actions: bindActionCreators(courseActions, dispatch)
	}
}

export default connect(mapStateToProps, mapDispatchToProps)(CoursesPage)<commit_msg>Update CoursesPage.js<commit_after>import React, { PropTypes } from 'react'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import * as courseActions from '../../actions/courseActions'
import CourseList from './CourseList'

class CoursesPage extends React.Component {
	constructor (props, context) {
	  super(props, context)
	}
	render() {
		const { courses } = this.props
		return (

Courses

				<CourseList courses={ courses } />

		)
	}
}

CoursesPage.propTypes = {
	courses: PropTypes.array.isRequired,
	actions: PropTypes.object.isRequired
}

function mapStateToProps (state, ownProps) {
	return {
		courses: state.courses
	}
}

function mapDispatchToProps (dispatch) {
	return {
		actions: bindActionCreators(courseActions, dispatch)
	}
}

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


<commit_before>const listjs = require('list.js');
const $ = require('jquery'); //would like to remove it
const {clipboard, ipcRenderer} = require('electron');
let symbols = require('./data/symbols.json').symbols;

let options = {
    valueNames: [ 'symbol', 'name' ],
    item: '

'
};
let symbollist = new List('symbollist', options, symbols);

createCatFilter()

function createCatFilter() {
  let cats = getCategories();
  cats.unshift("all");
  let r, l;
  let form = document.getElementById("cat-filter");
  for (let i=0; i<cats.length; i++) {
    r = document.createElement("input");
    l = document.createElement("label");
    r.setAttribute("type", "radio");
    r.setAttribute("name", "cats");
    r.setAttribute("value", cats[i]);
    r.setAttribute("tabindex", "-1");
    if (i === 0) {
      r.checked = true;
    }
    r.setAttribute("id", "cat-" + cats[i]);
    l.setAttribute("for","cat-" + cats[i]);
    l.innerHTML = cats[i];
    form.appendChild(r);
    form.appendChild(l);
  }
}

function getCategories() {
  let cats = [];
  for (let i=0; i<symbols.length; i++) {
    cats.push(symbols[i].cat);
  }
  cats = uniq_fast(cats)
  return cats;
}

function uniq_fast(a) {
    var seen = {};
    var out = [];
    var len = a.length;
    var j = 0;
    for(let i = 0; i < len; i++) {
         let item = a[i];
         if(seen[item] !== 1) {
               seen[item] = 1;
               out[j++] = item;
         }
    }
    return out;
}

$('input[name="cats"]').on('change', () => {
  let c = $('input[name="cats"]:checked').val();
  symbollist.remove()
  symbollist.add(symbols)
  let cats = getCategories()
  if (c != "all") {
    for (let i=0; i<cats.length; i++) {
      if (cats[i] != c) {
        symbollist.remove('cat', cats[i])
      }
    }
  }
})

//http://jsfiddle.net/Vtn5Y/
var li = $('li');
var liSelected;
$(window).keydown(function(e){
    if($('.selected') == null) {
      liSelected = false;
    }
    if(e.which === 40){
        if(liSelected){
            liSelected.removeClass('selected');
            next = liSelected.next();
            if(next.length > 0){
                liSelected = next.addClass('selected');
            }else{
                liSelected = li.eq(0).addClass('selected');
            }
        }else{
            liSelected = li.eq(0).addClass('selected');
        }
    }else if(e.which === 38){
        if(liSelected){
            liSelected.removeClass('selected');
            next = liSelected.prev();
            if(next.length > 0){
                liSelected = next.addClass('selected');
            }else{
                liSelected = li.last().addClass('selected');
            }
        }else{
            liSelected = li.last().addClass('selected');
        }
    }
    else if (e.which === 13) {
      var d = $('.selected h3').text()
      clipboard.writeText(d)
      console.log(clipboard.readText())
      //MESSAGE
      ipcRenderer.send('asynchronous-message', 'hide');
    }
});

function quit() {
  ipcRenderer.send('asynchronous-message', 'quit');
}
<commit_msg>Tidy up: switch, quotation marks JS all string quotation marks to single switch for keydown<commit_after>const listjs = require('list.js');
const $ = require('jquery'); //would like to remove it
const {clipboard, ipcRenderer} = require('electron');
let symbols = require('./data/symbols.json').symbols;

let options = {
    valueNames: [ 'symbol', 'name' ],
    item: '

'
};
let symbollist = new List('symbollist', options, symbols);

createCatFilter()

function createCatFilter() {
  let cats = getCategories();
  cats.unshift('all');
  let r, l;
  let form = document.getElementById('cat-filter');
  for (let i=0; i<cats.length; i++) {
    r = document.createElement('input');
    l = document.createElement('label');
    r.setAttribute('type', 'radio');
    r.setAttribute('name', 'cats');
    r.setAttribute('value', cats[i]);
    r.setAttribute('tabindex', '-1');
    if (i === 0) {
      r.checked = true;
    }
    r.setAttribute('id', 'cat-' + cats[i]);
    l.setAttribute('for','cat-' + cats[i]);
    l.innerHTML = cats[i];
    form.appendChild(r);
    form.appendChild(l);
  }
}

function getCategories() {
  let cats = [];
  for (let i=0; i<symbols.length; i++) {
    cats.push(symbols[i].cat);
  }
  cats = uniq_fast(cats)
  return cats;
}

function uniq_fast(a) {
    var seen = {};
    var out = [];
    var len = a.length;
    var j = 0;
    for(let i = 0; i < len; i++) {
         let item = a[i];
         if(seen[item] !== 1) {
               seen[item] = 1;
               out[j++] = item;
         }
    }
    return out;
}

$('input[name="cats"]').on('change', () => {
  let c = $('input[name="cats"]:checked').val();
  symbollist.remove()
  symbollist.add(symbols)
  let cats = getCategories()
  if (c != 'all') {
    for (let i=0; i<cats.length; i++) {
      if (cats[i] != c) {
        symbollist.remove('cat', cats[i])
      }
    }
  }
})

//http://jsfiddle.net/Vtn5Y/
var li = $('li');
var liSelected;
$(window).keydown(function(e){
    if($('.selected') == null) {
      liSelected = false;
    }
    switch (e.which) {
      case 40:
        if(liSelected){
            liSelected.removeClass('selected');
            next = liSelected.next();
            if(next.length > 0){
                liSelected = next.addClass('selected');
            }else{
                liSelected = li.eq(0).addClass('selected');
            }
        }else{
            liSelected = li.eq(0).addClass('selected');
        }
        break;
      case 38:
        if(liSelected){
            liSelected.removeClass('selected');
            next = liSelected.prev();
            if(next.length > 0){
                liSelected = next.addClass('selected');
            }else{
                liSelected = li.last().addClass('selected');
            }
        }else{
            liSelected = li.last().addClass('selected');
        }
        break;
      case 13:
        var d = $('.selected h3').text()
        clipboard.writeText(d)
        console.log(clipboard.readText())
        //MESSAGE
        ipcRenderer.send('asynchronous-message', 'hide');
        break;
      default:
        return;
    }
});

function quit() {
  ipcRenderer.send('asynchronous-message', 'quit');
}
<|endoftext|>


<commit_before>require('../../support/test_helper');

const assert = require('../../support/assert');
const TestClient = require('../../support/test-client');

describe('authorization', function() {
    it('should create a layergroup with regular apikey token', function(done) {
        const apikeyToken = 'regular1';
        const mapConfig = {
            version: '1.7.0',
            layers: [
                {
                    options: {
                        sql: 'select * FROM test_table_localhost_regular1',
                        cartocss: TestClient.CARTOCSS.POINTS,
                        cartocss_version: '2.3.0'
                    }
                }
            ]
        };
        const testClient = new TestClient(mapConfig, apikeyToken);

        testClient.getLayergroup(function (err, layergroupResult) {
            assert.ifError(err);

            assert.ok(layergroupResult.layergroupid);

            testClient.drain(done);
        });
    });

    it('should fail if apikey does not gran access to table', function (done) {
        const mapConfig = {
            version: '1.7.0',
            layers: [
                {
                    options: {
                        sql: 'select * FROM test_table_localhost_regular1',
                        cartocss: TestClient.CARTOCSS.POINTS,
                        cartocss_version: '2.3.0'
                    }
                }
            ]
        };
        const testClient = new TestClient(mapConfig); //no apikey provided, using default

        testClient.getLayergroup({ response: { status: 403 } }, function (err, layergroupResult) { //TODO 401
            assert.ifError(err);

            assert.ok(layergroupResult.hasOwnProperty('errors'));
            assert.equal(layergroupResult.errors.length, 1);
            assert.ok(layergroupResult.errors[0].match(/permission denied/), layergroupResult.errors[0]);

            testClient.drain(done);
        });
    });

    it('should forbide access to API if API key does not grant access', function (done) {
        const apikeyToken = 'regular2';
        const mapConfig = {
            version: '1.7.0',
            layers: [
                {
                    options: {
                        sql: 'select * FROM test_table_localhost_regular1',
                        cartocss: TestClient.CARTOCSS.POINTS,
                        cartocss_version: '2.3.0'
                    }
                }
            ]
        };
        const testClient = new TestClient(mapConfig, apikeyToken);

        testClient.getLayergroup({ response: { status: 403 } }, function (err, layergroupResult) {
            assert.ifError(err);

            assert.ok(layergroupResult.hasOwnProperty('errors'));
            assert.equal(layergroupResult.errors.length, 1);
            assert.ok(layergroupResult.errors[0].match(/Forbidden/), layergroupResult.errors[0]);

            testClient.drain(done);
        });
    });
});
<commit_msg>fix test typo<commit_after>require('../../support/test_helper');

const assert = require('../../support/assert');
const TestClient = require('../../support/test-client');

describe('authorization', function() {
    it('should create a layergroup with regular apikey token', function(done) {
        const apikeyToken = 'regular1';
        const mapConfig = {
            version: '1.7.0',
            layers: [
                {
                    options: {
                        sql: 'select * FROM test_table_localhost_regular1',
                        cartocss: TestClient.CARTOCSS.POINTS,
                        cartocss_version: '2.3.0'
                    }
                }
            ]
        };
        const testClient = new TestClient(mapConfig, apikeyToken);

        testClient.getLayergroup(function (err, layergroupResult) {
            assert.ifError(err);

            assert.ok(layergroupResult.layergroupid);

            testClient.drain(done);
        });
    });

    it('should fail if apikey does not grant access to table', function (done) {
        const mapConfig = {
            version: '1.7.0',
            layers: [
                {
                    options: {
                        sql: 'select * FROM test_table_localhost_regular1',
                        cartocss: TestClient.CARTOCSS.POINTS,
                        cartocss_version: '2.3.0'
                    }
                }
            ]
        };
        const testClient = new TestClient(mapConfig); //no apikey provided, using default

        testClient.getLayergroup({ response: { status: 403 } }, function (err, layergroupResult) { //TODO 401
            assert.ifError(err);

            assert.ok(layergroupResult.hasOwnProperty('errors'));
            assert.equal(layergroupResult.errors.length, 1);
            assert.ok(layergroupResult.errors[0].match(/permission denied/), layergroupResult.errors[0]);

            testClient.drain(done);
        });
    });

    it('should forbide access to API if API key does not grant access', function (done) {
        const apikeyToken = 'regular2';
        const mapConfig = {
            version: '1.7.0',
            layers: [
                {
                    options: {
                        sql: 'select * FROM test_table_localhost_regular1',
                        cartocss: TestClient.CARTOCSS.POINTS,
                        cartocss_version: '2.3.0'
                    }
                }
            ]
        };
        const testClient = new TestClient(mapConfig, apikeyToken);

        testClient.getLayergroup({ response: { status: 403 } }, function (err, layergroupResult) {
            assert.ifError(err);

            assert.ok(layergroupResult.hasOwnProperty('errors'));
            assert.equal(layergroupResult.errors.length, 1);
            assert.ok(layergroupResult.errors[0].match(/Forbidden/), layergroupResult.errors[0]);

            testClient.drain(done);
        });
    });
});
<|endoftext|>


<commit_before>require('../support/test_helper');

const assert = require('../support/assert');
const mapnik = require('mapnik');
const TestClient = require('../support/test_client');
const INVALID_FORMAT_ERROR = 'Invalid format, there is no CartoCSS defined';
const INCOMPATIBLE_LAYERS_ERROR = `
    The layergroup contains incompatible layers: don\'t mix styled layers with non styled layers (without cartocss)
`;
const POLYGONS_SQL = `
    select
        st_buffer(st_setsrid(st_makepoint(x*10, x*10), 4326)::geography, 1000000)::geometry as the_geom
    from generate_series(-3, 3) x
`;
const POINTS_SQL = `
    select
        st_setsrid(st_makepoint(x*10, x*10), 4326) as the_geom
    from generate_series(-3, 3) x
`;

describe('vector aggregation', function () {
    it('should create a single layer map w/o cartocss', function (done) {
        this.testClient = new TestClient({
            version: '1.6.0',
            layers: [
                {
                    type: 'cartodb',
                    options: {
                        sql: POINTS_SQL
                    }
                }
            ]
        });

        this.testClient.createLayergroup((err, layergroup) => {
            if (err) {
                return done(err);
            }

            assert.ok(layergroup);
            assert.ok(layergroup.layergroupid);

            done();
        });
    });

    it('should fail whether layergroup cantains incompatible layers', function (done) {
        this.testClient = new TestClient({
            version: '1.6.0',
            layers: [
                {
                    type: 'cartodb',
                    options: {
                        sql: POINTS_SQL
                    }
                },
                {
                    type: 'cartodb',
                    options: {
                        sql: POINTS_SQL,
                        cartocss: '#layer { marker-fill:blue; marker-allow-overlap:true; }',
                        cartocss_version: '2.0.2',
                    }
                }
            ]
        });

        this.testClient.createLayergroup((err) => {
            assert.ok(err);
            assert.equal(INCOMPATIBLE_LAYERS_ERROR, err.message);
            done();
        });
    });

    it('should get tile 0/0/0 for a vector layergroup', function (done) {
        this.testClient = new TestClient({
            version: '1.6.0',
            layers: [
                {
                    type: 'cartodb',
                    options: {
                        sql: 'select st_setsrid(st_makepoint(0, 0), 4326) as the_geom'
                    }
                }
            ]
        });

        this.testClient.getTile(0, 0, 0, { format: 'mvt' }, (err, mvtTile) => {
            if (err) {
                return done(err);
            }

            var vtile = new mapnik.VectorTile(0, 0, 0);
            vtile.setData(mvtTile);
            assert.equal(vtile.painted(), true);
            assert.equal(vtile.empty(), false);
            done();
        });
    });

    it('should fail when requesting a raster format tile for a vector layergroup', function (done) {
        this.testClient = new TestClient({
            version: '1.6.0',
            layers: [
                {
                    type: 'cartodb',
                    options: {
                        sql: POLYGONS_SQL,

                    }
                }
            ]
        });

        this.testClient.getTile(0, 0, 0, { format: 'png' }, (err) => {
            assert.ok(err);
            assert.equal(INVALID_FORMAT_ERROR, err.message);
            assert.equal(400, err.http_status);

            done();
        });
    });

});
<commit_msg>Fix bad assertion<commit_after>require('../support/test_helper');

const assert = require('../support/assert');
const mapnik = require('mapnik');
const TestClient = require('../support/test_client');
const INVALID_FORMAT_ERROR = 'Invalid format, there is no CartoCSS defined';
const INCOMPATIBLE_LAYERS_ERROR =
`The layergroup contains incompatible layers: don\'t mix styled layers with non styled layers (without cartocss)`;
const POLYGONS_SQL = `
    select
        st_buffer(st_setsrid(st_makepoint(x*10, x*10), 4326)::geography, 1000000)::geometry as the_geom
    from generate_series(-3, 3) x
`;
const POINTS_SQL = `
    select
        st_setsrid(st_makepoint(x*10, x*10), 4326) as the_geom
    from generate_series(-3, 3) x
`;

describe('vector aggregation', function () {
    it('should create a single layer map w/o cartocss', function (done) {
        this.testClient = new TestClient({
            version: '1.6.0',
            layers: [
                {
                    type: 'cartodb',
                    options: {
                        sql: POINTS_SQL
                    }
                }
            ]
        });

        this.testClient.createLayergroup((err, layergroup) => {
            if (err) {
                return done(err);
            }

            assert.ok(layergroup);
            assert.ok(layergroup.layergroupid);

            done();
        });
    });

    it('should fail whether layergroup cantains incompatible layers', function (done) {
        this.testClient = new TestClient({
            version: '1.6.0',
            layers: [
                {
                    type: 'cartodb',
                    options: {
                        sql: POINTS_SQL
                    }
                },
                {
                    type: 'cartodb',
                    options: {
                        sql: POINTS_SQL,
                        cartocss: '#layer { marker-fill:blue; marker-allow-overlap:true; }',
                        cartocss_version: '2.0.2',
                    }
                }
            ]
        });

        this.testClient.createLayergroup((err) => {
            assert.ok(err);
            assert.equal(INCOMPATIBLE_LAYERS_ERROR, err.message);
            done();
        });
    });

    it('should get tile 0/0/0 for a vector layergroup', function (done) {
        this.testClient = new TestClient({
            version: '1.6.0',
            layers: [
                {
                    type: 'cartodb',
                    options: {
                        sql: 'select st_setsrid(st_makepoint(0, 0), 4326) as the_geom'
                    }
                }
            ]
        });

        this.testClient.getTile(0, 0, 0, { format: 'mvt' }, (err, mvtTile) => {
            if (err) {
                return done(err);
            }

            var vtile = new mapnik.VectorTile(0, 0, 0);
            vtile.setData(mvtTile);
            assert.equal(vtile.painted(), true);
            assert.equal(vtile.empty(), false);
            done();
        });
    });

    it('should fail when requesting a raster format tile for a vector layergroup', function (done) {
        this.testClient = new TestClient({
            version: '1.6.0',
            layers: [
                {
                    type: 'cartodb',
                    options: {
                        sql: POLYGONS_SQL,

                    }
                }
            ]
        });

        this.testClient.getTile(0, 0, 0, { format: 'png' }, (err) => {
            assert.ok(err);
            assert.equal(INVALID_FORMAT_ERROR, err.message);
            assert.equal(400, err.http_status);

            done();
        });
    });

});
<|endoftext|>


<commit_before>'use strict';

var addMatchingCardsToResults = require('../lib/add-matching-cards-to-results');

describe('addMatchingCardsToResults', function () {
  it('adds a clone of matching card configurations to results array', function () {
    var a = {};
    var b = {
      patterns: ['1', '2']
    };
    var results = [a];

    addMatchingCardsToResults('1', b, results);

    expect(results.length).to.equal(2);
    expect(results[0]).to.equal(a);
    expect(results[1].patterns).to.deep.equal(['1', '2']);
    expect(results[1]).to.not.equal(b);
  });

  it('does not add a configuration if it does not match', function () {
    var a = {};
    var b = {
      patterns: ['1', '2']
    };
    var results = [a];

    addMatchingCardsToResults('3', b, results);

    expect(results.length).to.equal(1);
    expect(results[0]).to.equal(a);
  });

  it('adds a matchStrength property to configuration if card number matcehs and the length equals or is greater than the pattern length', function () {
    var results = [];

    addMatchingCardsToResults('304', {
      patterns: ['304']
    }, results);

    addMatchingCardsToResults('304', {
      patterns: ['30']
    }, results);

    addMatchingCardsToResults('304', {
      patterns: ['3045']
    }, results);

    addMatchingCardsToResults('304', {
      patterns: ['3']
    }, results);

    expect(results.length).to.equal(4);
    expect(results[0].matchStrength).to.equal(3);
    expect(results[1].matchStrength).to.equal(2);
    expect(results[2].matchStrength).to.equal(undefined); // eslint-disable-line no-undefined
    expect(results[3].matchStrength).to.equal(1);
  });

  it('adds a matchStrength property to configuration if card number matcehs and the length equals or is greater than an entry of the pattern range', function () {
    var results = [];

    addMatchingCardsToResults('304', {
      patterns: [['304', '305']]
    }, results);

    addMatchingCardsToResults('304', {
      patterns: [['30', '99']]
    }, results);

    addMatchingCardsToResults('304', {
      patterns: [['3045', '4500']]
    }, results);

    addMatchingCardsToResults('304', {
      patterns: [['3', '5']]
    }, results);

    expect(results.length).to.equal(4);
    expect(results[0].matchStrength).to.equal(3);
    expect(results[1].matchStrength).to.equal(2);
    expect(results[2].matchStrength).to.equal(undefined); // eslint-disable-line no-undefined
    expect(results[3].matchStrength).to.equal(1);
  });
});
<commit_msg>Fix typo<commit_after>'use strict';

var addMatchingCardsToResults = require('../lib/add-matching-cards-to-results');

describe('addMatchingCardsToResults', function () {
  it('adds a clone of matching card configurations to results array', function () {
    var a = {};
    var b = {
      patterns: ['1', '2']
    };
    var results = [a];

    addMatchingCardsToResults('1', b, results);

    expect(results.length).to.equal(2);
    expect(results[0]).to.equal(a);
    expect(results[1].patterns).to.deep.equal(['1', '2']);
    expect(results[1]).to.not.equal(b);
  });

  it('does not add a configuration if it does not match', function () {
    var a = {};
    var b = {
      patterns: ['1', '2']
    };
    var results = [a];

    addMatchingCardsToResults('3', b, results);

    expect(results.length).to.equal(1);
    expect(results[0]).to.equal(a);
  });

  it('adds a matchStrength property to configuration if card number matches and the length equals or is greater than the pattern length', function () {
    var results = [];

    addMatchingCardsToResults('304', {
      patterns: ['304']
    }, results);

    addMatchingCardsToResults('304', {
      patterns: ['30']
    }, results);

    addMatchingCardsToResults('304', {
      patterns: ['3045']
    }, results);

    addMatchingCardsToResults('304', {
      patterns: ['3']
    }, results);

    expect(results.length).to.equal(4);
    expect(results[0].matchStrength).to.equal(3);
    expect(results[1].matchStrength).to.equal(2);
    expect(results[2].matchStrength).to.equal(undefined); // eslint-disable-line no-undefined
    expect(results[3].matchStrength).to.equal(1);
  });

  it('adds a matchStrength property to configuration if card number matcehs and the length equals or is greater than an entry of the pattern range', function () {
    var results = [];

    addMatchingCardsToResults('304', {
      patterns: [['304', '305']]
    }, results);

    addMatchingCardsToResults('304', {
      patterns: [['30', '99']]
    }, results);

    addMatchingCardsToResults('304', {
      patterns: [['3045', '4500']]
    }, results);

    addMatchingCardsToResults('304', {
      patterns: [['3', '5']]
    }, results);

    expect(results.length).to.equal(4);
    expect(results[0].matchStrength).to.equal(3);
    expect(results[1].matchStrength).to.equal(2);
    expect(results[2].matchStrength).to.equal(undefined); // eslint-disable-line no-undefined
    expect(results[3].matchStrength).to.equal(1);
  });
});
<|endoftext|>


<commit_before>const hideAxis = {
    xAxis: [
        {
            type: 'value',
            show: false,
            boundaryGap: false,
            splitNumber: 4,
            scale: true,
            splitLine: {
                show: false
            },
            splitArea: {
                show: false
            }
        }
    ],
    yAxis: [
        {
            type: 'value',
            show: false,
            boundaryGap: false,
            splitNumber: 4,
            scale: true,
            splitLine: {
                show: false
            },
            splitArea: {
                show: false
            }
        }
    ]
};

const baseCartesian = {
    calculable: true,
    dataZoom: [
        {
            show: false,
            type: 'slider',
            throttle: 200,
            xAxisIndex: [0]
        },
        {
            show: false,
            type: 'slider',
            throttle: 200,
            yAxisIndex: [0]
        },
        {
            type: 'inside',
            throttle: 200,
            xAxisIndex: [0]
        },
        {
            type: 'inside',
            throttle: 200,
            yAxisIndex: [0]
        }
    ],
    xAxis: [
        {
            show: true,
            scale: true,
            // triggerEvent: false,
            // silent: true,
            splitLine: {
                show: false
            },
            splitArea: {
                show: false
            },
            axisTick: {
                interval: 0
            }
        }
    ],
    yAxis: [
        {
            show: true,
            scale: true,
            // triggerEvent: false,
            // silent: true,
            splitLine: {
                show: true
            },
            splitArea: {
                show: true
            }
        }
    ]
};

const axis = {
    line: {
        dataZoom: baseCartesian.dataZoom,
        calculable: baseCartesian.calculable,
        xAxis: [
            {
                ...baseCartesian.xAxis[0],
                type: 'category',
                boundaryGap: false,
                data: ['abc', 'def', 'ghi', 'jk', 'lm', 'no', 'pq']
            }
        ],
        yAxis: [
            {
                ...baseCartesian.yAxis[0],
                boundaryGap: false,
                type: 'value'
            }
        ]
    },
    bar: {
        dataZoom: baseCartesian.dataZoom,
        calculable: baseCartesian.calculable,
        xAxis: [
            {
                ...baseCartesian.xAxis[0],
                type: 'category',
                data: ['abc', 'def', 'ghi', 'jk', 'lm', 'no', 'pq']
            }
        ],
        yAxis: [
            {
                ...baseCartesian.yAxis[0],
                type: 'value'
            }
        ]
    },
    pie: {
        xAxis: [
            {
                type: 'category',
                show: false,
                boundaryGap: false,
                scale: true,
                splitLine: {
                    show: false
                },
                splitArea: {
                    show: false
                },
                data: ['abc', 'def', 'ghi', 'jk', 'lm', 'no', 'pq']
            }
        ],
        yAxis: [
            {
                type: 'value',
                show: false,
                boundaryGap: false,
                scale: true,
                splitLine: {
                    show: false
                },
                splitArea: {
                    show: false
                }
            }
        ]
    },
    scatter: {
        dataZoom: baseCartesian.dataZoom,
        calculable: baseCartesian.calculable,
        xAxis: [
            {
                ...baseCartesian.xAxis[0],
                boundaryGap: false,
                type: 'value'
            }
        ],
        yAxis: [
            {
                ...baseCartesian.yAxis[0],
                boundaryGap: false,
                type: 'value'
            }
        ]
    }
};

export const chartTypes = {
    line: {
        name: 'Líneas',
        value: 'line',
        config: {
            ...axis.line
        },
        subtypes: {
            basic: {
                name: 'Básico',
                value: 'basic',
                config: {},
                seriesConfig: {
                    type: 'line',
                    clickable: false
                }
            },
            area: {
                name: 'Área',
                value: 'area',
                config: {},
                seriesConfig: {
                    type: 'line',
                    clickable: false,
                    smooth: true,
                    itemStyle: { normal: { areaStyle: { type: 'default' } } }
                }
            }
        },
        controls: {
            subtype: true,
            columnPanel: {
                category: true,
                data: false,
                tree: true
            },
            dataPanel: {
                rangeX: true,
                rangeY: true,
                invert: true,
                transpose: true
            }
        }
    },
    bar: {
        name: 'Barras',
        value: 'bar',
        config: {
            ...axis.bar
        },
        subtypes: {
            basic: {
                name: 'Básico',
                value: 'basic',
                config: {},
                seriesConfig: {
                    type: 'bar',
                    clickable: false
                }
            },
            waterfall: {
                name: 'Cascada',
                value: 'waterfall',
                config: {},
                seriesConfig: {
                    type: 'bar',
                    clickable: false
                }
            },
            stackedBars: {
                name: 'Barras apiladas',
                value: 'stackedBars',
                config: {},
                seriesConfig: {
                    type: 'bar',
                    clickable: false
                }
            },
            splitBars: {
                name: 'Barras divididas',
                value: 'splitBars',
                config: {},
                seriesConfig: {
                    type: 'bar',
                    clickable: false
                }
            },
            crossedBars: {
                name: 'Barras cruzadas',
                value: 'crossedBars',
                config: {},
                seriesConfig: {
                    type: 'bar',
                    clickable: false
                }
            }
        },
        controls: {
            subtype: true,
            columnPanel: {
                category: true,
                data: false,
                tree: true
            },
            dataPanel: {
                rangeX: true,
                rangeY: true,
                invert: true,
                transpose: true
            }
        }
    },
    pie: {
        name: 'Torta',
        value: 'pie',
        config: {
            ...axis.pie
        },
        subtypes: {
            basic: {
                name: 'Básico',
                value: 'basic',
                config: {},
                seriesConfig: {
                    type: 'pie',
                    clickable: false,
                    legendHoverLink: false
                }
            },
            doughnut: {
                name: 'Dona',
                value: 'doughnut',
                config: {},
                seriesConfig: {
                    type: 'pie',
                    clickable: false,
                    legendHoverLink: false,
                    radius: ['40%', '75%']
                }
            },
            nightingale: {
                name: 'Nightingale',
                value: 'nightingale',
                config: {},
                seriesConfig: {
                    type: 'pie',
                    clickable: false,
                    legendHoverLink: false,
                    roseType: 'area'
                }
            },
            nightingaleDonut: {
                name: 'Dona Nightingale',
                value: 'nightingaleDonut',
                config: {},
                seriesConfig: {
                    type: 'pie',
                    clickable: false,
                    legendHoverLink: false,
                    roseType: 'area',
                    radius: ['40%', '75%']
                }
            }
        },
        controls: {
            subtype: true,
            columnPanel: {
                category: false,
                data: true,
                tree: false
            },
            dataPanel: {
                rangeX: false,
                rangeY: false,
                invert: true,
                transpose: false
            }
        }
    },
    scatter: {
        name: 'Dispersión',
        value: 'scatter',
        config: {
            ...axis.scatter
        },
        subtypes: {
            basic: {
                name: 'Básico',
                value: 'basic',
                config: {},
                seriesConfig: {
                    type: 'scatter',
                    clickable: false
                }
            },
            bubbles: {
                name: 'Burbujas',
                value: 'bubbles',
                config: {},
                seriesConfig: {
                    type: 'scatter',
                    clickable: false
                }
            },
            largeScale: {
                name: 'Gran escala',
                value: 'largeScale',
                config: {},
                seriesConfig: {
                    type: 'scatter',
                    clickable: false
                }
            }
        },
        controls: {
            subtype: true,
            columnPanel: {
                category: true,
                data: false,
                tree: true
            },
            dataPanel: {
                rangeX: true,
                rangeY: true,
                invert: true,
                transpose: true
            }
        }
    },
    radar: {
        name: 'Radar',
        value: 'radar',
        config: {
            ...hideAxis
        },
        subtypes: {
            basic: {
                name: 'Básico',
                value: 'basic',
                config: {

                },
                seriesConfig: {
                    type: 'radar',
                    clickable: false,
                    polarIndex: 1
                }
            },
            filled: {
                name: 'Relleno',
                value: 'filled',
                config: {

                },
                seriesConfig: {
                    type: 'radar',
                    clickable: false
                }
            }
        },
        controls: {
            subtype: true,
            columnPanel: {
                category: false,
                data: true,
                tree: false
            },
            dataPanel: {
                rangeX: false,
                rangeY: false,
                invert: true,
                transpose: false
            }
        }
    },
    sankey: {
        name: 'Cuerdas',
        value: 'sankey',
        config: {
            ...hideAxis
        },
        subtypes: {
            basic: {
                name: 'Básico',
                value: 'basic',
                config: {

                },
                seriesConfig: {
                    type: 'sankey',
                    clickable: false
                }
            },
            alternative: {
                name: 'Alternativo',
                value: 'alternative',
                config: {

                },
                seriesConfig: {
                    type: 'sankey',
                    clickable: false
                }
            }
        },
        controls: {
            subtype: true,
            columnPanel: {
                category: false,
                data: true,
                tree: false
            },
            dataPanel: {
                rangeX: false,
                rangeY: false,
                invert: true,
                transpose: false
            }
        }
    },
    force: {
        name: 'Grafos',
        value: 'force',
        config: {
            ...hideAxis
        },
        subtypes: {
            basic: {
                name: 'Básico',
                value: 'basic',
                config: {

                },
                seriesConfig: {
                    type: 'force',
                    clickable: false
                }
            },
            tree: {
                name: 'Árbol',
                value: 'tree',
                config: {

                },
                seriesConfig: {
                    type: 'force',
                    clickable: false
                }
            }
        },
        controls: {
            subtype: true,
            columnPanel: {
                category: false,
                data: true,
                tree: false
            },
            dataPanel: {
                rangeX: false,
                rangeY: false,
                invert: true,
                transpose: false
            }
        }
    },
    mixed: {
        name: 'Combinados',
        value: 'combined',
        config: {
            ...axis.line
        },
        subtypes: {
            linePlusBars: {
                name: 'Líneas + barras',
                value: 'linePlusBars',
                config: {

                },
                seriesConfig: {
                    type: 'line',
                    clickable: false
                }
            },
            linePlusScatter: {
                name: 'Líneas + dispersión',
                value: 'linePlusScatter',
                config: {

                },
                seriesConfig: {
                    type: 'line',
                    clickable: false
                }
            }
        },
        controls: {
            subtype: true,
            columnPanel: {
                category: true,
                data: false,
                tree: true
            },
            dataPanel: {
                rangeX: true,
                rangeY: true,
                invert: true,
                transpose: true
            }
        }
    }
};

export const chartSubtype = {
    line: 'basic',
    bar: 'basic',
    pie: 'basic',
    scatter: 'basic',
    radar: 'basic',
    sankey: 'basic',
    force: 'basic',
    mixed: 'basic'
};<commit_msg>Reordered pie variants<commit_after>const hideAxis = {
    xAxis: [
        {
            type: 'value',
            show: false,
            boundaryGap: false,
            splitNumber: 4,
            scale: true,
            splitLine: {
                show: false
            },
            splitArea: {
                show: false
            }
        }
    ],
    yAxis: [
        {
            type: 'value',
            show: false,
            boundaryGap: false,
            splitNumber: 4,
            scale: true,
            splitLine: {
                show: false
            },
            splitArea: {
                show: false
            }
        }
    ]
};

const baseCartesian = {
    calculable: true,
    dataZoom: [
        {
            show: false,
            type: 'slider',
            throttle: 200,
            xAxisIndex: [0]
        },
        {
            show: false,
            type: 'slider',
            throttle: 200,
            yAxisIndex: [0]
        },
        {
            type: 'inside',
            throttle: 200,
            xAxisIndex: [0]
        },
        {
            type: 'inside',
            throttle: 200,
            yAxisIndex: [0]
        }
    ],
    xAxis: [
        {
            show: true,
            scale: true,
            // triggerEvent: false,
            // silent: true,
            splitLine: {
                show: false
            },
            splitArea: {
                show: false
            },
            axisTick: {
                interval: 0
            }
        }
    ],
    yAxis: [
        {
            show: true,
            scale: true,
            // triggerEvent: false,
            // silent: true,
            splitLine: {
                show: true
            },
            splitArea: {
                show: true
            }
        }
    ]
};

const axis = {
    line: {
        dataZoom: baseCartesian.dataZoom,
        calculable: baseCartesian.calculable,
        xAxis: [
            {
                ...baseCartesian.xAxis[0],
                type: 'category',
                boundaryGap: false,
                data: ['abc', 'def', 'ghi', 'jk', 'lm', 'no', 'pq']
            }
        ],
        yAxis: [
            {
                ...baseCartesian.yAxis[0],
                boundaryGap: false,
                type: 'value'
            }
        ]
    },
    bar: {
        dataZoom: baseCartesian.dataZoom,
        calculable: baseCartesian.calculable,
        xAxis: [
            {
                ...baseCartesian.xAxis[0],
                type: 'category',
                data: ['abc', 'def', 'ghi', 'jk', 'lm', 'no', 'pq']
            }
        ],
        yAxis: [
            {
                ...baseCartesian.yAxis[0],
                type: 'value'
            }
        ]
    },
    pie: {
        xAxis: [
            {
                type: 'category',
                show: false,
                boundaryGap: false,
                scale: true,
                splitLine: {
                    show: false
                },
                splitArea: {
                    show: false
                },
                data: ['abc', 'def', 'ghi', 'jk', 'lm', 'no', 'pq']
            }
        ],
        yAxis: [
            {
                type: 'value',
                show: false,
                boundaryGap: false,
                scale: true,
                splitLine: {
                    show: false
                },
                splitArea: {
                    show: false
                }
            }
        ]
    },
    scatter: {
        dataZoom: baseCartesian.dataZoom,
        calculable: baseCartesian.calculable,
        xAxis: [
            {
                ...baseCartesian.xAxis[0],
                boundaryGap: false,
                type: 'value'
            }
        ],
        yAxis: [
            {
                ...baseCartesian.yAxis[0],
                boundaryGap: false,
                type: 'value'
            }
        ]
    }
};

export const chartTypes = {
    line: {
        name: 'Líneas',
        value: 'line',
        config: {
            ...axis.line
        },
        subtypes: {
            basic: {
                name: 'Básico',
                value: 'basic',
                config: {},
                seriesConfig: {
                    type: 'line',
                    clickable: false
                }
            },
            area: {
                name: 'Área',
                value: 'area',
                config: {},
                seriesConfig: {
                    type: 'line',
                    clickable: false,
                    smooth: true,
                    itemStyle: { normal: { areaStyle: { type: 'default' } } }
                }
            }
        },
        controls: {
            subtype: true,
            columnPanel: {
                category: true,
                data: false,
                tree: true
            },
            dataPanel: {
                rangeX: true,
                rangeY: true,
                invert: true,
                transpose: true
            }
        }
    },
    bar: {
        name: 'Barras',
        value: 'bar',
        config: {
            ...axis.bar
        },
        subtypes: {
            basic: {
                name: 'Básico',
                value: 'basic',
                config: {},
                seriesConfig: {
                    type: 'bar',
                    clickable: false
                }
            },
            waterfall: {
                name: 'Cascada',
                value: 'waterfall',
                config: {},
                seriesConfig: {
                    type: 'bar',
                    clickable: false
                }
            },
            stackedBars: {
                name: 'Barras apiladas',
                value: 'stackedBars',
                config: {},
                seriesConfig: {
                    type: 'bar',
                    clickable: false
                }
            },
            splitBars: {
                name: 'Barras divididas',
                value: 'splitBars',
                config: {},
                seriesConfig: {
                    type: 'bar',
                    clickable: false
                }
            },
            crossedBars: {
                name: 'Barras cruzadas',
                value: 'crossedBars',
                config: {},
                seriesConfig: {
                    type: 'bar',
                    clickable: false
                }
            }
        },
        controls: {
            subtype: true,
            columnPanel: {
                category: true,
                data: false,
                tree: true
            },
            dataPanel: {
                rangeX: true,
                rangeY: true,
                invert: true,
                transpose: true
            }
        }
    },
    pie: {
        name: 'Torta',
        value: 'pie',
        config: {
            ...axis.pie
        },
        subtypes: {
            basic: {
                name: 'Básico',
                value: 'basic',
                config: {},
                seriesConfig: {
                    type: 'pie',
                    clickable: false,
                    legendHoverLink: false
                }
            },
            nightingale: {
                name: 'Nightingale',
                value: 'nightingale',
                config: {},
                seriesConfig: {
                    type: 'pie',
                    clickable: false,
                    legendHoverLink: false,
                    roseType: 'area'
                }
            },
            doughnut: {
                name: 'Dona',
                value: 'doughnut',
                config: {},
                seriesConfig: {
                    type: 'pie',
                    clickable: false,
                    legendHoverLink: false,
                    radius: ['40%', '75%']
                }
            },
            nightingaleDonut: {
                name: 'Dona Nightingale',
                value: 'nightingaleDonut',
                config: {},
                seriesConfig: {
                    type: 'pie',
                    clickable: false,
                    legendHoverLink: false,
                    roseType: 'area',
                    radius: ['40%', '75%']
                }
            }
        },
        controls: {
            subtype: true,
            columnPanel: {
                category: false,
                data: true,
                tree: false
            },
            dataPanel: {
                rangeX: false,
                rangeY: false,
                invert: true,
                transpose: false
            }
        }
    },
    scatter: {
        name: 'Dispersión',
        value: 'scatter',
        config: {
            ...axis.scatter
        },
        subtypes: {
            basic: {
                name: 'Básico',
                value: 'basic',
                config: {},
                seriesConfig: {
                    type: 'scatter',
                    clickable: false
                }
            },
            bubbles: {
                name: 'Burbujas',
                value: 'bubbles',
                config: {},
                seriesConfig: {
                    type: 'scatter',
                    clickable: false
                }
            },
            largeScale: {
                name: 'Gran escala',
                value: 'largeScale',
                config: {},
                seriesConfig: {
                    type: 'scatter',
                    clickable: false
                }
            }
        },
        controls: {
            subtype: true,
            columnPanel: {
                category: true,
                data: false,
                tree: true
            },
            dataPanel: {
                rangeX: true,
                rangeY: true,
                invert: true,
                transpose: true
            }
        }
    },
    radar: {
        name: 'Radar',
        value: 'radar',
        config: {
            ...hideAxis
        },
        subtypes: {
            basic: {
                name: 'Básico',
                value: 'basic',
                config: {

                },
                seriesConfig: {
                    type: 'radar',
                    clickable: false,
                    polarIndex: 1
                }
            },
            filled: {
                name: 'Relleno',
                value: 'filled',
                config: {

                },
                seriesConfig: {
                    type: 'radar',
                    clickable: false
                }
            }
        },
        controls: {
            subtype: true,
            columnPanel: {
                category: false,
                data: true,
                tree: false
            },
            dataPanel: {
                rangeX: false,
                rangeY: false,
                invert: true,
                transpose: false
            }
        }
    },
    sankey: {
        name: 'Cuerdas',
        value: 'sankey',
        config: {
            ...hideAxis
        },
        subtypes: {
            basic: {
                name: 'Básico',
                value: 'basic',
                config: {

                },
                seriesConfig: {
                    type: 'sankey',
                    clickable: false
                }
            },
            alternative: {
                name: 'Alternativo',
                value: 'alternative',
                config: {

                },
                seriesConfig: {
                    type: 'sankey',
                    clickable: false
                }
            }
        },
        controls: {
            subtype: true,
            columnPanel: {
                category: false,
                data: true,
                tree: false
            },
            dataPanel: {
                rangeX: false,
                rangeY: false,
                invert: true,
                transpose: false
            }
        }
    },
    force: {
        name: 'Grafos',
        value: 'force',
        config: {
            ...hideAxis
        },
        subtypes: {
            basic: {
                name: 'Básico',
                value: 'basic',
                config: {

                },
                seriesConfig: {
                    type: 'force',
                    clickable: false
                }
            },
            tree: {
                name: 'Árbol',
                value: 'tree',
                config: {

                },
                seriesConfig: {
                    type: 'force',
                    clickable: false
                }
            }
        },
        controls: {
            subtype: true,
            columnPanel: {
                category: false,
                data: true,
                tree: false
            },
            dataPanel: {
                rangeX: false,
                rangeY: false,
                invert: true,
                transpose: false
            }
        }
    },
    mixed: {
        name: 'Combinados',
        value: 'combined',
        config: {
            ...axis.line
        },
        subtypes: {
            linePlusBars: {
                name: 'Líneas + barras',
                value: 'linePlusBars',
                config: {

                },
                seriesConfig: {
                    type: 'line',
                    clickable: false
                }
            },
            linePlusScatter: {
                name: 'Líneas + dispersión',
                value: 'linePlusScatter',
                config: {

                },
                seriesConfig: {
                    type: 'line',
                    clickable: false
                }
            }
        },
        controls: {
            subtype: true,
            columnPanel: {
                category: true,
                data: false,
                tree: true
            },
            dataPanel: {
                rangeX: true,
                rangeY: true,
                invert: true,
                transpose: true
            }
        }
    }
};

export const chartSubtype = {
    line: 'basic',
    bar: 'basic',
    pie: 'basic',
    scatter: 'basic',
    radar: 'basic',
    sankey: 'basic',
    force: 'basic',
    mixed: 'basic'
};<|endoftext|>


<commit_before>import { Group } from '../../objects/Group.js';

class WebXRController {

	constructor() {

		this._targetRay = null;
		this._grip = null;
		this._hand = null;

	}

	getHandSpace() {

		if ( this._hand === null ) {

			this._hand = new Group();
			this._hand.matrixAutoUpdate = false;
			this._hand.visible = false;

			this._hand.joints = {};
			this._hand.inputState = { pinching: false };

		}

		return this._hand;

	}

	getTargetRaySpace() {

		if ( this._targetRay === null ) {

			this._targetRay = new Group();
			this._targetRay.matrixAutoUpdate = false;
			this._targetRay.visible = false;

		}

		return this._targetRay;

	}

	getGripSpace() {

		if ( this._grip === null ) {

			this._grip = new Group();
			this._grip.matrixAutoUpdate = false;
			this._grip.visible = false;

		}

		return this._grip;

	}

	dispatchEvent( event ) {

		if ( this._targetRay !== null ) {

			this._targetRay.dispatchEvent( event );

		}

		if ( this._grip !== null ) {

			this._grip.dispatchEvent( event );

		}

		if ( this._hand !== null ) {

			this._hand.dispatchEvent( event );

		}

		return this;

	}

	disconnect( inputSource ) {

		this.dispatchEvent( { type: 'disconnected', data: inputSource } );

		if ( this._targetRay !== null ) {

			this._targetRay.visible = false;

		}

		if ( this._grip !== null ) {

			this._grip.visible = false;

		}

		if ( this._hand !== null ) {

			this._hand.visible = false;

		}

		return this;

	}

	update( inputSource, frame, referenceSpace ) {

		let inputPose = null;
		let gripPose = null;
		let handPose = null;

		const targetRay = this._targetRay;
		const grip = this._grip;
		const hand = this._hand;

		if ( inputSource && frame.session.visibilityState !== 'visible-blurred' ) {

			if ( targetRay !== null ) {

				inputPose = frame.getPose( inputSource.targetRaySpace, referenceSpace );

				if ( inputPose !== null ) {

					targetRay.matrix.fromArray( inputPose.transform.matrix );
					targetRay.matrix.decompose( targetRay.position, targetRay.rotation, targetRay.scale );

				}

			}

			if ( hand && inputSource.hand ) {

				handPose = true;

				for ( const inputjoint of inputSource.hand.values() ) {

					// Update the joints groups with the XRJoint poses
					const jointPose = frame.getJointPose( inputjoint, referenceSpace );

					if ( hand.joints[ inputjoint.jointName ] === undefined ) {

						// The transform of this joint will be updated with the joint pose on each frame
						const joint = new Group();
						joint.matrixAutoUpdate = false;
						joint.visible = false;
						hand.joints[ inputjoint.jointName ] = joint;
						// ??
						hand.add( joint );

					}

					const joint = hand.joints[ inputjoint.jointName ];

					if ( jointPose !== null ) {

						joint.matrix.fromArray( jointPose.transform.matrix );
						joint.matrix.decompose( joint.position, joint.rotation, joint.scale );
						joint.jointRadius = jointPose.radius;

					}

					joint.visible = jointPose !== null;

				}

				// Custom events

				// Check pinchz
				const indexTip = hand.joints[ 'index-finger-tip' ];
				const thumbTip = hand.joints[ 'thumb-tip' ];
				const distance = indexTip.position.distanceTo( thumbTip.position );

				const distanceToPinch = 0.02;
				const threshold = 0.005;

				if ( hand.inputState.pinching && distance > distanceToPinch + threshold ) {

					hand.inputState.pinching = false;
					this.dispatchEvent( {
						type: 'pinchend',
						handedness: inputSource.handedness,
						target: this
					} );

				} else if ( ! hand.inputState.pinching && distance <= distanceToPinch - threshold ) {

					hand.inputState.pinching = true;
					this.dispatchEvent( {
						type: 'pinchstart',
						handedness: inputSource.handedness,
						target: this
					} );

				}

			} else {

				if ( grip !== null && inputSource.gripSpace ) {

					gripPose = frame.getPose( inputSource.gripSpace, referenceSpace );

					if ( gripPose !== null ) {

						grip.matrix.fromArray( gripPose.transform.matrix );
						grip.matrix.decompose( grip.position, grip.rotation, grip.scale );

					}

				}

			}

		}

		if ( targetRay !== null ) {

			targetRay.visible = ( inputPose !== null );

			if ( targetRay.visible ) targetRay.dispatchEvent( { type: 'controllermove' } );

		}

		if ( grip !== null ) {

			grip.visible = ( gripPose !== null );

			if ( grip.visible ) grip.dispatchEvent( { type: 'controllermove' } );

		}

		if ( hand !== null ) {

			hand.visible = ( handPose !== null );

			if ( hand.visible ) hand.dispatchEvent( { type: 'controllermove' } );

		}

		return this;

	}

}

export { WebXRController };
<commit_msg>Revert "Added "controllermove" event to WebXRController (#20790)" (#21698)<commit_after>import { Group } from '../../objects/Group.js';

class WebXRController {

	constructor() {

		this._targetRay = null;
		this._grip = null;
		this._hand = null;

	}

	getHandSpace() {

		if ( this._hand === null ) {

			this._hand = new Group();
			this._hand.matrixAutoUpdate = false;
			this._hand.visible = false;

			this._hand.joints = {};
			this._hand.inputState = { pinching: false };

		}

		return this._hand;

	}

	getTargetRaySpace() {

		if ( this._targetRay === null ) {

			this._targetRay = new Group();
			this._targetRay.matrixAutoUpdate = false;
			this._targetRay.visible = false;

		}

		return this._targetRay;

	}

	getGripSpace() {

		if ( this._grip === null ) {

			this._grip = new Group();
			this._grip.matrixAutoUpdate = false;
			this._grip.visible = false;

		}

		return this._grip;

	}

	dispatchEvent( event ) {

		if ( this._targetRay !== null ) {

			this._targetRay.dispatchEvent( event );

		}

		if ( this._grip !== null ) {

			this._grip.dispatchEvent( event );

		}

		if ( this._hand !== null ) {

			this._hand.dispatchEvent( event );

		}

		return this;

	}

	disconnect( inputSource ) {

		this.dispatchEvent( { type: 'disconnected', data: inputSource } );

		if ( this._targetRay !== null ) {

			this._targetRay.visible = false;

		}

		if ( this._grip !== null ) {

			this._grip.visible = false;

		}

		if ( this._hand !== null ) {

			this._hand.visible = false;

		}

		return this;

	}

	update( inputSource, frame, referenceSpace ) {

		let inputPose = null;
		let gripPose = null;
		let handPose = null;

		const targetRay = this._targetRay;
		const grip = this._grip;
		const hand = this._hand;

		if ( inputSource && frame.session.visibilityState !== 'visible-blurred' ) {

			if ( targetRay !== null ) {

				inputPose = frame.getPose( inputSource.targetRaySpace, referenceSpace );

				if ( inputPose !== null ) {

					targetRay.matrix.fromArray( inputPose.transform.matrix );
					targetRay.matrix.decompose( targetRay.position, targetRay.rotation, targetRay.scale );

				}

			}

			if ( hand && inputSource.hand ) {

				handPose = true;

				for ( const inputjoint of inputSource.hand.values() ) {

					// Update the joints groups with the XRJoint poses
					const jointPose = frame.getJointPose( inputjoint, referenceSpace );

					if ( hand.joints[ inputjoint.jointName ] === undefined ) {

						// The transform of this joint will be updated with the joint pose on each frame
						const joint = new Group();
						joint.matrixAutoUpdate = false;
						joint.visible = false;
						hand.joints[ inputjoint.jointName ] = joint;
						// ??
						hand.add( joint );

					}

					const joint = hand.joints[ inputjoint.jointName ];

					if ( jointPose !== null ) {

						joint.matrix.fromArray( jointPose.transform.matrix );
						joint.matrix.decompose( joint.position, joint.rotation, joint.scale );
						joint.jointRadius = jointPose.radius;

					}

					joint.visible = jointPose !== null;

				}

				// Custom events

				// Check pinchz
				const indexTip = hand.joints[ 'index-finger-tip' ];
				const thumbTip = hand.joints[ 'thumb-tip' ];
				const distance = indexTip.position.distanceTo( thumbTip.position );

				const distanceToPinch = 0.02;
				const threshold = 0.005;

				if ( hand.inputState.pinching && distance > distanceToPinch + threshold ) {

					hand.inputState.pinching = false;
					this.dispatchEvent( {
						type: 'pinchend',
						handedness: inputSource.handedness,
						target: this
					} );

				} else if ( ! hand.inputState.pinching && distance <= distanceToPinch - threshold ) {

					hand.inputState.pinching = true;
					this.dispatchEvent( {
						type: 'pinchstart',
						handedness: inputSource.handedness,
						target: this
					} );

				}

			} else {

				if ( grip !== null && inputSource.gripSpace ) {

					gripPose = frame.getPose( inputSource.gripSpace, referenceSpace );

					if ( gripPose !== null ) {

						grip.matrix.fromArray( gripPose.transform.matrix );
						grip.matrix.decompose( grip.position, grip.rotation, grip.scale );

					}

				}

			}

		}

		if ( targetRay !== null ) {

			targetRay.visible = ( inputPose !== null );

		}

		if ( grip !== null ) {

			grip.visible = ( gripPose !== null );

		}

		if ( hand !== null ) {

			hand.visible = ( handPose !== null );

		}

		return this;

	}

}

export { WebXRController };
<|endoftext|>


<commit_before>/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
var app = {
    imgageNumber: 1,
    lastImageNumber: 11,
    originalAttrName: 'original',
    // Application Constructor
    initialize: function() {
        this.heroImg = document.getElementById('heroImg');
        this.video = document.getElementById('video');
        this.canvas = document.createElement("canvas");
        this.ctx = this.canvas.getContext('2d');
        this.videoImg = document.getElementById('videoImage');
        this.anonymousFacesFilter = { name: 'AnonymousFaces' };
        this.bindEvents();
    },
    // Bind Event Listeners
    //
    // Bind any events that are required on startup. Common events are:
    // 'load', 'deviceready', 'offline', and 'online'.
    bindEvents: function() {
        document.addEventListener('deviceready', this.onDeviceReady, false);
        document.getElementById('original').addEventListener('click', this.showOriginal, false);
        document.getElementById('faceFilter').addEventListener('click', this.applyFaceFilter, false);
        document.getElementById('sepiaToneFilter').addEventListener('click', this.applySepiaToneFilter, false);
        document.getElementById('previousImage').addEventListener('click', this.previousImage, false);
        document.getElementById('nextImage').addEventListener('click', this.nextImage, false);
        this.heroImg.addEventListener('load', this.loadImage);
        this.video.addEventListener('loadedmetadata', this.adjustCanvasDimension, false);
        this.video.addEventListener('loadeddata', app.applyAnonymousFaceFilterOnVideoBody, false);
        this.video.addEventListener('play', this.applyAnonymousFaceFilterOnVideo, false);
    },
    adjustCanvasDimension: function() {
        app.canvas.width = this.videoWidth;
        app.canvas.height = this.videoHeight;
    },
    applyAnonymousFaceFilterOnVideoBody: function() {
        app.ctx.drawImage(app.video, 0, 0, app.canvas.width, app.canvas.height);
        imageFilter.applyFilter({ srcUrl: app.canvas.toDataURL(), filter: app.anonymousFacesFilter },
            app.applyAnonymousFaceFilterOnVideoSuccessCB,
            app.applyAnonymousFaceFilterOnVideoFailCB);
    },
    applyAnonymousFaceFilterOnVideoSuccessCB: function(filteredImg) {
        app.videoImg.src = filteredImg;
        // setTimeout(loop, 1000 / 30); // drawing at 30fps
        setTimeout(app.applyAnonymousFaceFilterOnVideo);
    },
    applyAnonymousFaceFilterOnVideoFailCB: function() {
        app.video.pause();
        console.log('imageFilter.applyFilter() failed');
    },
    applyAnonymousFaceFilterOnVideo: function() {
        if (!app.video.paused && !app.video.ended) {
            app.applyAnonymousFaceFilterOnVideoBody();
        }
    },
    applyFilter: function(filter) {
        app.showFilterPanel(false);
        // call the plugin: imageFilter.applyFilter()
        imageFilter.applyFilter({ srcUrl: app.heroImg.src, filter: filter },
            function(filteredImg) {
                app.heroImg.src = filteredImg;
                app.showFilterPanel(true);
            },
            function() {
                app.showFilterPanel(true);
                console.log('imageFilter.applyFilter() failed');
            });
    },
    applyFaceFilter: function(event) {
        event.preventDefault();
        app.applyFilter(app.anonymousFacesFilter);
    },
    applySepiaToneFilter: function(event) {
        event.preventDefault();
        app.applyFilter({ name: 'SepiaTone', intensity: 0.7 });
    },
    loadImage: function() {
        document.getElementById('heroImgWidth').textContent = this.naturalWidth;
        document.getElementById('heroImgHeight').textContent = this.naturalHeight;
    },
    setImage: function() {
        if (app.imgageNumber <= 0) app.imgageNumber = app.lastImageNumber;
        if (app.imgageNumber > app.lastImageNumber) app.imgageNumber = 1;
        app.heroImg.src = 'img/img' + app.imgageNumber + '.jpg';
        app.heroImg.setAttribute(app.originalAttrName, app.heroImg.src);
    },
    previousImage: function(event) {
        event.preventDefault();
        app.imgageNumber--;
        app.setImage();
    },
    nextImage: function(event) {
        event.preventDefault();
        app.imgageNumber++;
        app.setImage();
    },
    showOriginal: function(event) {
        event.preventDefault();
        app.heroImg.src = app.heroImg.getAttribute(app.originalAttrName);
    },
    showFilterPanel: function(isShow) {
        var display = (isShow) ? 'block' : 'none';
        document.getElementById('filterPanel').setAttribute('style', 'display:' + display + ';');
    },
    // deviceready Event Handler
    //
    onDeviceReady: function() {
        app.setImage();
        app.showFilterPanel(true);
        app.video.load();
    }
};

app.initialize();<commit_msg>let the code be consistent<commit_after>/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
var app = {
    imgageNumber: 1,
    lastImageNumber: 11,
    originalAttrName: 'original',
    // Application Constructor
    initialize: function() {
        this.heroImg = document.getElementById('heroImg');
        this.video = document.getElementById('video');
        this.canvas = document.createElement("canvas");
        this.ctx = this.canvas.getContext('2d');
        this.videoImg = document.getElementById('videoImage');
        this.anonymousFacesFilter = { name: 'AnonymousFaces' };
        this.bindEvents();
    },
    // Bind Event Listeners
    //
    // Bind any events that are required on startup. Common events are:
    // 'load', 'deviceready', 'offline', and 'online'.
    bindEvents: function() {
        document.addEventListener('deviceready', this.onDeviceReady, false);
        document.getElementById('original').addEventListener('click', this.showOriginal, false);
        document.getElementById('faceFilter').addEventListener('click', this.applyFaceFilter, false);
        document.getElementById('sepiaToneFilter').addEventListener('click', this.applySepiaToneFilter, false);
        document.getElementById('previousImage').addEventListener('click', this.previousImage, false);
        document.getElementById('nextImage').addEventListener('click', this.nextImage, false);
        this.heroImg.addEventListener('load', this.loadImage);
        this.video.addEventListener('loadedmetadata', this.adjustCanvasDimension, false);
        this.video.addEventListener('loadeddata', this.applyAnonymousFaceFilterOnVideoBody, false);
        this.video.addEventListener('play', this.applyAnonymousFaceFilterOnVideo, false);
    },
    adjustCanvasDimension: function() {
        app.canvas.width = this.videoWidth;
        app.canvas.height = this.videoHeight;
    },
    applyAnonymousFaceFilterOnVideoBody: function() {
        app.ctx.drawImage(app.video, 0, 0, app.canvas.width, app.canvas.height);
        imageFilter.applyFilter({ srcUrl: app.canvas.toDataURL(), filter: app.anonymousFacesFilter },
            app.applyAnonymousFaceFilterOnVideoSuccessCB,
            app.applyAnonymousFaceFilterOnVideoFailCB);
    },
    applyAnonymousFaceFilterOnVideoSuccessCB: function(filteredImg) {
        app.videoImg.src = filteredImg;
        // setTimeout(loop, 1000 / 30); // drawing at 30fps
        setTimeout(app.applyAnonymousFaceFilterOnVideo);
    },
    applyAnonymousFaceFilterOnVideoFailCB: function() {
        app.video.pause();
        console.log('imageFilter.applyFilter() failed');
    },
    applyAnonymousFaceFilterOnVideo: function() {
        if (!app.video.paused && !app.video.ended) {
            app.applyAnonymousFaceFilterOnVideoBody();
        }
    },
    applyFilter: function(filter) {
        app.showFilterPanel(false);
        // call the plugin: imageFilter.applyFilter()
        imageFilter.applyFilter({ srcUrl: app.heroImg.src, filter: filter },
            function(filteredImg) {
                app.heroImg.src = filteredImg;
                app.showFilterPanel(true);
            },
            function() {
                app.showFilterPanel(true);
                console.log('imageFilter.applyFilter() failed');
            });
    },
    applyFaceFilter: function(event) {
        event.preventDefault();
        app.applyFilter(app.anonymousFacesFilter);
    },
    applySepiaToneFilter: function(event) {
        event.preventDefault();
        app.applyFilter({ name: 'SepiaTone', intensity: 0.7 });
    },
    loadImage: function() {
        document.getElementById('heroImgWidth').textContent = this.naturalWidth;
        document.getElementById('heroImgHeight').textContent = this.naturalHeight;
    },
    setImage: function() {
        if (app.imgageNumber <= 0) app.imgageNumber = app.lastImageNumber;
        if (app.imgageNumber > app.lastImageNumber) app.imgageNumber = 1;
        app.heroImg.src = 'img/img' + app.imgageNumber + '.jpg';
        app.heroImg.setAttribute(app.originalAttrName, app.heroImg.src);
    },
    previousImage: function(event) {
        event.preventDefault();
        app.imgageNumber--;
        app.setImage();
    },
    nextImage: function(event) {
        event.preventDefault();
        app.imgageNumber++;
        app.setImage();
    },
    showOriginal: function(event) {
        event.preventDefault();
        app.heroImg.src = app.heroImg.getAttribute(app.originalAttrName);
    },
    showFilterPanel: function(isShow) {
        var display = (isShow) ? 'block' : 'none';
        document.getElementById('filterPanel').setAttribute('style', 'display:' + display + ';');
    },
    // deviceready Event Handler
    //
    onDeviceReady: function() {
        app.setImage();
        app.showFilterPanel(true);
        app.video.load();
    }
};

app.initialize();<|endoftext|>


<commit_before>exports.config = {
  allScriptsTimeout: 11000,

  specs: [
    '../e2e/*.js'
  ],

  capabilities: {
    'browserName': 'chrome'
  },

  baseUrl: 'http://localhost:8000/app/',

  framework: 'jasmine',

  jasmineNodeOpts: {
    defaultTimeoutInterval: 30000
  }
};
<commit_msg>another test path fix<commit_after>exports.config = {
  allScriptsTimeout: 11000,

  specs: [
    '../e2e/*.js'
  ],

  capabilities: {
    'browserName': 'chrome'
  },

  baseUrl: 'http://localhost:8000/client/',

  framework: 'jasmine',

  jasmineNodeOpts: {
    defaultTimeoutInterval: 30000
  }
};
<|endoftext|>