<commit_before>import shortid from 'shortid';
import { compose } from 'redux';
import persistState from 'redux-localstorage';

export function addToObject(state, arrKey, obj) {
  const newObject = Object.assign({}, state[arrKey]);
  const copiedObject = Object.assign({}, obj);

  if (!copiedObject.id) {
    copiedObject.id = shortid.generate();
  }
  newObject[copiedObject.id] = copiedObject;
  return Object.assign({}, state, { [arrKey]: newObject });
}

export function alterInObject(state, arrKey, obj, alterations) {
  const newObject = Object.assign({}, state[arrKey]);
  newObject[obj.id] = Object.assign({}, newObject[obj.id], alterations);
  return Object.assign({}, state, { [arrKey]: newObject });
}

export function alterInArr(state, arrKey, obj, alterations) {
  // Finds an item in an array in the state and replaces it with a
  // new object with an altered property
  const idKey = 'id';
  const newArr = [];
  state[arrKey].forEach((arrItem) => {
    if (obj[idKey] === arrItem[idKey]) {
      newArr.push(Object.assign({}, arrItem, alterations));
    } else {
      newArr.push(arrItem);
    }
  });
  return Object.assign({}, state, { [arrKey]: newArr });
}

export function removeFromArr(state, arrKey, obj, idKey = 'id') {
  const newArr = [];
  state[arrKey].forEach((arrItem) => {
    if (!(obj[idKey] === arrItem[idKey])) {
      newArr.push(arrItem);
    }
  });
  return Object.assign({}, state, { [arrKey]: newArr });
}

export function getFromArr(arr, id) {
  let obj;
  arr.forEach((o) => {
    if (o.id === id) {
      obj = o;
    }
  });
  return obj;
}

export function addToArr(state, arrKey, obj) {
  const newObj = Object.assign({}, obj);
  if (!newObj.id) {
    newObj.id = shortid.generate();
  }
  const newState = {};
  newState[arrKey] = [...state[arrKey], newObj];
  return Object.assign({}, state, newState);
}

export function enhancer() {
  let enhancerWithPersistState = compose(persistState());
  if (process.env.NODE_ENV === 'dev') {
    enhancerWithPersistState = compose(
      persistState(), window.devToolsExtension && window.devToolsExtension()
    );
  }
  return enhancerWithPersistState;
}
<commit_msg>Added alert to install redux devtool (#1228)<commit_after>import shortid from 'shortid';
import { compose } from 'redux';
import persistState from 'redux-localstorage';

export function addToObject(state, arrKey, obj) {
  const newObject = Object.assign({}, state[arrKey]);
  const copiedObject = Object.assign({}, obj);

  if (!copiedObject.id) {
    copiedObject.id = shortid.generate();
  }
  newObject[copiedObject.id] = copiedObject;
  return Object.assign({}, state, { [arrKey]: newObject });
}

export function alterInObject(state, arrKey, obj, alterations) {
  const newObject = Object.assign({}, state[arrKey]);
  newObject[obj.id] = Object.assign({}, newObject[obj.id], alterations);
  return Object.assign({}, state, { [arrKey]: newObject });
}

export function alterInArr(state, arrKey, obj, alterations) {
  // Finds an item in an array in the state and replaces it with a
  // new object with an altered property
  const idKey = 'id';
  const newArr = [];
  state[arrKey].forEach((arrItem) => {
    if (obj[idKey] === arrItem[idKey]) {
      newArr.push(Object.assign({}, arrItem, alterations));
    } else {
      newArr.push(arrItem);
    }
  });
  return Object.assign({}, state, { [arrKey]: newArr });
}

export function removeFromArr(state, arrKey, obj, idKey = 'id') {
  const newArr = [];
  state[arrKey].forEach((arrItem) => {
    if (!(obj[idKey] === arrItem[idKey])) {
      newArr.push(arrItem);
    }
  });
  return Object.assign({}, state, { [arrKey]: newArr });
}

export function getFromArr(arr, id) {
  let obj;
  arr.forEach((o) => {
    if (o.id === id) {
      obj = o;
    }
  });
  return obj;
}

export function addToArr(state, arrKey, obj) {
  const newObj = Object.assign({}, obj);
  if (!newObj.id) {
    newObj.id = shortid.generate();
  }
  const newState = {};
  newState[arrKey] = [...state[arrKey], newObj];
  return Object.assign({}, state, newState);
}

export function enhancer() {
  let enhancerWithPersistState = compose(persistState());
  if (process.env.NODE_ENV === 'dev') {
    if (window.devToolsExtension) {
      enhancerWithPersistState = compose(
        persistState(), window.devToolsExtension && window.devToolsExtension()
      );
    } else {
      console.warn('You may encounter errors unless' +
        'you have Redux Devtool Extension installed: ' +
        'http://github.com/zalmoxisus/redux-devtools-extension');
    }
  }
  return enhancerWithPersistState;
}
<|endoftext|>


<commit_before><commit_msg>Rebuild sink<commit_after><|endoftext|>


<commit_before>Ext.ns('Kwf.Maintenance');
Kwf.Maintenance.Setup = Ext.extend(Ext.Panel, {
    border: false,
    initComponent: function() {
        this.layout = 'border';
        this.about = {
            cls: 'kwfSetupAbout',
            region: 'north',
            height: 150,
            html : '
'+
                    ''+
                    '
'+trlKwf('Setup')+'
'+
                    '
'+this.kwfVersion+'
'+
                    '
'+this.appVersion+'
'+
                    '
'
        };
        this.steps = new Kwf.Maintenance.SetupSteps({
            width: 300,
            region: 'west'
        });

        //welcome
        this.stepWelcome = new Ext.Panel({
            width: 350,
            height: 200,
            border: false,
            cls: 'kwfSetupWelcome',
            html: '
Welcome
'+
                  '
to the installation of Koala Framework.
'+
                  '
This Setup Tool will guide you throu the installation process.
',
            buttons: [{
                text: 'Continue',
                handler: function() {
                    this.cards.getLayout().setActiveItem(this.stepRequirements);
                    this.stepRequirements.refresh();
                    this.steps.setCurrentStep('requirements');
                },
                scope: this
            }]
        });

        //requirements
        this.stepRequirements = new Kwf.Maintenance.SetupRequirements({
        });
        this.stepRequirements.on('continue', function() {
            this.cards.getLayout().setActiveItem(this.stepDatabase);
            this.steps.setCurrentStep('dbconfig');
        }, this);

        //dbconfig
        this.stepDatabase = new Ext.FormPanel({
            border: false,
            bodyStyle: "padding: 10px;",
            cls: 'kwfSetupForm',
            items: [{
                xtype: 'textfield',
                name: 'db_username',
                fieldLabel: 'Username',
                allowBlank: false
            }, {
                xtype: 'textfield',
                name: 'db_password',
                fieldLabel: 'Password',
                inputType: 'password'
            }, {
                xtype: 'textfield',
                name: 'db_dbname',
                fieldLabel: 'Database',
                value: this.defaultDbName,
                allowBlank: false
            }, {
                xtype: 'textfield',
                name: 'db_host',
                value: 'localhost',
                fieldLabel: 'Host',
                allowBlank: false
            }],
            buttons: [{
                text: 'Continue',
                handler: function() {
                    if (!this.stepDatabase.getForm().isValid()) return;
                    Ext.Ajax.request({
                        url: '/kwf/maintenance/setup/json-check-db',
                        params: this.stepDatabase.getForm().getValues(),
                        success: function() {
                            this.cards.getLayout().setActiveItem(this.stepConfig);
                            this.steps.setCurrentStep('config');
                        },
                        scope: this
                    });
                },
                scope: this
            }]
        });

        //config
        this.stepConfig = new Ext.FormPanel({
            border: false,
            bodyStyle: "padding: 10px;",
            cls: 'kwfSetupForm',
            items: [{
                xtype: 'checkbox',
                name: 'display_errors',
                fieldLabel: 'Display Errors'
            }],
            buttons: [{
                text: 'Continue',
                handler: function() {
                    if (!this.stepConfig.getForm().isValid()) return;
                    this.cards.getLayout().setActiveItem(this.stepAdminAccount);
                    this.steps.setCurrentStep('adminAccount');
                },
                scope: this
            }]
        });

        //admin account
        this.stepAdminAccount = new Ext.FormPanel({
            border: false,
            bodyStyle: "padding: 10px;",
            cls: 'kwfSetupForm',
            items: [{
                xtype: 'textfield',
                vtype: 'email',
                name: 'admin_email',
                fieldLabel: 'E-Mail',
                allowBlank: false
            }, {
                xtype: 'textfield',
                name: 'admin_password',
                fieldLabel: 'Password',
                inputType: 'password',
                allowBlank: false
            }, {
                xtype: 'textfield',
                name: 'admin_password2',
                fieldLabel: 'Password repeat',
                inputType: 'password',
                allowBlank: false
            }],
            buttons: [{
                text: 'Continue',
                handler: function() {
                    if (!this.stepAdminAccount.getForm().isValid()) return;
                    if (this.stepAdminAccount.getForm().findField('admin_password').getValue() != this.stepAdminAccount.getForm().findField('admin_password2').getValue()) {
                         Ext.Msg.alert('Error', 'Passwords don\'t match');
                        return;
                    }
                    this._startInstallation();
                },
                scope: this
            }]
        });

        //install
        this.stepInstall = new Ext.Panel({
            border: false,
            cls: 'kwfSetupInstalling',
            bodyStyle: "padding: 10px;",
            html: 'Installing...'
        });

        //finished
        this.stepFinished = new Ext.Panel({
            border: false,
            cls: 'kwfSetupFinished',
            bodyStyle: "padding: 10px;",
            html: '
Installation Finished!

Installing '+this.appVersion+' finished.

» Proceed to your site

Thank you for using Koala Framework.
'
        });

        this.cards = new Ext.Panel({
            region: 'center',
            layout: 'card',
            activeItem: 0,
            items: [
                this.stepWelcome,
                this.stepRequirements,
                this.stepDatabase,
                this.stepConfig,
                this.stepAdminAccount,
                this.stepInstall,
                this.stepFinished
            ]
        });
        this.items = [
            this.about,
            {
                region: 'center',
                layout: 'border',
                border: false,
                items: [this.cards, this.steps]
            }
        ];

        Kwf.Maintenance.Setup.superclass.initComponent.call(this);
    },

    _startInstallation: function() {
        this.cards.getLayout().setActiveItem(this.stepInstall);
        this.steps.setCurrentStep('install');
        var params = {};
        Ext.apply(params, this.stepDatabase.getForm().getValues());
        Ext.apply(params, this.stepConfig.getForm().getValues());
        Ext.apply(params, this.stepAdminAccount.getForm().getValues());
        Ext.Ajax.request({
            url: '/kwf/maintenance/setup/json-install',
            params: params,
            progress: true,
            success: function() {
                this.cards.getLayout().setActiveItem(this.stepFinished);
                this.steps.setCurrentStep('finished');
            },
            scope: this
        });
    }
});
Ext.reg('kwf.maintenance.setup', Kwf.Maintenance.Setup);
<commit_msg>fix url after setup<commit_after>Ext.ns('Kwf.Maintenance');
Kwf.Maintenance.Setup = Ext.extend(Ext.Panel, {
    border: false,
    initComponent: function() {
        this.layout = 'border';
        this.about = {
            cls: 'kwfSetupAbout',
            region: 'north',
            height: 150,
            html : '
'+
                    ''+
                    '
'+trlKwf('Setup')+'
'+
                    '
'+this.kwfVersion+'
'+
                    '
'+this.appVersion+'
'+
                    '
'
        };
        this.steps = new Kwf.Maintenance.SetupSteps({
            width: 300,
            region: 'west'
        });

        //welcome
        this.stepWelcome = new Ext.Panel({
            width: 350,
            height: 200,
            border: false,
            cls: 'kwfSetupWelcome',
            html: '
Welcome
'+
                  '
to the installation of Koala Framework.
'+
                  '
This Setup Tool will guide you throu the installation process.
',
            buttons: [{
                text: 'Continue',
                handler: function() {
                    this.cards.getLayout().setActiveItem(this.stepRequirements);
                    this.stepRequirements.refresh();
                    this.steps.setCurrentStep('requirements');
                },
                scope: this
            }]
        });

        //requirements
        this.stepRequirements = new Kwf.Maintenance.SetupRequirements({
        });
        this.stepRequirements.on('continue', function() {
            this.cards.getLayout().setActiveItem(this.stepDatabase);
            this.steps.setCurrentStep('dbconfig');
        }, this);

        //dbconfig
        this.stepDatabase = new Ext.FormPanel({
            border: false,
            bodyStyle: "padding: 10px;",
            cls: 'kwfSetupForm',
            items: [{
                xtype: 'textfield',
                name: 'db_username',
                fieldLabel: 'Username',
                allowBlank: false
            }, {
                xtype: 'textfield',
                name: 'db_password',
                fieldLabel: 'Password',
                inputType: 'password'
            }, {
                xtype: 'textfield',
                name: 'db_dbname',
                fieldLabel: 'Database',
                value: this.defaultDbName,
                allowBlank: false
            }, {
                xtype: 'textfield',
                name: 'db_host',
                value: 'localhost',
                fieldLabel: 'Host',
                allowBlank: false
            }],
            buttons: [{
                text: 'Continue',
                handler: function() {
                    if (!this.stepDatabase.getForm().isValid()) return;
                    Ext.Ajax.request({
                        url: '/kwf/maintenance/setup/json-check-db',
                        params: this.stepDatabase.getForm().getValues(),
                        success: function() {
                            this.cards.getLayout().setActiveItem(this.stepConfig);
                            this.steps.setCurrentStep('config');
                        },
                        scope: this
                    });
                },
                scope: this
            }]
        });

        //config
        this.stepConfig = new Ext.FormPanel({
            border: false,
            bodyStyle: "padding: 10px;",
            cls: 'kwfSetupForm',
            items: [{
                xtype: 'checkbox',
                name: 'display_errors',
                fieldLabel: 'Display Errors'
            }],
            buttons: [{
                text: 'Continue',
                handler: function() {
                    if (!this.stepConfig.getForm().isValid()) return;
                    this.cards.getLayout().setActiveItem(this.stepAdminAccount);
                    this.steps.setCurrentStep('adminAccount');
                },
                scope: this
            }]
        });

        //admin account
        this.stepAdminAccount = new Ext.FormPanel({
            border: false,
            bodyStyle: "padding: 10px;",
            cls: 'kwfSetupForm',
            items: [{
                xtype: 'textfield',
                vtype: 'email',
                name: 'admin_email',
                fieldLabel: 'E-Mail',
                allowBlank: false
            }, {
                xtype: 'textfield',
                name: 'admin_password',
                fieldLabel: 'Password',
                inputType: 'password',
                allowBlank: false
            }, {
                xtype: 'textfield',
                name: 'admin_password2',
                fieldLabel: 'Password repeat',
                inputType: 'password',
                allowBlank: false
            }],
            buttons: [{
                text: 'Continue',
                handler: function() {
                    if (!this.stepAdminAccount.getForm().isValid()) return;
                    if (this.stepAdminAccount.getForm().findField('admin_password').getValue() != this.stepAdminAccount.getForm().findField('admin_password2').getValue()) {
                         Ext.Msg.alert('Error', 'Passwords don\'t match');
                        return;
                    }
                    this._startInstallation();
                },
                scope: this
            }]
        });

        //install
        this.stepInstall = new Ext.Panel({
            border: false,
            cls: 'kwfSetupInstalling',
            bodyStyle: "padding: 10px;",
            html: 'Installing...'
        });

        //finished
        this.stepFinished = new Ext.Panel({
            border: false,
            cls: 'kwfSetupFinished',
            bodyStyle: "padding: 10px;",
            html: '
Installation Finished!

Installing '+this.appVersion+' finished.

» Proceed to your site

Thank you for using Koala Framework.
'
        });

        this.cards = new Ext.Panel({
            region: 'center',
            layout: 'card',
            activeItem: 0,
            items: [
                this.stepWelcome,
                this.stepRequirements,
                this.stepDatabase,
                this.stepConfig,
                this.stepAdminAccount,
                this.stepInstall,
                this.stepFinished
            ]
        });
        this.items = [
            this.about,
            {
                region: 'center',
                layout: 'border',
                border: false,
                items: [this.cards, this.steps]
            }
        ];

        Kwf.Maintenance.Setup.superclass.initComponent.call(this);
    },

    _startInstallation: function() {
        this.cards.getLayout().setActiveItem(this.stepInstall);
        this.steps.setCurrentStep('install');
        var params = {};
        Ext.apply(params, this.stepDatabase.getForm().getValues());
        Ext.apply(params, this.stepConfig.getForm().getValues());
        Ext.apply(params, this.stepAdminAccount.getForm().getValues());
        Ext.Ajax.request({
            url: '/kwf/maintenance/setup/json-install',
            params: params,
            progress: true,
            success: function() {
                this.cards.getLayout().setActiveItem(this.stepFinished);
                this.steps.setCurrentStep('finished');
            },
            scope: this
        });
    }
});
Ext.reg('kwf.maintenance.setup', Kwf.Maintenance.Setup);
<|endoftext|>


<commit_before>import { moduleForComponent, test } from 'ember-qunit';

moduleForComponent('ggf-tablescore', 'Unit | Component | ggf tablescore', {
  // Specify the other units that are required for this test
  // needs: ['component:foo', 'helper:bar'],
  unit: true
});

test('it renders', function(assert) {
  assert.expect(2);

  // Creates the component instance
  var component = this.subject();
  assert.equal(component._state, 'preRender');

  // Renders the component to the page
  this.render();
  assert.equal(component._state, 'inDOM');
});
<commit_msg>Removed unnecessary component test<commit_after><|endoftext|>


<commit_before>"use strict";

const chai                    = require('chai');
const extract                 = require('../../src/extract');
const depSchema               = require('../../src/extract/jsonschema.json');
const cjsRecursiveFixtures    = require('./fixtures/cjs-recursive.json');
const deprecationFixtures     = require('./fixtures/deprecated-node-module.json');
const bundledFixtures         = require('./fixtures/bundled-dependencies.json');
const amdRecursiveFixtures    = require('./fixtures/amd-recursive.json');
const tsRecursiveFixtures     = require('./fixtures/ts-recursive.json');
const coffeeRecursiveFixtures = require('./fixtures/coffee-recursive.json');

const expect = chai.expect;

chai.use(require('chai-json-schema'));

function runRecursiveFixture(pFixture) {
    if (!Boolean(pFixture.ignore)){
        it(pFixture.title, () => {
            let lResult = extract(
                [pFixture.input.fileName],
                pFixture.input.options
            );

            expect(lResult.dependencies).to.deep.equal(pFixture.expected);
            expect(lResult).to.be.jsonSchema(depSchema);
        });

    }
}

describe('CommonJS recursive - ', () => cjsRecursiveFixtures.forEach(runRecursiveFixture));
describe('Deprecation - ', () => deprecationFixtures.forEach(runRecursiveFixture));
describe('Bundled - ', () => bundledFixtures.forEach(runRecursiveFixture));
describe('AMD recursive - ', () => amdRecursiveFixtures.forEach(runRecursiveFixture));
describe('TypeScript recursive - ', () => tsRecursiveFixtures.forEach(runRecursiveFixture));
describe('CoffeeScript recursive - (not-testable-in-node4)', () => coffeeRecursiveFixtures.forEach(runRecursiveFixture));

describe('Max depth', () => {
    it('returns the complete graph when max-depth is not specified', () => {
        const lResult = extract(
            ["./test/extract/fixtures/maxDepth/index.js"]
        );

        expect(lResult.dependencies).to.deep.equal(
            require('./fixtures/maxDepthUnspecified.json').dependencies
        );
        expect(lResult).to.be.jsonSchema(depSchema);
    });

    it('returns the file and one deep with --max-depth 1', () => {
        const lResult = extract(
            ["./test/extract/fixtures/maxDepth/index.js"],
            {
                maxDepth: 1
            }
        );

        expect(lResult.dependencies).to.deep.equal(
            require('./fixtures/maxDepth1.json').dependencies
        );
        expect(lResult).to.be.jsonSchema(depSchema);
    });

    it('returns the file and two deep with --max-depth 2', () => {
        const lResult = extract(
            ["./test/extract/fixtures/maxDepth/index.js"],
            {
                maxDepth: 2
            }
        );

        expect(lResult.dependencies).to.deep.equal(
            require('./fixtures/maxDepth2.json').dependencies
        );
        expect(lResult).to.be.jsonSchema(depSchema);
    });

    it('returns the file and three deep with --max-depth 3', () => {
        const lResult = extract(
            ["./test/extract/fixtures/maxDepth/index.js"],
            {
                maxDepth: 3
            }
        );

        expect(lResult.dependencies).to.deep.equal(
            require('./fixtures/maxDepth3.json').dependencies
        );
        expect(lResult).to.be.jsonSchema(depSchema);
    });

    it('returns the file and four deep with --max-depth 4', () => {
        const lResult = extract(
            ["./test/extract/fixtures/maxDepth/index.js"],
            {
                maxDepth: 4
            }
        );

        expect(lResult.dependencies).to.deep.equal(
            require('./fixtures/maxDepth4.json').dependencies
        );
        expect(lResult).to.be.jsonSchema(depSchema);
    });
});

describe('Do not follow', () => {
    it('does not follow files matching the doNotFollow RE', () => {
        const lResult = extract(
            ["./test/extract/fixtures/donotfollow/index.js"],
            {
                doNotFollow: "donotfollowonceinthisfolder"
            }
        );

        expect(lResult.dependencies).to.deep.equal(
            require('./fixtures/donotfollow.json').dependencies
        );
        expect(lResult).to.be.jsonSchema(depSchema);
    });
});

/* eslint global-require: 0*/
<commit_msg>style(test): space police<commit_after>"use strict";

const chai                    = require('chai');
const extract                 = require('../../src/extract');
const depSchema               = require('../../src/extract/jsonschema.json');
const cjsRecursiveFixtures    = require('./fixtures/cjs-recursive.json');
const deprecationFixtures     = require('./fixtures/deprecated-node-module.json');
const bundledFixtures         = require('./fixtures/bundled-dependencies.json');
const amdRecursiveFixtures    = require('./fixtures/amd-recursive.json');
const tsRecursiveFixtures     = require('./fixtures/ts-recursive.json');
const coffeeRecursiveFixtures = require('./fixtures/coffee-recursive.json');

const expect = chai.expect;

chai.use(require('chai-json-schema'));

function runRecursiveFixture(pFixture) {
    if (!Boolean(pFixture.ignore)){
        it(pFixture.title, () => {
            let lResult = extract(
                [pFixture.input.fileName],
                pFixture.input.options
            );

            expect(lResult.dependencies).to.deep.equal(pFixture.expected);
            expect(lResult).to.be.jsonSchema(depSchema);
        });

    }
}

describe('CommonJS recursive - ', () => cjsRecursiveFixtures.forEach(runRecursiveFixture));
describe('Deprecation - ', () => deprecationFixtures.forEach(runRecursiveFixture));
describe('Bundled - ', () => bundledFixtures.forEach(runRecursiveFixture));
describe('AMD recursive - ', () => amdRecursiveFixtures.forEach(runRecursiveFixture));
describe('TypeScript recursive - ', () => tsRecursiveFixtures.forEach(runRecursiveFixture));
describe(
    'CoffeeScript recursive - (not-testable-in-node4)',
    () => coffeeRecursiveFixtures.forEach(runRecursiveFixture)
);

describe('Max depth', () => {
    it('returns the complete graph when max-depth is not specified', () => {
        const lResult = extract(
            ["./test/extract/fixtures/maxDepth/index.js"]
        );

        expect(lResult.dependencies).to.deep.equal(
            require('./fixtures/maxDepthUnspecified.json').dependencies
        );
        expect(lResult).to.be.jsonSchema(depSchema);
    });

    it('returns the file and one deep with --max-depth 1', () => {
        const lResult = extract(
            ["./test/extract/fixtures/maxDepth/index.js"],
            {
                maxDepth: 1
            }
        );

        expect(lResult.dependencies).to.deep.equal(
            require('./fixtures/maxDepth1.json').dependencies
        );
        expect(lResult).to.be.jsonSchema(depSchema);
    });

    it('returns the file and two deep with --max-depth 2', () => {
        const lResult = extract(
            ["./test/extract/fixtures/maxDepth/index.js"],
            {
                maxDepth: 2
            }
        );

        expect(lResult.dependencies).to.deep.equal(
            require('./fixtures/maxDepth2.json').dependencies
        );
        expect(lResult).to.be.jsonSchema(depSchema);
    });

    it('returns the file and three deep with --max-depth 3', () => {
        const lResult = extract(
            ["./test/extract/fixtures/maxDepth/index.js"],
            {
                maxDepth: 3
            }
        );

        expect(lResult.dependencies).to.deep.equal(
            require('./fixtures/maxDepth3.json').dependencies
        );
        expect(lResult).to.be.jsonSchema(depSchema);
    });

    it('returns the file and four deep with --max-depth 4', () => {
        const lResult = extract(
            ["./test/extract/fixtures/maxDepth/index.js"],
            {
                maxDepth: 4
            }
        );

        expect(lResult.dependencies).to.deep.equal(
            require('./fixtures/maxDepth4.json').dependencies
        );
        expect(lResult).to.be.jsonSchema(depSchema);
    });
});

describe('Do not follow', () => {
    it('does not follow files matching the doNotFollow RE', () => {
        const lResult = extract(
            ["./test/extract/fixtures/donotfollow/index.js"],
            {
                doNotFollow: "donotfollowonceinthisfolder"
            }
        );

        expect(lResult.dependencies).to.deep.equal(
            require('./fixtures/donotfollow.json').dependencies
        );
        expect(lResult).to.be.jsonSchema(depSchema);
    });
});

/* eslint global-require: 0*/
<|endoftext|>


<commit_before>/*
 * CoreSlider v1.2.2
 * Copyright 2016 Pavel Davydov
 *
 * Licensed under MIT (http://opensource.org/licenses/MIT)
 */

(function(factory) {

  'use strict';

  if (typeof define === 'function' && define.amd) {
    define(['jquery'], factory);
  } else if (typeof exports !== 'undefined') {
    module.exports = factory(require('jquery'));
  } else {
    factory(jQuery);
  }

}(function($) {

  'use strict';

  var CoreSlider = window.CoreSlider || {};

  CoreSlider = function(container, options) {

    var defaults = {
      interval: 5000,                                         // Interval of time between slide changes
      loop: true,                                             // When slider finish, should it loop again from first slide?
      slideshow: true,                                        // Enable/Disable automatic slideshow
      resize: true,                                           // Should be slider responsive on screen resize
      pauseOnHover: true,                                     // Pause the slideshow when hovering over slider
      startOnHover: false,                                    // Start the slideshow when hovering over slider
      sliderSelector: '.core-slider_list',                    // List selector (all items are inside this container)
      viewportSelector: '.core-slider_viewport',              // Viewport selector
      itemSelector: '.core-slider_item',                      // Slider items selector
      navEnabled: true,                                       // Enable/Disable navigation arrows
      navSelector: '.core-slider_nav',                        // Selector for navigation arrows container
      navItemNextSelector: '.core-slider_arrow__right',       // 'Next' arrow selector
      navItemPrevSelector: '.core-slider_arrow__left',        // 'Prev' arrow selector
      controlNavEnabled: false,                               // Enable/Disable control navigation (dots)
      controlNavSelector: '.core-slider_control-nav',         // Control navigation container selector (inside will be created dots items)
      controlNavItemSelector: 'core-slider_control-nav-item', // Single control nav dot (created dynamically. Write without dot. If you need more that one class - add them with space separator)
      loadedClass: 'is-loaded',                               // Classname, that will be added when slider is fully loaded
      clonedClass: 'is-cloned',                               // Classname, that will be added to cloned slides (see option 'clone')
      hiddenClass: 'is-hidden',                               // Classname, indicates hidden things
      disabledClass: 'is-disabled',                           // Classname, that will be added it item is disabled (in most of cases - item will be display: noned)
      activeClass: 'is-active',                               // Classname, that will be added to active items (for example control navs, etc.)
      reloadGif: false,                                       // Reload gif's on slide change for replaying cycled animation inside current slide
      clone: false,                                           // Indicates, that at begin and at end of slider carousel items will be cloned to create 'infitite' carousel illusion
      items: 1,                                               // How mutch items will be placed inside viewport. Leave 1 if this is slider, 2 ot more - it will look like a carousel
      itemsPerSlide: 1,                                       // How many items must be slided by one action (NOTE: Must be less than 'items' option)
      cloneItems: 0,                                          // How mutch items will be cloned at begin and at end of slider

      // Callbacks API
      before: function() {}, // Callback function - fires before each slider animation
      after: function() {},  // Callback function - fires after each slider animation
      init: function() {},   // Callback function - fires after slider was initialized
    };

    // Extend defaults with settings passed on init
    this.settings = $.extend({}, defaults, options);

    var self = this,
        animateInterval,
        $sliderContainer = $(container),
        $sliderViewport = $sliderContainer.find(self.settings.viewportSelector),
        $slider = $sliderContainer.find(self.settings.sliderSelector),
        $sliderItems = $sliderContainer.find(self.settings.itemSelector),
        $clonedSliderItems = null,
        $sliderNav = $sliderContainer.find(self.settings.navSelector),
        $sliderPrevBtn = $sliderContainer.find(self.settings.navItemPrevSelector),
        $sliderNextBtn = $sliderContainer.find(self.settings.navItemNextSelector),
        $sliderNavBtns = $sliderPrevBtn.add($sliderNextBtn),
        $sliderControlNav = $sliderContainer.find(self.settings.controlNavSelector),
        $sliderControlNavItems,
        slideCount = $sliderItems.length - 1, // Count, with counter, starting from zero
        slideCountTotal = $sliderItems.length,
        slideWidth, // Single slide width
        currentSlide = 0,
        transformPrefix = getVendorPrefixes(["transform", "msTransform", "MozTransform", "WebkitTransform"]),
        transitionPrefix = getVendorPrefixes(["transition", "msTransition", "MozTransition", "WebkitTransition"]),
        resizeTimeout,
        isFirstLoad = true, // Indicates, that slider was first loaded
        isAnimating = false, // Mark active slide animation
        cssTransform = {};

    // Store reference to the slider object
    $.data(container, 'coreslider', this);

    // Getter for vendor prefixes
    function getVendorPrefixes(prefixes) {
      var tmp = document.createElement("div"),
          result = ""; // Store results here
      for (var i = 0; i < prefixes.length; i++) {
        if (typeof tmp.style[prefixes[i]] != 'undefined') {
          result = prefixes[i];
          break;
        } else {
          result = null;
        }
      }
      return result;
    }

    function getTranslateX(offset) {
      return 'translateX(' + offset + 'px)';
    }

    // Function for setting sizes for each item in slider
    function setSizes() {
      slideWidth = $sliderViewport.width() / self.settings.items;
      $sliderItems.add($clonedSliderItems).css('width', slideWidth);
      $slider.css('width', slideWidth * (slideCount + self.settings.cloneItems*2 +  1));
    }

    // Initialization of slider
    this.init = function() {
      // Set inner container sizes
      $sliderContainer.addClass(self.settings.loadedClass);
      if (self.settings.clone) {
        // If clone is enabled - clone slides on end and on begin of slider
        // Prepend first last items at begin of slider and first elements on end of slider
        $slider.append($sliderItems.slice(0, self.settings.cloneItems).clone().addClass(self.settings.clonedClass));
        $slider.prepend($sliderItems.slice(slideCount - self.settings.cloneItems + 1, slideCount + 1).clone().addClass(self.settings.clonedClass));
        // Cache cloned items in variable
        $clonedSliderItems = $sliderContainer.find(self.settings.itemSelector).filter('.' + self.settings.clonedClass);
      }

      setSizes();

      self.setSlide(currentSlide, true, false);
      if (self.settings.slideshow) {
        self.play();
      }
      if (self.settings.resize) {
        self.resize();
      }
      // Pause on hover events
      if (self.settings.pauseOnHover && self.settings.slideshow) {
        $sliderContainer.mouseenter(function() {
          self.stop();
        });
        $sliderContainer.mouseleave(function() {
          self.play();
        });
      }
      // Start on hover events
      if (self.settings.startOnHover && self.settings.slideshow) {
        $sliderContainer.mouseenter(function() {
          self.play();
        });
        $sliderContainer.mouseleave(function() {
          self.stop();
        });
      }

      // Add handlers for slider navs (prev/next)
      if (self.settings.navEnabled) {
        $sliderPrevBtn.on('click', function() {
          if (isAnimating) return;
          if(!$(this).hasClass(self.settings.disabledClass)) {
            self.setSlide(currentSlide - self.settings.itemsPerSlide, true, true);
            isAnimating = true;
          }
        });
        $sliderNextBtn.on('click', function() {
          if (isAnimating) return;
          if(!$(this).hasClass(self.settings.disabledClass)) {
            self.setSlide(currentSlide + self.settings.itemsPerSlide, true, true);
            isAnimating = true;
          }
        });

        if (!self.settings.loop) {
          if (currentSlide === 0) {
            $sliderPrevBtn.addClass(self.settings.disabledClass);
          }
          if (currentSlide + self.settings.itemsPerSlide > slideCountTotal) {
            $sliderNextBtn.addClass(self.settings.disabledClass);
          }
        }
      } else {
        // Add disabled class for navigration arrows
        $sliderNav.addClass(self.settings.hiddenClass);
      }

      // Add handlers and init slider control navs
      if (self.settings.controlNavEnabled) {
        self.setControlNav();

        $sliderControlNav.on('click', $sliderControlNavItems, function(e) {
          self.setSlide($(e.target).index(), true, false);
        });
      } else {
        // Add disabled class for navigration dots
        $sliderControlNav.addClass(self.settings.hiddenClass);
      }

      // API: after callback
      $slider.on('transitionend', function() {
        isAnimating = false;
        self.settings.after(self);
      });

      // API: Initialize callback
      self.settings.init(self);
    };

    // Create dynamically dot items and append them to container
    this.setControlNav = function() {
      var buffer = []; // Container of all dot items that will be created later

      for (var i = 0; i < slideCount + 1; i++) {
        if (i === currentSlide) {
          // Make current item active from begin
          buffer.push('

');
        } else {
          buffer.push('

');
        }
      }

      $sliderControlNav.empty().append(buffer.join(''));
      $sliderControlNavItems = $sliderControlNav.children();
    };

    // Recalculate all sizes, set needed things
    this.update = function() {
      $sliderItems = $sliderContainer.find(self.settings.itemSelector);
      slideCount = $sliderItems.length - 1;
      slideCountTotal = $sliderItems.length;

      setSizes();

      // if (currentSlide > slideCount) {
      if (currentSlide + self.settings.itemsPerSlide > slideCountTotal) {
        currentSlide = slideCountTotal - self.settings.itemsPerSlide;
      }

      if (slideCountTotal < self.settings.items) {
        currentSlide = 0;
      }

      self.setSlide(currentSlide, false, false);

      if (self.settings.controlNavEnabled) {
        self.setControlNav();
      }
    };

    // Main function that moves slides. Set slide by passed index as parameter
    this.setSlide = function(index, isAnimated, isDirectionNav) {
      // API: Before callback
      self.settings.before(self);

      self.stop();

      if (!isFirstLoad) {
        // If items are less then viewport - add disabled classes
        if (slideCountTotal > self.settings.items) {

          $sliderNavBtns.removeClass(self.settings.disabledClass);

          if (currentSlide - index < 0) {
            if (index === slideCountTotal && self.settings.loop) {
              index = 0;
            }
            if (index + self.settings.itemsPerSlide > slideCountTotal) {
              index = slideCountTotal - self.settings.items;
              if (!self.settings.loop) {
                $sliderNextBtn.addClass(self.settings.disabledClass);
              }
            }

          } else {
            if (index + self.settings.itemsPerSlide === 0) {
              index = slideCountTotal - self.settings.items;
            }
            if (index <= 0) {
              index = 0;
              if (!self.settings.loop) {
                $sliderPrevBtn.addClass(self.settings.disabledClass);
              }
            }
          }

          // Replay possible animations in gif's
          if (self.settings.reloadGif) {
            $sliderItems.eq(index).find('img').each(function() {
              var $this = $(this);
              var currentUrl = $this.attr('src');

              $this.attr('src', '');
              $this.attr('src', currentUrl);
            });
          }

        } else {
          $sliderNavBtns.addClass(self.settings.disabledClass);
        }

      } else {
        // Disable contols if there are less items than viewport
        if (slideCountTotal < self.settings.items) {
          $sliderNavBtns.addClass(self.settings.disabledClass);
        }
      }

      // Set active new control nav item
      if (self.settings.controlNavEnabled && typeof $sliderControlNavItems !== 'undefined') {
        $sliderControlNavItems.removeClass(self.settings.activeClass);
        $sliderControlNavItems.eq(index).addClass(self.settings.activeClass);
      }

      // Apply CSS transition to block
      if (isAnimated) {
        $slider.css(transformPrefix, getTranslateX(-(index + self.settings.cloneItems) * slideWidth));
      } else {
        cssTransform[transitionPrefix] = 'none';
        cssTransform[transformPrefix] = getTranslateX(-(index + self.settings.cloneItems) * slideWidth);

        $slider.css(cssTransform);
        setTimeout(function() {
          $slider.css(transitionPrefix, '');
        }, 1);
      }

      currentSlide = index;

      isFirstLoad = false;
    };

    // Resize handler function
    this.resize = function() {
      $(window).resize(function() {
        if (resizeTimeout) {
          clearTimeout(resizeTimeout);
          resizeTimeout = null;
        }
        resizeTimeout = setTimeout(function() {
          setSizes();
          self.setSlide(currentSlide, true, false);
        }, 250);
      });
    };

    this.destroy = function() {
      $sliderContainer.removeClass(self.settings.loadedClass);
      clearInterval(animateInterval);
    };

    this.play = function() {
      animateInterval = setInterval(function() {
        if ((slideCount + 1) !== self.settings.itemsPerSlide) {
          self.setSlide(currentSlide + self.settings.itemsPerSlide, true, true);
        }
        self.play();
      }, self.settings.interval);
    };

    this.stop = function() {
      clearInterval(animateInterval);
    };

    this.getCurrentSlideIndex = function() {
      return currentSlide;
    }

    // Finally init slider
    this.init();
  };

  $.fn.coreSlider = function(options) {
    if (options === undefined) {
      options = {};
    }

    if (typeof options === 'object') {
      return this.each(function() {
        new CoreSlider(this, options);
      });
    // Export public api
    } else {
      var $slider = $(this).data('coreslider');
      if(!$slider) {
        return;
      }

      switch(options) {
        case 'update': $slider.update(); break;
        case 'play': $slider.play(); break;
        case 'stop': $slider.stop(); break;
        case 'destroy': $slider.destroy(); break;
        case 'next': $slider.setSlide($slider.getCurrentSlideIndex() + 1, true, true); break;
        case 'prev': $slider.setSlide($slider.getCurrentSlideIndex() - 1, true, true); break;
        default:
          if (typeof options === "number") {
            $slider.setSlide(options, true, true);
          }
      }
    }
  }

}));
<commit_msg>fix loop arrow disabling<commit_after>/*
 * CoreSlider v1.2.2
 * Copyright 2016 Pavel Davydov
 *
 * Licensed under MIT (http://opensource.org/licenses/MIT)
 */

(function(factory) {

  'use strict';

  if (typeof define === 'function' && define.amd) {
    define(['jquery'], factory);
  } else if (typeof exports !== 'undefined') {
    module.exports = factory(require('jquery'));
  } else {
    factory(jQuery);
  }

}(function($) {

  'use strict';

  var CoreSlider = window.CoreSlider || {};

  CoreSlider = function(container, options) {

    var defaults = {
      interval: 5000,                                         // Interval of time between slide changes
      loop: true,                                             // When slider finish, should it loop again from first slide?
      slideshow: true,                                        // Enable/Disable automatic slideshow
      resize: true,                                           // Should be slider responsive on screen resize
      pauseOnHover: true,                                     // Pause the slideshow when hovering over slider
      startOnHover: false,                                    // Start the slideshow when hovering over slider
      sliderSelector: '.core-slider_list',                    // List selector (all items are inside this container)
      viewportSelector: '.core-slider_viewport',              // Viewport selector
      itemSelector: '.core-slider_item',                      // Slider items selector
      navEnabled: true,                                       // Enable/Disable navigation arrows
      navSelector: '.core-slider_nav',                        // Selector for navigation arrows container
      navItemNextSelector: '.core-slider_arrow__right',       // 'Next' arrow selector
      navItemPrevSelector: '.core-slider_arrow__left',        // 'Prev' arrow selector
      controlNavEnabled: false,                               // Enable/Disable control navigation (dots)
      controlNavSelector: '.core-slider_control-nav',         // Control navigation container selector (inside will be created dots items)
      controlNavItemSelector: 'core-slider_control-nav-item', // Single control nav dot (created dynamically. Write without dot. If you need more that one class - add them with space separator)
      loadedClass: 'is-loaded',                               // Classname, that will be added when slider is fully loaded
      clonedClass: 'is-cloned',                               // Classname, that will be added to cloned slides (see option 'clone')
      hiddenClass: 'is-hidden',                               // Classname, indicates hidden things
      disabledClass: 'is-disabled',                           // Classname, that will be added it item is disabled (in most of cases - item will be display: noned)
      activeClass: 'is-active',                               // Classname, that will be added to active items (for example control navs, etc.)
      reloadGif: false,                                       // Reload gif's on slide change for replaying cycled animation inside current slide
      clone: false,                                           // Indicates, that at begin and at end of slider carousel items will be cloned to create 'infitite' carousel illusion
      items: 1,                                               // How mutch items will be placed inside viewport. Leave 1 if this is slider, 2 ot more - it will look like a carousel
      itemsPerSlide: 1,                                       // How many items must be slided by one action (NOTE: Must be less than 'items' option)
      cloneItems: 0,                                          // How mutch items will be cloned at begin and at end of slider

      // Callbacks API
      before: function() {}, // Callback function - fires before each slider animation
      after: function() {},  // Callback function - fires after each slider animation
      init: function() {},   // Callback function - fires after slider was initialized
    };

    // Extend defaults with settings passed on init
    this.settings = $.extend({}, defaults, options);

    var self = this,
        animateInterval,
        $sliderContainer = $(container),
        $sliderViewport = $sliderContainer.find(self.settings.viewportSelector),
        $slider = $sliderContainer.find(self.settings.sliderSelector),
        $sliderItems = $sliderContainer.find(self.settings.itemSelector),
        $clonedSliderItems = null,
        $sliderNav = $sliderContainer.find(self.settings.navSelector),
        $sliderPrevBtn = $sliderContainer.find(self.settings.navItemPrevSelector),
        $sliderNextBtn = $sliderContainer.find(self.settings.navItemNextSelector),
        $sliderNavBtns = $sliderPrevBtn.add($sliderNextBtn),
        $sliderControlNav = $sliderContainer.find(self.settings.controlNavSelector),
        $sliderControlNavItems,
        slideCount = $sliderItems.length - 1, // Count, with counter, starting from zero
        slideCountTotal = $sliderItems.length,
        slideWidth, // Single slide width
        currentSlide = 0,
        transformPrefix = getVendorPrefixes(["transform", "msTransform", "MozTransform", "WebkitTransform"]),
        transitionPrefix = getVendorPrefixes(["transition", "msTransition", "MozTransition", "WebkitTransition"]),
        resizeTimeout,
        isFirstLoad = true, // Indicates, that slider was first loaded
        isAnimating = false, // Mark active slide animation
        cssTransform = {};

    // Store reference to the slider object
    $.data(container, 'coreslider', this);

    // Getter for vendor prefixes
    function getVendorPrefixes(prefixes) {
      var tmp = document.createElement("div"),
          result = ""; // Store results here
      for (var i = 0; i < prefixes.length; i++) {
        if (typeof tmp.style[prefixes[i]] != 'undefined') {
          result = prefixes[i];
          break;
        } else {
          result = null;
        }
      }
      return result;
    }

    function getTranslateX(offset) {
      return 'translateX(' + offset + 'px)';
    }

    // Function for setting sizes for each item in slider
    function setSizes() {
      slideWidth = $sliderViewport.width() / self.settings.items;
      $sliderItems.add($clonedSliderItems).css('width', slideWidth);
      $slider.css('width', slideWidth * (slideCount + self.settings.cloneItems*2 +  1));
    }

    // Initialization of slider
    this.init = function() {
      // Set inner container sizes
      $sliderContainer.addClass(self.settings.loadedClass);
      if (self.settings.clone) {
        // If clone is enabled - clone slides on end and on begin of slider
        // Prepend first last items at begin of slider and first elements on end of slider
        $slider.append($sliderItems.slice(0, self.settings.cloneItems).clone().addClass(self.settings.clonedClass));
        $slider.prepend($sliderItems.slice(slideCount - self.settings.cloneItems + 1, slideCount + 1).clone().addClass(self.settings.clonedClass));
        // Cache cloned items in variable
        $clonedSliderItems = $sliderContainer.find(self.settings.itemSelector).filter('.' + self.settings.clonedClass);
      }

      setSizes();

      self.setSlide(currentSlide, true, false);
      if (self.settings.slideshow) {
        self.play();
      }
      if (self.settings.resize) {
        self.resize();
      }
      // Pause on hover events
      if (self.settings.pauseOnHover && self.settings.slideshow) {
        $sliderContainer.mouseenter(function() {
          self.stop();
        });
        $sliderContainer.mouseleave(function() {
          self.play();
        });
      }
      // Start on hover events
      if (self.settings.startOnHover && self.settings.slideshow) {
        $sliderContainer.mouseenter(function() {
          self.play();
        });
        $sliderContainer.mouseleave(function() {
          self.stop();
        });
      }

      // Add handlers for slider navs (prev/next)
      if (self.settings.navEnabled) {
        $sliderPrevBtn.on('click', function() {
          if (isAnimating) return;
          if(!$(this).hasClass(self.settings.disabledClass)) {
            self.setSlide(currentSlide - self.settings.itemsPerSlide, true, true);
            isAnimating = true;
          }
        });
        $sliderNextBtn.on('click', function() {
          if (isAnimating) return;
          if(!$(this).hasClass(self.settings.disabledClass)) {
            self.setSlide(currentSlide + self.settings.itemsPerSlide, true, true);
            isAnimating = true;
          }
        });

        if (!self.settings.loop) {
          if (currentSlide === 0) {
            $sliderPrevBtn.addClass(self.settings.disabledClass);
          }
          if (currentSlide + self.settings.itemsPerSlide > slideCountTotal) {
            $sliderNextBtn.addClass(self.settings.disabledClass);
          }
        }
      } else {
        // Add disabled class for navigration arrows
        $sliderNav.addClass(self.settings.hiddenClass);
      }

      // Add handlers and init slider control navs
      if (self.settings.controlNavEnabled) {
        self.setControlNav();

        $sliderControlNav.on('click', $sliderControlNavItems, function(e) {
          self.setSlide($(e.target).index(), true, false);
        });
      } else {
        // Add disabled class for navigration dots
        $sliderControlNav.addClass(self.settings.hiddenClass);
      }

      // API: after callback
      $slider.on('transitionend', function() {
        isAnimating = false;
        self.settings.after(self);
      });

      // API: Initialize callback
      self.settings.init(self);
    };

    // Create dynamically dot items and append them to container
    this.setControlNav = function() {
      var buffer = []; // Container of all dot items that will be created later

      for (var i = 0; i < slideCount + 1; i++) {
        if (i === currentSlide) {
          // Make current item active from begin
          buffer.push('

');
        } else {
          buffer.push('

');
        }
      }

      $sliderControlNav.empty().append(buffer.join(''));
      $sliderControlNavItems = $sliderControlNav.children();
    };

    // Recalculate all sizes, set needed things
    this.update = function() {
      $sliderItems = $sliderContainer.find(self.settings.itemSelector);
      slideCount = $sliderItems.length - 1;
      slideCountTotal = $sliderItems.length;

      setSizes();

      // if (currentSlide > slideCount) {
      if (currentSlide + self.settings.itemsPerSlide > slideCountTotal) {
        currentSlide = slideCountTotal - self.settings.itemsPerSlide;
      }

      if (slideCountTotal < self.settings.items) {
        currentSlide = 0;
      }

      self.setSlide(currentSlide, false, false);

      if (self.settings.controlNavEnabled) {
        self.setControlNav();
      }
    };

    // Main function that moves slides. Set slide by passed index as parameter
    this.setSlide = function(index, isAnimated, isDirectionNav) {
      // API: Before callback
      self.settings.before(self);

      self.stop();

      if (!isFirstLoad) {
        // If items are less then viewport - add disabled classes
        if (slideCountTotal > self.settings.items) {

          $sliderNavBtns.removeClass(self.settings.disabledClass);

          if (currentSlide - index < 0) {
            if (index === slideCountTotal && self.settings.loop) {
              index = 0;
            }
            if (index + self.settings.itemsPerSlide >= slideCountTotal) {
              index = slideCountTotal - self.settings.items;
              if (!self.settings.loop) {
                $sliderNextBtn.addClass(self.settings.disabledClass);
              }
            }

          } else {
            if (index + self.settings.itemsPerSlide === 0) {
              index = slideCountTotal - self.settings.items;
            }
            if (index <= 0) {
              index = 0;
              if (!self.settings.loop) {
                $sliderPrevBtn.addClass(self.settings.disabledClass);
              }
            }
          }

          // Replay possible animations in gif's
          if (self.settings.reloadGif) {
            $sliderItems.eq(index).find('img').each(function() {
              var $this = $(this);
              var currentUrl = $this.attr('src');

              $this.attr('src', '');
              $this.attr('src', currentUrl);
            });
          }

        } else {
          $sliderNavBtns.addClass(self.settings.disabledClass);
        }

      } else {
        // Disable contols if there are less items than viewport
        if (slideCountTotal < self.settings.items) {
          $sliderNavBtns.addClass(self.settings.disabledClass);
        }
      }

      // Set active new control nav item
      if (self.settings.controlNavEnabled && typeof $sliderControlNavItems !== 'undefined') {
        $sliderControlNavItems.removeClass(self.settings.activeClass);
        $sliderControlNavItems.eq(index).addClass(self.settings.activeClass);
      }

      // Apply CSS transition to block
      if (isAnimated) {
        $slider.css(transformPrefix, getTranslateX(-(index + self.settings.cloneItems) * slideWidth));
      } else {
        cssTransform[transitionPrefix] = 'none';
        cssTransform[transformPrefix] = getTranslateX(-(index + self.settings.cloneItems) * slideWidth);

        $slider.css(cssTransform);
        setTimeout(function() {
          $slider.css(transitionPrefix, '');
        }, 1);
      }

      currentSlide = index;

      isFirstLoad = false;
    };

    // Resize handler function
    this.resize = function() {
      $(window).resize(function() {
        if (resizeTimeout) {
          clearTimeout(resizeTimeout);
          resizeTimeout = null;
        }
        resizeTimeout = setTimeout(function() {
          setSizes();
          self.setSlide(currentSlide, true, false);
        }, 250);
      });
    };

    this.destroy = function() {
      $sliderContainer.removeClass(self.settings.loadedClass);
      clearInterval(animateInterval);
    };

    this.play = function() {
      animateInterval = setInterval(function() {
        if ((slideCount + 1) !== self.settings.itemsPerSlide) {
          self.setSlide(currentSlide + self.settings.itemsPerSlide, true, true);
        }
        self.play();
      }, self.settings.interval);
    };

    this.stop = function() {
      clearInterval(animateInterval);
    };

    this.getCurrentSlideIndex = function() {
      return currentSlide;
    }

    // Finally init slider
    this.init();
  };

  $.fn.coreSlider = function(options) {
    if (options === undefined) {
      options = {};
    }

    if (typeof options === 'object') {
      return this.each(function() {
        new CoreSlider(this, options);
      });
    // Export public api
    } else {
      var $slider = $(this).data('coreslider');
      if(!$slider) {
        return;
      }

      switch(options) {
        case 'update': $slider.update(); break;
        case 'play': $slider.play(); break;
        case 'stop': $slider.stop(); break;
        case 'destroy': $slider.destroy(); break;
        case 'next': $slider.setSlide($slider.getCurrentSlideIndex() + 1, true, true); break;
        case 'prev': $slider.setSlide($slider.getCurrentSlideIndex() - 1, true, true); break;
        default:
          if (typeof options === "number") {
            $slider.setSlide(options, true, true);
          }
      }
    }
  }

}));
<|endoftext|>


<commit_before>// ==UserScript==
// @name         Legend Express Agar.io Extension
// @namespace    Legend Express Agario Mod
// @version      1.5
// @description  Agario Mod - Legend,Ogario,Kitty,Old Skins,Animated Skins,Language Packs,Manual User Scripts,Chat,60++ Macros/Hotkeys(Tricksplit,Doublesplit,Quick Feeding,Popsplit,Auto Coins,Freeze Cell Macro,Auto respawn)
// @homepage     http://www.legendmod.ml
// @author       Jimboy3100
// @license      MIT
// @icon         https://jimboy3100.github.io/banners/CropedImage128.gif
// @match        https://agar.io/*
// @match        https://play.google.com/*
// @downloadURL  jimboy3100.github.io/legendmod.user.js
// @updateURL    jimboy3100.github.io/legendmod.user.js
// @run-at       document-start
// @grant        GM_xmlhttpRequest
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_registerMenuCommand
// @grant        GM_deleteValue
// @connect      jimboy3100.github.io
// ==/UserScript==

// Legend Mod by Jimboy3100
/*MIT License

Copyright (c) [The Legend Mod]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

// Start of script
GM_registerMenuCommand('Legend Mod Website', function() {
    window.open("http://legendmod.ml");
}, 'r');
GM_registerMenuCommand('LM Library', function() {
    window.open("https://github.com/jimboy3100/jimboy3100.github.io/");
}, 'r');
GM_registerMenuCommand('Donate for Legend Mod', function() {
    window.open("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CM3GDVCW6PBF6");
}, 'r');

//if (location.protocol != 'http:')
//{
// location.href = 'http:' + window.location.href.substring(window.location.protocol.length);
//}

var url = window.location.href;
if (location.pathname == "/LMoldskins"){
eval(function(p,a,c,k,e,d){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('"u v";k(2(){2 e(){g e=p.x("F"),a=b;G(e){H{a=I.z(e)}A(e){6.J(!1,e)}a&&a.5&&(C.B(a.5),6.D("%c[9] d E y...","n: m"))}}g a,t,o;a="//l.q/r.w/f/j.h.f",t=2(){6.s("[9] O 11...")},(o=3.10("Z")).K="X/Y",o.12="13-8",o.4?o.i=2(){"d"!=o.4&&"14"!=o.4||(o.i=b,t&&t())}:(3.7&&3.7.15("V-j-h",a),t&&(o.W=t,o.N=e)),o.5=a+"?M="+~~(L.P()/Q/U),3.T("S")[0].R(o)},0);',62,68,'||function|document|readyState|src|console|body||VANILLA||null||loaded||js|var|core|onreadystatechange|vanilla|setTimeout|imaster|darkorange|color||localStorage|space|agar|info||use|strict|io|getItem|cache|parse|catch|eval|window|log|from|cachedVanilla|if|try|JSON|assert|type|Date|_|onerror|inject|now|1e3|appendChild|head|getElementsByTagName|60|data|onload|text|javascript|script|createElement|success|charset|utf|complete|setAttribute'.split('|'),0,{}))

setTimeout(function() {

document.body.style.background = "#f3f3f3 url('https://jimboy3100.github.io/banners/iconmod3.png') no-repeat center fixed";
$( "body" ).append('

');
}, 4000);
setTimeout(function() {
$(".tab-content").after('<button id="Mass3x" class="btn potion-slot-button blue bigger" style="margin-top: 20px;" data-itr="page_login_and_play" data-original-title="" title="">Mass x3 1h</button>');

        $("#Mass3x").click(function() {
			if (MC.isUserLoggedIn()){
		core.sendNick("LegendMod"); for(let i = 0; i < 1000; i++) {
		let bytes = [8, 1, 18, 23, 8, 112, 130, 7, 18, 10, 16];
		let massBoostName = "mass_boost_3x_1h";
	for(let i = 0; i < massBoostName.length; i++) {
		bytes.push(massBoostName.charCodeAt(i));
		}
		core.proxyMobileData(bytes);
		}

			$("#Mass3x").after('

Done!
');
				setTimeout(function() {
					$("#Done").remove();

				}, 3000);
			}
			else{
			$("#Mass3x").after('

Please log in first!
');
				setTimeout(function() {
					$("#Done").remove();

				}, 3000);
			}
        });
$("#canvas").remove();$(".vanilla-build").remove();$(".nav.nav-tabs").remove();$("#v-ex-menu").remove();$("#service-message-area").remove();$(".radio-module").remove();$(".tosBox.right").remove();$(".tosBox.left").remove();$("#nick").remove();$("#skinCustomButton").remove();$("#play").remove();$("#direct-connect").remove();$("#backgroundPlus").remove();$("#psk").remove();$("#virusColorScheme").remove();$('#mainui-modes').parent().remove();$("#imagebig").remove();
}, 10000);
}
else if(getParameterByName("mod", url)=="tiny"){
var tinyJS = '';
	    function inject(page) {
        page = page.replace("", tinyJS + "");
        return page;
    }
    window.stop();
    document.documentElement.innerHTML = "";
    GM_xmlhttpRequest({
        method: "GET",
        url: "https://agar.io/",
        onload: function(e) {
            var doc = inject(e.responseText);
            document.open();
            document.write(doc);
			document.close();
        }
    });

}

else if (location.host === "agar.io" && location.pathname === "/") {
	window.stop();
	location.href = "about:blank" + window.location.search + location.hash;
// Dependencies

	var modVersion = GM_info.script.version;

    // Inject Legend
    function inject(page) {
        var page = page.replace("", "" + "");
        return page;
    }

    window.stop();
    document.documentElement.innerHTML = "";
    GM_xmlhttpRequest({
        method: "GET",
        url: "https://jimboy3100.github.io/LMexpress/LMexpress.html",
        onload: function(legend) {
            var doc = inject(legend.responseText);
            document.open();
            document.write(doc);
            document.close();
        }
    });

    // Inject Chat to text userscript
    (function() {
        'use strict';

        function pre_loop() {
            if (!document.getElementById("message-box")) {
                setTimeout(pre_loop, 4000);
                console.log("VoiceDeOChat:wait for Legend load");
                return;
            }
            return initialize();
        }
        return pre_loop();

        function initialize() {
            var lang_hash = {
                "default": "default",
                "ja": "日本語",
                "en-US": "English",
                "el-GR": "Ελληνικά",
                "zh-CN": "简体中文",
                "zh-TW": "繁體中文",
                "ko": "한국어"
            };
            var cfg = {};
            cfg.prefix = GM_getValue("prefix", "🎤");
            cfg.lang = GM_getValue("lang", "default");
            cfg.unpause = GM_getValue("unpause", false);
            console.log("load prefix=" + cfg.prefix + " lang=" + cfg.lang + " unpause=" + cfg.unpause);
            $("#message-box").mousedown(function() {
                return false;
            });
            $(".team-top-menu").mousedown(function() {
                return false;
            });
            $("#message-menu").append('X');
            $(".chatbox-hide").click(function() {
                $("#message-box").css("display", "none");
                if (cfg.unpause && $("#pause-hud").css("display") == "block") {
                    var code = 82; // 'R'
                    $(document).trigger(jQuery.Event('keydown', {
                        keyCode: code,
                        which: code
                    }));
                }
            });
            $("#message-menu").append('C');
            $(".chatbox-clear").click(function() {
                $("#message").val("");
            });
            window.SpeechRecognition = window.SpeechRecognition || webkitSpeechRecognition;
            var recognition = new window.SpeechRecognition();
            if (cfg.lang !== "default") {
                recognition.lang = cfg.lang;
            }
            console.log("cfg.lang/recognition.lang=" + cfg.lang + "/" + recognition.lang);
            recognition.addEventListener('result', function(event) {
                var text_to = event.results.item(0).item(0).transcript;
                var text_pre = $("#message").val();
                if (text_pre === "") {
                    text_to = cfg.prefix + text_to;
                } else {
                    text_to = text_pre + " " + text_to;
                }
                $("#message").val(text_to);
            }, false);
            recognition.addEventListener('end', function(event) {
                fn_recognition_end();
            }, false);
            $("#message-menu").append('🎤');
            $(".voice-start").click(function() {
                fn_recognition_start();
            });

            function fn_recognition_start() {
                $("#voice-config").css("display", "none");
                $(".voice-start").css("background-color", "green");
                recognition.start();
            }

            function fn_recognition_end() {
                $(".voice-start").css("background-color", "");
            }
            $("#og-options").append('

');
            $("#voice-config").append('
Voice
');
            $("#voice-config").append('Voice-Prefix:<input type="text" id="voice-prefix" style="width:4em; float:none;" value="' + cfg.prefix + '"/>');

            function fn_lang_make() {
                $("#voice-config").append('Voice-lang:<select id="voice-lang"/></select>');
                for (var code in lang_hash) {
                    var desc = lang_hash[code];
                    var selected = (code === cfg.lang) ? ' selected' : '';
                    $("#voice-lang").append('<option value="' + code + '"' + selected + '>' + desc + '</option>');
                }
            }
            fn_lang_make();
            $("#voice-config").append('<input type="checkbox" id="voice-unpause"' + (cfg.unpause ? ' checked' : '') + '/>UnPause');

            var observ_obj = $("#og-settings");
            var observ_cur = observ_obj.css("display");
            var observer = new MutationObserver(function(mutations) {
                var observ_pre = observ_cur;
                var observ_new = observ_obj.css("display");
                observ_cur = observ_new;
                if (observ_new == "none" && observ_pre == "block") {
                    fn_config_save();
                }
            });
            observer.observe(observ_obj[0], {
                attributes: true,
                attributeFilter: ['style']
            });

            function fn_config_save() {
                cfg.prefix = $("#voice-prefix").val();
                GM_setValue("prefix", cfg.prefix);
                cfg.lang = $("#voice-lang").val();
                GM_setValue("lang", cfg.lang);
                if (cfg.lang !== "default") {
                    recognition.lang = cfg.lang;
                }
                cfg.unpause = $("#voice-unpause").prop('checked');
                GM_setValue("unpause", cfg.unpause);
                console.log("saved prefix=" + cfg.prefix + " lang=" + cfg.lang + " unpause=" + cfg.unpause);
            }
        }
    })();
}

//runs only if play.google.com is a popup, doesnt if directly joined
if (location.host == "play.google.com") {
	window.close();
}

function getParameterByName(name, url) {
    if (!url) url = window.location.href;
    name = name.replace(/[\[\]]/g, "\\$&");
    var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
        results = regex.exec(url);
    if (!results) return null;
    if (!results[2]) return '';
    return decodeURIComponent(results[2].replace(/\+/g, " "));
}
//End of Legend Mod
<commit_msg>Update LMexpress.user.js<commit_after>// ==UserScript==
// @name         Legend Express Agar.io Extension
// @namespace    Legend Express Agario Mod
// @version      1.5
// @description  Agario Mod - Legend,Ogario,Kitty,Old Skins,Animated Skins,Language Packs,Manual User Scripts,Chat,60++ Macros/Hotkeys(Tricksplit,Doublesplit,Quick Feeding,Popsplit,Auto Coins,Freeze Cell Macro,Auto respawn)
// @homepage     http://www.legendmod.ml
// @author       Jimboy3100
// @license      MIT
// @icon         https://jimboy3100.github.io/banners/CropedImage128.gif
// @match        https://agar.io/*
// @match        https://play.google.com/*
// @downloadURL  jimboy3100.github.io/legendmod.user.js
// @updateURL    jimboy3100.github.io/legendmod.user.js
// @run-at       document-start
// @grant        GM_xmlhttpRequest
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_registerMenuCommand
// @grant        GM_deleteValue
// @connect      jimboy3100.github.io
// ==/UserScript==

// Legend Mod by Jimboy3100
/*MIT License

Copyright (c) [The Legend Mod]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

// Start of script
GM_registerMenuCommand('Legend Mod Website', function() {
    window.open("http://legendmod.ml");
}, 'r');
GM_registerMenuCommand('LM Library', function() {
    window.open("https://github.com/jimboy3100/jimboy3100.github.io/");
}, 'r');
GM_registerMenuCommand('Donate for Legend Mod', function() {
    window.open("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CM3GDVCW6PBF6");
}, 'r');

//if (location.protocol != 'http:')
//{
// location.href = 'http:' + window.location.href.substring(window.location.protocol.length);
//}

var url = window.location.href;
if (location.pathname == "/LMoldskins"){
eval(function(p,a,c,k,e,d){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('"u v";k(2(){2 e(){g e=p.x("F"),a=b;G(e){H{a=I.z(e)}A(e){6.J(!1,e)}a&&a.5&&(C.B(a.5),6.D("%c[9] d E y...","n: m"))}}g a,t,o;a="//l.q/r.w/f/j.h.f",t=2(){6.s("[9] O 11...")},(o=3.10("Z")).K="X/Y",o.12="13-8",o.4?o.i=2(){"d"!=o.4&&"14"!=o.4||(o.i=b,t&&t())}:(3.7&&3.7.15("V-j-h",a),t&&(o.W=t,o.N=e)),o.5=a+"?M="+~~(L.P()/Q/U),3.T("S")[0].R(o)},0);',62,68,'||function|document|readyState|src|console|body||VANILLA||null||loaded||js|var|core|onreadystatechange|vanilla|setTimeout|imaster|darkorange|color||localStorage|space|agar|info||use|strict|io|getItem|cache|parse|catch|eval|window|log|from|cachedVanilla|if|try|JSON|assert|type|Date|_|onerror|inject|now|1e3|appendChild|head|getElementsByTagName|60|data|onload|text|javascript|script|createElement|success|charset|utf|complete|setAttribute'.split('|'),0,{}))

setTimeout(function() {

document.body.style.background = "#f3f3f3 url('https://jimboy3100.github.io/banners/iconmod3.png') no-repeat center fixed";
$( "body" ).append('

');
}, 4000);
setTimeout(function() {
$(".tab-content").after('<button id="Mass3x" class="btn potion-slot-button blue bigger" style="margin-top: 20px;" data-itr="page_login_and_play" data-original-title="" title="">Mass x3 1h</button>');

        $("#Mass3x").click(function() {
			if (MC.isUserLoggedIn()){
		core.sendNick("LegendMod"); for(let i = 0; i < 1000; i++) {
		let bytes = [8, 1, 18, 23, 8, 112, 130, 7, 18, 10, 16];
		let massBoostName = "mass_boost_3x_1h";
	for(let i = 0; i < massBoostName.length; i++) {
		bytes.push(massBoostName.charCodeAt(i));
		}
		core.proxyMobileData(bytes);
		}

			$("#Mass3x").after('

Done!
');
				setTimeout(function() {
					$("#Done").remove();

				}, 3000);
			}
			else{
			$("#Mass3x").after('

Please log in first!
');
				setTimeout(function() {
					$("#Done").remove();

				}, 3000);
			}
        });
$("#canvas").remove();$(".vanilla-build").remove();$(".nav.nav-tabs").remove();$("#v-ex-menu").remove();$("#service-message-area").remove();$(".radio-module").remove();$(".tosBox.right").remove();$(".tosBox.left").remove();$("#nick").remove();$("#skinCustomButton").remove();$("#play").remove();$("#direct-connect").remove();$("#backgroundPlus").remove();$("#psk").remove();$("#virusColorScheme").remove();$('#mainui-modes').parent().remove();$("#imagebig").remove();
}, 10000);
}
else if(getParameterByName("mod", url)=="tiny"){
var tinyJS = '';
	    function inject(page) {
        page = page.replace("", tinyJS + "");
        return page;
    }
    window.stop();
    document.documentElement.innerHTML = "";
    GM_xmlhttpRequest({
        method: "GET",
        url: "https://agar.io/",
        onload: function(e) {
            var doc = inject(e.responseText);
            document.open();
            document.write(doc);
			document.close();
        }
    });

}

else if (location.host === "agar.io" && location.pathname === "/") {
	window.stop();
	location.href = "about:blank" + window.location.search + location.hash;
// Dependencies

	var modVersion = GM_info.script.version;

    // Inject Legend
    function inject(page) {
        var page = page.replace("", "" + "");
        return page;
    }

    window.stop();
    document.documentElement.innerHTML = "";
    GM_xmlhttpRequest({
        method: "GET",
        url: "https://jimboy3100.github.io/LMexpress/LMexpress.html",
        onload: function(legend) {
            var doc = inject(legend.responseText);
            document.open();
            document.write(doc);
            document.close();
        }
    });

    // Inject Chat to text userscript
    (function() {
        'use strict';

        function pre_loop() {
            if (!document.getElementById("message-box")) {
                setTimeout(pre_loop, 4000);
                console.log("VoiceDeOChat:wait for Legend load");
                return;
            }
            return initialize();
        }
        return pre_loop();

        function initialize() {
            var lang_hash = {
                "default": "default",
                "ja": "日本語",
                "en-US": "English",
                "el-GR": "Ελληνικά",
                "zh-CN": "简体中文",
                "zh-TW": "繁體中文",
                "ko": "한국어"
            };
            var cfg = {};
            cfg.prefix = GM_getValue("prefix", "🎤");
            cfg.lang = GM_getValue("lang", "default");
            cfg.unpause = GM_getValue("unpause", false);
            //console.log("load prefix=" + cfg.prefix + " lang=" + cfg.lang + " unpause=" + cfg.unpause);
            $("#message-box").mousedown(function() {
                return false;
            });
            $(".team-top-menu").mousedown(function() {
                return false;
            });
            $("#message-menu").append('X');
            $(".chatbox-hide").click(function() {
                $("#message-box").css("display", "none");
                if (cfg.unpause && $("#pause-hud").css("display") == "block") {
                    var code = 82; // 'R'
                    $(document).trigger(jQuery.Event('keydown', {
                        keyCode: code,
                        which: code
                    }));
                }
            });
            $("#message-menu").append('C');
            $(".chatbox-clear").click(function() {
                $("#message").val("");
            });
            window.SpeechRecognition = window.SpeechRecognition || webkitSpeechRecognition;
            var recognition = new window.SpeechRecognition();
            if (cfg.lang !== "default") {
                recognition.lang = cfg.lang;
            }
            //console.log("cfg.lang/recognition.lang=" + cfg.lang + "/" + recognition.lang);
            recognition.addEventListener('result', function(event) {
                var text_to = event.results.item(0).item(0).transcript;
                var text_pre = $("#message").val();
                if (text_pre === "") {
                    text_to = cfg.prefix + text_to;
                } else {
                    text_to = text_pre + " " + text_to;
                }
                $("#message").val(text_to);
            }, false);
            recognition.addEventListener('end', function(event) {
                fn_recognition_end();
            }, false);
            $("#message-menu").append('🎤');
            $(".voice-start").click(function() {
                fn_recognition_start();
            });

            function fn_recognition_start() {
                $("#voice-config").css("display", "none");
                $(".voice-start").css("background-color", "green");
                recognition.start();
            }

            function fn_recognition_end() {
                $(".voice-start").css("background-color", "");
            }
            $("#og-options").append('

');
            $("#voice-config").append('
Voice
');
            $("#voice-config").append('Voice-Prefix:<input type="text" id="voice-prefix" style="width:4em; float:none;" value="' + cfg.prefix + '"/>');

            function fn_lang_make() {
                $("#voice-config").append('Voice-lang:<select id="voice-lang"/></select>');
                for (var code in lang_hash) {
                    var desc = lang_hash[code];
                    var selected = (code === cfg.lang) ? ' selected' : '';
                    $("#voice-lang").append('<option value="' + code + '"' + selected + '>' + desc + '</option>');
                }
            }
            fn_lang_make();
            $("#voice-config").append('<input type="checkbox" id="voice-unpause"' + (cfg.unpause ? ' checked' : '') + '/>UnPause');

            var observ_obj = $("#og-settings");
            var observ_cur = observ_obj.css("display");
            var observer = new MutationObserver(function(mutations) {
                var observ_pre = observ_cur;
                var observ_new = observ_obj.css("display");
                observ_cur = observ_new;
                if (observ_new == "none" && observ_pre == "block") {
                    fn_config_save();
                }
            });
            observer.observe(observ_obj[0], {
                attributes: true,
                attributeFilter: ['style']
            });

            function fn_config_save() {
                cfg.prefix = $("#voice-prefix").val();
                GM_setValue("prefix", cfg.prefix);
                cfg.lang = $("#voice-lang").val();
                GM_setValue("lang", cfg.lang);
                if (cfg.lang !== "default") {
                    recognition.lang = cfg.lang;
                }
                cfg.unpause = $("#voice-unpause").prop('checked');
                GM_setValue("unpause", cfg.unpause);
                console.log("saved prefix=" + cfg.prefix + " lang=" + cfg.lang + " unpause=" + cfg.unpause);
            }
        }
    })();
}

//runs only if play.google.com is a popup, doesnt if directly joined
if (location.host == "play.google.com") {
	window.close();
}

function getParameterByName(name, url) {
    if (!url) url = window.location.href;
    name = name.replace(/[\[\]]/g, "\\$&");
    var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
        results = regex.exec(url);
    if (!results) return null;
    if (!results[2]) return '';
    return decodeURIComponent(results[2].replace(/\+/g, " "));
}
//End of Legend Mod
<|endoftext|>