<commit_before>import React from 'react';
import renderer from 'react-test-renderer';

import TimePicker, {
  parseInTimeFormat, H24, H12, toOption, filterTime, createTimeList, makeOptions, inputError
} from '../../src/time-picker/TimePicker';

// Because of this bug: https://github.com/facebook/react/issues/7386
// Should be fixed in react 15.4
jest.mock('react-dom');

const exampleProps = {
  ...TimePicker.defaultProps,
  id: '12345',
  className: 'fancy-class-name',
  placeholder: '--:--',
  timeFormat: '24h',
  style: { margin: 10, position: 'relative' },
  value: { hours: 6, minutes: 30 },
  minTime: { hours: 5, minutes: 10 },
  maxTime: { hours: 8, minutes: 20 },
  onChange: () => {}
};

const timePicker = new TimePicker(exampleProps);

describe('TimePicker', () => {

  // ignored because react-dom is mocked (see above)
  // it causes problem with AutosizeInput when using refs
  xit('renders correctly', () => {
    const component = renderer.create(
      <TimePicker {...exampleProps} />
    );
    expect(component).toMatchSnapshot();
  });

  describe('getLocals', () => {

    it('computes className', () => {
      const { className } = timePicker.getLocals();
      expect(className).toContain('time-picker');
      expect(className).toContain('fancy-class-name');
    });

    it('passes value properly formatted when H24', () => {
      const timePicker = new TimePicker({
        ...TimePicker.defaultProps,
        value: { hours: 15, minutes: 33 }
      });
      const { value } = timePicker.getLocals();
      expect(value).toEqual('15:33');
    });

    it('passes value properly formatted when H12', () => {
      const timePicker = new TimePicker({
        ...TimePicker.defaultProps,
        value: { hours: 15, minutes: 33 },
        timeFormat: H12
      });
      const { value } = timePicker.getLocals();
      expect(value).toEqual('15:33');
    });

    it('passes an undefined value when value prop is undefined', () => {
      const timePicker = new TimePicker({ ...TimePicker.defaultProps });
      const { value } = timePicker.getLocals();
      expect(value).toBeUndefined();
    });

  });

  describe('parseInTimeFormat', () => {

    it('parses input and returns a valid 24h time', () => {
      const input = '13:59';
      const parsedInput = parseInTimeFormat(input, H24);
      expect(parsedInput.originalInput).toBe(input);
      expect(parsedInput.hours).toBe(13);
      expect(parsedInput.minutes).toBe(59);
    });

    it('parses input and returns a valid 12h time', () => {
      const input = '06:30';
      const parsedInput = parseInTimeFormat(input, H12);
      expect(parsedInput.originalInput).toBe(input);
      expect(parsedInput.hours).toBe(6);
      expect(parsedInput.minutes).toBe(30);
    });

    it('parses input and returns an error for invalid 24h time', () => {
      const input = '36:30';
      const parsedInput = parseInTimeFormat(input, H24);
      expect(parsedInput).toBe(inputError);
    });

    it('parses input and returns an error for invalid 12h time', () => {
      const input = '18:30';
      const parsedInput = parseInTimeFormat(input, H12);
      expect(parsedInput).toBe(inputError);
    });

    it('parses empty input', () => {
      const input = '';
      const parsedInput = parseInTimeFormat(input, H24);
      expect(parsedInput.originalInput).toBe(input);
      expect(parsedInput.hours).toBeUndefined();
      expect(parsedInput.minutes).toBeUndefined();
    });

    it('parses input when minutes are not set', () => {
      const input = '10:';
      const parsedInput = parseInTimeFormat(input, H24);
      expect(parsedInput.originalInput).toBe(input);
      expect(parsedInput.hours).toBeUndefined();
      expect(parsedInput.minutes).toBeUndefined();
    });

    it('parses input without separator and return a valid time', () => {
      const input = '1231';
      const parsedInput = parseInTimeFormat(input, H24);
      expect(parsedInput.hours).toBe(12);
      expect(parsedInput.minutes).toBe(31);
      expect(parsedInput.originalInput).toBe('12:31');
    });

    it('parses input and return error if string is not well formed', () => {
      const input = '1a:aa';
      const parsedInput = parseInTimeFormat(input, H24);
      expect(parsedInput).toBe(inputError);
    });

  });

  describe('createTimeList', () => {

    it('returns all the available times', () => {
      const time = { };
      const timeList24 = createTimeList(time, H24);
      expect(timeList24.length).toBe(48);
      expect(timeList24[0].hours).toBe(0);
      expect(timeList24[0].minutes).toBe(0);
      expect(timeList24[0].timeFormat).toBe('24h');
      expect(timeList24[26].hours).toBe(13);
      expect(timeList24[26].minutes).toBe(0);
      expect(timeList24[27].hours).toBe(13);
      expect(timeList24[27].minutes).toBe(30);
      const timeList12 = createTimeList(time, H12);
      expect(timeList24).not.toEqual(timeList12);
      expect(timeList12[0].timeFormat).toBe('12h');
    });

    it('returns an array of a single element for 24h', () => {
      const time = { hours: 10, minutes: 31 };
      const timeList = createTimeList(time, H24);
      expect(timeList.length).toBe(1);
      expect(timeList[0]).toEqual({ hours: 10, minutes: 31, timeFormat: H24 });

    });

    it('returns an array of 2 elements for 12h', () => {
      const time = { hours: 10, minutes: 31 };
      const timeList = createTimeList(time, H12);
      expect(timeList.length).toBe(2);
      expect(timeList[0]).toEqual({ hours: 10, minutes: 31, timeFormat: H12 });
      expect(timeList[1]).toEqual({ hours: 22, minutes: 31, timeFormat: H12 });

    });

  });

  describe('filterTime', () => {

    it('filters based on minTime/maxTime ', () => {
      const minTime = { hours: 8, minutes: 0 };
      const maxTime = { hours: 9, minutes: 0 };
      const timeList = [
        { hours: 7, minutes: 22 },
        { hours: 8, minutes: 33 },
        { hours: 9, minutes: 44 }
      ];
      const timeListFilterd = timeList.filter(filterTime({ originalInput: '', minTime, maxTime }));
      expect(timeListFilterd.length).toBe(1);
      expect(timeListFilterd[0]).toEqual({ hours: 8, minutes: 33 });
    });

    it('filters based on original input', () => {
      const timeList = [
        { hours: 7, minutes: 22 },
        { hours: 8, minutes: 33 },
        { hours: 9, minutes: 44 }
      ];
      const timeListFilterd = timeList.filter(filterTime({
        originalInput: '08', minTime: TimePicker.defaultProps.minTime, maxTime: TimePicker.defaultProps.maxTime
      }));
      expect(timeListFilterd.length).toBe(1);
      expect(timeListFilterd[0]).toEqual({ hours: 8, minutes: 33 });
    });

  });

  describe('toOption', () => {

    it('formats into a valid option for 24H time', () => {
      const time = { hours: 10, minutes: 20 };
      const formattedTime = toOption(time, H24);
      expect(formattedTime.label).toBe('10:20');
    });

    describe('12H time', () => {

      it('works 1', () => {
        const time = { hours: 13, minutes: 20, timeFormat: H12 };
        const formattedTime = toOption(time);
        expect(formattedTime.label).toBe('01:20 pm');
      });

      it('works 2', () => {
        const time = { hours: 10, minutes: 20, timeFormat: H12 };
        const formattedTime = toOption(time);
        expect(formattedTime.label).toBe('10:20 am');
      });

      it('works 3', () => {
        const time = { hours: 12, minutes: 34, timeFormat: H12 };
        const formattedTime = toOption(time);
        expect(formattedTime.label).toBe('12:34 pm');
      });

      it('works 4', () => {
        const time = { hours: 0, minutes: 34, timeFormat: H12 };
        const formattedTime = toOption(time);
        expect(formattedTime.label).toBe('12:34 am');
      });

      it('works 5', () => {
        const time = { hours: 24, minutes: 34, timeFormat: H12 };
        const formattedTime = toOption(time);
        expect(formattedTime.label).toBe('12:34 am');
      });

    });

  });

  describe('makeOptions', () => {

    it('computes options based on min/max for 24H time', () => {
      const inputStr = '';
      const results = makeOptions({ timeFormat: H24, minTime: { hours: 5, minutes: 10 }, maxTime: { hours: 7, minutes: 20 } }, inputStr);
      expect(results.length).toBe(4);
      expect(results[0]).toEqual({ label: '05:30', value: '05:30' });
      expect(results[3]).toEqual({ label: '07:00', value: '07:00' });
    });

    it('computes options based on min/max for 12H time', () => {
      const inputStr = '';
      const results = makeOptions({ timeFormat: H12, minTime: { hours: 5, minutes: 10 }, maxTime: { hours: 7, minutes: 20 } }, inputStr);
      expect(results.length).toBe(4);
      expect(results[0]).toEqual({ label: '05:30 am', value: '05:30' });
      expect(results[3]).toEqual({ label: '07:00 am', value: '07:00' });
    });

  });

});
<commit_msg>Using only one test to check the correct value of the timePicker<commit_after>import React from 'react';
import renderer from 'react-test-renderer';

import TimePicker, {
  parseInTimeFormat, H24, H12, toOption, filterTime, createTimeList, makeOptions, inputError
} from '../../src/time-picker/TimePicker';

// Because of this bug: https://github.com/facebook/react/issues/7386
// Should be fixed in react 15.4
jest.mock('react-dom');

const exampleProps = {
  ...TimePicker.defaultProps,
  id: '12345',
  className: 'fancy-class-name',
  placeholder: '--:--',
  timeFormat: '24h',
  style: { margin: 10, position: 'relative' },
  value: { hours: 6, minutes: 30 },
  minTime: { hours: 5, minutes: 10 },
  maxTime: { hours: 8, minutes: 20 },
  onChange: () => {}
};

const timePicker = new TimePicker(exampleProps);

describe('TimePicker', () => {

  // ignored because react-dom is mocked (see above)
  // it causes problem with AutosizeInput when using refs
  xit('renders correctly', () => {
    const component = renderer.create(
      <TimePicker {...exampleProps} />
    );
    expect(component).toMatchSnapshot();
  });

  describe('getLocals', () => {

    it('computes className', () => {
      const { className } = timePicker.getLocals();
      expect(className).toContain('time-picker');
      expect(className).toContain('fancy-class-name');
    });

    it('passes value properly formatted', () => {
      const timePicker = new TimePicker({
        ...TimePicker.defaultProps,
        value: { hours: 15, minutes: 33 }
      });
      const { value } = timePicker.getLocals();
      expect(value).toBe('15:33');
    });

    it('passes an undefined value when value prop is undefined', () => {
      const timePicker = new TimePicker({ ...TimePicker.defaultProps });
      const { value } = timePicker.getLocals();
      expect(value).toBeUndefined();
    });

  });

  describe('parseInTimeFormat', () => {

    it('parses input and returns a valid 24h time', () => {
      const input = '13:59';
      const parsedInput = parseInTimeFormat(input, H24);
      expect(parsedInput.originalInput).toBe(input);
      expect(parsedInput.hours).toBe(13);
      expect(parsedInput.minutes).toBe(59);
    });

    it('parses input and returns a valid 12h time', () => {
      const input = '06:30';
      const parsedInput = parseInTimeFormat(input, H12);
      expect(parsedInput.originalInput).toBe(input);
      expect(parsedInput.hours).toBe(6);
      expect(parsedInput.minutes).toBe(30);
    });

    it('parses input and returns an error for invalid 24h time', () => {
      const input = '36:30';
      const parsedInput = parseInTimeFormat(input, H24);
      expect(parsedInput).toBe(inputError);
    });

    it('parses input and returns an error for invalid 12h time', () => {
      const input = '18:30';
      const parsedInput = parseInTimeFormat(input, H12);
      expect(parsedInput).toBe(inputError);
    });

    it('parses empty input', () => {
      const input = '';
      const parsedInput = parseInTimeFormat(input, H24);
      expect(parsedInput.originalInput).toBe(input);
      expect(parsedInput.hours).toBeUndefined();
      expect(parsedInput.minutes).toBeUndefined();
    });

    it('parses input when minutes are not set', () => {
      const input = '10:';
      const parsedInput = parseInTimeFormat(input, H24);
      expect(parsedInput.originalInput).toBe(input);
      expect(parsedInput.hours).toBeUndefined();
      expect(parsedInput.minutes).toBeUndefined();
    });

    it('parses input without separator and return a valid time', () => {
      const input = '1231';
      const parsedInput = parseInTimeFormat(input, H24);
      expect(parsedInput.hours).toBe(12);
      expect(parsedInput.minutes).toBe(31);
      expect(parsedInput.originalInput).toBe('12:31');
    });

    it('parses input and return error if string is not well formed', () => {
      const input = '1a:aa';
      const parsedInput = parseInTimeFormat(input, H24);
      expect(parsedInput).toBe(inputError);
    });

  });

  describe('createTimeList', () => {

    it('returns all the available times', () => {
      const time = { };
      const timeList24 = createTimeList(time, H24);
      expect(timeList24.length).toBe(48);
      expect(timeList24[0].hours).toBe(0);
      expect(timeList24[0].minutes).toBe(0);
      expect(timeList24[0].timeFormat).toBe('24h');
      expect(timeList24[26].hours).toBe(13);
      expect(timeList24[26].minutes).toBe(0);
      expect(timeList24[27].hours).toBe(13);
      expect(timeList24[27].minutes).toBe(30);
      const timeList12 = createTimeList(time, H12);
      expect(timeList24).not.toEqual(timeList12);
      expect(timeList12[0].timeFormat).toBe('12h');
    });

    it('returns an array of a single element for 24h', () => {
      const time = { hours: 10, minutes: 31 };
      const timeList = createTimeList(time, H24);
      expect(timeList.length).toBe(1);
      expect(timeList[0]).toEqual({ hours: 10, minutes: 31, timeFormat: H24 });

    });

    it('returns an array of 2 elements for 12h', () => {
      const time = { hours: 10, minutes: 31 };
      const timeList = createTimeList(time, H12);
      expect(timeList.length).toBe(2);
      expect(timeList[0]).toEqual({ hours: 10, minutes: 31, timeFormat: H12 });
      expect(timeList[1]).toEqual({ hours: 22, minutes: 31, timeFormat: H12 });

    });

  });

  describe('filterTime', () => {

    it('filters based on minTime/maxTime ', () => {
      const minTime = { hours: 8, minutes: 0 };
      const maxTime = { hours: 9, minutes: 0 };
      const timeList = [
        { hours: 7, minutes: 22 },
        { hours: 8, minutes: 33 },
        { hours: 9, minutes: 44 }
      ];
      const timeListFilterd = timeList.filter(filterTime({ originalInput: '', minTime, maxTime }));
      expect(timeListFilterd.length).toBe(1);
      expect(timeListFilterd[0]).toEqual({ hours: 8, minutes: 33 });
    });

    it('filters based on original input', () => {
      const timeList = [
        { hours: 7, minutes: 22 },
        { hours: 8, minutes: 33 },
        { hours: 9, minutes: 44 }
      ];
      const timeListFilterd = timeList.filter(filterTime({
        originalInput: '08', minTime: TimePicker.defaultProps.minTime, maxTime: TimePicker.defaultProps.maxTime
      }));
      expect(timeListFilterd.length).toBe(1);
      expect(timeListFilterd[0]).toEqual({ hours: 8, minutes: 33 });
    });

  });

  describe('toOption', () => {

    it('formats into a valid option for 24H time', () => {
      const time = { hours: 10, minutes: 20 };
      const formattedTime = toOption(time, H24);
      expect(formattedTime.label).toBe('10:20');
    });

    describe('12H time', () => {

      it('works 1', () => {
        const time = { hours: 13, minutes: 20, timeFormat: H12 };
        const formattedTime = toOption(time);
        expect(formattedTime.label).toBe('01:20 pm');
      });

      it('works 2', () => {
        const time = { hours: 10, minutes: 20, timeFormat: H12 };
        const formattedTime = toOption(time);
        expect(formattedTime.label).toBe('10:20 am');
      });

      it('works 3', () => {
        const time = { hours: 12, minutes: 34, timeFormat: H12 };
        const formattedTime = toOption(time);
        expect(formattedTime.label).toBe('12:34 pm');
      });

      it('works 4', () => {
        const time = { hours: 0, minutes: 34, timeFormat: H12 };
        const formattedTime = toOption(time);
        expect(formattedTime.label).toBe('12:34 am');
      });

      it('works 5', () => {
        const time = { hours: 24, minutes: 34, timeFormat: H12 };
        const formattedTime = toOption(time);
        expect(formattedTime.label).toBe('12:34 am');
      });

    });

  });

  describe('makeOptions', () => {

    it('computes options based on min/max for 24H time', () => {
      const inputStr = '';
      const results = makeOptions({ timeFormat: H24, minTime: { hours: 5, minutes: 10 }, maxTime: { hours: 7, minutes: 20 } }, inputStr);
      expect(results.length).toBe(4);
      expect(results[0]).toEqual({ label: '05:30', value: '05:30' });
      expect(results[3]).toEqual({ label: '07:00', value: '07:00' });
    });

    it('computes options based on min/max for 12H time', () => {
      const inputStr = '';
      const results = makeOptions({ timeFormat: H12, minTime: { hours: 5, minutes: 10 }, maxTime: { hours: 7, minutes: 20 } }, inputStr);
      expect(results.length).toBe(4);
      expect(results[0]).toEqual({ label: '05:30 am', value: '05:30' });
      expect(results[3]).toEqual({ label: '07:00 am', value: '07:00' });
    });

  });

});
<|endoftext|>


<commit_before><commit_msg>No longer needed<commit_after><|endoftext|>


<commit_before>var DynamicWeightedEngine = require('../lib/DynamicWeightedEngine');
var debug = require('debug')('awesomeBalancer:dynamic');

var data = [{
    value: '192.168.1.203',
    weight: 1
},
{
    value: '192.168.1.204',
    weight: 2
},
{
    value: '192.168.1.205',
    weight: 2
},
{
    value: '192.168.1.206',
    weight: 2
},
{
    value: '192.168.1.207',
    weight: 2
},
{
    value: '192.168.1.208',
    weight: 2
},
{
    value: '192.168.1.211',
    weight: 2
}];

var a = new DynamicWeightedEngine(data);

setInterval(function () {
    var rel = a.pick();
    debug('pick成功啦', rel);
}, 4000);
<commit_msg>fix test<commit_after>var d = require('../lib/DynamicWeightedEngine');
var debug = require('debug')('awesomeBalancer:dynamic');

var data = [{
    value: '192.168.1.203',
    weight: 1
},
{
    value: '192.168.1.204',
    weight: 1
},
{
    value: '192.168.1.205',
    weight: 1
},
{
    value: '192.168.1.206',
    weight: 1
},
{
    value: '192.168.1.207',
    weight: 1
},
{
    value: '192.168.1.208',
    weight: 1
},
{
    value: '192.168.1.211',
    weight: 1
}];

var a = new DynamicWeightedEngine(data);

setInterval(function () {
    var rel = a.pick();
    debug('pick成功啦', rel);
}, 4000);
<|endoftext|>


<commit_before>    /**
     * @ngdoc model
     * @name MerchelloTab
     * @function
     *
     * @description
     * Backoffice model used for tab navigation
     */
    var MerchelloTab = function() {
        var self = this;
        self.id = '';
        self.name = '';
        self.url = '';
        self.active = false;
    };

    angular.module('merchello.models').constant('MerchelloTab', MerchelloTab);

    /**
     * @ngdoc model
     * @name MerchelloTabCollection
     * @function
     *
     * @description
     * Backoffice model used for tab navigation
     */
    var MerchelloTabCollection = function() {
        this.items = [];
    };

    MerchelloTabCollection.prototype = (function() {

        // safely adds a tab to the collection
        function addTab(id, name, url) {
            var existing = _.find(this.items, function(tab) { return tab.id === id; });
            if (existing === undefined || existing === null) {
                var tab = new MerchelloTab();
                tab.id = id;
                tab.name = name;
                tab.url = url;
                this.items.push(tab);
            }
        }

        function setActive(id) {
           angular.forEach(this.items, function(item) {
               if(item.id === id) {
                   item.active = true;
               } else {
                   item.active = false;
               }
           });
        }

        return {
            addTab: addTab,
            setActive: setActive
        };
    }());

    angular.module('merchello.models').constant('MerchelloTabCollection', MerchelloTabCollection);<commit_msg>Adds insertTab<commit_after>    /**
     * @ngdoc model
     * @name MerchelloTab
     * @function
     *
     * @description
     * Backoffice model used for tab navigation
     */
    var MerchelloTab = function() {
        var self = this;
        self.id = '';
        self.name = '';
        self.url = '';
        self.active = false;
    };

    angular.module('merchello.models').constant('MerchelloTab', MerchelloTab);

    /**
     * @ngdoc model
     * @name MerchelloTabCollection
     * @function
     *
     * @description
     * Backoffice model used for tab navigation
     */
    var MerchelloTabCollection = function() {
        this.items = [];
    };

    MerchelloTabCollection.prototype = (function() {

        // safely adds a tab to the collection
        function addTab(id, name, url) {
            var existing = _.find(this.items, function(tab) { return tab.id === id; });
            if (existing === undefined || existing === null) {
                var tab = new MerchelloTab();
                tab.id = id;
                tab.name = name;
                tab.url = url;
                this.items.push(tab);
            }
        }

        function setActive(id) {
           angular.forEach(this.items, function(item) {
               if(item.id === id) {
                   item.active = true;
               } else {
                   item.active = false;
               }
           });
        }

        function insertTab(id, name, url, index) {
            var existing = _.find(this.items, function(tab) { return tab.id === id; });
            if (existing === undefined || existing === null) {
                var tab = new MerchelloTab();
                tab.id = id;
                tab.name = name;
                tab.url = url;
                if (this.items.length <= index) {
                    addTab.call(this, tab);
                } else {
                    this.items.splice(index, 0, tab);
                }
            }
        }

        return {
            addTab: addTab,
            setActive: setActive,
            insertTab: insertTab
        };
    }());

    angular.module('merchello.models').constant('MerchelloTabCollection', MerchelloTabCollection);<|endoftext|>


<commit_before><commit_msg>尝试向Mongo中插入日期类型的数据<commit_after><|endoftext|>


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

const assert = require('../support/assert');
const TestClient = require('../support/test-client');
const serverOptions = require('../../lib/cartodb/server_options');

const suites = [{
    desc: 'regressions mvt (mapnik)',
    usePostGIS: false
}];

if (process.env.POSTGIS_VERSION === '2.4') {
    suites.push({
        desc: 'regressions mvt (postgis)',
        usePostGIS: true
    });
}

describe('aggregation', function () {

    suites.forEach((suite) => {
        const { desc, usePostGIS } = suite;

        describe(desc, function () {
            const originalUsePostGIS = serverOptions.renderer.mvt.usePostGIS;

            before(function () {
                serverOptions.renderer.mvt.usePostGIS = usePostGIS;
            });

            after(function (){
                serverOptions.renderer.mvt.usePostGIS = originalUsePostGIS;
            });

            afterEach(function (done) {
                this.testClient.drain(done);
            });

            it('aggregates with centroid placement', function (done) {
                const mapConfig = {
                    version: '1.7.0',
                    layers: [
                        {
                            type: 'cartodb',
                            options: {
                                sql: 'select * from populated_places_simple_reduced',
                                aggregation: {
                                    placement: 'point-sample',
                                    columns: {
                                        pop_max_avg: {
                                            aggregate_function: 'avg',
                                            aggregated_column: 'pop_max'
                                        }
                                    },
                                    threshold: 1
                                }
                            }
                        }
                    ]
                };

                this.testClient = new TestClient(mapConfig);
                this.testClient.getLayergroup((err, body) => {
                    if (err) {
                        return done(err);
                    }

                    assert.equal(typeof body.metadata, 'object');
                    assert.ok(Array.isArray(body.metadata.layers));

                    body.metadata.layers.forEach(layer => assert.ok(layer.meta.aggregation.mvt));

                    done();
                });
            });
        });
    });
});
<commit_msg>improve description for suite and test<commit_after>require('../support/test_helper');

const assert = require('../support/assert');
const TestClient = require('../support/test-client');
const serverOptions = require('../../lib/cartodb/server_options');

const suites = [{
    desc: 'mapnik',
    usePostGIS: false
}];

if (process.env.POSTGIS_VERSION === '2.4') {
    suites.push({
        desc: 'postgis',
        usePostGIS: true
    });
}

describe('mvt regressions', function () {

    suites.forEach((suite) => {
        const { desc, usePostGIS } = suite;

        describe(desc, function () {
            const originalUsePostGIS = serverOptions.renderer.mvt.usePostGIS;

            before(function () {
                serverOptions.renderer.mvt.usePostGIS = usePostGIS;
            });

            after(function (){
                serverOptions.renderer.mvt.usePostGIS = originalUsePostGIS;
            });

            afterEach(function (done) {
                this.testClient.drain(done);
            });

            it('should not error on missing column from aggregation', function (done) {
                const mapConfig = {
                    version: '1.7.0',
                    layers: [
                        {
                            type: 'cartodb',
                            options: {
                                sql: 'select * from populated_places_simple_reduced',
                                aggregation: {
                                    placement: 'point-sample',
                                    columns: {
                                        pop_max_avg: {
                                            aggregate_function: 'avg',
                                            aggregated_column: 'pop_max'
                                        }
                                    },
                                    threshold: 1
                                }
                            }
                        }
                    ]
                };

                this.testClient = new TestClient(mapConfig);
                this.testClient.getLayergroup((err, body) => {
                    if (err) {
                        return done(err);
                    }

                    assert.equal(typeof body.metadata, 'object');
                    assert.ok(Array.isArray(body.metadata.layers));

                    body.metadata.layers.forEach(layer => assert.ok(layer.meta.aggregation.mvt));

                    done();
                });
            });
        });
    });
});
<|endoftext|>


<commit_before>/*
	WebPlotDigitizer - http://arohatgi.info/WebPlotDigitizer

	Copyright 2010-2017 Ankit Rohatgi <ankitrohatgi@hotmail.com>

	This file is part of WebPlotDigitizer.

    WebPlotDigitizer is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    WebPlotDigitizer is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with WebPlotDigitizer.  If not, see <http://www.gnu.org/licenses/>.

*/

/* Parse dates and convert back and forth to Julian days */
var wpd = wpd || {};

wpd.dateConverter = (function () {

    function parse(input) {
        if(input == null) { return null; }

        if(typeof input === "string") {
            if(input.indexOf('/') < 0 && input.indexOf(':') < 0) { return null; }
        }

        return toJD(input);
    }

    function toJD(dateString) {
        dateString = dateString.toString();
	    var dateParts = dateString.split(/[-/ :]/),
            hasDatePart = dateString.indexOf('/') >= 0,
			year,
			month,
			date,
            hour,
            min,
            sec,
            timeIdxOffset,
            today,
			tempDate,
			rtnValue;

        if(dateParts.length <= 0 || dateParts.length > 6) {
            return null;
        }

        if(hasDatePart){
            year = parseInt(dateParts[0], 10);
            month = parseInt(dateParts[1] === undefined ? 0 : dateParts[1], 10);
            date = parseInt(dateParts[2] === undefined ? 1 : dateParts[2], 10);
            timeIdxOffset = 3;
        } else {
            today = new Date();
            year = today.getFullYear();
            month = today.getMonth() + 1;
            date = today.getDate();
            timeIdxOffset = 0;
        }
        hour = parseInt(dateParts[timeIdxOffset] === undefined ? 0 : dateParts[timeIdxOffset], 10);
        min = parseInt(dateParts[timeIdxOffset+1] === undefined ? 0 : dateParts[timeIdxOffset+1], 10);
        sec = parseInt(dateParts[timeIdxOffset+2] === undefined ? 0 : dateParts[timeIdxOffset+2], 10);

        if(isNaN(year) || isNaN(month) || isNaN(date) || isNaN(hour) || isNaN(min) || isNaN(sec)) {
            return null;
        }

        if(month > 12 || month < 1) {
            return null;
        }

        if(date > 31 || date < 1) {
            return null;
        }

        if(hour > 23 || hour < 0) {
            return null;
        }

        if(min > 59 || min < 0) {
            return null;
        }

        if(sec > 59 || sec < 0) {
            return null;
        }

        // Temporary till I figure out julian dates:
        tempDate = new Date();
        tempDate.setUTCFullYear(year);
        tempDate.setUTCMonth(month-1);
        tempDate.setUTCDate(date);
        tempDate.setUTCHours(hour, min, sec);
        rtnValue = parseFloat(Date.parse(tempDate));
        if(!isNaN(rtnValue)) {
            return rtnValue;
        }
        return null;
    }

    function formatDateNumber(dateNumber, formatString) {
        // round to smallest time unit
        var coeff = 1;

        if(formatString.indexOf('s') >= 0)
            coeff = 1000;
        else if(formatString.indexOf('i') >= 0)
            coeff = 1000 * 60;
        else if(formatString.indexOf('h') >= 0)
            coeff = 1000 * 60 * 60;
        else if(formatString.indexOf('d') >= 0)
            coeff = 1000 * 60 * 60 * 24;
        else if(formatString.indexOf('m') >= 0)
            coeff = 1000 * 60 * 60 * 24 * 365.2425 / 12;
        else if(formatString.indexOf('y') >= 0)
            coeff = 1000 * 60 * 60 * 24 * 365.2425;

        return formatDate(new Date(Math.round(new Date(dateNumber).getTime() / coeff) * coeff), formatString);
    }

    function formatDate(dateObject, formatString) {
        var longMonths = [
                            "January",
                            "February",
                            "March",
                            "April",
                            "May",
                            "June",
                            "July",
                            "August",
                            "September",
                            "October",
                            "November",
                            "December"
                        ],
            shortMonths = [
                            "Jan",
                            "Feb",
                            "Mar",
                            "Apr",
                            "May",
                            "Jun",
                            "Jul",
                            "Aug",
                            "Sep",
                            "Oct",
                            "Nov",
                            "Dec"
                        ];

        var outputString = formatString;

        outputString = outputString.replace("YYYY", "yyyy");
        outputString = outputString.replace("YY", "yy");
        outputString = outputString.replace("MMMM", "mmmm");
        outputString = outputString.replace("MMM", "mmm");
        outputString = outputString.replace("MM", "mm");
        outputString = outputString.replace("DD", "dd");
        outputString = outputString.replace("HH", "hh");
        outputString = outputString.replace("II", "ii");
        outputString = outputString.replace("SS", "ss");

        outputString = outputString.replace("yyyy", dateObject.getUTCFullYear());

        var twoDigitYear = dateObject.getUTCFullYear()%100;
        twoDigitYear = twoDigitYear < 10 ? '0' + twoDigitYear : twoDigitYear;

        outputString = outputString.replace("yy", twoDigitYear);

        outputString = outputString.replace("mmmm", longMonths[dateObject.getUTCMonth()]);
        outputString = outputString.replace("mmm", shortMonths[dateObject.getUTCMonth()]);
        outputString = outputString.replace("mm", (dateObject.getUTCMonth()+1));
        outputString = outputString.replace("dd", dateObject.getUTCDate());

        outputString = outputString.replace("hh", dateObject.getUTCHours());
        outputString = outputString.replace("ii", dateObject.getUTCMinutes());
        outputString = outputString.replace("ss", dateObject.getUTCSeconds());

		return outputString;
    }

    function getFormatString(dateString) {
    	var dateParts = dateString.split(/[-/ :]/),
            hasDatePart = dateString.indexOf('/') >= 0,
            formatString = 'yyyy/mm/dd hh:ii:ss';

        if(dateParts.length >= 1) {
            formatString = hasDatePart ? 'yyyy' : 'hh';
        }

        if(dateParts.length >= 2) {
            formatString += hasDatePart ? '/mm' : ':ii';
        }

        if(dateParts.length >= 3) {
            formatString += hasDatePart ? '/dd' : ':ss';
        }

        if(dateParts.length >= 4) {
            formatString += ' hh';
        }

        if(dateParts.length >= 5) {
            formatString += ':ii';
        }

        if(dateParts.length === 6) {
            formatString += ':ss';
        }

        return formatString;
    }

    return {
        parse: parse,
        getFormatString: getFormatString,
        formatDateNumber: formatDateNumber
    };
})();

<commit_msg>Add leading zeroes to one digit date and time numbers<commit_after>/*
	WebPlotDigitizer - http://arohatgi.info/WebPlotDigitizer

	Copyright 2010-2017 Ankit Rohatgi <ankitrohatgi@hotmail.com>

	This file is part of WebPlotDigitizer.

    WebPlotDigitizer is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    WebPlotDigitizer is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with WebPlotDigitizer.  If not, see <http://www.gnu.org/licenses/>.

*/

/* Parse dates and convert back and forth to Julian days */
var wpd = wpd || {};

wpd.dateConverter = (function () {

    function parse(input) {
        if(input == null) { return null; }

        if(typeof input === "string") {
            if(input.indexOf('/') < 0 && input.indexOf(':') < 0) { return null; }
        }

        return toJD(input);
    }

    function toJD(dateString) {
        dateString = dateString.toString();
	    var dateParts = dateString.split(/[-/ :]/),
            hasDatePart = dateString.indexOf('/') >= 0,
			year,
			month,
			date,
            hour,
            min,
            sec,
            timeIdxOffset,
            today,
			tempDate,
			rtnValue;

        if(dateParts.length <= 0 || dateParts.length > 6) {
            return null;
        }

        if(hasDatePart){
            year = parseInt(dateParts[0], 10);
            month = parseInt(dateParts[1] === undefined ? 0 : dateParts[1], 10);
            date = parseInt(dateParts[2] === undefined ? 1 : dateParts[2], 10);
            timeIdxOffset = 3;
        } else {
            today = new Date();
            year = today.getFullYear();
            month = today.getMonth() + 1;
            date = today.getDate();
            timeIdxOffset = 0;
        }
        hour = parseInt(dateParts[timeIdxOffset] === undefined ? 0 : dateParts[timeIdxOffset], 10);
        min = parseInt(dateParts[timeIdxOffset+1] === undefined ? 0 : dateParts[timeIdxOffset+1], 10);
        sec = parseInt(dateParts[timeIdxOffset+2] === undefined ? 0 : dateParts[timeIdxOffset+2], 10);

        if(isNaN(year) || isNaN(month) || isNaN(date) || isNaN(hour) || isNaN(min) || isNaN(sec)) {
            return null;
        }

        if(month > 12 || month < 1) {
            return null;
        }

        if(date > 31 || date < 1) {
            return null;
        }

        if(hour > 23 || hour < 0) {
            return null;
        }

        if(min > 59 || min < 0) {
            return null;
        }

        if(sec > 59 || sec < 0) {
            return null;
        }

        // Temporary till I figure out julian dates:
        tempDate = new Date();
        tempDate.setUTCFullYear(year);
        tempDate.setUTCMonth(month-1);
        tempDate.setUTCDate(date);
        tempDate.setUTCHours(hour, min, sec);
        rtnValue = parseFloat(Date.parse(tempDate));
        if(!isNaN(rtnValue)) {
            return rtnValue;
        }
        return null;
    }

    function formatDateNumber(dateNumber, formatString) {
        // round to smallest time unit
        var coeff = 1;

        if(formatString.indexOf('s') >= 0)
            coeff = 1000;
        else if(formatString.indexOf('i') >= 0)
            coeff = 1000 * 60;
        else if(formatString.indexOf('h') >= 0)
            coeff = 1000 * 60 * 60;
        else if(formatString.indexOf('d') >= 0)
            coeff = 1000 * 60 * 60 * 24;
        else if(formatString.indexOf('m') >= 0)
            coeff = 1000 * 60 * 60 * 24 * 365.2425 / 12;
        else if(formatString.indexOf('y') >= 0)
            coeff = 1000 * 60 * 60 * 24 * 365.2425;

        return formatDate(new Date(Math.round(new Date(dateNumber).getTime() / coeff) * coeff), formatString);
    }

    function formatDate(dateObject, formatString) {
        var longMonths = [
                            "January",
                            "February",
                            "March",
                            "April",
                            "May",
                            "June",
                            "July",
                            "August",
                            "September",
                            "October",
                            "November",
                            "December"
                        ],
            shortMonths = [
                            "Jan",
                            "Feb",
                            "Mar",
                            "Apr",
                            "May",
                            "Jun",
                            "Jul",
                            "Aug",
                            "Sep",
                            "Oct",
                            "Nov",
                            "Dec"
                        ];

        var outputString = formatString;

        outputString = outputString.replace("YYYY", "yyyy");
        outputString = outputString.replace("YY", "yy");
        outputString = outputString.replace("MMMM", "mmmm");
        outputString = outputString.replace("MMM", "mmm");
        outputString = outputString.replace("MM", "mm");
        outputString = outputString.replace("DD", "dd");
        outputString = outputString.replace("HH", "hh");
        outputString = outputString.replace("II", "ii");
        outputString = outputString.replace("SS", "ss");

        outputString = outputString.replace("yyyy", dateObject.getUTCFullYear());

        var twoDigitYear = dateObject.getUTCFullYear()%100;
        twoDigitYear = twoDigitYear < 10 ? '0' + twoDigitYear : twoDigitYear;

        outputString = outputString.replace("yy", twoDigitYear);

        outputString = outputString.replace("mmmm", longMonths[dateObject.getUTCMonth()]);
        outputString = outputString.replace("mmm", shortMonths[dateObject.getUTCMonth()]);
        outputString = outputString.replace("mm", ("0" + (dateObject.getUTCMonth()+1)).slice(-2));
        outputString = outputString.replace("dd", ("0" + dateObject.getUTCDate()).slice(-2));

        outputString = outputString.replace("hh", ("0" + dateObject.getUTCHours()).slice(-2));
        outputString = outputString.replace("ii", ("0" + dateObject.getUTCMinutes()).slice(-2));
        outputString = outputString.replace("ss", ("0" + dateObject.getUTCSeconds()).slice(-2));

		return outputString;
    }

    function getFormatString(dateString) {
    	var dateParts = dateString.split(/[-/ :]/),
            hasDatePart = dateString.indexOf('/') >= 0,
            formatString = 'yyyy/mm/dd hh:ii:ss';

        if(dateParts.length >= 1) {
            formatString = hasDatePart ? 'yyyy' : 'hh';
        }

        if(dateParts.length >= 2) {
            formatString += hasDatePart ? '/mm' : ':ii';
        }

        if(dateParts.length >= 3) {
            formatString += hasDatePart ? '/dd' : ':ss';
        }

        if(dateParts.length >= 4) {
            formatString += ' hh';
        }

        if(dateParts.length >= 5) {
            formatString += ':ii';
        }

        if(dateParts.length === 6) {
            formatString += ':ss';
        }

        return formatString;
    }

    return {
        parse: parse,
        getFormatString: getFormatString,
        formatDateNumber: formatDateNumber
    };
})();

<|endoftext|>


<commit_before>/* global _ */
"use strict";
import "lodash/lodash";
import "popper.js/dist/popper";
import "bootstrap/dist/js/bootstrap";
import ParserPluginForm from "./parser_plugin_form";
import store from "./store";

$(document).ready(() => {
  new Vue({
    el: "#in-tail-parse",
    store,
    components: {
      "parser-plugin-form": ParserPluginForm
    },
    props: [
      "initialPluginName",
      "pluginType",
      "pluginLabel",
    ],
    data: function() {
      return {
        "path": "",
        "parseType": "",
        "highlightedLines": null
      };
    },
    computed: {
      token: function() {
        return Rails.csrfToken();
      }
    },
    watch: {
      "parse.expression": function() {
        console.log(`parse.expression: ${this.parse.expression}`);
        this.preview();
      },
      "parse.time_format": function() {
        console.log(`parse.time_format: ${this.parse.time_format}`);
        this.preview();
      },
      "parseType": function() {
        this.preview();
      },
    },
    beforeMount: function() {
      this.path = this.$el.attributes.path.nodeValue;
    },
    mounted: function() {
      this.parse = {};
    },
    updated: function() {
      this.$nextTick(() => {
        if ($("[data-toggle=tooltip]").tooltip) {
          $("[data-toggle=tooltip]").tooltip("dispose");
          $("[data-toggle=tooltip]").tooltip("enable");
        }
      });
    },
    methods: {
      onChangePluginName: function(name) {
        console.log("#in-tail-parse onChangePluginName", name);
        console.log("#in-tail-parse onChangePluginName store", this.$store);
        this.parseType = name;
        this.parse = {}; // clear parser plugin configuration
      },
      onChangeParseConfig: function(data) {
        console.log("#in-tail-parse onChangeParseConfig", store.getters["parserParams/toParams"]);
        _.merge(this.parse, store.getters["parserParams/toParams"]);
        this.preview();
      },
      onChangeFormats: function(data) {
        console.log("#in_tail_parse onChangeFormats", data);
        _.merge(this.parse, data);
        this.preview();
      },
      updateHighlightedLines: function(matches) {
        if (!matches) {
          this.highlightedLines = null;
          return;
        }

        let $container = $("
");
        _.each(matches, (match) => {
          const colors = ["#ff9", "#cff", "#fcf", "#dfd"];
          const whole = match.whole;
          let html = "";
          let _matches = [];
          let lastPos = 0;

          _.each(match.matches, (m) => {
            let matched = m.matched;
            if (!matched) {
              return;
            }
            // Ignore empty matched with "foobar".match(/foo(.*?)bar/)[1] #=> ""
            if (matched.length === 0) {
              return;
            }
            // rotate color
            let currentColor = colors.shift();
            colors.push(currentColor);

            // create highlighted range HTML
            let $highlighted = $("").text(matched);
            $highlighted.attr({
              "class": "regexp-preview",
              "data-toggle": "tooltip",
              "data-placement": "top",
              "title": m.key,
              "style": "background-color:" + currentColor
            });
            let highlightedHtml = $highlighted.wrap("
").parent().html();
            let pos = {
              start: m.pos[0],
              end: m.pos[1]
            };
            if (pos.start > 0) {
              html += _.escape(whole.substring(lastPos, pos.start));
            }
            html += highlightedHtml;
            lastPos = pos.end;
          });
          html += whole.substring(lastPos);

          $container.append(html);
          $container.append("
");
        });

        this.highlightedLines = $container.html();
        this.$emit("hook:updated");
      },

      preview: function() {
        console.log("preview!!!!");
        if (this.previewAjax && this.previewAjax.state() === "pending") {
          this.previewAjax.abort();
        }
        const parseType = store.getters["parserParams/pluginName"];
        this.previewAjax = $.ajax({
          method: "POST",
          url: `${relativeUrlRoot}/api/regexp_preview`,
          headers: {
            "X-CSRF-Token": this.token
          },
          data: {
            parse_type: _.isEmpty(parseType) ? "regexp" : parseType,
            file: this.path,
            plugin_config: this.parse
          }
        }).then(
          (result) => {
            if (result.matches) {
              this.updateHighlightedLines(result.matches);
            } else {
              console.error(result.error);
              this.previewError = result.error;
            }
          },
          (error) => {
            this.highlightedLines = null;
            // console.error(error.responseText)
            if (error.stack) {
              console.error(error.stack);
            }
          });
      }
    }
  });
});
<commit_msg>Remove debug log<commit_after>/* global _ */
"use strict";
import "lodash/lodash";
import "popper.js/dist/popper";
import "bootstrap/dist/js/bootstrap";
import ParserPluginForm from "./parser_plugin_form";
import store from "./store";

$(document).ready(() => {
  new Vue({
    el: "#in-tail-parse",
    store,
    components: {
      "parser-plugin-form": ParserPluginForm
    },
    props: [
      "initialPluginName",
      "pluginType",
      "pluginLabel",
    ],
    data: function() {
      return {
        "path": "",
        "parseType": "",
        "highlightedLines": null
      };
    },
    computed: {
      token: function() {
        return Rails.csrfToken();
      }
    },
    watch: {
      "parse.expression": function() {
        console.log(`parse.expression: ${this.parse.expression}`);
        this.preview();
      },
      "parse.time_format": function() {
        console.log(`parse.time_format: ${this.parse.time_format}`);
        this.preview();
      },
      "parseType": function() {
        this.preview();
      },
    },
    beforeMount: function() {
      this.path = this.$el.attributes.path.nodeValue;
    },
    mounted: function() {
      this.parse = {};
    },
    updated: function() {
      this.$nextTick(() => {
        if ($("[data-toggle=tooltip]").tooltip) {
          $("[data-toggle=tooltip]").tooltip("dispose");
          $("[data-toggle=tooltip]").tooltip("enable");
        }
      });
    },
    methods: {
      onChangePluginName: function(name) {
        console.log("#in-tail-parse onChangePluginName", name);
        this.parseType = name;
        this.parse = {}; // clear parser plugin configuration
      },
      onChangeParseConfig: function(data) {
        console.log("#in-tail-parse onChangeParseConfig", store.getters["parserParams/toParams"]);
        _.merge(this.parse, store.getters["parserParams/toParams"]);
        this.preview();
      },
      onChangeFormats: function(data) {
        console.log("#in_tail_parse onChangeFormats", data);
        _.merge(this.parse, data);
        this.preview();
      },
      updateHighlightedLines: function(matches) {
        if (!matches) {
          this.highlightedLines = null;
          return;
        }

        let $container = $("
");
        _.each(matches, (match) => {
          const colors = ["#ff9", "#cff", "#fcf", "#dfd"];
          const whole = match.whole;
          let html = "";
          let _matches = [];
          let lastPos = 0;

          _.each(match.matches, (m) => {
            let matched = m.matched;
            if (!matched) {
              return;
            }
            // Ignore empty matched with "foobar".match(/foo(.*?)bar/)[1] #=> ""
            if (matched.length === 0) {
              return;
            }
            // rotate color
            let currentColor = colors.shift();
            colors.push(currentColor);

            // create highlighted range HTML
            let $highlighted = $("").text(matched);
            $highlighted.attr({
              "class": "regexp-preview",
              "data-toggle": "tooltip",
              "data-placement": "top",
              "title": m.key,
              "style": "background-color:" + currentColor
            });
            let highlightedHtml = $highlighted.wrap("
").parent().html();
            let pos = {
              start: m.pos[0],
              end: m.pos[1]
            };
            if (pos.start > 0) {
              html += _.escape(whole.substring(lastPos, pos.start));
            }
            html += highlightedHtml;
            lastPos = pos.end;
          });
          html += whole.substring(lastPos);

          $container.append(html);
          $container.append("
");
        });

        this.highlightedLines = $container.html();
        this.$emit("hook:updated");
      },

      preview: function() {
        console.log("preview!!!!");
        if (this.previewAjax && this.previewAjax.state() === "pending") {
          this.previewAjax.abort();
        }
        const parseType = store.getters["parserParams/pluginName"];
        this.previewAjax = $.ajax({
          method: "POST",
          url: `${relativeUrlRoot}/api/regexp_preview`,
          headers: {
            "X-CSRF-Token": this.token
          },
          data: {
            parse_type: _.isEmpty(parseType) ? "regexp" : parseType,
            file: this.path,
            plugin_config: this.parse
          }
        }).then(
          (result) => {
            if (result.matches) {
              this.updateHighlightedLines(result.matches);
            } else {
              console.error(result.error);
              this.previewError = result.error;
            }
          },
          (error) => {
            this.highlightedLines = null;
            // console.error(error.responseText)
            if (error.stack) {
              console.error(error.stack);
            }
          });
      }
    }
  });
});
<|endoftext|>


<commit_before>"use strict";

(function () {
    angular
        .module("argo")
        .controller("Default", Default);

    Default.$inject = ["$rootScope", "$mdDialog",
        "$mdBottomSheet", "accountsService"];

    function Default($rootScope, $mdDialog, $mdBottomSheet,
        accountsService) {
        var vm = this;

        vm.tabSelectedIndex = 0;

        vm.next = function () {
            vm.tabSelectedIndex = Math.min(vm.tabSelectedIndex + 1, 5);
        };
        vm.previous = function () {
            vm.tabSelectedIndex = Math.max(vm.tabSelectedIndex - 1, 0);
        };

        vm.openTokenDialog = function (event) {
            $mdDialog.show({
                controller: "TokenDialog",
                controllerAs: "dialog",
                templateUrl: "app/layout/token-dialog.html",
                targetEvent: event
            }).then(function(tokenInfo) {
                if (tokenInfo) {
                    vm.environment = tokenInfo.environment;
                    vm.token = tokenInfo.token;
                } else {
                    vm.environment = "";
                    vm.token = "";
                    vm.accountId = "";
                }

                accountsService.getAccounts({
                    environment: vm.environment,
                    token: vm.token
                }).then(function (accounts) {
                    $mdBottomSheet.show({
                        controller: "AccountsBottomSheet",
                        controllerAs: "sheet",
                        templateUrl: "app/account/accounts-bottomsheet.html",
                        locals: {accounts: accounts},
                        targetEvent: event
                    }).then(function (accountSelected) {
                        vm.accountId = accountSelected.accountId;

                        accountsService.getAccounts({
                            environment: vm.environment,
                            token: vm.token,
                            accountId: vm.accountId
                        }).then(function (account) {
                            vm.account = account;
                            $rootScope.$broadcast("accountChange", account);
                        });
                    });
                });
            });
        };

        // vm.showCustomToast = function () {
        //     $mdToast.show({
        //         controller: "MyToast",
        //         controllerAs: "toast",
        //         templateUrl: "app/layout/toast.html",
        //         hideDelay: 6000,
        //         position: "bottom right"
        //     });
        // };
    }
}());
<commit_msg>Remove $broadcast.<commit_after>"use strict";

(function () {
    angular
        .module("argo")
        .controller("Default", Default);

    Default.$inject = ["$mdDialog", "$mdBottomSheet", "accountsService"];

    function Default($mdDialog, $mdBottomSheet, accountsService) {
        var vm = this;

        vm.tabSelectedIndex = 0;

        vm.next = function () {
            vm.tabSelectedIndex = Math.min(vm.tabSelectedIndex + 1, 5);
        };
        vm.previous = function () {
            vm.tabSelectedIndex = Math.max(vm.tabSelectedIndex - 1, 0);
        };

        vm.openTokenDialog = function (event) {
            $mdDialog.show({
                controller: "TokenDialog",
                controllerAs: "dialog",
                templateUrl: "app/layout/token-dialog.html",
                targetEvent: event
            }).then(function(tokenInfo) {
                if (tokenInfo) {
                    vm.environment = tokenInfo.environment;
                    vm.token = tokenInfo.token;
                } else {
                    vm.environment = "";
                    vm.token = "";
                    vm.accountId = "";
                }

                accountsService.getAccounts({
                    environment: vm.environment,
                    token: vm.token
                }).then(function (accounts) {
                    $mdBottomSheet.show({
                        controller: "AccountsBottomSheet",
                        controllerAs: "sheet",
                        templateUrl: "app/account/accounts-bottomsheet.html",
                        locals: {accounts: accounts},
                        targetEvent: event
                    }).then(function (accountSelected) {
                        vm.accountId = accountSelected.accountId;

                        accountsService.getAccounts({
                            environment: vm.environment,
                            token: vm.token,
                            accountId: vm.accountId
                        }).then(function (account) {
                            vm.account = account;
                        });
                    });
                });
            });
        };

        // vm.showCustomToast = function () {
        //     $mdToast.show({
        //         controller: "MyToast",
        //         controllerAs: "toast",
        //         templateUrl: "app/layout/toast.html",
        //         hideDelay: 6000,
        //         position: "bottom right"
        //     });
        // };
    }
}());
<|endoftext|>


<commit_before>'use strict';

angular.module('psui-datepicker', ['psui'])
.directive('psuiDatepicker', [function () {
	return {
		restrict: 'AE',
		scope: {
			ngModel: "=?"
		},
		require: ['?ngModel'],
		link: function(scope, elm, attrs, ctrls) {

			var ngModel = null;
			if (ctrls && ctrls[0]) {
				ngModel = ctrls[0];
			}

			// use empty function to commit data, it will be overriden if there is ngModel
			var commitData = function() {
			}

			var commitDataDiv = function() {
			}

			if (ngModel) {
				commitData = function() {
					ngModel.$setViewValue(elm.val());
				}

				commitDataDiv = function() {
					ngModel.$setViewValue(elm.text());
				}
			}

			var wrapper;
			var isDropdownVisible = false;

			// create base html elements
			if (elm.parent().hasClass('psui-wrapper')) {
				// element is wrapped, we are going to use this wrapper
				wrapper = elm.parent;
			} else {
				// there is no wrapper, we have to create one
				wrapper = angular.element('

');
				elm.wrap(wrapper);
			}

			if (elm.nodeName === "psui-datepicker") {
				// we are element
			} else {
				// we are attribute
			}

			elm.addClass('psui-datepicker');

			var dropdown = angular.element('

');
			wrapper.append(dropdown);

			dropdown.addClass('psui-datepicker-dropdown');

			var buttonsHolder = angular.element('

');
			wrapper.append(buttonsHolder);

			var buttonShowDropdown = angular.element('<button>v</button>');
			buttonsHolder.append(buttonShowDropdown);
			buttonShowDropdown.on('click', function(evt) {
				if (dropdown.hasClass('psui-hidden')) {
					dropdown.removeClass('psui-hidden');
					if (elm.val()){
						var arr = elm.val().split(".");
						if((arr[0] && arr[1] && arr[2]) && arr[2]<2200 && arr[2]>1800 && arr[0]>0 && arr[0]<32 && arr[1]>0 && arr[1]<13){
							arr[1]= arr[1]-1;
							var datum = new Date(arr[2], arr[1], arr[0]);
							dateTbody.empty();
							makeDateTable(datum);
						}
					}
				} else {
					dropdown.addClass('psui-hidden');
				}
			});

			elm.on('dblclick', function(evt){
				if (dropdown.hasClass('psui-hidden')) {
					if(elm.val()){
						var arr = elm.val().split(".");
						if((arr[0] && arr[1] && arr[2]) && arr[2]<2200 && arr[2]>1800 && arr[0]>0 && arr[0]<32 && arr[1]>0 && arr[1]<13){
							arr[1]= arr[1]-1;
							var datum = new Date(arr[2], arr[1], arr[0]);
							dateTbody.empty();
							makeDateTable(datum);
						}
					}
					dropdown.removeClass('psui-hidden');
				} else {
					dropdown.addClass('psui-hidden');
				}
			})

			var dateTable = angular.element('

');
			var dateTbody = angular.element('

');
			dateTable.append(dateTbody);
			dropdown.append(dateTable);

			var whichMonth = function(month){
				if (month == 0){
					return "Jan";
				}else if (month == 1){
					return "Feb";
				}else if (month == 2){
					return "Mar";
				}else if (month == 3){
					return "Apr";
				}else if (month == 4){
					return "Maj";
				}else if (month == 5){
					return "Jun";
				}else if (month == 6){
					return "Jul";
				}else if (month == 7){
					return "Aug";
				}else if (month == 8){
					return "Sep";
				}else if (month == 9){
					return "Okt";
				}else if (month == 10){
					return "Nov";
				}else if (month == 11){
					return "Dec";
				}
			}

			var makeDateTable = function(date){
				var tr,td;

				tr = angular.element('

');

				td = angular.element('«	');
				td.data("datum",new Date(date.getTime()));
				td.on('click', function(evt){

					var element = angular.element(evt.target);
					var prevMonth = new Date (element.data("datum").getTime());
					prevMonth.setMonth(prevMonth.getMonth()-1);
					dateTbody.empty();
					makeDateTable(prevMonth);
				})
				tr.append(td);
				td = angular.element('' + whichMonth(date.getMonth()) + ' ' + date.getFullYear() + '	');
				td.data("datum",new Date(date.getTime()));
				td.on('click',function(evt){
					var element = angular.element(evt.target);
					var thisMonth = new Date (element.data("datum").getTime());
					dateTbody.empty();
					makeMonthTable(thisMonth);
				})
				tr.append(td);
				td = angular.element('»	');
				td.data("datum",new Date(date.getTime()));
				td.on('click', function(evt){

					var element = angular.element(evt.target);
					var nextMonth = new Date (element.data("datum").getTime());
					nextMonth.setMonth(nextMonth.getMonth()+1);
					dateTbody.empty();
					makeDateTable(nextMonth);
				})
				tr.append(td);
				dateTbody.append(tr);

				tr = angular.element('

');
				td = angular.element('Current Day	');
				td.data("datum", new Date() );
				td.on('click', function(evt){

					var element = angular.element(evt.target);
					var curDate = new Date (element.data("datum").getTime());
					dateTbody.empty();
					makeDateTable(curDate);

				})
				tr.append(td);
				dateTbody.append(tr);

				tr = angular.element('

');

				td = angular.element('Po	');
				tr.append(td);
				td = angular.element('Ut	');
				tr.append(td);
				td = angular.element('St	');
				tr.append(td);
				td = angular.element('Št	');
				tr.append(td);
				td = angular.element('Pi	');
				tr.append(td);
				td = angular.element('So	');
				tr.append(td);
				td = angular.element('Ne	');
				tr.append(td);

				dateTbody.append(tr);

				var month = date.getMonth();

				var dayNumber = date.getDate();
				date.setDate(date.getDate()-dayNumber +1);

				var whichDay = date.getDay() -1;
				if (whichDay == -1){
					whichDay = 6;
				}

				if (whichDay == 0){
				date.setDate(date.getDate()-7);
				}else {
				date.setDate(date.getDate()- whichDay);
				}

				for (var i = 0; i<6; i++){
					tr = angular.element('

');
					for (var j = 0; j<7; j++){
						if (month == date.getMonth()){
							td = angular.element('' + date.getDate() + '	');
						} else{
							td = angular.element('' + date.getDate() + '	');
						}
						td.data("datum",new Date(date.getTime()));

						td.on('click', function(evt){
							var element = angular.element(evt.target);
							var chosenDay = element.data("datum").getDate();
							var chosenMonth = element.data("datum").getMonth() + 1;
							var chosenYear = element.data("datum").getFullYear();

							if (elm[0].nodeName == "DIV"){
								elm.text(chosenDay + '.' + chosenMonth + '.' + chosenYear);
								scope.$apply(commitDataDiv);
							} else {
								elm.val(chosenDay + '.' + chosenMonth + '.' + chosenYear);
								scope.$apply(commitData);
							}

							dropdown.addClass('psui-hidden');
						})
						tr.append(td);
						date.setDate(date.getDate() + 1);
					}
					dateTbody.append(tr);
				}

			}

			var makeMonthTable = function(date){
				var tr,td;

				tr = angular.element('

');

				td = angular.element('«	');
				td.data("datum",new Date(date.getTime()));
				td.on('click', function(evt){

					var element = angular.element(evt.target);
					var prevYear = new Date (element.data("datum").getTime());
					prevYear.setFullYear(prevYear.getFullYear()-1);
					dateTbody.empty();
					makeMonthTable(prevYear);
				})
				tr.append(td);
				td = angular.element('' + date.getFullYear() + '	');
				td.data("datum",new Date(date.getTime()));
				td.on('click',function(evt){
					var element = angular.element(evt.target);
					var thisYear = new Date (element.data("datum").getTime());
					dateTbody.empty();
					makeYearTable(thisYear);
				})
				tr.append(td);
				td = angular.element('»	');
				td.data("datum",new Date(date.getTime()));
				td.on('click', function(evt){

					var element = angular.element(evt.target);
					var nextYear = new Date (element.data("datum").getTime());
					nextYear.setFullYear(nextYear.getFullYear()+1);
					dateTbody.empty();
					makeMonthTable(nextYear);
				})
				tr.append(td);
				dateTbody.append(tr);

				tr = angular.element('

');
				td = angular.element('Current Day	');
				td.data("datum", new Date() );
				td.on('click', function(evt){

					var element = angular.element(evt.target);
					var curDate = new Date (element.data("datum").getTime());
					dateTbody.empty();
					makeDateTable(curDate);

				})
				tr.append(td);
				dateTbody.append(tr);

				var month = 0;
				var dateMonthTable = new Date (date.getTime());
				for (var i = 0; i<3; i++){
					tr = angular.element('

');
					for (var j = 0; j<4; j++){
						td = angular.element('' + whichMonth(month) + '	');
						dateMonthTable.setMonth(month);
						td.data("datum",new Date(dateMonthTable.getTime()));

						td.on('click', function(evt){
							var element = angular.element(evt.target);
							var thisDate = new Date (element.data("datum").getTime());
							dateTbody.empty();
							makeDateTable(thisDate);
						})
						tr.append(td);
						month = month + 1;
					}
					dateTbody.append(tr);
				}

			}

			var makeYearTable = function(date){
				var tr,td;

				tr = angular.element('

');

				td = angular.element('«	');
				td.data("datum",new Date(date.getTime()));
				td.on('click', function(evt){

					var element = angular.element(evt.target);
					var prevYears = new Date (element.data("datum").getTime());
					prevYears.setFullYear(prevYears.getFullYear()-9);
					dateTbody.empty();
					makeYearTable(prevYears);
				})
				tr.append(td);
				td = angular.element('	');
				tr.append(td);
				td = angular.element('»	');
				td.data("datum",new Date(date.getTime()));
				td.on('click', function(evt){

					var element = angular.element(evt.target);
					var nextYears = new Date (element.data("datum").getTime());
					nextYears.setFullYear(nextYears.getFullYear()+9);
					dateTbody.empty();
					makeYearTable(nextYears);
				})
				tr.append(td);
				dateTbody.append(tr);

				tr = angular.element('

');
				td = angular.element('Current Day	');
				td.data("datum", new Date() );
				td.on('click', function(evt){

					var element = angular.element(evt.target);
					var curDate = new Date (element.data("datum").getTime());
					dateTbody.empty();
					makeDateTable(curDate);

				})
				tr.append(td);
				dateTbody.append(tr);

				var year = date.getFullYear() - 4;
				var dateYearTable = new Date (date.getTime());

				for (var i = 0; i<3; i++){
					tr = angular.element('

');
					for (var j = 0; j<3; j++){
						td = angular.element('' + year + '	');
						dateYearTable.setFullYear(year);
						td.data("datum",new Date(dateYearTable.getTime()));

						td.on('click', function(evt){
							var element = angular.element(evt.target);
							var thisYear = new Date (element.data("datum").getTime());
							dateTbody.empty();
							makeMonthTable(thisYear);
						})
						tr.append(td);
						year = year + 1;
					}
					dateTbody.append(tr);
				}

			}

			var d = new Date();

			makeDateTable(d);

		}
	}
}])<commit_msg>Blur functionality on datepicker added.<commit_after>'use strict';

angular.module('psui-datepicker', ['psui'])
.directive('psuiDatepicker', [function () {
	return {
		restrict: 'AE',
		scope: {
			ngModel: "=?"
		},
		require: ['?ngModel'],
		link: function(scope, elm, attrs, ctrls) {

			var ngModel = null;
			if (ctrls && ctrls[0]) {
				ngModel = ctrls[0];
			}

			// use empty function to commit data, it will be overriden if there is ngModel
			var commitData = function() {
			}

			var commitDataDiv = function() {
			}

			if (ngModel) {
				commitData = function() {
					ngModel.$setViewValue(elm.val());
				}

				commitDataDiv = function() {
					ngModel.$setViewValue(elm.text());
				}
			}

			var wrapper;
			var isDropdownVisible = false;
			var state = 0;
			// create base html elements
			if (elm.parent().hasClass('psui-wrapper')) {
				// element is wrapped, we are going to use this wrapper
				wrapper = elm.parent;
			} else {
				// there is no wrapper, we have to create one
				wrapper = angular.element('

');
				elm.wrap(wrapper);
			}

			if (elm.nodeName === "psui-datepicker") {
				// we are element
			} else {
				// we are attribute
			}

			elm.addClass('psui-datepicker');

			var dropdown = angular.element('

');
			wrapper.append(dropdown);

			dropdown.addClass('psui-datepicker-dropdown');

			var buttonsHolder = angular.element('

');
			wrapper.append(buttonsHolder);

			var buttonShowDropdown = angular.element('<button>v</button>');
			buttonsHolder.append(buttonShowDropdown);

			elm.on('blur',function(evt){
				dropdown.addClass('psui-hidden');
				state=0;
			})

			elm.on('focus',function(evt){
				dropdown.addClass('psui-hidden');
				state=1;
			})

			elm.on('click',function(evt){
				if (state =1){
					dropdown.addClass('psui-hidden');
				}
			})

			buttonShowDropdown.on('blur',function(evt){
				dropdown.addClass('psui-hidden');
			})

			buttonShowDropdown.on('click', function(evt) {
				if (dropdown.hasClass('psui-hidden')) {
					dropdown.removeClass('psui-hidden');
					if (elm.val()){
						var arr = elm.val().split(".");
						if((arr[0] && arr[1] && arr[2]) && arr[2]<2200 && arr[2]>1800 && arr[0]>0 && arr[0]<32 && arr[1]>0 && arr[1]<13){
							arr[1]= arr[1]-1;
							var datum = new Date(arr[2], arr[1], arr[0]);
							dateTbody.empty();
							makeDateTable(datum);
						}
					}
				} else {
					dropdown.addClass('psui-hidden');
				}
			});

			elm.on('dblclick', function(evt){
				if (dropdown.hasClass('psui-hidden')) {
					if(elm.val()){
						var arr = elm.val().split(".");
						if((arr[0] && arr[1] && arr[2]) && arr[2]<2200 && arr[2]>1800 && arr[0]>0 && arr[0]<32 && arr[1]>0 && arr[1]<13){
							arr[1]= arr[1]-1;
							var datum = new Date(arr[2], arr[1], arr[0]);
							dateTbody.empty();
							makeDateTable(datum);
						}
					}
					dropdown.removeClass('psui-hidden');
				} else {
					dropdown.addClass('psui-hidden');
				}
			})

			var dateTable = angular.element('

');
			var dateTbody = angular.element('

');
			dateTable.append(dateTbody);
			dropdown.append(dateTable);

			var whichMonth = function(month){
				if (month == 0){
					return "Jan";
				}else if (month == 1){
					return "Feb";
				}else if (month == 2){
					return "Mar";
				}else if (month == 3){
					return "Apr";
				}else if (month == 4){
					return "Maj";
				}else if (month == 5){
					return "Jun";
				}else if (month == 6){
					return "Jul";
				}else if (month == 7){
					return "Aug";
				}else if (month == 8){
					return "Sep";
				}else if (month == 9){
					return "Okt";
				}else if (month == 10){
					return "Nov";
				}else if (month == 11){
					return "Dec";
				}
			}

			var makeDateTable = function(date){
				var tr,td;

				tr = angular.element('

');

				td = angular.element('«	');
				td.data("datum",new Date(date.getTime()));
				td.on('click', function(evt){

					var element = angular.element(evt.target);
					var prevMonth = new Date (element.data("datum").getTime());
					prevMonth.setMonth(prevMonth.getMonth()-1);
					dateTbody.empty();
					makeDateTable(prevMonth);
				})
				tr.append(td);
				td = angular.element('' + whichMonth(date.getMonth()) + ' ' + date.getFullYear() + '	');
				td.data("datum",new Date(date.getTime()));
				td.on('click',function(evt){
					var element = angular.element(evt.target);
					var thisMonth = new Date (element.data("datum").getTime());
					dateTbody.empty();
					makeMonthTable(thisMonth);
				})
				tr.append(td);
				td = angular.element('»	');
				td.data("datum",new Date(date.getTime()));
				td.on('click', function(evt){

					var element = angular.element(evt.target);
					var nextMonth = new Date (element.data("datum").getTime());
					nextMonth.setMonth(nextMonth.getMonth()+1);
					dateTbody.empty();
					makeDateTable(nextMonth);
				})
				tr.append(td);
				dateTbody.append(tr);

				tr = angular.element('

');
				td = angular.element('Current Day	');
				td.data("datum", new Date() );
				td.on('click', function(evt){

					var element = angular.element(evt.target);
					var curDate = new Date (element.data("datum").getTime());
					dateTbody.empty();
					makeDateTable(curDate);

				})
				tr.append(td);
				dateTbody.append(tr);

				tr = angular.element('

');

				td = angular.element('Po	');
				tr.append(td);
				td = angular.element('Ut	');
				tr.append(td);
				td = angular.element('St	');
				tr.append(td);
				td = angular.element('Št	');
				tr.append(td);
				td = angular.element('Pi	');
				tr.append(td);
				td = angular.element('So	');
				tr.append(td);
				td = angular.element('Ne	');
				tr.append(td);

				dateTbody.append(tr);

				var month = date.getMonth();

				var dayNumber = date.getDate();
				date.setDate(date.getDate()-dayNumber +1);

				var whichDay = date.getDay() -1;
				if (whichDay == -1){
					whichDay = 6;
				}

				if (whichDay == 0){
				date.setDate(date.getDate()-7);
				}else {
				date.setDate(date.getDate()- whichDay);
				}

				for (var i = 0; i<6; i++){
					tr = angular.element('

');
					for (var j = 0; j<7; j++){
						if (month == date.getMonth()){
							td = angular.element('' + date.getDate() + '	');
						} else{
							td = angular.element('' + date.getDate() + '	');
						}
						td.data("datum",new Date(date.getTime()));

						td.on('click', function(evt){
							var element = angular.element(evt.target);
							var chosenDay = element.data("datum").getDate();
							var chosenMonth = element.data("datum").getMonth() + 1;
							var chosenYear = element.data("datum").getFullYear();

							if (elm[0].nodeName == "DIV"){
								elm.text(chosenDay + '.' + chosenMonth + '.' + chosenYear);
								scope.$apply(commitDataDiv);
							} else {
								elm.val(chosenDay + '.' + chosenMonth + '.' + chosenYear);
								scope.$apply(commitData);
							}

							dropdown.addClass('psui-hidden');
						})
						tr.append(td);
						date.setDate(date.getDate() + 1);
					}
					dateTbody.append(tr);
				}

			}

			var makeMonthTable = function(date){
				var tr,td;

				tr = angular.element('

');

				td = angular.element('«	');
				td.data("datum",new Date(date.getTime()));
				td.on('click', function(evt){

					var element = angular.element(evt.target);
					var prevYear = new Date (element.data("datum").getTime());
					prevYear.setFullYear(prevYear.getFullYear()-1);
					dateTbody.empty();
					makeMonthTable(prevYear);
				})
				tr.append(td);
				td = angular.element('' + date.getFullYear() + '	');
				td.data("datum",new Date(date.getTime()));
				td.on('click',function(evt){
					var element = angular.element(evt.target);
					var thisYear = new Date (element.data("datum").getTime());
					dateTbody.empty();
					makeYearTable(thisYear);
				})
				tr.append(td);
				td = angular.element('»	');
				td.data("datum",new Date(date.getTime()));
				td.on('click', function(evt){

					var element = angular.element(evt.target);
					var nextYear = new Date (element.data("datum").getTime());
					nextYear.setFullYear(nextYear.getFullYear()+1);
					dateTbody.empty();
					makeMonthTable(nextYear);
				})
				tr.append(td);
				dateTbody.append(tr);

				tr = angular.element('

');
				td = angular.element('Current Day	');
				td.data("datum", new Date() );
				td.on('click', function(evt){

					var element = angular.element(evt.target);
					var curDate = new Date (element.data("datum").getTime());
					dateTbody.empty();
					makeDateTable(curDate);

				})
				tr.append(td);
				dateTbody.append(tr);

				var month = 0;
				var dateMonthTable = new Date (date.getTime());
				for (var i = 0; i<3; i++){
					tr = angular.element('

');
					for (var j = 0; j<4; j++){
						td = angular.element('' + whichMonth(month) + '	');
						dateMonthTable.setMonth(month);
						td.data("datum",new Date(dateMonthTable.getTime()));

						td.on('click', function(evt){
							var element = angular.element(evt.target);
							var thisDate = new Date (element.data("datum").getTime());
							dateTbody.empty();
							makeDateTable(thisDate);
						})
						tr.append(td);
						month = month + 1;
					}
					dateTbody.append(tr);
				}

			}

			var makeYearTable = function(date){
				var tr,td;

				tr = angular.element('

');

				td = angular.element('«	');
				td.data("datum",new Date(date.getTime()));
				td.on('click', function(evt){

					var element = angular.element(evt.target);
					var prevYears = new Date (element.data("datum").getTime());
					prevYears.setFullYear(prevYears.getFullYear()-9);
					dateTbody.empty();
					makeYearTable(prevYears);
				})
				tr.append(td);
				td = angular.element('	');
				tr.append(td);
				td = angular.element('»	');
				td.data("datum",new Date(date.getTime()));
				td.on('click', function(evt){

					var element = angular.element(evt.target);
					var nextYears = new Date (element.data("datum").getTime());
					nextYears.setFullYear(nextYears.getFullYear()+9);
					dateTbody.empty();
					makeYearTable(nextYears);
				})
				tr.append(td);
				dateTbody.append(tr);

				tr = angular.element('

');
				td = angular.element('Current Day	');
				td.data("datum", new Date() );
				td.on('click', function(evt){

					var element = angular.element(evt.target);
					var curDate = new Date (element.data("datum").getTime());
					dateTbody.empty();
					makeDateTable(curDate);

				})
				tr.append(td);
				dateTbody.append(tr);

				var year = date.getFullYear() - 4;
				var dateYearTable = new Date (date.getTime());

				for (var i = 0; i<3; i++){
					tr = angular.element('

');
					for (var j = 0; j<3; j++){
						td = angular.element('' + year + '	');
						dateYearTable.setFullYear(year);
						td.data("datum",new Date(dateYearTable.getTime()));

						td.on('click', function(evt){
							var element = angular.element(evt.target);
							var thisYear = new Date (element.data("datum").getTime());
							dateTbody.empty();
							makeMonthTable(thisYear);
						})
						tr.append(td);
						year = year + 1;
					}
					dateTbody.append(tr);
				}

			}

			var d = new Date();

			makeDateTable(d);

		}
	}
}])<|endoftext|>