<commit_before>describe("JSInput", function() {
    beforeEach(function () {
        loadFixtures('js/capa/fixtures/jsinput.html');
    });

    it('sets all data-processed attributes to true on first load', function() {
        var sections = $(document).find('section[id="inputtype_"]');
        JSInput.walkDOM();
        sections.each(function(index, section) {
            expect(section.attr('data-processed')).toEqual('true');
        });
    });

    it('sets the data-processed attribute to true on subsequent load', function() {
        var section1 = $(document).find('section[id="inputtype_1"]'),
            section2 = $(document).find('section[id="inputtype_2"]');
        section1.attr('data-processed', false);
        JSInput.walkDOM();
        expect(section1.attr('data-processed')).toEqual('true');
        expect(section2.attr('data-processed')).toEqual('true');
    });

    it('sets the waitfor attribute to its update function', function() {
        var inputFields = $(document).find('input[id="input_"]');
        JSInput.walkDOM();
        inputFields.each(function(index, inputField) {
            expect(inputField.data('waitfor')).toBeDefined();
        });
    });

    it('tests the correct number of sections', function () {
        var sections = $(document).find('section[id="inputtype_"]');
        var inputFields = $(document).find('input[id="input_"]');
        expect(sections.length).toEqual(2);
        expect(sections.length).toEqual(inputFields.length);
    });
});

<commit_msg>Fix JSInput tests<commit_after>describe("JSInput", function () {
    var sections;
    var inputFields;

    beforeEach(function () {
        loadFixtures('js/capa/fixtures/jsinput.html');
        sections = $('section[id^="inputtype_"]');
        inputFields = $('input[id^="input_"]');
        JSInput.walkDOM();
    });

    it('sets all data-processed attributes to true on first load', function () {
        sections.each(function (index, item) {
            expect(item).toHaveData('processed', true);
        });
    });

    it('sets the data-processed attribute to true on subsequent load', function() {
        var section1 = $(this.sections[0]);
        var section2 = $(this.sections[1]);
        section1.attr('data-processed', false);
        JSInput.walkDOM();
        expect(section1.attr('data-processed')).toEqual('true');
        expect(section2.attr('data-processed')).toEqual('true');
    });

    it('sets the waitfor attribute to its update function', function () {
        inputFields.each(function (index, item) {
            expect(item).toHaveAttr('waitfor');
        });
    });

    it('tests the correct number of sections', function () {
        expect(sections.length).toEqual(2);
        expect(sections.length).toEqual(inputFields.length);
    });
});

<|endoftext|>


<commit_before>/**
 * Copyright (c) 2014-2015, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */

/**
 * This component operates as a "Controller-View".  It listens for changes in
 * the TodoStore and passes the new data to its children.
 */

var Footer = require('./Footer.react');
var Header = require('./Header.react');
var MainSection = require('./MainSection.react');
var React = require('react');
var TodoStore = require('../stores/TodoStore');

/**
 * Retrieve the current TODO data from the TodoStore
 */
function getTodoState() {
  return {
    allTodos: TodoStore.getAll(),
    areAllComplete: TodoStore.areAllComplete()
  };
}

var TodoApp = React.createClass({

  getInitialState: function() {
    return getTodoState();
  },

  componentDidMount: function() {
    TodoStore.addChangeListener(this._onChange);
  },

  componentWillUnmount: function() {
    TodoStore.removeChangeListener(this._onChange);
  },

  /**
   * @return {object}
   */
  render: function() {
  	return (

        <MainSection
          allTodos={this.state.allTodos}
          areAllComplete={this.state.areAllComplete}
        />

  	);
  },

  /**
   * Event handler for 'change' events coming from the TodoStore
   */
  _onChange: function() {
    this.setState(getTodoState());
  }

});

module.exports = TodoApp;
<commit_msg>Fix indent<commit_after>/**
 * Copyright (c) 2014-2015, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */

/**
 * This component operates as a "Controller-View".  It listens for changes in
 * the TodoStore and passes the new data to its children.
 */

var Footer = require('./Footer.react');
var Header = require('./Header.react');
var MainSection = require('./MainSection.react');
var React = require('react');
var TodoStore = require('../stores/TodoStore');

/**
 * Retrieve the current TODO data from the TodoStore
 */
function getTodoState() {
  return {
    allTodos: TodoStore.getAll(),
    areAllComplete: TodoStore.areAllComplete()
  };
}

var TodoApp = React.createClass({

  getInitialState: function() {
    return getTodoState();
  },

  componentDidMount: function() {
    TodoStore.addChangeListener(this._onChange);
  },

  componentWillUnmount: function() {
    TodoStore.removeChangeListener(this._onChange);
  },

  /**
   * @return {object}
   */
  render: function() {
    return (

        <MainSection
          allTodos={this.state.allTodos}
          areAllComplete={this.state.areAllComplete}
        />

    );
  },

  /**
   * Event handler for 'change' events coming from the TodoStore
   */
  _onChange: function() {
    this.setState(getTodoState());
  }

});

module.exports = TodoApp;
<|endoftext|>


<commit_before>import ShoppingListCache from '../cache/ShoppingListCache';

const CACHE_VERSION = 17;
const URLS_TO_CACHE = [
    '/',
    '/index.html',
    '/sw.js',
    '/manifest.json',
    '/style/fonts/roboto_100_italic_latin-ext.woff2',
    '/style/fonts/roboto_300_italic_latin-ext.woff2',
    '/style/fonts/roboto_400_italic_latin-ext.woff2',
    '/style/fonts/roboto_500_italic_latin-ext.woff2',
    '/style/fonts/roboto_700_italic_latin-ext.woff2',
    '/style/fonts/roboto_900_italic_latin-ext.woff2',
    '/style/fonts/roboto_100_italic_latin.woff2',
    '/style/fonts/roboto_300_italic_latin.woff2',
    '/style/fonts/roboto_400_italic_latin.woff2',
    '/style/fonts/roboto_500_italic_latin.woff2',
    '/style/fonts/roboto_700_italic_latin.woff2',
    '/style/fonts/roboto_900_italic_latin.woff2',
    '/style/fonts/roboto_100_normal_latin-ext.woff2',
    '/style/fonts/roboto_300_normal_latin-ext.woff2',
    '/style/fonts/roboto_400_normal_latin-ext.woff2',
    '/style/fonts/roboto_500_normal_latin-ext.woff2',
    '/style/fonts/roboto_700_normal_latin-ext.woff2',
    '/style/fonts/roboto_900_normal_latin-ext.woff2',
    '/style/fonts/roboto_100_normal_latin.woff2',
    '/style/fonts/roboto_300_normal_latin.woff2',
    '/style/fonts/roboto_400_normal_latin.woff2',
    '/style/fonts/roboto_500_normal_latin.woff2',
    '/style/fonts/roboto_700_normal_latin.woff2',
    '/style/fonts/roboto_900_normal_latin.woff2',
    '/templates/authentication/login/login.html',
    '/templates/navigation/navigation.html',
    '/templates/navigation/navMenu/navMenu.html',
    '/templates/navigation/leftSideNav/leftSideNav.html',
    '/templates/user/delete/userDelete.html',
    '/templates/user/edit/userData.html',
    '/templates/lists/list.html',
    '/templates/lists/lists.html',
    '/templates/lists/view/overview.html',
    '/templates/lists/view/view.html',
    '/templates/lists/view/emptyList.html',
    '/templates/lists/new/newList.html',
    '/templates/lists/edit/editList.html',
    '/templates/directives/loadingCycle.html',
    '/templates/authentication/register/register.html',
    '/templates/authentication/register/confirmation/confirmationNotification.html',
    '/templates/authentication/register/confirmation/confirmation.html',
    '/templates/item/new/newItem.html',
    '/templates/item/item.html',
    '/templates/article/article.html',
    '/templates/article/dictionary/dictionary.html',
    '/templates/article/dictionary/emptyDictionary.html',
    '/style/css/app-compact.css',
    '/js/ShoppingList.min.js',
    '/img/icons/action/ic_add_shopping_cart_24px.svg',
    '/img/icons/action/ic_lock_outline_24px.svg',
    '/img/icons/action/ic_shopping_cart_24px.svg',
    '/img/icons/action/ic_delete_24px.svg',
    '/img/icons/action/ic_settings_24px.svg',
    '/img/icons/action/ic_list_24px.svg',
    '/img/icons/action/ic_search_24px.svg',
    '/img/icons/action/ic_chrome_reader_mode_24px.svg',
    '/img/icons/communication/ic_email_24px.svg',
    '/img/icons/communication/ic_vpn_key_24px.svg',
    '/img/icons/communication/ic_clear_all_24px.svg',
    '/img/icons/content/ic_remove_circle_24px.svg',
    '/img/icons/content/ic_save_24px.svg',
    '/img/icons/hardware/ic_keyboard_arrow_left_24px.svg',
    '/img/icons/navigation/ic_menu_24px.svg',
    '/img/icons/navigation/ic_more_vert_24px.svg',
    '/img/icons/navigation/ic_refresh_24px.svg',
    '/img/icons/navigation/ic_close_24px.svg',
    '/img/icons/navigation/ic_arrow_back_24px.svg',
    '/img/icons/notification/ic_sync_24px.svg',
    '/img/icons/notification/ic_sync_disabled_24px.svg',
    '/img/icons/notification/ic_sync_problem_24px.svg',
    '/img/icons/social/ic_mood_bad_48px.svg',
    '/img/icons/social/ic_person_24px.svg',
    '/img/icons/social/ic_person_add_24px.svg',
    '/img/icons/Toggle/ic_check_box_24px.svg',
    '/img/icons/Toggle/ic_check_box_outline_blank_24px.svg'
];

const shoppingListCache = new ShoppingListCache(self, CACHE_VERSION, URLS_TO_CACHE);

shoppingListCache.initListeners();<commit_msg>Update Cache Version to 18<commit_after>import ShoppingListCache from '../cache/ShoppingListCache';

const CACHE_VERSION = 18;
const URLS_TO_CACHE = [
    '/',
    '/index.html',
    '/sw.js',
    '/manifest.json',
    '/style/fonts/roboto_100_italic_latin-ext.woff2',
    '/style/fonts/roboto_300_italic_latin-ext.woff2',
    '/style/fonts/roboto_400_italic_latin-ext.woff2',
    '/style/fonts/roboto_500_italic_latin-ext.woff2',
    '/style/fonts/roboto_700_italic_latin-ext.woff2',
    '/style/fonts/roboto_900_italic_latin-ext.woff2',
    '/style/fonts/roboto_100_italic_latin.woff2',
    '/style/fonts/roboto_300_italic_latin.woff2',
    '/style/fonts/roboto_400_italic_latin.woff2',
    '/style/fonts/roboto_500_italic_latin.woff2',
    '/style/fonts/roboto_700_italic_latin.woff2',
    '/style/fonts/roboto_900_italic_latin.woff2',
    '/style/fonts/roboto_100_normal_latin-ext.woff2',
    '/style/fonts/roboto_300_normal_latin-ext.woff2',
    '/style/fonts/roboto_400_normal_latin-ext.woff2',
    '/style/fonts/roboto_500_normal_latin-ext.woff2',
    '/style/fonts/roboto_700_normal_latin-ext.woff2',
    '/style/fonts/roboto_900_normal_latin-ext.woff2',
    '/style/fonts/roboto_100_normal_latin.woff2',
    '/style/fonts/roboto_300_normal_latin.woff2',
    '/style/fonts/roboto_400_normal_latin.woff2',
    '/style/fonts/roboto_500_normal_latin.woff2',
    '/style/fonts/roboto_700_normal_latin.woff2',
    '/style/fonts/roboto_900_normal_latin.woff2',
    '/templates/authentication/login/login.html',
    '/templates/navigation/navigation.html',
    '/templates/navigation/navMenu/navMenu.html',
    '/templates/navigation/leftSideNav/leftSideNav.html',
    '/templates/user/delete/userDelete.html',
    '/templates/user/edit/userData.html',
    '/templates/lists/list.html',
    '/templates/lists/lists.html',
    '/templates/lists/view/overview.html',
    '/templates/lists/view/view.html',
    '/templates/lists/view/emptyList.html',
    '/templates/lists/new/newList.html',
    '/templates/lists/edit/editList.html',
    '/templates/directives/loadingCycle.html',
    '/templates/authentication/register/register.html',
    '/templates/authentication/register/confirmation/confirmationNotification.html',
    '/templates/authentication/register/confirmation/confirmation.html',
    '/templates/item/new/newItem.html',
    '/templates/item/item.html',
    '/templates/article/article.html',
    '/templates/article/dictionary/dictionary.html',
    '/templates/article/dictionary/emptyDictionary.html',
    '/style/css/app-compact.css',
    '/js/ShoppingList.min.js',
    '/img/icons/action/ic_add_shopping_cart_24px.svg',
    '/img/icons/action/ic_lock_outline_24px.svg',
    '/img/icons/action/ic_shopping_cart_24px.svg',
    '/img/icons/action/ic_delete_24px.svg',
    '/img/icons/action/ic_settings_24px.svg',
    '/img/icons/action/ic_list_24px.svg',
    '/img/icons/action/ic_search_24px.svg',
    '/img/icons/action/ic_chrome_reader_mode_24px.svg',
    '/img/icons/communication/ic_email_24px.svg',
    '/img/icons/communication/ic_vpn_key_24px.svg',
    '/img/icons/communication/ic_clear_all_24px.svg',
    '/img/icons/content/ic_remove_circle_24px.svg',
    '/img/icons/content/ic_save_24px.svg',
    '/img/icons/hardware/ic_keyboard_arrow_left_24px.svg',
    '/img/icons/navigation/ic_menu_24px.svg',
    '/img/icons/navigation/ic_more_vert_24px.svg',
    '/img/icons/navigation/ic_refresh_24px.svg',
    '/img/icons/navigation/ic_close_24px.svg',
    '/img/icons/navigation/ic_arrow_back_24px.svg',
    '/img/icons/notification/ic_sync_24px.svg',
    '/img/icons/notification/ic_sync_disabled_24px.svg',
    '/img/icons/notification/ic_sync_problem_24px.svg',
    '/img/icons/social/ic_mood_bad_48px.svg',
    '/img/icons/social/ic_person_24px.svg',
    '/img/icons/social/ic_person_add_24px.svg',
    '/img/icons/Toggle/ic_check_box_24px.svg',
    '/img/icons/Toggle/ic_check_box_outline_blank_24px.svg'
];

const shoppingListCache = new ShoppingListCache(self, CACHE_VERSION, URLS_TO_CACHE);

shoppingListCache.initListeners();<|endoftext|>


<commit_before>const celsiusUnits = {
    metric: {
        label: '°C',
        convert: value => (value - 32) / 1.8,  // Convert to celsius
        convertTransfer: value => value / 1.8  // Convert difference to celsuis
    },
    imperial: {
        label: '°F',
        convert: value => value * 1.8 + 32,  // Convert to fahrenheit
        convertTransfer: value => value * 1.8 // Convert difference to fahrenheit
    }
}

const mmUnits = {
    metric: {
        label: 'mm',
        convert: value => value * 25.4 // Convert to millimeters
    },
    imperial: {
        label: 'in',
        convert: value => value / 25.4 // Convert to inches
    }
}

export const variables = [
    {
        name: 'MAT',
        label: 'Mean annual temperature',
        multiplier: 10,
        units: celsiusUnits
    },
    {
        name: 'MWMT',
        label: 'Mean warmest month temperature',
        multiplier: 10,
        units: celsiusUnits
    },
    {
        name: 'MCMT',
        label: 'Mean coldest month temperature',
        multiplier: 10,
        units: celsiusUnits
    },
    {
        name: 'TD',
        label: 'Temperature difference between MWMT and MCMT, or continentality',
        multiplier: 10,
        units: {
            metric: {
                label: '°C',
                convert: value => value / 1.8  // Convert temp difference to C
            },
            imperial: {
                label: '°F',
                convert: value => value * 1.8 // Convert temp difference to F
            }
        }
    },
    {
        name: 'MAP',
        label: 'Mean annual precipitation (mm)',
        multiplier: 1,
        units: mmUnits
    },
    {
        name: 'MSP',
        label: 'May to September precipitation (mm)',
        multiplier: 1,
        units: mmUnits
    },
    {
        name: 'AHM',
        label: 'Annual heatmoisture index',
        multiplier: 10,
        units: null
    },
    {
        name: 'SHM',
        label: 'Summer heatmoisture index',
        multiplier: 10,
        units: null
    },
    {
        name: 'DD_0',
        label: 'Degreedays below 0°C, chilling degreedays',
        multiplier: 1,
        units: null
    },
    {
        name: 'FFP',
        label: 'Frostfree period',
        multiplier: 1,
        units: null
    },
    {
        name: 'PAS',
        label: 'Precipitation as snow (mm) between August in previous year and July in current year',
        multiplier: 1,
        units: mmUnits
    },
    {
        name: 'EMT',
        label: 'Extreme minimum temperature over 30 years',
        multiplier: 10,
        units: celsiusUnits
    },
    {
        name: 'EXT',
        label: 'Extreme maximum temperature over 30 years',
        multiplier: 10,
        units: celsiusUnits
    },
    {
        name: 'Eref',
        label: 'Hargreaves reference evaporation (mm)',
        multiplier: 1,
        units: mmUnits
    },
    {
        name: 'CMD',
        label: 'Hargreaves climatic moisture deficit (mm)',
        multiplier: 1,
        units: mmUnits
    }
];

export const species = [
    {
        name: 'psme',
        label: 'Douglas-fir',
        transfers: {
            MAT: 20,
            MWMT: 20,
            MCMT: 20,
            TD: 20,
            EMT: 20,
            EXT: 20,
            MAP: 200,
            MSP: 50,
            FFP: 20,
            AHM: 30,
            SHM: 20
        }
    },
    {
        name: 'pico',
        label: 'Lodgepole pine',
        transfers: {
            MAT: 20,
            MWMT: 20,
            MCMT: 20,
            TD: 20,
            EMT: 20,
            EXT: 20,
            MAP: 200,
            MSP: 50,
            FFP: 20,
            AHM: 30,
            SHM: 20
        }
    },
    {
        name: 'pipo',
        label: 'Ponderosa pine',
        transfers: {
            MAT: 25,
            MWMT: 25,
            MCMT: 25,
            TD: 25,
            EMT: 25,
            EXT: 25,
            MAP: 200,
            MSP: 50,
            FFP: 30,
            AHM: 30,
            SHM: 20
        }
    },
    {
        name: 'thpl',
        label: 'Western red cedar',
        transfers: {
            MAT: 30,
            MWMT: 30,
            MCMT: 30,
            TD: 30,
            EMT: 30,
            EXT: 30,
            MAP: 200,
            MSP: 50,
            FFP: 50,
            AHM: 30,
            SHM: 20
        }
    },
    {
        name: 'pimo',
        label: 'Western white pine',
        transfers: {
            MAT: 30,
            MWMT: 30,
            MCMT: 30,
            TD: 30,
            EMT: 30,
            EXT: 30,
            MAP: 200,
            MSP: 50,
            FFP: 50,
            AHM: 30,
            SHM: 20
        }
    }
]
<commit_msg>Remove units from variable labels<commit_after>const celsiusUnits = {
    metric: {
        label: '°C',
        convert: value => (value - 32) / 1.8,  // Convert to celsius
        convertTransfer: value => value / 1.8  // Convert difference to celsuis
    },
    imperial: {
        label: '°F',
        convert: value => value * 1.8 + 32,  // Convert to fahrenheit
        convertTransfer: value => value * 1.8 // Convert difference to fahrenheit
    }
}

const mmUnits = {
    metric: {
        label: 'mm',
        convert: value => value * 25.4 // Convert to millimeters
    },
    imperial: {
        label: 'in',
        convert: value => value / 25.4 // Convert to inches
    }
}

export const variables = [
    {
        name: 'MAT',
        label: 'Mean annual temperature',
        multiplier: 10,
        units: celsiusUnits
    },
    {
        name: 'MWMT',
        label: 'Mean warmest month temperature',
        multiplier: 10,
        units: celsiusUnits
    },
    {
        name: 'MCMT',
        label: 'Mean coldest month temperature',
        multiplier: 10,
        units: celsiusUnits
    },
    {
        name: 'TD',
        label: 'Temperature difference between MWMT and MCMT, or continentality',
        multiplier: 10,
        units: {
            metric: {
                label: '°C',
                convert: value => value / 1.8  // Convert temp difference to C
            },
            imperial: {
                label: '°F',
                convert: value => value * 1.8 // Convert temp difference to F
            }
        }
    },
    {
        name: 'MAP',
        label: 'Mean annual precipitation',
        multiplier: 1,
        units: mmUnits
    },
    {
        name: 'MSP',
        label: 'May to September precipitation',
        multiplier: 1,
        units: mmUnits
    },
    {
        name: 'AHM',
        label: 'Annual heatmoisture index',
        multiplier: 10,
        units: null
    },
    {
        name: 'SHM',
        label: 'Summer heatmoisture index',
        multiplier: 10,
        units: null
    },
    {
        name: 'DD_0',
        label: 'Degreedays below 0°C, chilling degreedays',
        multiplier: 1,
        units: null
    },
    {
        name: 'FFP',
        label: 'Frostfree period',
        multiplier: 1,
        units: null
    },
    {
        name: 'PAS',
        label: 'Precipitation as snow (mm) between August in previous year and July in current year',
        multiplier: 1,
        units: mmUnits
    },
    {
        name: 'EMT',
        label: 'Extreme minimum temperature over 30 years',
        multiplier: 10,
        units: celsiusUnits
    },
    {
        name: 'EXT',
        label: 'Extreme maximum temperature over 30 years',
        multiplier: 10,
        units: celsiusUnits
    },
    {
        name: 'Eref',
        label: 'Hargreaves reference evaporation',
        multiplier: 1,
        units: mmUnits
    },
    {
        name: 'CMD',
        label: 'Hargreaves climatic moisture deficit',
        multiplier: 1,
        units: mmUnits
    }
];

export const species = [
    {
        name: 'psme',
        label: 'Douglas-fir',
        transfers: {
            MAT: 20,
            MWMT: 20,
            MCMT: 20,
            TD: 20,
            EMT: 20,
            EXT: 20,
            MAP: 200,
            MSP: 50,
            FFP: 20,
            AHM: 30,
            SHM: 20
        }
    },
    {
        name: 'pico',
        label: 'Lodgepole pine',
        transfers: {
            MAT: 20,
            MWMT: 20,
            MCMT: 20,
            TD: 20,
            EMT: 20,
            EXT: 20,
            MAP: 200,
            MSP: 50,
            FFP: 20,
            AHM: 30,
            SHM: 20
        }
    },
    {
        name: 'pipo',
        label: 'Ponderosa pine',
        transfers: {
            MAT: 25,
            MWMT: 25,
            MCMT: 25,
            TD: 25,
            EMT: 25,
            EXT: 25,
            MAP: 200,
            MSP: 50,
            FFP: 30,
            AHM: 30,
            SHM: 20
        }
    },
    {
        name: 'thpl',
        label: 'Western red cedar',
        transfers: {
            MAT: 30,
            MWMT: 30,
            MCMT: 30,
            TD: 30,
            EMT: 30,
            EXT: 30,
            MAP: 200,
            MSP: 50,
            FFP: 50,
            AHM: 30,
            SHM: 20
        }
    },
    {
        name: 'pimo',
        label: 'Western white pine',
        transfers: {
            MAT: 30,
            MWMT: 30,
            MCMT: 30,
            TD: 30,
            EMT: 30,
            EXT: 30,
            MAP: 200,
            MSP: 50,
            FFP: 50,
            AHM: 30,
            SHM: 20
        }
    }
]
<|endoftext|>


<commit_before>// Generated on 2014-08-29 using generator-angular 0.9.5
'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function (grunt) {

  // Load grunt tasks automatically
  require('load-grunt-tasks')(grunt);

  // Time how long tasks take. Can help when optimizing build times
  require('time-grunt')(grunt);

  // Configurable paths for the application
  var appConfig = {
    app: require('./bower.json').appPath || 'app',
    dist: 'src/main/webapp'
  };

  // Define the configuration for all the tasks
  grunt.initConfig({

    // Project settings
    yeoman: appConfig,

    // Watches files for changes and runs tasks based on the changed files
    watch: {
      bower: {
        files: ['bower.json'],
        tasks: ['wiredep']
      },
      js: {
        files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
        tasks: ['newer:jshint:all'],
        options: {
          livereload: '<%= connect.options.livereload %>'
        }
      },
      jsTest: {
        files: ['test/spec/{,*/}*.js'],
        tasks: ['newer:jshint:test', 'karma']
      },
      styles: {
        files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
        tasks: ['newer:copy:styles', 'autoprefixer']
      },
      gruntfile: {
        files: ['Gruntfile.js']
      },
      livereload: {
        options: {
          livereload: '<%= connect.options.livereload %>'
        },
        files: [
          '<%= yeoman.app %>/{,*/}*.html',
          '.tmp/styles/{,*/}*.css',
          '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
        ]
      }
    },

    // The actual grunt server settings
    connect: {
      options: {
        port: 9000,
        // Change this to '0.0.0.0' to access the server from outside.
        hostname: 'localhost',
        livereload: 35729
      },
      livereload: {
        options: {
          open: true,
          middleware: function (connect) {
            return [
              connect.static('.tmp'),
              connect().use(
                '/bower_components',
                connect.static('./bower_components')
              ),
              connect.static(appConfig.app)
            ];
          }
        }
      },
      test: {
        options: {
          port: 9001,
          middleware: function (connect) {
            return [
              connect.static('.tmp'),
              connect.static('test'),
              connect().use(
                '/bower_components',
                connect.static('./bower_components')
              ),
              connect.static(appConfig.app)
            ];
          }
        }
      },
      dist: {
        options: {
          open: true,
          base: '<%= yeoman.dist %>'
        }
      }
    },

    // Make sure code styles are up to par and there are no obvious mistakes
    jshint: {
      options: {
        jshintrc: '.jshintrc',
        reporter: require('jshint-stylish')
      },
      all: {
        src: [
          'Gruntfile.js',
          '<%= yeoman.app %>/scripts/{,*/}*.js'
        ]
      },
      test: {
        options: {
          jshintrc: 'test/.jshintrc'
        },
        src: ['test/spec/{,*/}*.js']
      }
    },

    // Empties folders to start fresh
    clean: {
      dist: {
        files: [{
          dot: true,
          src: [
            '.tmp',
            '<%= yeoman.dist %>/{,*/}*',
            '!<%= yeoman.dist %>/.git*'
          ]
        }]
      },
      server: '.tmp'
    },

    // Add vendor prefixed styles
    autoprefixer: {
      options: {
        browsers: ['last 1 version']
      },
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/styles/',
          src: '{,*/}*.css',
          dest: '.tmp/styles/'
        }]
      }
    },

    // Automatically inject Bower components into the app
    wiredep: {
      options: {
        cwd: '<%= yeoman.app %>'
      },
      app: {
        src: ['<%= yeoman.app %>/index.html'],
        ignorePath:  /\.\.\//
      }
    },

    // Renames files for browser caching purposes
    filerev: {
      dist: {
        src: [
          '<%= yeoman.dist %>/scripts/{,*/}*.js',
          '<%= yeoman.dist %>/styles/*.css',
          '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
          '<%= yeoman.dist %>/styles/fonts/*'
        ]
      }
    },

    // Reads HTML for usemin blocks to enable smart builds that automatically
    // concat, minify and revision files. Creates configurations in memory so
    // additional tasks can operate on them
    useminPrepare: {
      html: '<%= yeoman.app %>/index.html',
      options: {
        dest: '<%= yeoman.dist %>',
        flow: {
          html: {
            steps: {
              js: ['concat', 'uglifyjs'],
              css: ['cssmin']
            },
            post: {}
          }
        }
      }
    },

    // Performs rewrites based on filerev and the useminPrepare configuration
    usemin: {
      html: ['<%= yeoman.dist %>/{,*/}*.html'],
      css: ['<%= yeoman.dist %>/styles/*.css'],
      options: {
        assetsDirs: ['<%= yeoman.dist %>','<%= yeoman.dist %>/images']
      }
    },

    // The following *-min tasks will produce minified files in the dist folder
    // By default, your `index.html`'s <!-- Usemin block --> will take care of
    // minification. These next options are pre-configured if you do not wish
    // to use the Usemin blocks.
    // cssmin: {
    //   dist: {
    //     files: {
    //       '<%= yeoman.dist %>/styles/main.css': [
    //         '.tmp/styles/{,*/}*.css'
    //       ]
    //     }
    //   }
    // },
    // uglify: {
    //   dist: {
    //     files: {
    //       '<%= yeoman.dist %>/scripts/scripts.js': [
    //         '<%= yeoman.dist %>/scripts/scripts.js'
    //       ]
    //     }
    //   }
    // },
    // concat: {
    //   dist: {}
    // },

    imagemin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.{png,jpg,jpeg,gif}',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },

    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.svg',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },

    htmlmin: {
      dist: {
        options: {
          collapseWhitespace: true,
          conservativeCollapse: true,
          collapseBooleanAttributes: true,
          removeCommentsFromCDATA: true,
          removeOptionalTags: true
        },
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>',
          src: ['*.html', 'views/{,*/}*.html'],
          dest: '<%= yeoman.dist %>'
        }]
      }
    },

    // ngmin tries to make the code safe for minification automatically by
    // using the Angular long form for dependency injection. It doesn't work on
    // things like resolve or inject so those have to be done manually.
    ngmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/concat/scripts',
          src: '*.js',
          dest: '.tmp/concat/scripts'
        }]
      }
    },

    // Replace Google CDN references
    cdnify: {
      dist: {
        html: ['<%= yeoman.dist %>/*.html']
      }
    },

    // Copies remaining files to places other tasks can use
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>',
          dest: '<%= yeoman.dist %>',
          src: [
            '*.{ico,png,txt}',
            '.htaccess',
            '*.html',
            'views/{,*/}*.html',
            'images/{,*/}*.{webp}',
            'fonts/*',
            'WEB-INF/*',
            'scripts/ace/{,*/}/{,*/}/*'
          ]
        }, {
          expand : true,
          dot : true,
          cwd: '<%= yeoman.app %>',
          dest: '<%= yeoman.dist %>',
          src: ['styles/looknfeel/*']
        }, {
          expand: true,
          cwd: '.tmp/images',
          dest: '<%= yeoman.dist %>/images',
          src: ['generated/*']
        }, {
          expand: true,
          cwd: 'bower_components/bootstrap/dist',
          src: 'fonts/*',
          dest: '<%= yeoman.dist %>'
        }]
      },
      styles: {
        expand: true,
        cwd: '<%= yeoman.app %>/styles',
        dest: '.tmp/styles/',
        src: '{,*/}*.css'
      }
    },

    // Run some tasks in parallel to speed up the build process
    concurrent: {
      server: [
        'copy:styles'
      ],
      test: [
        'copy:styles'
      ],
      dist: [
        'copy:styles',
        'imagemin',
        'svgmin'
      ]
    },

    // Test settings
    karma: {
      unit: {
        configFile: 'test/karma.conf.js',
        singleRun: true
      }
    }
  });

  grunt.registerTask('serve', 'Compile then start a connect web server', function (target) {
    if (target === 'dist') {
      return grunt.task.run(['build', 'connect:dist:keepalive']);
    }

    grunt.task.run([
      'clean:server',
      'wiredep',
      'concurrent:server',
      'autoprefixer',
      'connect:livereload',
      'watch'
    ]);
  });

  grunt.registerTask('server', 'DEPRECATED TASK. Use the "serve" task instead', function (target) {
    grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
    grunt.task.run(['serve:' + target]);
  });

  grunt.registerTask('test', [
    'clean:server',
    'concurrent:test',
    'autoprefixer',
    'connect:test',
    'karma'
  ]);

  grunt.registerTask('build', [
    'clean:dist',
    'wiredep',
    'useminPrepare',
    'concurrent:dist',
    'autoprefixer',
    'concat',
    'ngmin',
    'copy:dist',
    'cdnify',
    'cssmin',
    'uglify',
    'filerev',
    'usemin',
    'htmlmin'
  ]);

  grunt.registerTask('default', [
    'newer:jshint',
    'test',
    'build'
  ]);
};
<commit_msg>Modify Grunt to handle jquery-ui - and remove renaming of images for cache<commit_after>// Generated on 2014-08-29 using generator-angular 0.9.5
'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function (grunt) {

  // Load grunt tasks automatically
  require('load-grunt-tasks')(grunt);

  // Time how long tasks take. Can help when optimizing build times
  require('time-grunt')(grunt);

  // Configurable paths for the application
  var appConfig = {
    app: require('./bower.json').appPath || 'app',
    dist: 'src/main/webapp'
  };

  // Define the configuration for all the tasks
  grunt.initConfig({

    // Project settings
    yeoman: appConfig,

    // Watches files for changes and runs tasks based on the changed files
    watch: {
      bower: {
        files: ['bower.json'],
        tasks: ['wiredep']
      },
      js: {
        files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
        tasks: ['newer:jshint:all'],
        options: {
          livereload: '<%= connect.options.livereload %>'
        }
      },
      jsTest: {
        files: ['test/spec/{,*/}*.js'],
        tasks: ['newer:jshint:test', 'karma']
      },
      styles: {
        files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
        tasks: ['newer:copy:styles', 'autoprefixer']
      },
      gruntfile: {
        files: ['Gruntfile.js']
      },
      livereload: {
        options: {
          livereload: '<%= connect.options.livereload %>'
        },
        files: [
          '<%= yeoman.app %>/{,*/}*.html',
          '.tmp/styles/{,*/}*.css',
          '<%= yeoman.app %>/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
        ]
      }
    },

    // The actual grunt server settings
    connect: {
      options: {
        port: 9000,
        // Change this to '0.0.0.0' to access the server from outside.
        hostname: 'localhost',
        livereload: 35729
      },
      livereload: {
        options: {
          open: true,
          middleware: function (connect) {
            return [
              connect.static('.tmp'),
              connect().use(
                '/bower_components',
                connect.static('./bower_components')
              ),
              connect.static(appConfig.app)
            ];
          }
        }
      },
      test: {
        options: {
          port: 9001,
          middleware: function (connect) {
            return [
              connect.static('.tmp'),
              connect.static('test'),
              connect().use(
                '/bower_components',
                connect.static('./bower_components')
              ),
              connect.static(appConfig.app)
            ];
          }
        }
      },
      dist: {
        options: {
          open: true,
          base: '<%= yeoman.dist %>'
        }
      }
    },

    // Make sure code styles are up to par and there are no obvious mistakes
    jshint: {
      options: {
        jshintrc: '.jshintrc',
        reporter: require('jshint-stylish')
      },
      all: {
        src: [
          'Gruntfile.js',
          '<%= yeoman.app %>/scripts/{,*/}*.js'
        ]
      },
      test: {
        options: {
          jshintrc: 'test/.jshintrc'
        },
        src: ['test/spec/{,*/}*.js']
      }
    },

    // Empties folders to start fresh
    clean: {
      dist: {
        files: [{
          dot: true,
          src: [
            '.tmp',
            '<%= yeoman.dist %>/{,*/}*',
            '!<%= yeoman.dist %>/.git*'
          ]
        }]
      },
      server: '.tmp'
    },

    // Add vendor prefixed styles
    autoprefixer: {
      options: {
        browsers: ['last 1 version']
      },
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/styles/',
          src: '{,*/}*.css',
          dest: '.tmp/styles/'
        }]
      }
    },

    // Automatically inject Bower components into the app
    wiredep: {
      options: {
        cwd: '<%= yeoman.app %>'
      },
      app: {
        src: ['<%= yeoman.app %>/index.html'],
        ignorePath:  /\.\.\//
      }
    },

    // Renames files for browser caching purposes
    filerev: {
      dist: {
        src: [
          '<%= yeoman.dist %>/scripts/{,*/}*.js',
          '<%= yeoman.dist %>/styles/*.css',
          '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
          '<%= yeoman.dist %>/styles/fonts/*'
        ]
      }
    },

    // Reads HTML for usemin blocks to enable smart builds that automatically
    // concat, minify and revision files. Creates configurations in memory so
    // additional tasks can operate on them
    useminPrepare: {
      html: '<%= yeoman.app %>/index.html',
      options: {
        dest: '<%= yeoman.dist %>',
        flow: {
          html: {
            steps: {
              js: ['concat', 'uglifyjs'],
              css: ['cssmin']
            },
            post: {}
          }
        }
      }
    },

    // Performs rewrites based on filerev and the useminPrepare configuration
    usemin: {
      html: ['<%= yeoman.dist %>/{,*/}*.html'],
      css: ['<%= yeoman.dist %>/styles/*.css'],
      options: {
        assetsDirs: ['<%= yeoman.dist %>','<%= yeoman.dist %>/images']
      }
    },

    // The following *-min tasks will produce minified files in the dist folder
    // By default, your `index.html`'s <!-- Usemin block --> will take care of
    // minification. These next options are pre-configured if you do not wish
    // to use the Usemin blocks.
    // cssmin: {
    //   dist: {
    //     files: {
    //       '<%= yeoman.dist %>/styles/main.css': [
    //         '.tmp/styles/{,*/}*.css'
    //       ]
    //     }
    //   }
    // },
    // uglify: {
    //   dist: {
    //     files: {
    //       '<%= yeoman.dist %>/scripts/scripts.js': [
    //         '<%= yeoman.dist %>/scripts/scripts.js'
    //       ]
    //     }
    //   }
    // },
    // concat: {
    //   dist: {}
    // },

    imagemin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.{png,jpg,jpeg,gif}',
          dest: '<%= yeoman.dist %>/images'
        }]
      },
      jqueryui: {
        files: [{
          expand: true,
          cwd: 'bower_components/jquery-ui/themes/base/images',
          src: '{,*/}*.{png,jpg,jpeg,gif}',
          dest: '<%= yeoman.dist %>/styles/images'
        }]
      }
    },

    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.svg',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },

    htmlmin: {
      dist: {
        options: {
          collapseWhitespace: true,
          conservativeCollapse: true,
          collapseBooleanAttributes: true,
          removeCommentsFromCDATA: true,
          removeOptionalTags: true
        },
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>',
          src: ['*.html', 'views/{,*/}*.html'],
          dest: '<%= yeoman.dist %>'
        }]
      }
    },

    // ngmin tries to make the code safe for minification automatically by
    // using the Angular long form for dependency injection. It doesn't work on
    // things like resolve or inject so those have to be done manually.
    ngmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/concat/scripts',
          src: '*.js',
          dest: '.tmp/concat/scripts'
        }]
      }
    },

    // Replace Google CDN references
    cdnify: {
      dist: {
        html: ['<%= yeoman.dist %>/*.html']
      }
    },

    // Copies remaining files to places other tasks can use
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>',
          dest: '<%= yeoman.dist %>',
          src: [
            '*.{ico,png,txt}',
            '.htaccess',
            '*.html',
            'views/{,*/}*.html',
            'images/{,*/}*.{webp}',
            'fonts/*',
            'WEB-INF/*',
            'scripts/ace/{,*/}/{,*/}/*'
          ]
        }, {
          expand : true,
          dot : true,
          cwd: '<%= yeoman.app %>',
          dest: '<%= yeoman.dist %>',
          src: ['styles/looknfeel/*']
        }, {
          expand: true,
          cwd: '.tmp/images',
          dest: '<%= yeoman.dist %>/images',
          src: ['generated/*']
        }, {
          expand: true,
          cwd: 'bower_components/bootstrap/dist',
          src: 'fonts/*',
          dest: '<%= yeoman.dist %>'
        }]
      },
      styles: {
        expand: true,
        cwd: '<%= yeoman.app %>/styles',
        dest: '.tmp/styles/',
        src: '{,*/}*.css'
      }
    },

    // Run some tasks in parallel to speed up the build process
    concurrent: {
      server: [
        'copy:styles'
      ],
      test: [
        'copy:styles'
      ],
      dist: [
        'copy:styles',
        'imagemin',
        'imagemin:jqueryui',
        'svgmin'
      ]
    },

    // Test settings
    karma: {
      unit: {
        configFile: 'test/karma.conf.js',
        singleRun: true
      }
    }
  });

  grunt.registerTask('serve', 'Compile then start a connect web server', function (target) {
    if (target === 'dist') {
      return grunt.task.run(['build', 'connect:dist:keepalive']);
    }

    grunt.task.run([
      'clean:server',
      'wiredep',
      'concurrent:server',
      'autoprefixer',
      'connect:livereload',
      /*'newer:jshint'*/
      'watch'
    ]);
  });

  grunt.registerTask('server', 'DEPRECATED TASK. Use the "serve" task instead', function (target) {
    grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
    grunt.task.run(['serve:' + target]);
  });

  grunt.registerTask('test', [
    'clean:server',
    'concurrent:test',
    'autoprefixer',
    'connect:test',
    'karma'
  ]);

  grunt.registerTask('build', [
    'clean:dist',
    'wiredep',
    'useminPrepare',
    'concurrent:dist',
    'autoprefixer',
    'concat',
    'ngmin',
    'copy:dist',
    'cdnify',
    'cssmin',
    'uglify',
    /*'filerev',*/
    'usemin',
    'htmlmin'
  ]);

  grunt.registerTask('default', [
    'newer:jshint',
    'test',
    'build'
  ]);
};
<|endoftext|>


<commit_before>let Promise = require('bluebird')

let redisRepository = require('../Repositories/RedisRepository')

let fileService     = require('./FileService')
let errorMsgService = require('./ErrorMsgService')

let extension = '.csv'
let folder    = './userProject/'

let getOverAllSimulation = function (token, id) {
  return new Promise((resolve, reject) => {
    redisRepository.getAccountId(token).then(accountId => {
      let path = folder + accountId + '/' + id  + '/result/'
      return fileService.readFile(path + 'overallSimPar' + extension)
    }).then(result => {
      resolve(result)
    }).catch(error => {
      if (error === 'token expired') {
        reject(errorMsgService.tokenExpired)
      } else if (error === 'file error') {
        reject(errorMsgService.fsError)
      } else {
        reject(errorMsgService.serverError)
      }
    })
  })
}

let getOverAllTheory = function (token, id) {
  return new Promise((resolve, reject) => {
    redisRepository.getAccountId(token).then(accountId => {
      let path = folder + accountId + '/' + id  + '/result/'
      return fileService.readFile(path + 'overallTheoryPar' + extension)
    }).then(result => {
      resolve(result)
    }).catch(error => {
      if (error === 'token expired') {
        reject(errorMsgService.tokenExpired)
      } else if (error === 'file error') {
        reject(errorMsgService.fsError)
      } else {
        reject(errorMsgService.serverError)
      }
    })
  })
}

let getBaseGameSimulation = function (token, id) {
  return new Promise((resolve, reject) => {
    redisRepository.getAccountId(token).then(accountId => {
      let path = folder + accountId + '/' + id  + '/result/'
      return fileService.readFile(path + 'baseSimPar' + extension)
    }).then(result => {
      resolve(result)
    }).catch(error => {
      if (error === 'token expired') {
        reject(errorMsgService.tokenExpired)
      } else if (error === 'file error') {
        reject(errorMsgService.fsError)
      } else {
        reject(errorMsgService.serverError)
      }
    })
  })
}

let getBaseGameTheory = function (token, id) {
  return new Promise((resolve, reject) => {
    redisRepository.getAccountId(token).then(accountId => {
      let path = folder + accountId + '/' + id  + '/result/'
      return fileService.readFile(path + 'baseTheoryPar' + extension)
    }).then(result => {
      resolve(result)
    }).catch(error => {
      if (error === 'token expired') {
        reject(errorMsgService.tokenExpired)
      } else if (error === 'file error') {
        reject(errorMsgService.fsError)
      } else {
        reject(errorMsgService.serverError)
      }
    })
  })
}

let getFreeGameSimulation = function (token, id) {
  return new Promise((resolve, reject) => {
    redisRepository.getAccountId(token).then(accountId => {
      let path = folder + accountId + '/' + id  + '/result/'
      return fileService.readFile(path + 'freeSimPar' + extension)
    }).then(result => {
      resolve(result)
    }).catch(error => {
      if (error === 'token expired') {
        reject(errorMsgService.tokenExpired)
      } else if (error === 'file error') {
        reject(errorMsgService.fsError)
      } else {
        reject(errorMsgService.serverError)
      }
    })
  })
}

let getFreeGameTheory = function (token, id) {
  return new Promise((resolve, reject) => {
    redisRepository.getAccountId(token).then(accountId => {
      let path = folder + accountId + '/' + id  + '/result/'
      return fileService.readFile(path + 'freeTheoryPar' + extension)
    }).then(result => {
      resolve(result)
    }).catch(error => {
      if (error === 'token expired') {
        reject(errorMsgService.tokenExpired)
      } else if (error === 'file error') {
        reject(errorMsgService.fsError)
      } else {
        reject(errorMsgService.serverError)
      }
    })
  })
}

module.exports = {
  getOverAllSimulation:  getOverAllSimulation,
  getOverAllTheory:      getOverAllTheory,
  getBaseGameSimulation: getBaseGameSimulation,
  getBaseGameTheory:     getBaseGameTheory,
  getFreeGameSimulation: getFreeGameSimulation,
  getFreeGameTheory:     getFreeGameTheory
}<commit_msg>fix some bugs<commit_after>let Promise = require('bluebird')

let redisRepository = require('../Repositories/RedisRepository')

let fileService     = require('./FileService')
let errorMsgService = require('./ErrorMsgService')

let extension = '.csv'
let folder    = './userProject/'

let getOverAllSimulation = function (token, id) {
  return new Promise((resolve, reject) => {
    redisRepository.getAccountId(token).then(accountId => {
      let path = folder + accountId + '/' + id  + '/result/'
      return fileService.readFile(path + 'overallSimPar' + extension)
    }).then(result => {
      resolve(result)
    }).catch(error => {
      if (error === 'token expired') {
        reject(errorMsgService.tokenExpired)
      } else if (error === 'file error') {
        reject(errorMsgService.fsError)
      } else {
        reject(errorMsgService.serverError)
      }
    })
  })
}

let getOverAllTheory = function (token, id) {
  return new Promise((resolve, reject) => {
    redisRepository.getAccountId(token).then(accountId => {
      let path = folder + accountId + '/' + id  + '/result/'
      return fileService.readFile(path + 'overallTheoryPar' + extension)
    }).then(result => {
      resolve(result)
    }).catch(error => {
      if (error === 'token expired') {
        reject(errorMsgService.tokenExpired)
      } else if (error === 'file error') {
        reject(errorMsgService.fsError)
      } else {
        reject(errorMsgService.serverError)
      }
    })
  })
}

let getBaseGameSimulation = function (token, id) {
  return new Promise((resolve, reject) => {
    redisRepository.getAccountId(token).then(accountId => {
      let path = folder + accountId + '/' + id  + '/result/'
      return fileService.readFile(path + 'baseSimPar' + extension)
    }).then(result => {
      resolve(result)
    }).catch(error => {
      if (error === 'token expired') {
        reject(errorMsgService.tokenExpired)
      } else if (error === 'file error') {
        reject(errorMsgService.fsError)
      } else {
        reject(errorMsgService.serverError)
      }
    })
  })
}

let getBaseGameTheory = function (token, id) {
  return new Promise((resolve, reject) => {
    redisRepository.getAccountId(token).then(accountId => {
      let path = folder + accountId + '/' + id  + '/result/'
      return fileService.readFile(path + 'baseTheoryPar' + extension)
    }).then(result => {
      resolve(result)
    }).catch(error => {
      if (error === 'token expired') {
        reject(errorMsgService.tokenExpired)
      } else if (error === 'file error') {
        reject(errorMsgService.fsError)
      } else {
        reject(errorMsgService.serverError)
      }
    })
  })
}

let getFreeGameSimulation = function (token, id) {
  return new Promise((resolve, reject) => {
    redisRepository.getAccountId(token).then(accountId => {
      let path = folder + accountId + '/' + id  + '/result/'
      return fileService.readFile(path + 'bonusSimPar' + extension)
    }).then(result => {
      resolve(result)
    }).catch(error => {
      if (error === 'token expired') {
        reject(errorMsgService.tokenExpired)
      } else if (error === 'file error') {
        reject(errorMsgService.fsError)
      } else {
        reject(errorMsgService.serverError)
      }
    })
  })
}

let getFreeGameTheory = function (token, id) {
  return new Promise((resolve, reject) => {
    redisRepository.getAccountId(token).then(accountId => {
      let path = folder + accountId + '/' + id  + '/result/'
      return fileService.readFile(path + 'bonusTheoryPar' + extension)
    }).then(result => {
      resolve(result)
    }).catch(error => {
      if (error === 'token expired') {
        reject(errorMsgService.tokenExpired)
      } else if (error === 'file error') {
        reject(errorMsgService.fsError)
      } else {
        reject(errorMsgService.serverError)
      }
    })
  })
}

module.exports = {
  getOverAllSimulation:  getOverAllSimulation,
  getOverAllTheory:      getOverAllTheory,
  getBaseGameSimulation: getBaseGameSimulation,
  getBaseGameTheory:     getBaseGameTheory,
  getFreeGameSimulation: getFreeGameSimulation,
  getFreeGameTheory:     getFreeGameTheory
}<|endoftext|>


<commit_before>
function getURLId() {
	var sPageURL = window.location.search.substring(1);
	var sParameterName = sPageURL.split('=');
	if (sParameterName[0] == 'id') {
		console.log(sParameterName[1]);
		var query_id = document.getElementById('title').innerHTML = sParameterName[1];

		return query_id;
	}
}

$(document).ready(function() {
	getShow();
});

function objectifyForm(formArray) {//serialize data function
  var returnArray = {};
  for (var i = 0; i < formArray.length; i++){
    returnArray[formArray[i]['name']] = formArray[i]['value'];
  }
  return returnArray;
}

// this is the id of the form
$("#searchForm").submit(function(e) {
	var formJsonObj = objectifyForm($("#searchForm").serializeArray());

	formJsonObj['verified'] = 1;
	formJsonObj['id'] = getURLId();
	console.log(formJsonObj);

	var url = env_variables.url;
	$.ajax({
	  url: url,
	  dataType: 'json',
	  type: 'POST',
	  data: JSON.stringify(formJsonObj),
	  success: function (data) {
	  		Materialize.toast('Verification successfully sent!', 4000);
	  },
	  error: function() {
	  	console.log('erorr');
	  }
	});
    e.preventDefault(); // avoid to execute the actual submit of the form.
});

function foo(id) {
	var el = $(id);
	if (el.attr('contenteditable') == 'true'){
		el.attr('contenteditable', 'false');
	} else {
		el.attr('contenteditable', 'true')
	}
}

function getShow() {
	var url = env_variables.url + '?id=' + getURLId();
	$.ajax({
	  url: url,
	  dataType: "json",
	  success: function (data) {
	  		var episode = data['episode'];
	  		$('#parent').val(episode['parent']);
	  		$('#name').val(episode['name']);
	  		$('#season').val(episode['season']);
	  		$('#episode').val(episode['episode']);
	  		$('#video_files').val(episode['video_files']);
	  		$('#subtitles').val(episode['subtitles']);
	  		$('#trash').val(episode['trash']);

	  		console.log(episode);
	  },
	  error: function() {
	  	console.log('erorr');
	  }
	});
}<commit_msg>Now the post and get functions work with changes done with the api.<commit_after>
function getURLId() {
	var sPageURL = window.location.search.substring(1);
	var sParameterName = sPageURL.split('=');
	if (sParameterName[0] == 'id') {
		console.log(sParameterName[1]);
		var query_id = document.getElementById('title').innerHTML = sParameterName[1];

		return query_id;
	}
}

$(document).ready(function() {
	getShow();
});

// this is the id of the form
$("#searchForm").submit(function(e) {
	var url = env_variables.url + 'verify/' + getURLId();
	$.ajax({
	  url: url,
	  type: 'POST',
	  success: function (data) {
	  		Materialize.toast('Verification successfully sent!', 4000);
	  },
	  error: function() {
	  	console.log('erorr');
	  }
	});
    e.preventDefault(); // avoid to execute the actual submit of the form.
});

function foo(id) {
	var el = $(id);
	if (el.attr('contenteditable') == 'true'){
		el.attr('contenteditable', 'false');
	} else {
		el.attr('contenteditable', 'true')
	}
}

function getShow() {
	var url = env_variables.url + getURLId();
	$.ajax({
	  url: url,
	  dataType: "json",
	  success: function (data) {
	  		$('#parent').val(data['parent']);
	  		$('#name').val(data['name']);
	  		$('#season').val(data['season']);
	  		$('#episode').val(data['episode']);
	  		$('#video_files').val(data['video_files']);
	  		$('#subtitles').val(data['subtitles']);
	  		$('#trash').val(data['trash']);

	  		console.log(data);
	  },
	  error: function() {
	  	console.log('erorr');
	  }
	});
}<|endoftext|>


<commit_before>/*
 * Copyright 2009-2012 European Molecular Biology Laboratory
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

(function($, undefined) {
    if($ == undefined)
        throw "jQuery not loaded";

    $.gsUserInfo = null;
    $.accession = null;
    $.gsTargetDir = null;

    function
    gsLoggedIn( gsUserName )
    {
        $("#gs_auth_username").html(gsUserName);
        $("#gs_login_section").hide();
        $("#gs_upload_section").show();

        $.when(retrieveGSUserInformation()).then( function(json) {
            $.gsUserInfo = json;
            checkGSTargetDirectory();
        });
    }

    function
    gsLoggedOut()
    {
        $.gsUserInfo = null;

        $("#gs_auth_status").html("");
        $("#gs_login_section").show();
        $("#gs_upload_section").hide();
    }

    function
    checkIfLoggedToGS( onLoggedInFunc, onLoggedOutFunc )
    {
        $.ajax({
            url : "https://identity.genomespace.org/identityServer/usermanagement/utility/token/username"
            , xhrFields: { withCredentials: true }
            , success : onLoggedInFunc
            , error : onLoggedOutFunc
        });
    }

    function
    checkGSMessage()
    {
        var message = $.cookie("gs-auth-message");
        if (null != message) {
            $("#gs_auth_message").html(message);
            $.cookie("gs-auth-message", null);
        }
    }

    function
    retrieveGSUserInformation()
    {
        var dfr = $.Deferred();

        $.ajax({
            url : "https://identity.genomespace.org/identityServer/selfmanagement/user"
            , xhrFields: { withCredentials: true }
            , success : dfr.resolve
            , error: dfr.reject
            , dataType: "json"
        });

        return dfr.promise();
    }

    function
    checkGSTargetDirectory()
    {
        $.ajax({
            url : contextPath + "/gs/upload"
            , data: { action: "checkDirectory"
                , accession: $.accession
                , token: $.gsUserInfo.token
            }
            , dataType: "json"
            , success : function(json) {
                if (null != json) {
                    if ("exists" == json.status ) {
                        $.gsTargetDir = json.target;
                        $("#gs_target_dir").html(json.target);
                        $("#gs_warning").show();
                    }
                }
            }
        });
    }

    function
    gsUploadFile(fileName)
    {
        var dfr = $.Deferred();

        $.ajax({
            url : contextPath + "/gs/upload"
            , data: { action: "uploadFile"
                , accession: $.accession
                , filename: fileName
                , target:  $.gsTargetDir
                , token: $.gsUserInfo.token
            }
            , dataType: "json"
            , success : dfr.resolve
            , error: dfr.reject

        });

        return dfr.promise();
    }

    function
    gsCreateTargetDirectory()
    {
        var dfr = $.Deferred();

        $.ajax({
            url : contextPath + "/gs/upload"
            , data: { action: "createDirectory"
                , accession: $.accession
                , token: $.gsUserInfo.token
            }
            , dataType: "json"
            , success : dfr.resolve
            , error: dfr.reject
        });

        return dfr.promise();
    }

    function
    uploadFile(counter)
    {
        var $check = $("#file_" + counter + "_check");
        if (0 != $check.length) {
            if ($check.prop("checked")) {
                var fileName = $("#file_" + counter + "_name").val();
                $.progressStatus.html("Sending " + fileName + " to GenomeSpace...");
                $check.prop("disabled", true);
                $("#file_" + counter + "_progress").addClass("in_progress");
                $.when(gsUploadFile(fileName)).then(function() {
                    $("#file_" + counter + "_progress").removeClass("in_progress").addClass("ok");
                    uploadFile(counter + 1);
                }, function() {
                    $("#file_" + counter + "_progress").removeClass("in_progress").addClass("failed");
                    $.progressStatus.html("There was an error uploading " + fileName + " to GenomeSpace");
                })
            } else {
                uploadFile(counter + 1);
            }
        } else {
            if (counter > 1) {
                $.progressStatus.html("Upload completed. Please follow this link to open GenomeSpace UI.");
            } else {
                $.progressStatus.html("");
            }
            reenableForm();
        }
    }

    function
    uploadFiles()
    {
        // first - disable submit button to prevent second event call
        var $this = $(this);
        $this.prop("disabled", true);
        $(".file_div > span").removeClass();

        if (null == $.gsTargetDir) {
            $.progressStatus.html("Creating target directory " + $.gsTargetDir + " in GenomeSpace...");

            $.when(gsCreateTargetDirectory()).then(function(json) {
                $.gsTargetDir = json.target;
                uploadFile(1);
            }, function() {
                // directory creation went wrong?
                $.progressStatus.html("There was an error creating target directory in GenomeSpace");
                $this.removeProp("disabled");
            });
        } else {
            uploadFile(1);
        }
    }

    function
    reenableForm()
    {
        $("#gs_upload_submit").removeProp("disabled");
        $(".file_check").removeProp("disabled");
    }

    $(function() {
        $.accession = $("#ae_accession").val();
        $.progressStatus = $("#gs_progress_status");
        checkGSMessage();
        checkIfLoggedToGS(gsLoggedIn, gsLoggedOut);
        $("#gs_upload_submit").click(uploadFiles);
    });

})(window.jQuery);<commit_msg> - misc changes<commit_after>/*
 * Copyright 2009-2012 European Molecular Biology Laboratory
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

(function($, undefined) {
    if($ == undefined)
        throw "jQuery not loaded";

    $.gsUserInfo = null;
    $.accession = null;
    $.gsTargetDir = null;

    function
    gsLoggedIn( gsUserName )
    {
        $("#gs_auth_username").html(gsUserName);
        $("#gs_login_section").hide();
        $("#gs_upload_section").show();

        $.when(retrieveGSUserInformation()).then( function(json) {
            $.gsUserInfo = json;
            checkGSTargetDirectory();
        });
    }

    function
    gsLoggedOut()
    {
        $.gsUserInfo = null;

        $("#gs_auth_status").html("");
        $("#gs_login_section").show();
        $("#gs_upload_section").hide();
    }

    function
    checkIfLoggedToGS( onLoggedInFunc, onLoggedOutFunc )
    {
        $.ajax({
            url : "https://identity.genomespace.org/identityServer/usermanagement/utility/token/username"
            , xhrFields: { withCredentials: true }
            , success : onLoggedInFunc
            , error : onLoggedOutFunc
        });
    }

    function
    checkGSMessage()
    {
        var message = $.cookie("gs-auth-message");
        if (null != message) {
            $("#gs_auth_message").html(message);
            $.cookie("gs-auth-message", null);
        }
    }

    function
    retrieveGSUserInformation()
    {
        var dfr = $.Deferred();

        $.ajax({
            url : "https://identity.genomespace.org/identityServer/selfmanagement/user"
            , xhrFields: { withCredentials: true }
            , success : dfr.resolve
            , error: dfr.reject
            , dataType: "json"
        });

        return dfr.promise();
    }

    function
    checkGSTargetDirectory()
    {
        $.ajax({
            url : contextPath + "/gs/upload"
            , data: { action: "checkDirectory"
                , accession: $.accession
                , token: $.gsUserInfo.token
            }
            , dataType: "json"
            , success : function(json) {
                if (null != json) {
                    if ("exists" == json.status ) {
                        $.gsTargetDir = json.target;
                        $("#gs_target_dir").html(json.target);
                        $("#gs_warning").show();
                    }
                }
            }
        });
    }

    function
    gsUploadFile(fileName)
    {
        var dfr = $.Deferred();

        $.ajax({
            url : contextPath + "/gs/upload"
            , data: { action: "uploadFile"
                , accession: $.accession
                , filename: fileName
                , target:  $.gsTargetDir
                , token: $.gsUserInfo.token
            }
            , dataType: "json"
            , success : dfr.resolve
            , error: dfr.reject

        });

        return dfr.promise();
    }

    function
    gsCreateTargetDirectory()
    {
        var dfr = $.Deferred();

        $.ajax({
            url : contextPath + "/gs/upload"
            , data: { action: "createDirectory"
                , accession: $.accession
                , token: $.gsUserInfo.token
            }
            , dataType: "json"
            , success : dfr.resolve
            , error: dfr.reject
        });

        return dfr.promise();
    }

    function
    uploadFile(counter)
    {
        var $check = $("#file_" + counter + "_check");
        if (0 != $check.length) {
            if ($check.prop("checked")) {
                var fileName = $("#file_" + counter + "_name").val();
                $.progressStatus.html("Sending " + fileName + " to GenomeSpace...");
                $check.prop("disabled", true);
                $("#file_" + counter + "_progress").addClass("in_progress");
                $.when(gsUploadFile(fileName)).then(function() {
                    $("#file_" + counter + "_progress").removeClass("in_progress").addClass("ok");
                    uploadFile(counter + 1);
                }, function() {
                    $("#file_" + counter + "_progress").removeClass("in_progress").addClass("failed");
                    $.progressStatus.html("There was an error uploading " + fileName + " to GenomeSpace");
                })
            } else {
                uploadFile(counter + 1);
            }
        } else {
            if (counter > 1) {
                $.progressStatus.html("Upload completed. Please follow this link to open GenomeSpace UI.");
            } else {
                $.progressStatus.html("");
            }
            reenableForm();
        }
    }

    function
    uploadFiles()
    {
        // first - disable submit button to prevent second event call
        var $this = $(this);
        $this.prop("disabled", true);
        $(".file_div > span").removeClass();

        if (null == $.gsTargetDir) {
            $.progressStatus.html("Creating target directory in GenomeSpace...");

            $.when(gsCreateTargetDirectory()).then(function(json) {
                $.gsTargetDir = json.target;
                uploadFile(1);
            }, function() {
                // directory creation went wrong?
                $.progressStatus.html("There was an error creating target directory in GenomeSpace");
                $this.removeProp("disabled");
            });
        } else {
            uploadFile(1);
        }
    }

    function
    reenableForm()
    {
        $("#gs_upload_submit").removeProp("disabled");
        $(".file_check").removeProp("disabled");
    }

    $(function() {
        $.accession = $("#ae_accession").val();
        $.progressStatus = $("#gs_progress_status");
        checkGSMessage();
        checkIfLoggedToGS(gsLoggedIn, gsLoggedOut);
        $("#gs_upload_submit").click(uploadFiles);
    });

})(window.jQuery);<|endoftext|>


<commit_before>Dasht.map_geocoder_cache = {}

Dasht.map_plot_address = function(map, markers, geocoder, address) {
    // Maybe pull the location from cache.
    var location;
    if (location = Dasht.map_geocoder_cache[address]) {
        Dasht.map_plot_location(map, markers, address, location);
        return;
    }

    geocoder.geocode({ "address": address }, function(results, status) {
        // Don't plot if the lookup failed.
        if (status != google.maps.GeocoderStatus.OK) return;
        var location = results[0].geometry.location;
        Dasht.map_geocoder_cache[address] = location;
        Dasht.map_plot_location(map, markers, address, location);
    });
}

Dasht.map_plot_ip = function(map, markers, ip) {
    // Maybe pull the location from cache.
    var location;
    if (location = Dasht.map_geocoder_cache[ip]) {
        Dasht.map_plot_location(map, markers, ip, location);
        return;
    }

    // http://freegeoip.net/json/
    jQuery.ajax({
        url: 'http://104.236.251.84/json/' + ip,
        type: 'POST',
        dataType: 'jsonp',
        success: function(response) {
            var location = new google.maps.LatLng(response.latitude, response.longitude);
            Dasht.map_geocoder_cache[ip] = location;
            Dasht.map_plot_location(map, markers, ip, location);
        },
        error: function (xhr, ajaxOptions, thrownError) {
            alert("Failed!");
        }
    });
}

Dasht.map_plot_location = function(map, markers, address_or_ip, location) {
    var location_exists = _.any(_.values(markers), function(marker) {
        return _.isEqual(marker.position, location);
    });
    if (location_exists) return;

    // Drop a pin.
    var marker = new google.maps.Marker({
        map: map,
        animation: google.maps.Animation.DROP,
        position: location
    });

    // Keep track of markers.
    markers[address_or_ip] = marker;
}

Dasht.map_init = function(el, options) {
    // Initialize.
    var old_data = undefined;
    var styles = [
        {
            stylers: [
                { hue: "#ffffff" },
                { saturation: -100 },
                { lightness: 20 },
                { gamma: 0.5 }
            ]
        },
        {
            featureType: "water",
            stylers: [
                { hue: "#ffffff" },
                { saturation: 80 },
                { lightness: 100 },
                { gamma: 0.43 }
            ]
        }
    ];

    var mapOptions = {
        zoom: 4,
        center: new google.maps.LatLng(39.8282, -98.5795),
        styles: styles,
        disableDefaultUI: true
    };

    var map_el = $(el).find(".map").get()[0];
    var num_entries = options["n"] || 10;
    var map = new google.maps.Map(map_el, mapOptions);
    var markers = {};
    var geocoder = new google.maps.Geocoder();
    var ip_regex = /\d+\.\d+\.\d+\.\d+/;

    Dasht.fill_tile($(el).find(".map"));

    // Update values.
    setTimeout(function() {
        Dasht.get_value(options, function(new_data) {
            new_data = new_data[0];
            if (_.isEqual(old_data, new_data)) return;

            // Remove old markers.
            var old_markers = _.difference(_.keys(markers), new_data);
            _.each(old_markers, function(address) {
                markers[address].setMap(null);
                delete markers[address];
            });

            // Plot each marker.
            _.each(new_data, function(item, index) {
                if (item.search(ip_regex) >= 0) {
                    Dasht.map_plot_ip(map, markers, item);
                } else {
                    Dasht.map_plot_address(map, markers, geocoder, item);
                }
            });

            old_data = new_data;
        });
    }, 1000);
}
<commit_msg>Use domain name for freegeoip, not ip address.<commit_after>Dasht.map_geocoder_cache = {}

Dasht.map_plot_address = function(map, markers, geocoder, address) {
    // Maybe pull the location from cache.
    var location;
    if (location = Dasht.map_geocoder_cache[address]) {
        Dasht.map_plot_location(map, markers, address, location);
        return;
    }

    geocoder.geocode({ "address": address }, function(results, status) {
        // Don't plot if the lookup failed.
        if (status != google.maps.GeocoderStatus.OK) return;
        var location = results[0].geometry.location;
        Dasht.map_geocoder_cache[address] = location;
        Dasht.map_plot_location(map, markers, address, location);
    });
}

Dasht.map_plot_ip = function(map, markers, ip) {
    // Maybe pull the location from cache.
    var location;
    if (location = Dasht.map_geocoder_cache[ip]) {
        Dasht.map_plot_location(map, markers, ip, location);
        return;
    }

    jQuery.ajax({
        url: 'http://freegeoip.net/json/' + ip,
        type: 'POST',
        dataType: 'jsonp',
        success: function(response) {
            var location = new google.maps.LatLng(response.latitude, response.longitude);
            Dasht.map_geocoder_cache[ip] = location;
            Dasht.map_plot_location(map, markers, ip, location);
        },
        error: function (xhr, ajaxOptions, thrownError) {
            alert("Failed!");
        }
    });
}

Dasht.map_plot_location = function(map, markers, address_or_ip, location) {
    var location_exists = _.any(_.values(markers), function(marker) {
        return _.isEqual(marker.position, location);
    });
    if (location_exists) return;

    // Drop a pin.
    var marker = new google.maps.Marker({
        map: map,
        animation: google.maps.Animation.DROP,
        position: location
    });

    // Keep track of markers.
    markers[address_or_ip] = marker;
}

Dasht.map_init = function(el, options) {
    // Initialize.
    var old_data = undefined;
    var styles = [
        {
            stylers: [
                { hue: "#ffffff" },
                { saturation: -100 },
                { lightness: 20 },
                { gamma: 0.5 }
            ]
        },
        {
            featureType: "water",
            stylers: [
                { hue: "#ffffff" },
                { saturation: 80 },
                { lightness: 100 },
                { gamma: 0.43 }
            ]
        }
    ];

    var mapOptions = {
        zoom: 4,
        center: new google.maps.LatLng(39.8282, -98.5795),
        styles: styles,
        disableDefaultUI: true
    };

    var map_el = $(el).find(".map").get()[0];
    var num_entries = options["n"] || 10;
    var map = new google.maps.Map(map_el, mapOptions);
    var markers = {};
    var geocoder = new google.maps.Geocoder();
    var ip_regex = /\d+\.\d+\.\d+\.\d+/;

    Dasht.fill_tile($(el).find(".map"));

    // Update values.
    setTimeout(function() {
        Dasht.get_value(options, function(new_data) {
            new_data = new_data[0];
            if (_.isEqual(old_data, new_data)) return;

            // Remove old markers.
            var old_markers = _.difference(_.keys(markers), new_data);
            _.each(old_markers, function(address) {
                markers[address].setMap(null);
                delete markers[address];
            });

            // Plot each marker.
            _.each(new_data, function(item, index) {
                if (item.search(ip_regex) >= 0) {
                    Dasht.map_plot_ip(map, markers, item);
                } else {
                    Dasht.map_plot_address(map, markers, geocoder, item);
                }
            });

            old_data = new_data;
        });
    }, 1000);
}
<|endoftext|>