<commit_before>Package.describe({
    name: 'cultofcoders:redis-oplog',
    version: '2.0.1',
    // Brief, one-line summary of the package.
    summary: "Replacement for Meteor's MongoDB oplog implementation",
    // URL to the Git repository containing the source code for this package.
    git: 'https://github.com/cult-of-coders/redis-oplog',
    // By default, Meteor will default to using README.md for documentation.
    // To avoid submitting documentation, set this field to null.
    documentation: 'README.md',
});

Npm.depends({
    redis: '2.8.0',
    'deep-extend': '0.5.0',
    'lodash.clonedeep': '4.5.0',
});

Package.onUse(function(api) {
    api.versionsFrom('1.5.1');
    api.use([
        'underscore',
        'ecmascript',
        'ejson',
        'minimongo',
        'mongo',
        'random',
        'ddp-server',
        'diff-sequence',
        'id-map',
        'mongo-id',
        'tracker',
    ]);

    api.mainModule('redis-oplog.js', 'server');
    api.mainModule('redis-oplog.client.js', 'client');
});

Package.onTest(function(api) {
    api.use('cultofcoders:redis-oplog');

    // extensions
    api.use('aldeed:collection2@3.0.0');
    api.use('reywood:publish-composite@1.5.2');
    api.use('natestrauser:publish-performant-counts@0.1.2');
    api.use('socialize:user-presence@0.4.0');

    api.use('ecmascript');
    api.use('tracker');
    api.use('mongo');
    api.use('random');
    api.use('accounts-password');
    api.use('matb33:collection-hooks@0.8.4');
    api.use('alanning:roles@1.2.16');

    api.use(['meteortesting:mocha', 'practicalmeteor:chai']);

    api.mainModule('testing/main.server.js', 'server');
    api.addFiles('testing/publishComposite/boot.js', 'server');
    api.addFiles('testing/optimistic-ui/boot.js', 'server');

    api.mainModule('testing/main.client.js', 'client');
});
<commit_msg>Bump to 2.0.2<commit_after>Package.describe({
    name: 'cultofcoders:redis-oplog',
    version: '2.0.2',
    // Brief, one-line summary of the package.
    summary: "Replacement for Meteor's MongoDB oplog implementation",
    // URL to the Git repository containing the source code for this package.
    git: 'https://github.com/cult-of-coders/redis-oplog',
    // By default, Meteor will default to using README.md for documentation.
    // To avoid submitting documentation, set this field to null.
    documentation: 'README.md',
});

Npm.depends({
    redis: '2.8.0',
    'deep-extend': '0.5.0',
    'lodash.clonedeep': '4.5.0',
});

Package.onUse(function(api) {
    api.versionsFrom('1.5.1');
    api.use([
        'underscore',
        'ecmascript',
        'ejson',
        'minimongo',
        'mongo',
        'random',
        'ddp-server',
        'diff-sequence',
        'id-map',
        'mongo-id',
        'tracker',
    ]);

    api.mainModule('redis-oplog.js', 'server');
    api.mainModule('redis-oplog.client.js', 'client');
});

Package.onTest(function(api) {
    api.use('cultofcoders:redis-oplog');

    // extensions
    api.use('aldeed:collection2@3.0.0');
    api.use('reywood:publish-composite@1.5.2');
    api.use('natestrauser:publish-performant-counts@0.1.2');
    api.use('socialize:user-presence@0.4.0');

    api.use('ecmascript');
    api.use('tracker');
    api.use('mongo');
    api.use('random');
    api.use('accounts-password');
    api.use('matb33:collection-hooks@0.8.4');
    api.use('alanning:roles@1.2.16');

    api.use(['meteortesting:mocha', 'practicalmeteor:chai']);

    api.mainModule('testing/main.server.js', 'server');
    api.addFiles('testing/publishComposite/boot.js', 'server');
    api.addFiles('testing/optimistic-ui/boot.js', 'server');

    api.mainModule('testing/main.client.js', 'client');
});
<|endoftext|>


<commit_before>/*
    Copyright 2015, Quixey Inc.
    All rights reserved.

    Licensed under the Modified BSD License found in the
    LICENSE file in the root directory of this source tree.
*/

Package.describe({
    summary: "JFramework for Meteor + React",
    name: "quixey:jframework",
    version: "1.3",
    git: "https://github.com/quixey/jframework.git"
});

Npm.depends({
    "react-router": "0.11.6"
});

Package.onUse(function(api) {
    api.versionsFrom("1.0.2.1");

    // Sets up window.ReactRouter
    api.addFiles(
        '.npm/package/node_modules/react-router/dist/react-router.js', 'client'
    );

    /*
        For used packages like "mongo" which use Tracker, we monkey patch it to
        use our version of the Tracker.* functions.
        For users of jframework, they only see our exported version of Tracker.
    */
    api.use("tracker");

    api.use([
        "meteor",
        "webapp",
        "logging",
        "ddp",
        "mongo",
        "check",
        "underscore",
        "jquery",
        "random",
        "ejson",
        "coffeescript",
        "reload",
        "autoupdate",
        "quixey:react@0.12.2"
    ]);

    api.imply([
        "meteor",
        "webapp",
        "logging",
        "ddp",
        "mongo",
        "check",
        "underscore",
        "jquery",
        "random",
        "ejson",
        "quixey:react@0.12.2"
    ]);

    api.addFiles([
        "lib/date.js",
        "lib/URI.js",
        "tracker.coffee",
        "j.coffee",
        "util.coffee",
        "var.coffee",
        "autovar.coffee",
        "dict.coffee",
        "list.coffee",
        "autodict.coffee",
        "autolist.coffee",
        "components.coffee",
        "proptypes.coffee",
        "models.coffee",
        "fetching.coffee",
        "routing.coffee",
        "dom.coffee"
    ]);

    api.addFiles([
        "components/AreYouSure.coffee",
        "components/Button.coffee",
        "components/CancelButton.coffee",
        "components/Dropdown.coffee",
        "components/DeleteButton.coffee",
        "components/EditButton.coffee",
        "components/Expandable.coffee",
        "components/KeyValueTable.coffee",
        "components/LinkButton.coffee",
        "components/Loader.coffee",
        "components/SubmitCancelDelete.coffee",
        "components/TableRow.coffee",
        "components/TextBox.coffee"
    ]);

    api.addFiles([
        "publish.coffee",
        "denorm.coffee"
    ], "server");

    api.addFiles([
    ], "client");

    api.export("Tracker");
    api.export("J");
    api.export("$$");
});

Package.onTest(function(api) {
    api.use([
        "tinytest",
        "quixey:jframework",
        "coffeescript",
        "insecure"
    ]);

    api.imply([
        "tinytest",
        "quixey:jframework"
    ]);

    api.addFiles([
        "tests/test-models.coffee",
        "tests/util-tests.coffee",
        "tests/autovar-tests.coffee",
        "tests/list-tests.coffee",
        "tests/dict-tests.coffee",
        "tests/jframework-tests.coffee",
        "tests/queryspec-tests.coffee",
        "tests/denorm-tests.coffee"
    ]);

    api.addFiles([
        "tests/publish-tests.coffee",
        "tests/jframework-client-tests.coffee"
    ], "client");
});
<commit_msg>Fix version num to 1.3.0<commit_after>/*
    Copyright 2015, Quixey Inc.
    All rights reserved.

    Licensed under the Modified BSD License found in the
    LICENSE file in the root directory of this source tree.
*/

Package.describe({
    summary: "JFramework for Meteor + React",
    name: "quixey:jframework",
    version: "1.3.0",
    git: "https://github.com/quixey/jframework.git"
});

Npm.depends({
    "react-router": "0.11.6"
});

Package.onUse(function(api) {
    api.versionsFrom("1.0.2.1");

    // Sets up window.ReactRouter
    api.addFiles(
        '.npm/package/node_modules/react-router/dist/react-router.js', 'client'
    );

    /*
        For used packages like "mongo" which use Tracker, we monkey patch it to
        use our version of the Tracker.* functions.
        For users of jframework, they only see our exported version of Tracker.
    */
    api.use("tracker");

    api.use([
        "meteor",
        "webapp",
        "logging",
        "ddp",
        "mongo",
        "check",
        "underscore",
        "jquery",
        "random",
        "ejson",
        "coffeescript",
        "reload",
        "autoupdate",
        "quixey:react@0.12.2"
    ]);

    api.imply([
        "meteor",
        "webapp",
        "logging",
        "ddp",
        "mongo",
        "check",
        "underscore",
        "jquery",
        "random",
        "ejson",
        "quixey:react@0.12.2"
    ]);

    api.addFiles([
        "lib/date.js",
        "lib/URI.js",
        "tracker.coffee",
        "j.coffee",
        "util.coffee",
        "var.coffee",
        "autovar.coffee",
        "dict.coffee",
        "list.coffee",
        "autodict.coffee",
        "autolist.coffee",
        "components.coffee",
        "proptypes.coffee",
        "models.coffee",
        "fetching.coffee",
        "routing.coffee",
        "dom.coffee"
    ]);

    api.addFiles([
        "components/AreYouSure.coffee",
        "components/Button.coffee",
        "components/CancelButton.coffee",
        "components/Dropdown.coffee",
        "components/DeleteButton.coffee",
        "components/EditButton.coffee",
        "components/Expandable.coffee",
        "components/KeyValueTable.coffee",
        "components/LinkButton.coffee",
        "components/Loader.coffee",
        "components/SubmitCancelDelete.coffee",
        "components/TableRow.coffee",
        "components/TextBox.coffee"
    ]);

    api.addFiles([
        "publish.coffee",
        "denorm.coffee"
    ], "server");

    api.addFiles([
    ], "client");

    api.export("Tracker");
    api.export("J");
    api.export("$$");
});

Package.onTest(function(api) {
    api.use([
        "tinytest",
        "quixey:jframework",
        "coffeescript",
        "insecure"
    ]);

    api.imply([
        "tinytest",
        "quixey:jframework"
    ]);

    api.addFiles([
        "tests/test-models.coffee",
        "tests/util-tests.coffee",
        "tests/autovar-tests.coffee",
        "tests/list-tests.coffee",
        "tests/dict-tests.coffee",
        "tests/jframework-tests.coffee",
        "tests/queryspec-tests.coffee",
        "tests/denorm-tests.coffee"
    ]);

    api.addFiles([
        "tests/publish-tests.coffee",
        "tests/jframework-client-tests.coffee"
    ], "client");
});
<|endoftext|>


<commit_before>/* global Package, Npm */
Package.describe({
    name: 'socialize:base-model',
    summary: 'A model for all other models to extend.',
    version: '1.1.1',
    git: 'https://github.com/copleykj/socialize-base-model.git',
});

Npm.depends({
    'mongodb-diff': '0.4.4',
});

Package.onUse(function onUse(api) {
    api.versionsFrom('1.3');

    api.use(['meteor', 'mongo', 'underscore', 'ecmascript']);

    api.use([
        'aldeed:collection2-core@2.0.4', 'aldeed:schema-index@2.1.1', 'aldeed:schema-deny@2.0.1',
        'matb33:collection-hooks@0.8.4',
    ]);

    api.use('cultofcoders:redis-oplog', { weak: true });

    api.imply(['meteor', 'mongo', 'underscore', 'ecmascript']);

    api.imply([
        'aldeed:collection2-core', 'aldeed:schema-index', 'aldeed:schema-deny',
        'matb33:collection-hooks',
    ]);

    api.mainModule('base-model.js');
});

Package.onTest(function onTest(api) {
    api.use(['tinytest', 'meteor', 'mongo', 'underscore', 'ecmascript']);

    api.use([
        'aldeed:collection2-core@2.0.4', 'matb33:collection-hooks@0.8.4',
        'socialize:base-model',
    ]);

    api.mainModule('tests.js');
});
<commit_msg>depend on and imply server-time since we will use it in multiple packages<commit_after>/* global Package, Npm */
Package.describe({
    name: 'socialize:base-model',
    summary: 'A model for all other models to extend.',
    version: '1.1.1',
    git: 'https://github.com/copleykj/socialize-base-model.git',
});

Npm.depends({
    'mongodb-diff': '0.4.4',
});

Package.onUse(function onUse(api) {
    api.versionsFrom('1.3');

    api.use(['meteor', 'mongo', 'underscore', 'ecmascript']);

    api.use([
        'aldeed:collection2-core@2.0.4', 'aldeed:schema-index@2.1.1', 'aldeed:schema-deny@2.0.1',
        'matb33:collection-hooks@0.8.4', 'socialize:server-time@1.0.0',
    ]);

    api.use('cultofcoders:redis-oplog', { weak: true });

    api.imply(['meteor', 'mongo', 'underscore', 'ecmascript']);

    api.imply([
        'aldeed:collection2-core', 'aldeed:schema-index', 'aldeed:schema-deny',
        'matb33:collection-hooks', 'socialize:server-time',
    ]);

    api.mainModule('base-model.js');
});

Package.onTest(function onTest(api) {
    api.use(['tinytest', 'meteor', 'mongo', 'underscore', 'ecmascript']);

    api.use([
        'aldeed:collection2-core@2.0.4', 'matb33:collection-hooks@0.8.4',
        'socialize:base-model',
    ]);

    api.mainModule('tests.js');
});
<|endoftext|>


<commit_before>var modulesVersion = '0.6.3'; // this package should release with original universe:modules

Package.describe({
    name: 'universe:ecmascript',
    version: modulesVersion,
    summary: 'Supports ES2015+ in all .js files with modules',
    git: 'https://github.com/vazco/universe-ecmascript',
    documentation: 'README.md'
});

Package.registerBuildPlugin({
    name: 'UniverseEcmascript',
    use: ['universe:modules-compiler@1.0.4'],
    sources: ['plugin.js']
});

Package.onUse(function (api) {
    api.versionsFrom('1.2.0.2');

    // Use Meteor 1.2 build plugin
    api.use(['universe:modules@' + modulesVersion, 'isobuild:compiler-plugin@1.0.0']);
    api.imply('universe:modules@' + modulesVersion);
});<commit_msg>fixes<commit_after>var modulesVersion = '0.6.4'; // this package should release with original universe:modules

Package.describe({
    name: 'universe:ecmascript',
    version: modulesVersion,
    summary: 'Supports ES2015+ in all .js files with modules',
    git: 'https://github.com/vazco/universe-ecmascript',
    documentation: 'README.md'
});

Package.registerBuildPlugin({
    name: 'UniverseEcmascript',
    use: ['universe:modules-compiler@1.0.5'],
    sources: ['plugin.js']
});

Package.onUse(function (api) {
    api.versionsFrom('1.2.0.2');

    // Use Meteor 1.2 build plugin
    api.use(['universe:modules@' + modulesVersion, 'isobuild:compiler-plugin@1.0.0']);
    api.imply('universe:modules@' + modulesVersion);
});<|endoftext|>


<commit_before>Package.describe({
    summary: "Famo.us wrapper for Accounts Templates.",
    version: "0.1.2",
    name: "splendido:accounts-templates-famous-wrapper",
    git: "https://github.com/splendido/accounts-templates-famous.git",
});

Package.on_use(function(api, where) {
    api.versionsFrom("METEOR@0.9.2.2");

    api.use([
        "reactive-dict",
        "templating",
    ], "client");

    api.use([
        "check",
        "underscore",
        "splendido:accounts-templates-core",
        "gadicohen:famous-views",
        "aldeed:template-extension"
    ], ["client", "server"]);

    api.imply([
        "splendido:accounts-templates-core@0.9.10",
        "gadicohen:famous-views@0.1.12",
        "aldeed:template-extension@2.0.0",
    ], ["client", "server"]);

    //api.use('mjnetworks:famous@0.2.2-1', ['client']/*, { weak: true }*/);

    api.use("splendido:accounts-templates-unstyled@0.9.10", ["client", "server"], { weak: true });
    api.use("splendido:accounts-templates-bootstrap@0.9.10", ["client", "server"], { weak: true });
    api.use("splendido:accounts-templates-foundation@0.9.10", ["client", "server"], { weak: true });
    api.use("splendido:accounts-templates-semantic-ui@0.9.10", ["client", "server"], { weak: true });

    api.add_files([
        "lib/at_famous_form.html",
        "lib/at_famous_form.js",
        "lib/at_famous_oauth.html",
        "lib/at_famous_oauth.js",
        "lib/at_pwd_form_btn.js",
        "lib/full_page_at_famous_form.html",
        "lib/full_page_at_famous_form.js",
        "lib/default_animations.js",
        "lib/famous_wrapper.js",
    ], ["client"]);

    api.add_files([
        "lib/at_configure_anim.js",
    ], ["client", "server"]);
});

Package.on_test(function(api) {
    api.use([
        "splendido:accounts-templates-core@0.9.10",
    ]);
    api.use(["tinytest", "test-helpers"], ["client", "server"]);
    api.add_files("tests/tests.js", ["client", "server"]);
});
<commit_msg>Bump to versino 0.1.3<commit_after>Package.describe({
    summary: "Famo.us wrapper for Accounts Templates.",
    version: "0.1.3",
    name: "splendido:accounts-templates-famous-wrapper",
    git: "https://github.com/splendido/accounts-templates-famous.git",
});

Package.on_use(function(api, where) {
    api.versionsFrom("METEOR@0.9.2.2");

    api.use([
        "reactive-dict",
        "templating",
    ], "client");

    api.use([
        "check",
        "underscore",
        "splendido:accounts-templates-core",
        "gadicohen:famous-views",
        "aldeed:template-extension"
    ], ["client", "server"]);

    api.imply([
        "splendido:accounts-templates-core@0.9.13",
        "gadicohen:famous-views@0.1.12",
        "aldeed:template-extension@2.0.0",
    ], ["client", "server"]);

    //api.use('mjnetworks:famous@0.2.2-1', ['client']/*, { weak: true }*/);

    api.use("splendido:accounts-templates-unstyled@0.9.13", ["client", "server"], { weak: true });
    api.use("splendido:accounts-templates-bootstrap@0.9.13", ["client", "server"], { weak: true });
    api.use("splendido:accounts-templates-foundation@0.9.13", ["client", "server"], { weak: true });
    api.use("splendido:accounts-templates-semantic-ui@0.9.13", ["client", "server"], { weak: true });

    api.add_files([
        "lib/at_famous_form.html",
        "lib/at_famous_form.js",
        "lib/at_famous_oauth.html",
        "lib/at_famous_oauth.js",
        "lib/at_pwd_form_btn.js",
        "lib/full_page_at_famous_form.html",
        "lib/full_page_at_famous_form.js",
        "lib/default_animations.js",
        "lib/famous_wrapper.js",
    ], ["client"]);

    api.add_files([
        "lib/at_configure_anim.js",
    ], ["client", "server"]);
});

Package.on_test(function(api) {
    api.use([
        "splendido:accounts-templates-core@0.9.13",
    ]);
    api.use(["tinytest", "test-helpers"], ["client", "server"]);
    api.add_files("tests/tests.js", ["client", "server"]);
});
<|endoftext|>


<commit_before>Package.describe({
  name: 'vsivsi:orion-file-collection',
  summary: 'MongoDB gridFS support for orionjs:filesystem',
  version: '0.2.3',
  git: 'https://github.com/vsivsi/orion-file-collection'
});

Package.onUse(function(api) {
  api.versionsFrom('1.0');

  api.use([
    'orionjs:core@1.0.0',
    'orionjs:filesystem@1.0.1',
    'vsivsi:file-collection@1.3.0'
    ]);

  api.addFiles([
    'index.js'
    ]);

    api.export('orionFileCollection');
});

Package.onTest(function(api) {
  api.use('tinytest');
  api.use('orionjs:filesystem');
});
<commit_msg>version bump v0.2.4<commit_after>Package.describe({
  name: 'vsivsi:orion-file-collection',
  summary: 'MongoDB gridFS support for orionjs:filesystem',
  version: '0.2.4',
  git: 'https://github.com/vsivsi/orion-file-collection'
});

Package.onUse(function(api) {
  api.versionsFrom('1.0');

  api.use([
    'orionjs:core@1.0.0',
    'orionjs:filesystem@1.0.1',
    'vsivsi:file-collection@1.3.0'
    ]);

  api.addFiles([
    'index.js'
    ]);

    api.export('orionFileCollection');
});

Package.onTest(function(api) {
  api.use('tinytest');
  api.use('orionjs:filesystem');
});
<|endoftext|>


<commit_before>Package.describe({
  name: 'sakerdot:accounts-discourse',
  version: '1.0.1',
  summary: 'A login service using Discourse SSO as a provider',
  git: 'https://github.com/Sakerdot/accounts-discourse',
  documentation: 'README.md',
});

Package.onUse(function(api) {
  api.versionsFrom('1.4.2');

  api.use('ecmascript', ['client', 'server']);
  api.use('reload', 'client');
  api.use('random', 'client');
  api.use('check', 'server');

  api.use('accounts-base', ['client', 'server']);
  api.imply('accounts-base', ['client', 'server']);

  api.use('service-configuration', ['client', 'server']);
  api.imply('service-configuration', ['client', 'server']);

  api.mainModule('discourse_client.js', 'client');
  api.mainModule('discourse_server.js', 'server');
});
<commit_msg>changed package version<commit_after>Package.describe({
  name: 'sakerdot:accounts-discourse',
  version: '1.0.2',
  summary: 'A login service using Discourse SSO as a provider',
  git: 'https://github.com/Sakerdot/accounts-discourse',
  documentation: 'README.md',
});

Package.onUse(function(api) {
  api.versionsFrom('1.4.2');

  api.use('ecmascript', ['client', 'server']);
  api.use('reload', 'client');
  api.use('random', 'client');
  api.use('check', 'server');

  api.use('accounts-base', ['client', 'server']);
  api.imply('accounts-base', ['client', 'server']);

  api.use('service-configuration', ['client', 'server']);
  api.imply('service-configuration', ['client', 'server']);

  api.mainModule('discourse_client.js', 'client');
  api.mainModule('discourse_server.js', 'server');
});
<|endoftext|>


<commit_before>Package.describe({
  name: "okgrow:analytics",
  version: "1.0.10",
  summary: "Complete Google Analytics, Mixpanel, KISSmetrics (and more) integration for Meteor",
  git: "https://github.com/okgrow/analytics",
  documentation: "README.md",
});

Npm.depends({
  underscore: "1.8.3",
});

Package.onUse(function (api) {
  api.versionsFrom("1.0.3.1");

  // "ecmascript" is mandatory dependency to compile our es6.
  api.use("ecmascript");
  api.use("es5-shim");

  // weak dependencies indicate we will load after the following packages.
  api.use("accounts-base", ["client", "server"], { weak: true });
  api.use("browser-policy-content", "server", { weak: true });

  // constrain their versions IF another package, or app brings them in.
  api.use("iron:router@1.0.7", "client", { weak: true });
  api.use("meteorhacks:flow-router@1.17.2", "client", { weak: true });
  api.use("kadira:flow-router@2.6.0", "client", { weak: true });

  api.mainModule("client-main.js", "client");
  api.mainModule("server-main.js", "server");

  // For backward compatibility.
  api.export("analytics", ["client", "server"]);
});
<commit_msg>Bumped version to 1.1.0 - es6 import support.<commit_after>Package.describe({
  name: "okgrow:analytics",
  version: "1.1.0",
  summary: "Complete Google Analytics, Mixpanel, KISSmetrics (and more) integration for Meteor",
  git: "https://github.com/okgrow/analytics",
  documentation: "README.md",
});

Npm.depends({
  underscore: "1.8.3",
});

Package.onUse(function (api) {
  api.versionsFrom("1.0.3.1");

  // "ecmascript" is mandatory dependency to compile our es6.
  api.use("ecmascript");
  api.use("es5-shim");

  // weak dependencies indicate we will load after the following packages.
  api.use("accounts-base", ["client", "server"], { weak: true });
  api.use("browser-policy-content", "server", { weak: true });

  // constrain their versions IF another package, or app brings them in.
  api.use("iron:router@1.0.7", "client", { weak: true });
  api.use("meteorhacks:flow-router@1.17.2", "client", { weak: true });
  api.use("kadira:flow-router@2.6.0", "client", { weak: true });

  api.mainModule("client-main.js", "client");
  api.mainModule("server-main.js", "server");

  // For backward compatibility.
  api.export("analytics", ["client", "server"]);
});
<|endoftext|>


<commit_before>import R from 'ramda';

/**
 * Constructor for Vector2 monad
 * @param {number} x
 * @param {number} y
 */
export const Vector2 = function ( x, y ) {
  this.value = [ x, y ];
}

/**
 * Returns the result of adding a given Vector2 to this one
 * @param {Vector2} vec
 * @return Vector2
 */
Vector2.prototype.add = function ( vec ) {
  return new Vector2(
    ...R.zipWith(
      R.add,
      this.value,
      vec.value
    )
  );
};

/**
 * Returns the result of subtracting a given Vector2 from this one
 * @param {Vector2} vec
 * @return Vector2
 */
Vector2.prototype.subtract = function ( vec ) {
  return new Vector2(
    ...R.zipWith(
      R.subtract,
      this.value,
      vec.value
    )
  );
};

/**
 * Returns the result of scaling this Vector2 by a give Scalar
 * @param {Scalar} scalar : value to scale vector by
 * @return Vector2
 */
Vector2.prototype.scale = function ( scalar ) {
  return new Vector2(
    ...R.map(
      R.multiply( scalar ),
      this.value
    )
  );
};

// Utilities
/**
 * Returns dot product of two vector2 monads
 * @param {Vector2} a
 * @param {Vector2} b
 * @return Scalar
 */
export const dotProduct2 = ( a, b ) => {
  const [ ax, ay ] = a.value;
  const [ bx, by ] = b.value;
  return ax * bx + ay * by;
};

/**
 * Magnitude of given Vector2
 * @param {Vector2} vec
 * @return Scalar
 */
export const magnitude2 = vec => {
  const [ x, y ] = vec.value;
  return Math.sqrt( x * 2 + y * 2 );
};

export default Vector2;
<commit_msg>Optimize vector math functions<commit_after>import R from 'ramda';

/**
 * Constructor for Vector2 monad
 * @param {number} x
 * @param {number} y
 */
export const Vector2 = function ( x, y ) {
  this.value = [ x, y ];
};

/**
 * Returns the result of adding a given Vector2 to this one
 * @param {Vector2} vec
 * @return Vector2
 */
Vector2.prototype.add = function ( vec ) {
  const [ x1, y1 ] = this.value;
  const [ x2, y2 ] = vec.value;

  return new Vector2(
    x1 + x2,
    y1 + y2
  );
};

/**
 * Returns the result of subtracting a given Vector2 from this one
 * @param {Vector2} vec
 * @return Vector2
 */
Vector2.prototype.subtract = function ( vec ) {
  const [ x1, y1 ] = this.value;
  const [ x2, y2 ] = vec.value;

  return new Vector2(
    x1 - x2,
    y1 - y2
  );
};

/**
 * Returns the result of scaling this Vector2 by a give Scalar
 * @param {Scalar} scalar : value to scale vector by
 * @return Vector2
 */
Vector2.prototype.scale = function ( scalar ) {
  const [ x, y ] = this.value;

  return new Vector2(
    x * scalar,
    y * scalar
  );
};

// Utilities
/**
 * Returns dot product of two vector2 monads
 * @param {Vector2} a
 * @param {Vector2} b
 * @return Scalar
 */
export const dotProduct2 = ( a, b ) => {
  const [ ax, ay ] = a.value;
  const [ bx, by ] = b.value;

  return ax * bx + ay * by;
};

/**
 * Magnitude of given Vector2
 * @param {Vector2} vec
 * @return Scalar
 */
export const magnitude2 = vec => {
  const [ x, y ] = vec.value;
  return Math.sqrt( x * 2 + y * 2 );
};

export default Vector2;
<|endoftext|>


<commit_before>define('tsa', ['data', 'map', 'table', 'ui', 'visualization', 'generalLibraries'], function(data, map, table, ui, visualization) {
    var self = {};
    self.ui = ui;
    self.map = map;
    self.data = data;
    self.table = table;
    self.visualization = visualization;

    var r =0, dir=false;
    var isShown = true;
    self.initialParameters = {};

    self.initializeApplication = function() {
        self.initialParameters = getUrlParameters();
        var selectedView = self.initialParameters['view'] || 'map';
        if (selectedView === 'visualization') {
            toggleLeftPanel();
        }

        self.ui.loadView(selectedView);
        bindEvents();
        self.map.initializeMap();
        self.data.loadData();
    };

    function getUrlParameters() {
        var search = location.search.substring(1);
        return (search)? JSON.parse('{"' + search.replace(/&/g, '","').replace(/=/g,'":"') + '"}',
                            function(key, value) { return key===""?value:decodeURIComponent(value) }):{};
    }

    function bindEvents() {
        $(document).on('facetsloaded', function() {
            self.ui.renderFacets($("#leftPanel .facets-container"));
            $('.clear-filter').click(function() {
                if (!this.dataset.facet) {
                    return;
                }
                var facet = _(self.data.facets).findWhere({ keyfield: this.dataset.facet });
                self.data.clearFacetFilters(facet);
            });
        });

        $(document).on('dataloaded', function() {
            self.ui.renderFilterItems();
            checkInitialFilters();

            if (self.ui.getActiveView() !== 'datasets') {
                self.table.shouldInitialize = true;
                return;
            }

            self.table.initializeTable();
        });

        $(document).on('datafiltered', function() {
            //update map markers and dataseries table.
            self.ui.renderFilterItems();
            self.map.updateSitesMarkers();
            self.table.updateDataseries();
        });

        $(document).on('sitesloaded', function() {
            self.map.loadMarkers();
            self.map.renderLegend();
        });

        $(document).on('plotdataloading', function() {
            self.ui.startPlotAnimation();
        });

        $(document).on('plotdataready', function() {
            self.ui.endPlotAnimation();
            if (self.visualization.doPlot) {
                self.visualization.plotSeries();
            }
        });

        $(document).on('plotstarted', function() {
            self.ui.startPlotAnimation();
        });

        $(document).on('plotfinished', function() {
            self.ui.endPlotAnimation();
        });

        $(document).on('shown.bs.tab', 'a[href="#mapContent"]', function() {
            google.maps.event.trigger(self.map.map, 'resize');
        });

        $(document).on('shown.bs.tab', 'a[href="#datasetsContent"]', function() {
            if (self.table.shouldInitialize) {
                self.table.initializeTable();
            }
        });

        $(document).on('shown.bs.tab', 'a[href="#visualizationContent"]', function() {
            if (self.visualization.unplottedSeries.length || self.visualization.shouldPlot) {
                self.ui.endPlotAnimation();
                self.visualization.plotSeries();
            }
            self.visualization.doPlot = true;
        });

        $('#btnClearAllFilters').click(function() {
            self.data.facets.forEach(function(facet) {
                self.data.clearFacetFilters(facet);
            });
        });

        $("#btnAddToPlot").click(function() {
            var dialog = $("#InfoDialog");
            var id = +dialog.get(0).dataset['series'];

            dialog.modal('hide');
            var checkbox = $('#datasetsTable').find(':checkbox[data-seriesid="' + id + '"]');
            checkbox.click();

            self.visualization.doPlot = true;
            self.ui.loadView('visualization');
        });

        $("#btnPlotDataset").click(function() {
            var dialog = $("#InfoDialog");
            var id = +dialog.get(0).dataset['series'];

            // Clear checkboxes
            self.visualization.plottedSeries.forEach(function(series) {
                self.table.uncheckSeries(series.seriesid);
            });

            self.visualization.unplottedSeries.forEach(function(series) {
                self.table.uncheckSeries(series.seriesid);
            });

            // Clear the plot arrays.
            self.visualization.plottedSeries.length = 0;
            self.visualization.unplottedSeries.length = 0;

            // Reset the date intervals
            self.visualization.initializeDatePickers();

            // Clear the graph
            self.visualization.clearGraph();
            self.visualization.boxWhiskerSvgs = [];

            dialog.modal('hide');
            var checkbox = $('#datasetsTable').find(':checkbox[data-seriesid="' + id + '"]');
            checkbox.click();

            self.visualization.doPlot = true;
            self.ui.loadView('visualization');
        });

        $("#btnExport").click(function() {
            $(".modal-header").find(".alert").remove();
            $(".modal-header").append(
                '
\
                    Compiling file. Please wait... \

'
            );

            var link = document.createElement("a");

            // feature detection
            if(link.download === undefined) {
              // it needs to implement server side export
              $(".modal-header").find(".alert").empty();
              $(".modal-header").find(".alert").removeClass("alert-info");
              $(".modal-header").find(".alert").addClass("alert-danger");
              $(".modal-header").find(".alert").append("We're sorry, your browser does not support HTML5 download. " +
                                                        "
Please use Chrome, Firefox or Opera to download.");
              return;
            }

            var dialog = $("#InfoDialog");
            var id = +dialog.get(0).dataset['series'];
            var series = _(self.data.dataseries).where({seriesid: id}).pop();

            var csvContent = "data:text/csv;charset=utf8,";

            // Append dataset values once the dataset is loaded
            series.loadDataset(function() {
                    // Append header
                csvContent +=   "# ------------------------------------------------------------------------------------------\n" +
                                "# WARNING: These data may be provisional and subject to revision. The data are released\n" +
                                "# on the condition that neither iUTAH may be held liable for any damages resulting from\n" +
                                "# its use. The following metadata describe the data in this file:\n" +
                                "# ------------------------------------------------------------------------------------------\n#\n";

                // Append Site Information
                csvContent +=   "# Site Information\n" +
                                "# ---------------------------\n" +
                                "# Network: " + series['network'] + "\n" +
                                "# SiteCode: " + series['sitecode'] + "\n" +
                                "# SiteName: " + series['sitename'] + "\n" +
                                "# IsActive: " + series['isactive'] + "\n" +
                                "# Latitude: " + series['latitude'] + "\n" +
                                "# Longitude: " + series['longitude'] + "\n" +
                                "# Elevation: " + series.dataset.elevation + "\n" +
                                "# VerticalDatum: " + series.dataset['verticalDatum'] + "\n" +
                                "# State: " + series['state'] + "\n" +
                                "# County: " + series['county'] + "\n" +
                                //"# SiteComments:" + series['sitecomments'] + "\n" +                 // Not found
                                "# SiteType: " + series['sitetype'] + "\n#\n";

                // Append Variable Information
                csvContent +=   "# Variable Information\n" +
                                "# ---------------------------\n" +
                                "# VariableCode: " + series['variablecode'] + "\n" +
                                "# VariableName: " + series['variablename'] + "\n" +
                                "# ValueType: " + series['valuetype'] + "\n" +
                                "# DataType: " + series['datatype'] + "\n" +
                                "# GeneralCategory: " + series['generalcategory'] + "\n" +
                                "# SampleMedium: " + series['samplemedium'] + "\n" +
                                "# VariableUnitsName: " + series['variableunitsname'] + "\n" +
                                "# VariableUnitsType: " + series['variableunitstype'] + "\n" +
                                "# VariableUnitsAbbreviation: " + series['variableunitsabbreviation'] + "\n" +
                                "# NoDataValue:" + series.dataset['noDataValue'] + "\n" +
                                //"# IsRegular:" + series['isregular'] + "\n" +                                         // Not found
                                "# TimeSupport: " + series['timesupport'] + "\n" +
                                "# TimeSupportUnitsAbbreviation: " + series['timesupportunitsabbreviation'] + "\n" +
                                "# TimeSupportUnitsName: " + series['timesupportunitsname'] + "\n" +
                                "# TimeSupportUnitsType: " + series['timesupportunitstype'] + "\n#\n";
                                //"# Speciation:" + series['speciation'] + "\n#\n";                                     // Not found

                // Append Method Information
                csvContent +=   "# Method Information\n" +
                                "# ---------------------------\n" +
                                "# MethodDescription: " + series['methoddescription'] + "\n" +
                                "# MethodLink: " + series['sitecode'] + "\n#\n";

                // Append Series Information
                csvContent +=   "# Series Information\n" +
                                "# ---------------------------\n" +
                                "# BeginDateTime: " + series['begindatetime'] + "\n" +
                                "# EndDateTime: " + series['enddatetime'] + "\n" +
                                "# DateLastUpdated: " + series['datelastupdated'] + "\n" +
                                "# NumberOfObservations: " + series['numberobservations'] + "\n" +
                                "# QualityControlLevelCode: " + series['qualitycontrollevelcode'] + "\n" +
                                "# QualityControllLevelDefinition: " + series['qualitycontrolleveldefinition'] + "\n" +
                                "# QualityControlLevelExplanation: " + series['qualitycontrollevelexplanation'] + "\n" +
                                "# GetDataUrl: " + series['getdataurl'] + "\n#\n";

                // Append Source Information
                csvContent +=   "# Source Information\n" +
                                "# ---------------------------\n" +
                                "# SourceOrganization: " + series['sourceorganization'] + "\n" +
                                "# SourceDescription: " + series['sourcedescription'] + "\n#\n";
                                //"# ContactName:" + series['contactname'] + "\n" +                   // Not found
                                //"# ContactEmail:" + series['contactemail'] + "\n" +                 // Not found
                                //"# ContactPhone:" + series['contactphone'] + "\n" +                 // Not found
                                //"# Citation:" + series['citation'] + "\n";                          // Not found

                // Append property names
                csvContent += "DateTime, ";
                csvContent += "TimeOffset, ";
                csvContent += "DateTimeUTC, ";
                csvContent += "Value, ";
                csvContent += "CensorCode";
                csvContent += "\n";

                // Append property values
                series.dataset.forEach(function(data){
                     csvContent += data['date'].replace("T", " ") + ", "
                                + data['timeOffset'] + ", "
                                + data['dateTimeUTC'].replace("T", " ") + ", "
                                + data['value'] + ", "
                                + data['censorCode'] + "\n";
                });

                var filename = series.sitecode + " - " + series.variablename + ".csv";

                // Set HTML5 download
                var blob = new Blob(["\ufeff", csvContent]);
                var url = URL.createObjectURL(blob);

                link.setAttribute("href", url);
                link.setAttribute("download", filename);
                link.className = "glyphicon glyphicon-file";
                link.innerHTML = " " + filename + "";

                $(".modal-header").find(".alert").empty();
                $(".modal-header").find(".alert").removeClass("alert-info");
                $(".modal-header").find(".alert").addClass("alert-success");
                $(".modal-header").find(".alert").append(link);
            });
        });

        $('#dpd1').bind('changeDate', onDateChange);
        $('#dpd2').bind('changeDate', onDateChange);
        $('#dpd1').bind('input', onDateChange);
        $('#dpd2').bind('input', onDateChange);

        $("#btnTimeSeries").click(function() {
            $("#visualizationDropDown").text($(this).text() + " ").append("");
            self.visualization.currentPlot = self.visualization.plotTypes.multiseries;
        });

        $("#btnHistogram").click(function() {
            $("#visualizationDropDown").text($(this).text() + " ").append("");
            self.visualization.currentPlot = self.visualization.plotTypes.histogram;
        });

        $("#btnBoxAndWhisker").click(function() {
            $("#visualizationDropDown").text($(this).text() + " ").append("");
            self.visualization.currentPlot = self.visualization.plotTypes.box;
        });

        $("#btnSetPlotOptions").click(function() {
            var dateFirst = $('#dpd1')
            var dateLast = $('#dpd2');

            $("#graphArea").find(".alert").remove();

            var a = new Date(dateFirst.val());
            var b = new Date(dateLast.val())
            if(a <= b){
                self.visualization.plotSeries();  // Dates do not overlap, proceed
            } else {
                // Dates overlap, display an error.
                $("#graphArea").prepend(
                    '
\
                      <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>\
                       Dates cannot overlap. \

'
                );
            }
        });

        $("#btnCollapseToggle").click(function() {
            dir = !dir;
            var slideDistance = 307;
            r = dir? -slideDistance : 0;
            $("#panel-right").stop().animate({right: r+'px'}, 0);
            $("#btnCollapseToggle span").removeClass();
            if (!dir){
                //$("#graphContainer").animate({width:$("#graphContainer").width() - 280}, 800);    // animation
                $("#graphContainer").width($("#graphContainer").width() - slideDistance);           // no animation
                $("#btnCollapseToggle span").addClass("glyphicon glyphicon-chevron-right");
            }
            else{
                //$("#graphContainer").animate({width:$("#graphContainer").width() + 280}, 800);    // animation
                $("#graphContainer").width($("#graphContainer").width() + slideDistance);           // no animation
                $("#btnCollapseToggle span").addClass("glyphicon glyphicon-chevron-left");
            }
            self.visualization.plotSeries();
        });

        $("#btnLeftPanelCollapse").on("click", toggleLeftPanel);

        $("#btnHideLeftToolbar").on("click", toggleLeftPanel);

        $("#visualizationTab").on("click", function(){
            $("#leftPanel .panel-group").hide();

            var btn = $("#btnLeftPanelCollapse")[0];
            btn.setAttribute("data-enabled", "false");
        });

        $("#datasetsTab").on("click", function(){
            toggleLeftPanelButton();
        });

        $("#mapTab").on("click", function() {
            toggleLeftPanelButton();
        });
    }

    function toggleLeftPanel(){
        if ($("#btnLeftPanelCollapse")[0].getAttribute("data-enabled") == "true"){
            $("#leftPanel .panel-group").toggle();
            isShown = !isShown;
            google.maps.event.trigger(self.map.map, 'resize');
        }
    }

    function toggleLeftPanelButton(){
        var btn = $("#btnLeftPanelCollapse")[0];
        btn.setAttribute("data-enabled", "true");

        if (isShown){
            $("#leftPanel .panel-group").show();
        }
    }

    function onDateChange() {
         $("#dateIntervals button").removeClass("active");
    }

    function checkInitialFilters() {
        var selectedNetwork = self.initialParameters['network'];
        var selectedSite = self.initialParameters['sitecode'];
        var selectedVariable = self.initialParameters['variablecode'];
        var selectedControlLevel = self.initialParameters['qualitycontrollevelcode'];
        var shouldPlot = self.initialParameters['plot'] === 'true';
        var networkFilter = _(_(self.data.facets)
            .findWhere({name:'Network'}).filters)
            .findWhere({network:selectedNetwork});

        self.data.toggleFilter('sourcedataserviceid', (networkFilter)? networkFilter.sourcedataserviceid: undefined);
        self.data.toggleFilter('sitecode', selectedSite);
        self.data.toggleFilter('variablecode', selectedVariable);
        self.data.toggleFilter('qualitycontrollevelcode', selectedControlLevel);

        if (self.data.filteredDataseries.length === 1 && shouldPlot) {
            var dataseries = _(self.data.filteredDataseries).first();
            self.visualization.doPlot = (self.initialParameters['view'] === 'visualization')? true: false;
            self.visualization.prepareSeries(dataseries);
        }
    }

    return self;
});<commit_msg>Removed unnecessary first line in exported files<commit_after>define('tsa', ['data', 'map', 'table', 'ui', 'visualization', 'generalLibraries'], function(data, map, table, ui, visualization) {
    var self = {};
    self.ui = ui;
    self.map = map;
    self.data = data;
    self.table = table;
    self.visualization = visualization;

    var r =0, dir=false;
    var isShown = true;
    self.initialParameters = {};

    self.initializeApplication = function() {
        self.initialParameters = getUrlParameters();
        var selectedView = self.initialParameters['view'] || 'map';
        if (selectedView === 'visualization') {
            toggleLeftPanel();
        }

        self.ui.loadView(selectedView);
        bindEvents();
        self.map.initializeMap();
        self.data.loadData();
    };

    function getUrlParameters() {
        var search = location.search.substring(1);
        return (search)? JSON.parse('{"' + search.replace(/&/g, '","').replace(/=/g,'":"') + '"}',
                            function(key, value) { return key===""?value:decodeURIComponent(value) }):{};
    }

    function bindEvents() {
        $(document).on('facetsloaded', function() {
            self.ui.renderFacets($("#leftPanel .facets-container"));
            $('.clear-filter').click(function() {
                if (!this.dataset.facet) {
                    return;
                }
                var facet = _(self.data.facets).findWhere({ keyfield: this.dataset.facet });
                self.data.clearFacetFilters(facet);
            });
        });

        $(document).on('dataloaded', function() {
            self.ui.renderFilterItems();
            checkInitialFilters();

            if (self.ui.getActiveView() !== 'datasets') {
                self.table.shouldInitialize = true;
                return;
            }

            self.table.initializeTable();
        });

        $(document).on('datafiltered', function() {
            //update map markers and dataseries table.
            self.ui.renderFilterItems();
            self.map.updateSitesMarkers();
            self.table.updateDataseries();
        });

        $(document).on('sitesloaded', function() {
            self.map.loadMarkers();
            self.map.renderLegend();
        });

        $(document).on('plotdataloading', function() {
            self.ui.startPlotAnimation();
        });

        $(document).on('plotdataready', function() {
            self.ui.endPlotAnimation();
            if (self.visualization.doPlot) {
                self.visualization.plotSeries();
            }
        });

        $(document).on('plotstarted', function() {
            self.ui.startPlotAnimation();
        });

        $(document).on('plotfinished', function() {
            self.ui.endPlotAnimation();
        });

        $(document).on('shown.bs.tab', 'a[href="#mapContent"]', function() {
            google.maps.event.trigger(self.map.map, 'resize');
        });

        $(document).on('shown.bs.tab', 'a[href="#datasetsContent"]', function() {
            if (self.table.shouldInitialize) {
                self.table.initializeTable();
            }
        });

        $(document).on('shown.bs.tab', 'a[href="#visualizationContent"]', function() {
            if (self.visualization.unplottedSeries.length || self.visualization.shouldPlot) {
                self.ui.endPlotAnimation();
                self.visualization.plotSeries();
            }
            self.visualization.doPlot = true;
        });

        $('#btnClearAllFilters').click(function() {
            self.data.facets.forEach(function(facet) {
                self.data.clearFacetFilters(facet);
            });
        });

        $("#btnAddToPlot").click(function() {
            var dialog = $("#InfoDialog");
            var id = +dialog.get(0).dataset['series'];

            dialog.modal('hide');
            var checkbox = $('#datasetsTable').find(':checkbox[data-seriesid="' + id + '"]');
            checkbox.click();

            self.visualization.doPlot = true;
            self.ui.loadView('visualization');
        });

        $("#btnPlotDataset").click(function() {
            var dialog = $("#InfoDialog");
            var id = +dialog.get(0).dataset['series'];

            // Clear checkboxes
            self.visualization.plottedSeries.forEach(function(series) {
                self.table.uncheckSeries(series.seriesid);
            });

            self.visualization.unplottedSeries.forEach(function(series) {
                self.table.uncheckSeries(series.seriesid);
            });

            // Clear the plot arrays.
            self.visualization.plottedSeries.length = 0;
            self.visualization.unplottedSeries.length = 0;

            // Reset the date intervals
            self.visualization.initializeDatePickers();

            // Clear the graph
            self.visualization.clearGraph();
            self.visualization.boxWhiskerSvgs = [];

            dialog.modal('hide');
            var checkbox = $('#datasetsTable').find(':checkbox[data-seriesid="' + id + '"]');
            checkbox.click();

            self.visualization.doPlot = true;
            self.ui.loadView('visualization');
        });

        $("#btnExport").click(function() {
            $(".modal-header").find(".alert").remove();
            $(".modal-header").append(
                '
\
                    Compiling file. Please wait... \

'
            );

            var link = document.createElement("a");

            // feature detection
            if(link.download === undefined) {
              // it needs to implement server side export
              $(".modal-header").find(".alert").empty();
              $(".modal-header").find(".alert").removeClass("alert-info");
              $(".modal-header").find(".alert").addClass("alert-danger");
              $(".modal-header").find(".alert").append("We're sorry, your browser does not support HTML5 download. " +
                                                        "
Please use Chrome, Firefox or Opera to download.");
              return;
            }

            var dialog = $("#InfoDialog");
            var id = +dialog.get(0).dataset['series'];
            var series = _(self.data.dataseries).where({seriesid: id}).pop();

            var csvContent = "";

            // Append dataset values once the dataset is loaded
            series.loadDataset(function() {
                    // Append header
                csvContent +=   "# ------------------------------------------------------------------------------------------\n" +
                                "# WARNING: These data may be provisional and subject to revision. The data are released\n" +
                                "# on the condition that neither iUTAH may be held liable for any damages resulting from\n" +
                                "# its use. The following metadata describe the data in this file:\n" +
                                "# ------------------------------------------------------------------------------------------\n#\n";

                // Append Site Information
                csvContent +=   "# Site Information\n" +
                                "# ---------------------------\n" +
                                "# Network: " + series['network'] + "\n" +
                                "# SiteCode: " + series['sitecode'] + "\n" +
                                "# SiteName: " + series['sitename'] + "\n" +
                                "# IsActive: " + series['isactive'] + "\n" +
                                "# Latitude: " + series['latitude'] + "\n" +
                                "# Longitude: " + series['longitude'] + "\n" +
                                "# Elevation: " + series.dataset.elevation + "\n" +
                                "# VerticalDatum: " + series.dataset['verticalDatum'] + "\n" +
                                "# State: " + series['state'] + "\n" +
                                "# County: " + series['county'] + "\n" +
                                //"# SiteComments:" + series['sitecomments'] + "\n" +                 // Not found
                                "# SiteType: " + series['sitetype'] + "\n#\n";

                // Append Variable Information
                csvContent +=   "# Variable Information\n" +
                                "# ---------------------------\n" +
                                "# VariableCode: " + series['variablecode'] + "\n" +
                                "# VariableName: " + series['variablename'] + "\n" +
                                "# ValueType: " + series['valuetype'] + "\n" +
                                "# DataType: " + series['datatype'] + "\n" +
                                "# GeneralCategory: " + series['generalcategory'] + "\n" +
                                "# SampleMedium: " + series['samplemedium'] + "\n" +
                                "# VariableUnitsName: " + series['variableunitsname'] + "\n" +
                                "# VariableUnitsType: " + series['variableunitstype'] + "\n" +
                                "# VariableUnitsAbbreviation: " + series['variableunitsabbreviation'] + "\n" +
                                "# NoDataValue:" + series.dataset['noDataValue'] + "\n" +
                                //"# IsRegular:" + series['isregular'] + "\n" +                                         // Not found
                                "# TimeSupport: " + series['timesupport'] + "\n" +
                                "# TimeSupportUnitsAbbreviation: " + series['timesupportunitsabbreviation'] + "\n" +
                                "# TimeSupportUnitsName: " + series['timesupportunitsname'] + "\n" +
                                "# TimeSupportUnitsType: " + series['timesupportunitstype'] + "\n#\n";
                                //"# Speciation:" + series['speciation'] + "\n#\n";                                     // Not found

                // Append Method Information
                csvContent +=   "# Method Information\n" +
                                "# ---------------------------\n" +
                                "# MethodDescription: " + series['methoddescription'] + "\n" +
                                "# MethodLink: " + series['sitecode'] + "\n#\n";

                // Append Series Information
                csvContent +=   "# Series Information\n" +
                                "# ---------------------------\n" +
                                "# BeginDateTime: " + series['begindatetime'] + "\n" +
                                "# EndDateTime: " + series['enddatetime'] + "\n" +
                                "# DateLastUpdated: " + series['datelastupdated'] + "\n" +
                                "# NumberOfObservations: " + series['numberobservations'] + "\n" +
                                "# QualityControlLevelCode: " + series['qualitycontrollevelcode'] + "\n" +
                                "# QualityControllLevelDefinition: " + series['qualitycontrolleveldefinition'] + "\n" +
                                "# QualityControlLevelExplanation: " + series['qualitycontrollevelexplanation'] + "\n" +
                                "# GetDataUrl: " + series['getdataurl'] + "\n#\n";

                // Append Source Information
                csvContent +=   "# Source Information\n" +
                                "# ---------------------------\n" +
                                "# SourceOrganization: " + series['sourceorganization'] + "\n" +
                                "# SourceDescription: " + series['sourcedescription'] + "\n#\n";
                                //"# ContactName:" + series['contactname'] + "\n" +                   // Not found
                                //"# ContactEmail:" + series['contactemail'] + "\n" +                 // Not found
                                //"# ContactPhone:" + series['contactphone'] + "\n" +                 // Not found
                                //"# Citation:" + series['citation'] + "\n";                          // Not found

                // Append property names
                csvContent += "DateTime, ";
                csvContent += "TimeOffset, ";
                csvContent += "DateTimeUTC, ";
                csvContent += "Value, ";
                csvContent += "CensorCode";
                csvContent += "\n";

                // Append property values
                series.dataset.forEach(function(data){
                     csvContent += data['date'].replace("T", " ") + ", "
                                + data['timeOffset'] + ", "
                                + data['dateTimeUTC'].replace("T", " ") + ", "
                                + data['value'] + ", "
                                + data['censorCode'] + "\n";
                });

                var filename = series.sitecode + " - " + series.variablename + ".csv";

                // Set HTML5 download
                var blob = new Blob(["\ufeff", csvContent]);
                var url = URL.createObjectURL(blob);

                link.setAttribute("href", url);
                link.setAttribute("download", filename);
                link.className = "glyphicon glyphicon-file";
                link.innerHTML = " " + filename + "";

                $(".modal-header").find(".alert").empty();
                $(".modal-header").find(".alert").removeClass("alert-info");
                $(".modal-header").find(".alert").addClass("alert-success");
                $(".modal-header").find(".alert").append(link);
            });
        });

        $('#dpd1').bind('changeDate', onDateChange);
        $('#dpd2').bind('changeDate', onDateChange);
        $('#dpd1').bind('input', onDateChange);
        $('#dpd2').bind('input', onDateChange);

        $("#btnTimeSeries").click(function() {
            $("#visualizationDropDown").text($(this).text() + " ").append("");
            self.visualization.currentPlot = self.visualization.plotTypes.multiseries;
        });

        $("#btnHistogram").click(function() {
            $("#visualizationDropDown").text($(this).text() + " ").append("");
            self.visualization.currentPlot = self.visualization.plotTypes.histogram;
        });

        $("#btnBoxAndWhisker").click(function() {
            $("#visualizationDropDown").text($(this).text() + " ").append("");
            self.visualization.currentPlot = self.visualization.plotTypes.box;
        });

        $("#btnSetPlotOptions").click(function() {
            var dateFirst = $('#dpd1')
            var dateLast = $('#dpd2');

            $("#graphArea").find(".alert").remove();

            var a = new Date(dateFirst.val());
            var b = new Date(dateLast.val())
            if(a <= b){
                self.visualization.plotSeries();  // Dates do not overlap, proceed
            } else {
                // Dates overlap, display an error.
                $("#graphArea").prepend(
                    '
\
                      <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>\
                       Dates cannot overlap. \

'
                );
            }
        });

        $("#btnCollapseToggle").click(function() {
            dir = !dir;
            var slideDistance = 307;
            r = dir? -slideDistance : 0;
            $("#panel-right").stop().animate({right: r+'px'}, 0);
            $("#btnCollapseToggle span").removeClass();
            if (!dir){
                //$("#graphContainer").animate({width:$("#graphContainer").width() - 280}, 800);    // animation
                $("#graphContainer").width($("#graphContainer").width() - slideDistance);           // no animation
                $("#btnCollapseToggle span").addClass("glyphicon glyphicon-chevron-right");
            }
            else{
                //$("#graphContainer").animate({width:$("#graphContainer").width() + 280}, 800);    // animation
                $("#graphContainer").width($("#graphContainer").width() + slideDistance);           // no animation
                $("#btnCollapseToggle span").addClass("glyphicon glyphicon-chevron-left");
            }
            self.visualization.plotSeries();
        });

        $("#btnLeftPanelCollapse").on("click", toggleLeftPanel);

        $("#btnHideLeftToolbar").on("click", toggleLeftPanel);

        $("#visualizationTab").on("click", function(){
            $("#leftPanel .panel-group").hide();

            var btn = $("#btnLeftPanelCollapse")[0];
            btn.setAttribute("data-enabled", "false");
        });

        $("#datasetsTab").on("click", function(){
            toggleLeftPanelButton();
        });

        $("#mapTab").on("click", function() {
            toggleLeftPanelButton();
        });
    }

    function toggleLeftPanel(){
        if ($("#btnLeftPanelCollapse")[0].getAttribute("data-enabled") == "true"){
            $("#leftPanel .panel-group").toggle();
            isShown = !isShown;
            google.maps.event.trigger(self.map.map, 'resize');
        }
    }

    function toggleLeftPanelButton(){
        var btn = $("#btnLeftPanelCollapse")[0];
        btn.setAttribute("data-enabled", "true");

        if (isShown){
            $("#leftPanel .panel-group").show();
        }
    }

    function onDateChange() {
         $("#dateIntervals button").removeClass("active");
    }

    function checkInitialFilters() {
        var selectedNetwork = self.initialParameters['network'];
        var selectedSite = self.initialParameters['sitecode'];
        var selectedVariable = self.initialParameters['variablecode'];
        var selectedControlLevel = self.initialParameters['qualitycontrollevelcode'];
        var shouldPlot = self.initialParameters['plot'] === 'true';
        var networkFilter = _(_(self.data.facets)
            .findWhere({name:'Network'}).filters)
            .findWhere({network:selectedNetwork});

        self.data.toggleFilter('sourcedataserviceid', (networkFilter)? networkFilter.sourcedataserviceid: undefined);
        self.data.toggleFilter('sitecode', selectedSite);
        self.data.toggleFilter('variablecode', selectedVariable);
        self.data.toggleFilter('qualitycontrollevelcode', selectedControlLevel);

        if (self.data.filteredDataseries.length === 1 && shouldPlot) {
            var dataseries = _(self.data.filteredDataseries).first();
            self.visualization.doPlot = (self.initialParameters['view'] === 'visualization')? true: false;
            self.visualization.prepareSeries(dataseries);
        }
    }

    return self;
});<|endoftext|>


<commit_before>import _ from 'lodash';
import electronStore from 'electron-store';

import options from '../../common/settings';
import { restartApi, stopApi } from '../mpris';

const store = new electronStore();

function setIfUnset (storeKey) {
  const args = [...arguments];
  args.shift();
  if (!store.get(storeKey)) {
    store.set(storeKey, ...args);
  }
}

function initStore () {
  setIfUnset('lastFm');
  setIfUnset('settings');

  setIfUnset('localFolders', []);
  setIfUnset('playLists', []);

  setIfUnset( 'favorites', {
    tracks: [],
    artists: [],
    albums: []
  });

  setIfUnset('equalizer', {
    selected: 'Default',
    presets: {
      Default: {
        values: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        preAmp: 0
      },
      Classical: {
        values: [0, 0, 0, 0, 0, 0, -4, -4, -4, -6],
        preAmp: 0
      },
      Club: {
        values: [0, 0, 2, 4, 4, 4, 2, 0, 0, 0],
        preAmp: 0
      },
      Pop: {
        values: [-1, 2, 3, 4, 3, 0, -1, -1, -1, -1],
        preAmp: 0
      },
      Reggae: {
        values: [0, 0, 0, -2, 0, 2, 2, 0, 0, 0],
        preAmp: 0
      },
      Rock: {
        values: [4, 3, -2, -3, -2, 2, 5, 6, 6, 6],
        preAmp: 0
      },
      'Full bass': {
        values: [6, 6, 6, 4, 0, -2, -4, -6, -6, -6],
        preAmp: 0
      },
      'Full trebble': {
        values: [-6, -6, -6, -2, 2, 6, 8, 8, 9, 9],
        preAmp: 0
      }
    }
  });
}

// Should be called in startup process
initStore();

function getOption (key) {
  const settings = store.get('settings') || {};
  let value = settings[key];

  if (typeof value === 'undefined') {
    value = _.find(options, { name: key }).default;
  }

  return value;
}

function isValidPort(value) {
  return typeof value === 'number' && value > 1024 && value < 49151;
}

function setOption (key, value) {
  const settings = store.get('settings') || {};

  store.set('settings', Object.assign({}, settings, { [`${key}`]: value }));

  if (
    (key === 'api.port' && isValidPort(value) && getOption('api.enabled')) ||
    (key === 'api.enabled' && value)
  ) {
    restartApi();
  } else if (key === 'api.enabled' && !value) {
    stopApi();
  }
}

export { store, getOption, setOption };
<commit_msg>Fix a bug related to persistence<commit_after>import _ from 'lodash';
import electronStore from 'electron-store';
import logger from 'electron-timber';

import options from '../../common/settings';
import { restartApi, stopApi } from '../mpris';

const store = new electronStore();

function setIfUnset (key, value) {
  if (!store.get(key)) {
    store.set(key, value);
  }
}

function initStore () {
  setIfUnset('lastFm', {});
  setIfUnset('settings', {});

  setIfUnset('localFolders', []);
  setIfUnset('playLists', []);

  setIfUnset( 'favorites', {
    tracks: [],
    artists: [],
    albums: []
  });

  setIfUnset('equalizer', {
    selected: 'Default',
    presets: {
      Default: {
        values: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        preAmp: 0
      },
      Classical: {
        values: [0, 0, 0, 0, 0, 0, -4, -4, -4, -6],
        preAmp: 0
      },
      Club: {
        values: [0, 0, 2, 4, 4, 4, 2, 0, 0, 0],
        preAmp: 0
      },
      Pop: {
        values: [-1, 2, 3, 4, 3, 0, -1, -1, -1, -1],
        preAmp: 0
      },
      Reggae: {
        values: [0, 0, 0, -2, 0, 2, 2, 0, 0, 0],
        preAmp: 0
      },
      Rock: {
        values: [4, 3, -2, -3, -2, 2, 5, 6, 6, 6],
        preAmp: 0
      },
      'Full bass': {
        values: [6, 6, 6, 4, 0, -2, -4, -6, -6, -6],
        preAmp: 0
      },
      'Full trebble': {
        values: [-6, -6, -6, -2, 2, 6, 8, 8, 9, 9],
        preAmp: 0
      }
    }
  });
}

// Should be called in startup process
initStore();

function getOption (key) {
  const settings = store.get('settings') || {};
  let value = settings[key];

  if (typeof value === 'undefined') {
    value = _.find(options, { name: key }).default;
  }

  return value;
}

function isValidPort(value) {
  return typeof value === 'number' && value > 1024 && value < 49151;
}

function setOption (key, value) {
  const settings = store.get('settings') || {};

  store.set('settings', Object.assign({}, settings, { [`${key}`]: value }));

  if (
    (key === 'api.port' && isValidPort(value) && getOption('api.enabled')) ||
    (key === 'api.enabled' && value)
  ) {
    restartApi();
  } else if (key === 'api.enabled' && !value) {
    stopApi();
  }
}

export { store, getOption, setOption };
<|endoftext|>


<commit_before>const API_URL = process.env.API_URL || 'http://localhost:8080';

export default function api(feed) {
    return new Promise((resolve, reject) =>
        fetch(`${API_URL}/api/${feed}`)
        .then((response) => response.json())
        .then(resolve)
        .catch(reject)
    );
}
<commit_msg>Added new api address<commit_after>const API_URL = process.env.API_URL || 'https://api.byggreal.kennethaasan.no';

export default function api(feed) {
    return new Promise((resolve, reject) =>
        fetch(`${API_URL}/api/${feed}`)
        .then((response) => response.json())
        .then(resolve)
        .catch(reject)
    );
}
<|endoftext|>


<commit_before> // logical "not" IC: hex inverter

 // constants
 var TERMINAL_DISCONNECTED = null;
 var TERMINAL_VCC = 'VCC';
 var TERMINAL_GND = 'GND';
 var TERMINAL_INPUT = 'INPUT';
 var TERMINAL_OUTPUT = 'OUTPUT';

 // init terminal functions
 var element1.role = [];
 element1.role[terminal1] = TERMINAL_VCC;
 element1.role[terminal8] = TERMINAL_GND;
 element1.role[terminal2] = TERMINAL_OUTPUT;
 element1.role[terminal3] = TERMINAL_INPUT;

 // init levels
 var element1.level = [];
 element1.level[terminal1] = 5 * Volt; // switched on
 element1.level[terminal8] = 0 * Volt;
 element1.level[terminal3] = CMOS_LOW;
 element1.level[terminal2] = CMOS_HIGH;

 invert = function(currentOutputLevel, inputLevel) {
   var VCC = this.level[terminal1]-this.level[terminal8];

   if (VCC < 3*Volt || VCC > 15*Volt) // inactive or destroyed; null = disconnected
     return TERMINAL_DISCONNECTED;

   if (currentOutputLevel == CMOS_LOW && inputLevel >= CMOS_LOW_TO_HIGH) // input = HIGH
        return CMOS_LOW
   else if (currentOutputLevel == CMOS_HIGH && inputLevel <= CMOS_HIGH_TO_LOW) // input = LOW
        return CMOS_HIGH
   else return currentOutputLevel; // hysterese (e.g. Schmitt-Trigger)
   }

 update = function(event) {
   this.level[terminal2] = this.invert(this.level[terminal2], this.level[terminal3]);
   this.level[terminal4] = this.invert(this.level[terminal4], this.level[terminal5]);
   this.level[terminal6] = this.invert(this.level[terminal6], this.level[terminal7]);
   this.level[terminal15] = this.invert(this.level[terminal15], this.level[terminal14]);
   this.level[terminal12] = this.invert(this.level[terminal12], this.level[terminal11]);
   this.level[terminal10] = this.invert(this.level[terminal10], this.level[terminal9]);
   }

 element1.onclick = update;
<commit_msg>gEDA.js ...<commit_after> // logical "not" IC: hex inverter

 // constants
var NOT_CONNECTED = null;
var VCC = 'VCC';
var GND = 'GND';
var INPUT = 'INPUT';
var OUTPUT = 'OUTPUT';

var V = Volt = 1;
var mV = 0.001;
var LOW = 0 * Volt;
var HIGH = 5 * Volt;

Terminal = {
	var SVGElement = null;
	var role = NOT_CONNECTED;
	var level = LOW;
	}

HexInverter14 = {

	var terminals = {};

	terminals[14].role = VCC;
		...
		role = VCC;
		level[14] = 5 * Volt;
		role[7] = GND;
		level[7] = 0 * Volt;

		role[01] = INPUT;
		role[03] = INPUT;
		role[05] = INPUT;
		role[09] = INPUT;
		role[11] = INPUT;
		role[13] = INPUT;
		level[01] = LOW;
		level[03] = LOW;
		level[05] = LOW;
		level[09] = LOW;
		level[11] = LOW;
		level[13] = LOW;
		role[02] = OUTPUT;
		role[04] = OUTPUT;
		role[06] = OUTPUT;
		role[08] = OUTPUT;
		role[10] = OUTPUT;
		role[12] = OUTPUT;
		level[02] = HIGH;
		level[04] = HIGH;
		level[06] = HIGH;
		level[08] = HIGH;
		level[10] = HIGH;
		level[12] = HIGH;
		}

	var HIGH_TO_LOW = LOW_TO_HIGH = 2.5 * Volt;

	invert = function(currentOutputLevel, inputLevel) {
		var VCC = this.level[14]-this.level[7];

		if (VCC < 3*Volt || VCC > 15*Volt) // inactive or destroyed; null = disconnected
			return NOT_CONNECTED;

		if (currentOutputLevel == LOW && inputLevel >= this.LOW_TO_HIGH)	// input = HIGH
			return LOW
		else
		if (currentOutputLevel == HIGH && inputLevel <= this.HIGH_TO_LOW)	// input = LOW
			return HIGH
		else
			return currentOutputLevel; // hysterese (e.g. Schmitt-Trigger)
		}

	update = function(event) {
		this.level[2] = this.invert(this.level[2], this.level[3]);
		this.level[4] = this.invert(this.level[4], this.level[5]);
		this.level[6] = this.invert(this.level[6], this.level[7]);
		this.level[10] = this.invert(this.level[10], this.level[9]);
		this.level[12] = this.invert(this.level[12], this.level[11]);
		this.level[15] = this.invert(this.level[15], this.level[14]);
		}
	}

HexInverter16 = {
	// init terminal functions
	var role = {};
	role[1] = VCC;
	role[8] = GND;
	role[2] = OUTPUT;
	role[3] = INPUT;

	// init levels
	var level = {};
	level[1] = 5 * Volt; // switched on
	level[8] = 0 * Volt;
	level[3] = LOW;
	level[2] = HIGH;

	var HIGH_TO_LOW = LOW_TO_HIGH = 2.5 * Volt;

	invert = function(currentOutputLevel, inputLevel) {
		var VCC = this.level[1]-this.level[8];

		if (VCC < 3*Volt || VCC > 15*Volt) // inactive or destroyed; null = disconnected
			return NOT_CONNECTED;

		if (currentOutputLevel == LOW && inputLevel >= this.LOW_TO_HIGH)	// input = HIGH
			return LOW
		else
		if (currentOutputLevel == HIGH && inputLevel <= this.HIGH_TO_LOW)	// input = LOW
			return HIGH
		else
			return currentOutputLevel; // hysterese (e.g. Schmitt-Trigger)
		}

	update = function(event) {
		this.level[2] = this.invert(this.level[2], this.level[3]);
		this.level[4] = this.invert(this.level[4], this.level[5]);
		this.level[6] = this.invert(this.level[6], this.level[7]);
		this.level[10] = this.invert(this.level[10], this.level[9]);
		this.level[12] = this.invert(this.level[12], this.level[11]);
		this.level[15] = this.invert(this.level[15], this.level[14]);
		}
	}

<|endoftext|>


<commit_before>import $ from 'jquery';
import { Howl } from 'howler';

const playing = [];

export default class Sample {

  constructor({ id, file, name, location }) {
    this.id = id;
    this.file = file;
    this.name = name;
    this.location = location;

    this.boundProgressStep = this.progressStep.bind(this);

    this.initSound();

    this.createElements();
    this.bindEvents();
  }

  progressStep() {
    const { howl, $progress } = this;

    const seek = howl.seek() || 0;
    const progress = (seek / howl.duration()) * 100;
    $progress.css('flex-basis', `${progress}%`);

    if (howl.playing()) {
      requestAnimationFrame(this.boundProgressStep);
    }
  }

  initSound() {
    const howl = this.howl = new Howl({
      src: [encodeURI(`samples/${this.file}`)],
      //html5: true, // Use HTML5 Audio, so large files can be streamed
      preload: false,
    });

    howl.on('play', () => {
      playing.push(howl);
      this.$sample.addClass('sample--playing');
      requestAnimationFrame(this.boundProgressStep);
    });

    howl.on('stop', () => {
      playing.splice(playing.indexOf(howl));
      this.$sample.removeClass('sample--playing');
    });
  }

  createElements() {
    const $sample = this.$sample = $('<div />')
      .addClass('sample');

    $sample.append($('<div />')
      .addClass('sample__name')
      .text(this.name)
    );

    $sample.append($('<div />')
      .addClass('sample__location')
      .text(this.location)
    );

    const $progress = this.$progress = $('<div />')
      .addClass('sample__progress');

    $sample.append($('<div />')
      .addClass('sample__progress-container')
      .append($progress)
    );
  }

  bindEvents() {
    const { $sample } = this;

    // Preload sound when the user hovers over the sample for more than 150ms
    let hoverTimer;

    $sample.on('mouseenter', () => {
      if (this.howl.state() === 'unloaded') {
        hoverTimer = setTimeout(() => {
          this.howl.load();
        }, 150);
      }
    });

    $sample.on('mouseleave', () => {
      clearTimeout(hoverTimer);
    });

    // Preload the sound when the user presses down on the sample
    $sample.on('mousedown touchstart', () => {
      if (this.howl.state() === 'unloaded') {
        this.howl.load();
      }
    });

    // Play the sound on click
    $sample.on('click', (e) => {
      // Stop all other playing sounds unless the shift key was pressed
      if (!e.shiftKey) {
        playing.forEach((howl) => howl.stop());
        playing.length = 0;
      }

      this.howl.play();
    });
  }

}
<commit_msg>Remove playing state on sound end<commit_after>import $ from 'jquery';
import { Howl } from 'howler';

const playing = [];

export default class Sample {

  constructor({ id, file, name, location }) {
    this.id = id;
    this.file = file;
    this.name = name;
    this.location = location;

    this.boundProgressStep = this.progressStep.bind(this);

    this.initSound();

    this.createElements();
    this.bindEvents();
  }

  progressStep() {
    const { howl, $progress } = this;

    const seek = howl.seek() || 0;
    const progress = (seek / howl.duration()) * 100;
    $progress.css('flex-basis', `${progress}%`);

    if (howl.playing()) {
      requestAnimationFrame(this.boundProgressStep);
    }
  }

  initSound() {
    const howl = this.howl = new Howl({
      src: [encodeURI(`samples/${this.file}`)],
      //html5: true, // Use HTML5 Audio, so large files can be streamed
      preload: false,
    });

    howl.on('play', () => {
      playing.push(howl);
      this.$sample.addClass('sample--playing');
      requestAnimationFrame(this.boundProgressStep);
    });

    howl.on('stop', () => {
      playing.splice(playing.indexOf(howl));
      this.$sample.removeClass('sample--playing');
    });
    howl.on('end', () => {
      howl.stop();
    });
  }

  createElements() {
    const $sample = this.$sample = $('<div />')
      .addClass('sample');

    $sample.append($('<div />')
      .addClass('sample__name')
      .text(this.name)
    );

    $sample.append($('<div />')
      .addClass('sample__location')
      .text(this.location)
    );

    const $progress = this.$progress = $('<div />')
      .addClass('sample__progress');

    $sample.append($('<div />')
      .addClass('sample__progress-container')
      .append($progress)
    );
  }

  bindEvents() {
    const { $sample } = this;

    // Preload sound when the user hovers over the sample for more than 150ms
    let hoverTimer;

    $sample.on('mouseenter', () => {
      if (this.howl.state() === 'unloaded') {
        hoverTimer = setTimeout(() => {
          this.howl.load();
        }, 150);
      }
    });

    $sample.on('mouseleave', () => {
      clearTimeout(hoverTimer);
    });

    // Preload the sound when the user presses down on the sample
    $sample.on('mousedown touchstart', () => {
      if (this.howl.state() === 'unloaded') {
        this.howl.load();
      }
    });

    // Play the sound on click
    $sample.on('click', (e) => {
      // Stop all other playing sounds unless the shift key was pressed
      if (!e.shiftKey) {
        playing.forEach((howl) => howl.stop());
        playing.length = 0;
      }

      this.howl.play();
    });
  }

}
<|endoftext|>


<commit_before>exports = module.exports = function(IoC, store, logger) {
  var flowstate = require('flowstate');

  var dispatcher = new flowstate.Manager(store);

  return Promise.resolve(dispatcher)
    .then(function(dispatcher) {
      var components = IoC.components('http://i.bixbyjs.org/http/prompt/Prompt');

      return Promise.all(components.map(function(comp) { return comp.create(); } ))
        .then(function(plugins) {
          plugins.forEach(function(plugin, i) {
            var name = components[i].a['@name'];
            logger.info('Loaded HTTP prompt: ' + name);
            dispatcher.use(name, plugin.begin, plugin.resume);
          });
        })
        .then(function() {
          return dispatcher;
        });
    })
    .then(function(dispatcher) {
      return dispatcher;
    });
};

// TODO: Rename this to http/prompt/Dispatcher
exports['@implements'] = 'http://i.bixbyjs.org/http/state/Dispatcher';
exports['@singleton'] = true;
exports['@require'] = [
  '!container',
  'http://i.bixbyjs.org/http/workflow/StateStore',
  'http://i.bixbyjs.org/Logger'
];
<commit_msg>Change interface of prompts.<commit_after>exports = module.exports = function(IoC, store, logger) {
  var flowstate = require('flowstate');

  var dispatcher = new flowstate.Manager(store);

  return Promise.resolve(dispatcher)
    .then(function(dispatcher) {
      var components = IoC.components('http://i.bixbyjs.org/http/state/Prompt');

      return Promise.all(components.map(function(comp) { return comp.create(); } ))
        .then(function(plugins) {
          plugins.forEach(function(plugin, i) {
            var name = components[i].a['@name'];
            logger.info('Loaded HTTP prompt: ' + name);
            dispatcher.use(name, plugin.begin, plugin.resume);
          });
        })
        .then(function() {
          return dispatcher;
        });
    })
    .then(function(dispatcher) {
      return dispatcher;
    });
};

// TODO: Rename this to http/prompt/Dispatcher
exports['@implements'] = 'http://i.bixbyjs.org/http/state/Dispatcher';
exports['@singleton'] = true;
exports['@require'] = [
  '!container',
  'http://i.bixbyjs.org/http/workflow/StateStore',
  'http://i.bixbyjs.org/Logger'
];
<|endoftext|>