<commit_before>'use strict';

/*
* When adding names to the namespace, ensure that they are added in alphabetical order according to alias (namespace key).
*/

var ns = [];

ns.push({
	'alias': 'tabulate',
	'path': '@stdlib/utils/tabulate',
	'value': require( '@stdlib/utils/tabulate' ),
	'type': 'Function',
	'related': [
		'@stdlib/utils/count-by',
		'@stdlib/utils/group-by',
		'@stdlib/utils/tabulate-by'
	]
});

ns.push({
	'alias': 'tabulateBy',
	'path': '@stdlib/utils/tabulate-by',
	'value': require( '@stdlib/utils/tabulate-by' ),
	'type': 'Function',
	'related': [
		'@stdlib/utils/count-by',
		'@stdlib/utils/group-by',
		'@stdlib/utils/tabulate'
	]
});

ns.push({
	'alias': 'tabulateByAsync',
	'path': '@stdlib/utils/tabulate-by-async',
	'value': require( '@stdlib/utils/tabulate-by-async' ),
	'type': 'Function',
	'related': [
		'@stdlib/utils/count-by-async',
		'@stdlib/utils/group-by-async',
		'@stdlib/utils/tabulate-by'
	]
});

ns.push({
	'alias': 'tic',
	'path': '@stdlib/time/tic',
	'value': require( '@stdlib/time/tic' ),
	'type': 'Function',
	'related': [
		'@stdlib/time/toc'
	]
});

ns.push({
	'alias': 'timeit',
	'path': '@stdlib/utils/timeit',
	'value': require( '@stdlib/utils/timeit' ),
	'type': 'Function',
	'related': []
});

ns.push({
	'alias': 'tmpdir',
	'path': '@stdlib/utils/tmpdir',
	'value': require( '@stdlib/utils/tmpdir' ),
	'type': 'Function',
	'related': [
		'@stdlib/utils/configdir',
		'@stdlib/utils/homedir'
	]
});

ns.push({
	'alias': 'toc',
	'path': '@stdlib/time/toc',
	'value': require( '@stdlib/time/toc' ),
	'type': 'Function',
	'related': [
		'@stdlib/time/tic'
	]
});

ns.push({
	'alias': 'trim',
	'path': '@stdlib/string/trim',
	'value': require( '@stdlib/string/trim' ),
	'type': 'Function',
	'related': [
		'@stdlib/string/left-trim',
		'@stdlib/string/pad',
		'@stdlib/string/right-trim'
	]
});

ns.push({
	'alias': 'trycatch',
	'path': '@stdlib/utils/try-catch',
	'value': require( '@stdlib/utils/try-catch' ),
	'type': 'Function',
	'related': [
		'@stdlib/utils/try-catch-async',
		'@stdlib/utils/try-then'
	]
});

ns.push({
	'alias': 'trycatchAsync',
	'path': '@stdlib/utils/try-catch-async',
	'value': require( '@stdlib/utils/try-catch-async' ),
	'type': 'Function',
	'related': [
		'@stdlib/utils/try-catch',
		'@stdlib/utils/try-then-async'
	]
});

ns.push({
	'alias': 'tryFunction',
	'path': '@stdlib/utils/try-function',
	'value': require( '@stdlib/utils/try-function' ),
	'type': 'Function',
	'related': []
});

ns.push({
	'alias': 'tryRequire',
	'path': '@stdlib/utils/try-require',
	'value': require( '@stdlib/utils/try-require' ),
	'type': 'Function',
	'related': []
});

ns.push({
	'alias': 'trythen',
	'path': '@stdlib/utils/try-then',
	'value': require( '@stdlib/utils/try-then' ),
	'type': 'Function',
	'related': [
		'@stdlib/utils/try-catch',
		'@stdlib/utils/try-then-async'
	]
});

ns.push({
	'alias': 'trythenAsync',
	'path': '@stdlib/utils/try-then-async',
	'value': require( '@stdlib/utils/try-then-async' ),
	'type': 'Function',
	'related': [
		'@stdlib/utils/try-catch-async',
		'@stdlib/utils/try-then'
	]
});

ns.push({
	'alias': 'ttest',
	'path': '@stdlib/math/statistics/ttest',
	'value': require( '@stdlib/math/statistics/ttest' ),
	'type': 'Function',
	'related': [
		'@stdlib/math/statistics/ttest2'
	]
});

ns.push({
	'alias': 'ttest2',
	'path': '@stdlib/math/statistics/ttest2',
	'value': require( '@stdlib/math/statistics/ttest2' ),
	'type': 'Function',
	'related': [
		'@stdlib/math/statistics/ttest'
	]
});

ns.push({
	'alias': 'TWO_PI',
	'path': '@stdlib/math/constants/float64-two-pi',
	'value': require( '@stdlib/math/constants/float64-two-pi' ),
	'type': 'number',
	'related': [
		'@stdlib/math/constants/float64-pi'
	]
});

ns.push({
	'alias': 'typedarray2json',
	'path': '@stdlib/types/array/to-json',
	'value': require( '@stdlib/types/array/to-json' ),
	'type': 'Function',
	'related': [
		'@stdlib/types/array/reviver'
	]
});

ns.push({
	'alias': 'typedarray',
	'path': '@stdlib/types/array/typed',
	'value': require( '@stdlib/types/array/typed' ),
	'type': 'Function',
	'related': [
		'@stdlib/types/array/float64',
		'@stdlib/types/array/float32',
		'@stdlib/types/array/int32',
		'@stdlib/types/array/uint32',
		'@stdlib/types/array/int16',
		'@stdlib/types/array/uint16',
		'@stdlib/types/array/int8',
		'@stdlib/types/array/uint8',
		'@stdlib/types/array/uint8c'
	]
});

ns.push({
	'alias': 'typemax',
	'path': '@stdlib/types/utils/typemax',
	'value': require( '@stdlib/types/utils/typemax' ),
	'type': 'Function',
	'related': [
		'@stdlib/math/utils/realmax',
		'@stdlib/types/utils/typemin'
	]
});

ns.push({
	'alias': 'typemin',
	'path': '@stdlib/types/utils/typemin',
	'value': require( '@stdlib/types/utils/typemin' ),
	'type': 'Function',
	'related': [
		'@stdlib/math/utils/realmin',
		'@stdlib/types/utils/typemax'
	]
});

ns.push({
	'alias': 'typeOf',
	'path': '@stdlib/utils/type-of',
	'value': require( '@stdlib/utils/type-of' ),
	'type': 'Function',
	'related': [
		'@stdlib/utils/constructor-name',
		'@stdlib/utils/native-class'
	]
});

// EXPORTS //

module.exports = ns;
<commit_msg>Update paths<commit_after>'use strict';

/*
* When adding names to the namespace, ensure that they are added in alphabetical order according to alias (namespace key).
*/

var ns = [];

ns.push({
	'alias': 'tabulate',
	'path': '@stdlib/utils/tabulate',
	'value': require( '@stdlib/utils/tabulate' ),
	'type': 'Function',
	'related': [
		'@stdlib/utils/count-by',
		'@stdlib/utils/group-by',
		'@stdlib/utils/tabulate-by'
	]
});

ns.push({
	'alias': 'tabulateBy',
	'path': '@stdlib/utils/tabulate-by',
	'value': require( '@stdlib/utils/tabulate-by' ),
	'type': 'Function',
	'related': [
		'@stdlib/utils/count-by',
		'@stdlib/utils/group-by',
		'@stdlib/utils/tabulate'
	]
});

ns.push({
	'alias': 'tabulateByAsync',
	'path': '@stdlib/utils/tabulate-by-async',
	'value': require( '@stdlib/utils/tabulate-by-async' ),
	'type': 'Function',
	'related': [
		'@stdlib/utils/count-by-async',
		'@stdlib/utils/group-by-async',
		'@stdlib/utils/tabulate-by'
	]
});

ns.push({
	'alias': 'tic',
	'path': '@stdlib/time/tic',
	'value': require( '@stdlib/time/tic' ),
	'type': 'Function',
	'related': [
		'@stdlib/time/toc'
	]
});

ns.push({
	'alias': 'timeit',
	'path': '@stdlib/utils/timeit',
	'value': require( '@stdlib/utils/timeit' ),
	'type': 'Function',
	'related': []
});

ns.push({
	'alias': 'tmpdir',
	'path': '@stdlib/utils/tmpdir',
	'value': require( '@stdlib/utils/tmpdir' ),
	'type': 'Function',
	'related': [
		'@stdlib/utils/configdir',
		'@stdlib/utils/homedir'
	]
});

ns.push({
	'alias': 'toc',
	'path': '@stdlib/time/toc',
	'value': require( '@stdlib/time/toc' ),
	'type': 'Function',
	'related': [
		'@stdlib/time/tic'
	]
});

ns.push({
	'alias': 'trim',
	'path': '@stdlib/string/trim',
	'value': require( '@stdlib/string/trim' ),
	'type': 'Function',
	'related': [
		'@stdlib/string/left-trim',
		'@stdlib/string/pad',
		'@stdlib/string/right-trim'
	]
});

ns.push({
	'alias': 'trycatch',
	'path': '@stdlib/utils/try-catch',
	'value': require( '@stdlib/utils/try-catch' ),
	'type': 'Function',
	'related': [
		'@stdlib/utils/try-catch-async',
		'@stdlib/utils/try-then'
	]
});

ns.push({
	'alias': 'trycatchAsync',
	'path': '@stdlib/utils/try-catch-async',
	'value': require( '@stdlib/utils/try-catch-async' ),
	'type': 'Function',
	'related': [
		'@stdlib/utils/try-catch',
		'@stdlib/utils/try-then-async'
	]
});

ns.push({
	'alias': 'tryFunction',
	'path': '@stdlib/utils/try-function',
	'value': require( '@stdlib/utils/try-function' ),
	'type': 'Function',
	'related': []
});

ns.push({
	'alias': 'tryRequire',
	'path': '@stdlib/utils/try-require',
	'value': require( '@stdlib/utils/try-require' ),
	'type': 'Function',
	'related': []
});

ns.push({
	'alias': 'trythen',
	'path': '@stdlib/utils/try-then',
	'value': require( '@stdlib/utils/try-then' ),
	'type': 'Function',
	'related': [
		'@stdlib/utils/try-catch',
		'@stdlib/utils/try-then-async'
	]
});

ns.push({
	'alias': 'trythenAsync',
	'path': '@stdlib/utils/try-then-async',
	'value': require( '@stdlib/utils/try-then-async' ),
	'type': 'Function',
	'related': [
		'@stdlib/utils/try-catch-async',
		'@stdlib/utils/try-then'
	]
});

ns.push({
	'alias': 'ttest',
	'path': '@stdlib/math/statistics/ttest',
	'value': require( '@stdlib/math/statistics/ttest' ),
	'type': 'Function',
	'related': [
		'@stdlib/math/statistics/ttest2'
	]
});

ns.push({
	'alias': 'ttest2',
	'path': '@stdlib/math/statistics/ttest2',
	'value': require( '@stdlib/math/statistics/ttest2' ),
	'type': 'Function',
	'related': [
		'@stdlib/math/statistics/ttest'
	]
});

ns.push({
	'alias': 'TWO_PI',
	'path': '@stdlib/math/constants/float64-two-pi',
	'value': require( '@stdlib/math/constants/float64-two-pi' ),
	'type': 'number',
	'related': [
		'@stdlib/math/constants/float64-pi'
	]
});

ns.push({
	'alias': 'typedarray2json',
	'path': '@stdlib/types/array/to-json',
	'value': require( '@stdlib/types/array/to-json' ),
	'type': 'Function',
	'related': [
		'@stdlib/types/array/reviver'
	]
});

ns.push({
	'alias': 'typedarray',
	'path': '@stdlib/types/array/typed',
	'value': require( '@stdlib/types/array/typed' ),
	'type': 'Function',
	'related': [
		'@stdlib/types/array/float64',
		'@stdlib/types/array/float32',
		'@stdlib/types/array/int32',
		'@stdlib/types/array/uint32',
		'@stdlib/types/array/int16',
		'@stdlib/types/array/uint16',
		'@stdlib/types/array/int8',
		'@stdlib/types/array/uint8',
		'@stdlib/types/array/uint8c'
	]
});

ns.push({
	'alias': 'typemax',
	'path': '@stdlib/types/utils/typemax',
	'value': require( '@stdlib/types/utils/typemax' ),
	'type': 'Function',
	'related': [
		'@stdlib/types/utils/realmax',
		'@stdlib/types/utils/typemin'
	]
});

ns.push({
	'alias': 'typemin',
	'path': '@stdlib/types/utils/typemin',
	'value': require( '@stdlib/types/utils/typemin' ),
	'type': 'Function',
	'related': [
		'@stdlib/types/utils/realmin',
		'@stdlib/types/utils/typemax'
	]
});

ns.push({
	'alias': 'typeOf',
	'path': '@stdlib/utils/type-of',
	'value': require( '@stdlib/utils/type-of' ),
	'type': 'Function',
	'related': [
		'@stdlib/utils/constructor-name',
		'@stdlib/utils/native-class'
	]
});

// EXPORTS //

module.exports = ns;
<|endoftext|>


<commit_before>/* eslint-env mocha, browser*/
/* global proclaim, it */

var arePropertyDescriptorsSupported = function () {
	var obj = {};
	try {
		Object.defineProperty(obj, 'x', { enumerable: false, value: obj });
        /* eslint-disable no-unused-vars, no-restricted-syntax */
        for (var _ in obj) { return false; }
        /* eslint-enable no-unused-vars, no-restricted-syntax */
		return obj.x === obj;
	} catch (e) { // this is IE 8.
		return false;
	}
};
var supportsDescriptors = Object.defineProperty && arePropertyDescriptorsSupported();

it('has the well known symbol iterator as static properties on Symbol', function() {
	proclaim.notEqual(Symbol.iterator, undefined);

	if (supportsDescriptors) {
		var iterator = Symbol.iterator;
		Symbol.iterator = "nope";
		proclaim.equal(Symbol.iterator, iterator);
	}
});

var hasNodeListGlobal = typeof NodeList !== 'undefined' ? it : xit;

hasNodeListGlobal('can attach to a NodeList correctly', function() {

	NodeList.prototype[Symbol.iterator] = function() {
		var called = false;
		var that = this;
		var i = 0;
		return {
			next: function() {
				if (called) {
					return {
						done: true
					};
				} else {
					called = true;
					return {
						done: false,
						value: that[0]
					};
				}
			}
		};
	};
	var ul = document.createElement('ul');
	ul.appendChild(document.createElement('li'));

	var dom = ul.childNodes;

	var iterator = dom[Symbol.iterator]();
	var entry;
	while(true) {
		entry = iterator.next();
		if (entry.done !== false) break;
		entry.value.innerHTML = 'Test';
	}

	proclaim.equal(dom[0].innerHTML, 'Test');
});
<commit_msg>remove unusued variable (#1316)<commit_after>/* eslint-env mocha, browser*/
/* global proclaim, it */

var arePropertyDescriptorsSupported = function () {
	var obj = {};
	try {
		Object.defineProperty(obj, 'x', { enumerable: false, value: obj });
        /* eslint-disable no-unused-vars, no-restricted-syntax */
        for (var _ in obj) { return false; }
        /* eslint-enable no-unused-vars, no-restricted-syntax */
		return obj.x === obj;
	} catch (e) { // this is IE 8.
		return false;
	}
};
var supportsDescriptors = Object.defineProperty && arePropertyDescriptorsSupported();

it('has the well known symbol iterator as static properties on Symbol', function() {
	proclaim.notEqual(Symbol.iterator, undefined);

	if (supportsDescriptors) {
		var iterator = Symbol.iterator;
		Symbol.iterator = "nope";
		proclaim.equal(Symbol.iterator, iterator);
	}
});

var hasNodeListGlobal = typeof NodeList !== 'undefined' ? it : xit;

hasNodeListGlobal('can attach to a NodeList correctly', function() {

	NodeList.prototype[Symbol.iterator] = function() {
		var called = false;
		var that = this;

		return {
			next: function() {
				if (called) {
					return {
						done: true
					};
				} else {
					called = true;
					return {
						done: false,
						value: that[0]
					};
				}
			}
		};
	};
	var ul = document.createElement('ul');
	ul.appendChild(document.createElement('li'));

	var dom = ul.childNodes;

	var iterator = dom[Symbol.iterator]();
	var entry;
	while(true) {
		entry = iterator.next();
		if (entry.done !== false) break;
		entry.value.innerHTML = 'Test';
	}

	proclaim.equal(dom[0].innerHTML, 'Test');
});
<|endoftext|>


<commit_before>/* jshint node: true */

module.exports = function(environment) {
    const authorizationType = 'cookie';

    const ENV = {
        modulePrefix: 'preprint-service',
        environment: environment,
        rootURL: '/',
        locationType: 'auto',
        authorizationType: authorizationType,
        sentryDSN: 'http://test@localhost/80' || process.env.SENTRY_DSN,
        'ember-simple-auth': {
            authorizer: `authorizer:osf-${authorizationType}`,
            authenticator: `authenticator:osf-${authorizationType}`
        },
        EmberENV: {
            FEATURES: {
                // Here you can enable experimental features on an ember canary build
                // e.g. 'with-controller': true
            }
        },
        APP: {
            // Here you can pass flags/options to your application instance
            // when it is created
        },
        SHARE: {
            baseUrl: process.env.SHARE_BASE_URL || 'https://staging-share.osf.io/',
            searchUrl: process.env.SHARE_SEARCH_URL || 'https://staging-share.osf.io/api/v2/search/creativeworks/_search'
        },
        moment: {
            outputFormat: 'YYYY-MM-DD hh:mm a'
        },
        PREPRINTS: {
            defaultProvider: 'osf',

            // Logos are needed for open graph sharing meta tags (Facebook, LinkedIn, etc) and must be at least 200x200
            providers: [
                // OSF must be the first provider
                {
                    id: 'osf',
                    domain: 'osf.io',
                    logoSharing: {
                        path: '/assets/img/provider_logos/osf-dark.png',
                        type: 'image/png',
                        width: 363,
                        height: 242
                    },
                    permissionLanguage: 'no_trademark'
                },
                {
                    id: 'engrxiv',
                    domain: 'engrxiv.com',
                    logoSharing: {
                        path: '/assets/img/provider_logos/engrxiv-sharing.png',
                        type: 'image/png',
                        width: 1200,
                        height: 488

                    },
                    permissionLanguage: 'arxiv_non_endorsement'

                },
                {
                    id: 'socarxiv',
                    domain: 'socarxiv.org',
                    logoSharing: {
                        path: '/assets/img/provider_logos/socarxiv-sharing.png',
                        type: 'image/png',
                        width: 1200,
                        height: 488
                    },
                    permissionLanguage: 'arxiv_trademark_license'
                },
                {
                    id: 'psyarxiv',
                    domain: 'psyarxiv.org',
                    logoSharing: {
                        path: '/assets/img/provider_logos/psyarxiv-sharing.png',
                        type: 'image/png',
                        width: 1200,
                        height: 488
                    },
                    permissionLanguage: 'arxiv_trademark_license'
                },
                {
                    id: 'bitss',
                    domain: 'bitss.org',
                    logoSharing: { // T
                        path: '/assets/img/provider_logos/bitss-small.png',
                        type: 'image/png',
                        width: 1500,
                        height: 1500
                    },
                    permissionLanguage: 'no_trademark'
                },
                {
                    id: 'scielo',
                    domain: 'scielo.org',
                    logoSharing: {
                        path: '/assets/img/provider_logos/scielo-logo.png',
                        type: 'image/png',
                        width: 1200,
                        height: 488
                    },
                    permissionLanguage: 'no_trademark'
                },
                {
                    id: 'agrixiv',
                    domain: 'agrixiv.org',
                    logoSharing: {
                        path: 'assets/img/provider_logos/agrixiv-banner.svg',
                        type: 'image/png',
                        width: 1200,
                        height: 488
                    },
                    permissionLanguage: 'arxiv_non_endorsement'
                }
            ],
        },
        i18n: {
            defaultLocale: 'en'
        },
        metricsAdapters: [
            {
                name: 'GoogleAnalytics',
                environments: ['all'],
                config: {
                    id: process.env.GOOGLE_ANALYTICS_ID
                }
            }
        ],
        FB_APP_ID: process.env.FB_APP_ID,
    };

    if (environment === 'development') {
        // ENV.APP.LOG_RESOLVER = true;
        // ENV.APP.LOG_ACTIVE_GENERATION = true;
        // ENV.APP.LOG_TRANSITIONS = true;
        // ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
        // ENV.APP.LOG_VIEW_LOOKUPS = true;

        ENV.metricsAdapters[0].config.cookieDomain = 'none';
    }

    if (environment === 'test') {
        // Testem prefers this...
        ENV.baseURL = '/';
        ENV.locationType = 'none';

        // keep test console output quieter
        ENV.APP.LOG_ACTIVE_GENERATION = false;
        ENV.APP.LOG_VIEW_LOOKUPS = false;

        ENV.APP.rootElement = '#ember-testing';

        // Don't make external requests during unit test
        // TODO: Provide mocks for all components with manual AJAX calls in the future.
        ENV.SHARE.baseUrl = '/nowhere';
        ENV.SHARE.searchUrl = '/nowhere';

        ENV.metricsAdapters[0].config.cookieDomain = 'none'
    }

    if (environment === 'production') {
        ENV.sentryDSN = process.env.SENTRY_DSN || 'https://2f0a61d03b99480ea11e259edec18bd9@sentry.cos.io/45';
        ENV.ASSET_SUFFIX = process.env.GIT_COMMIT || 'git_commit_env_not_set';
    } else {
        // Fallback to throwaway defaults if the environment variables are not set
        ENV.metricsAdapters[0].config.id = ENV.metricsAdapters[0].config.id || 'UA-84580271-1';
        ENV.FB_APP_ID = ENV.FB_APP_ID || '1039002926217080';

        const {DOMAIN_PREFIX, PORT, OSF_URL} = process.env;

        for (const provider of ENV.PREPRINTS.providers) {
            if (!provider.domain)
                continue;

            if (provider.id === 'osf') {
                provider.domain = OSF_URL || 'localhost:5000';
                continue;
            }

            const suffix = DOMAIN_PREFIX ? '' : `:${PORT ? PORT : '4200'}`;
            provider.domain = `${DOMAIN_PREFIX || 'local'}.${provider.domain}${suffix}`;
        }
    }

    if (ENV.ASSET_SUFFIX) {
        ENV.PREPRINTS.providers = ENV.PREPRINTS.providers.map(provider => {
            provider.logoSharing.path = provider.logoSharing.path
                .replace(/\..*$/, match => `-${ENV.ASSET_SUFFIX}${match}`);

            return provider;
        });
    }

    return ENV;
};
<commit_msg>Remove BITSS domain and update engrXiv domain<commit_after>/* jshint node: true */

module.exports = function(environment) {
    const authorizationType = 'cookie';

    const ENV = {
        modulePrefix: 'preprint-service',
        environment: environment,
        rootURL: '/',
        locationType: 'auto',
        authorizationType: authorizationType,
        sentryDSN: 'http://test@localhost/80' || process.env.SENTRY_DSN,
        'ember-simple-auth': {
            authorizer: `authorizer:osf-${authorizationType}`,
            authenticator: `authenticator:osf-${authorizationType}`
        },
        EmberENV: {
            FEATURES: {
                // Here you can enable experimental features on an ember canary build
                // e.g. 'with-controller': true
            }
        },
        APP: {
            // Here you can pass flags/options to your application instance
            // when it is created
        },
        SHARE: {
            baseUrl: process.env.SHARE_BASE_URL || 'https://staging-share.osf.io/',
            searchUrl: process.env.SHARE_SEARCH_URL || 'https://staging-share.osf.io/api/v2/search/creativeworks/_search'
        },
        moment: {
            outputFormat: 'YYYY-MM-DD hh:mm a'
        },
        PREPRINTS: {
            defaultProvider: 'osf',

            // Logos are needed for open graph sharing meta tags (Facebook, LinkedIn, etc) and must be at least 200x200
            providers: [
                // OSF must be the first provider
                {
                    id: 'osf',
                    domain: 'osf.io',
                    logoSharing: {
                        path: '/assets/img/provider_logos/osf-dark.png',
                        type: 'image/png',
                        width: 363,
                        height: 242
                    },
                    permissionLanguage: 'no_trademark'
                },
                {
                    id: 'engrxiv',
                    domain: 'engrxiv.org',
                    logoSharing: {
                        path: '/assets/img/provider_logos/engrxiv-sharing.png',
                        type: 'image/png',
                        width: 1200,
                        height: 488

                    },
                    permissionLanguage: 'arxiv_non_endorsement'

                },
                {
                    id: 'socarxiv',
                    domain: 'socarxiv.org',
                    logoSharing: {
                        path: '/assets/img/provider_logos/socarxiv-sharing.png',
                        type: 'image/png',
                        width: 1200,
                        height: 488
                    },
                    permissionLanguage: 'arxiv_trademark_license'
                },
                {
                    id: 'psyarxiv',
                    domain: 'psyarxiv.org',
                    logoSharing: {
                        path: '/assets/img/provider_logos/psyarxiv-sharing.png',
                        type: 'image/png',
                        width: 1200,
                        height: 488
                    },
                    permissionLanguage: 'arxiv_trademark_license'
                },
                {
                    id: 'bitss',
                    logoSharing: { // T
                        path: '/assets/img/provider_logos/bitss-small.png',
                        type: 'image/png',
                        width: 1500,
                        height: 1500
                    },
                    permissionLanguage: 'no_trademark'
                },
                {
                    id: 'scielo',
                    domain: 'scielo.org',
                    logoSharing: {
                        path: '/assets/img/provider_logos/scielo-logo.png',
                        type: 'image/png',
                        width: 1200,
                        height: 488
                    },
                    permissionLanguage: 'no_trademark'
                },
                {
                    id: 'agrixiv',
                    domain: 'agrixiv.org',
                    logoSharing: {
                        path: 'assets/img/provider_logos/agrixiv-banner.svg',
                        type: 'image/png',
                        width: 1200,
                        height: 488
                    },
                    permissionLanguage: 'arxiv_non_endorsement'
                }
            ],
        },
        i18n: {
            defaultLocale: 'en'
        },
        metricsAdapters: [
            {
                name: 'GoogleAnalytics',
                environments: ['all'],
                config: {
                    id: process.env.GOOGLE_ANALYTICS_ID
                }
            }
        ],
        FB_APP_ID: process.env.FB_APP_ID,
    };

    if (environment === 'development') {
        // ENV.APP.LOG_RESOLVER = true;
        // ENV.APP.LOG_ACTIVE_GENERATION = true;
        // ENV.APP.LOG_TRANSITIONS = true;
        // ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
        // ENV.APP.LOG_VIEW_LOOKUPS = true;

        ENV.metricsAdapters[0].config.cookieDomain = 'none';
    }

    if (environment === 'test') {
        // Testem prefers this...
        ENV.baseURL = '/';
        ENV.locationType = 'none';

        // keep test console output quieter
        ENV.APP.LOG_ACTIVE_GENERATION = false;
        ENV.APP.LOG_VIEW_LOOKUPS = false;

        ENV.APP.rootElement = '#ember-testing';

        // Don't make external requests during unit test
        // TODO: Provide mocks for all components with manual AJAX calls in the future.
        ENV.SHARE.baseUrl = '/nowhere';
        ENV.SHARE.searchUrl = '/nowhere';

        ENV.metricsAdapters[0].config.cookieDomain = 'none'
    }

    if (environment === 'production') {
        ENV.sentryDSN = process.env.SENTRY_DSN || 'https://2f0a61d03b99480ea11e259edec18bd9@sentry.cos.io/45';
        ENV.ASSET_SUFFIX = process.env.GIT_COMMIT || 'git_commit_env_not_set';
    } else {
        // Fallback to throwaway defaults if the environment variables are not set
        ENV.metricsAdapters[0].config.id = ENV.metricsAdapters[0].config.id || 'UA-84580271-1';
        ENV.FB_APP_ID = ENV.FB_APP_ID || '1039002926217080';

        const {DOMAIN_PREFIX, PORT, OSF_URL} = process.env;

        for (const provider of ENV.PREPRINTS.providers) {
            if (!provider.domain)
                continue;

            if (provider.id === 'osf') {
                provider.domain = OSF_URL || 'localhost:5000';
                continue;
            }

            const suffix = DOMAIN_PREFIX ? '' : `:${PORT ? PORT : '4200'}`;
            provider.domain = `${DOMAIN_PREFIX || 'local'}.${provider.domain}${suffix}`;
        }
    }

    if (ENV.ASSET_SUFFIX) {
        ENV.PREPRINTS.providers = ENV.PREPRINTS.providers.map(provider => {
            provider.logoSharing.path = provider.logoSharing.path
                .replace(/\..*$/, match => `-${ENV.ASSET_SUFFIX}${match}`);

            return provider;
        });
    }

    return ENV;
};
<|endoftext|>


<commit_before>import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { View, StyleSheet, Animated, ScrollView, Easing, Text } from 'react-native'
import ColumnChartItem from './column-chart-item'
import {initData, drawYAxis, drawYAxisLabels, drawGuideLine, numberWithCommas, drawXAxis, drawXAxisLabels} from '../common'

export default class ColumnChart extends Component {
  constructor (props) {
    super(props)
    let defaultGap = this.props.defaultColumnWidth + this.props.defaultColumnMargin
    let newState = initData(this.props.data, this.props.height, defaultGap)
    this.state = {
      sortedData: newState.sortedData,
      max: newState.max,
      selectedIndex: null,
      fadeAnim: new Animated.Value(0),
      guideArray: newState.guideArray,
      gap: defaultGap
    }
    this.renderColumns = this.renderColumns.bind(this)
    this.handleClick = this.handleClick.bind(this)
    this.drawTooltip = this.drawTooltip.bind(this)
  }

  componentWillReceiveProps (nextProps) {
    if (nextProps.data !== this.props.data) {
      this.setState(Object.assign({
        fadeAnim: new Animated.Value(0)
      }, initData(nextProps.data, this.props.height, this.state.gap)), () => {
        Animated.timing(this.state.fadeAnim, { toValue: 1, easing: Easing.bounce, duration: 1000, useNativeDriver: true }).start()
      })
    }
  }

  componentDidMount () {
    Animated.timing(this.state.fadeAnim, {
      toValue: 1, easing: Easing.bounce, duration: 1000, useNativeDriver: true
    }).start()
  }

  renderColumns (fadeAnim) {
    let seriesArray = this.state.sortedData
    let seriesCount = seriesArray.length
    let renderColumns = []
    if (seriesCount > 0) {
      let standardSeries = seriesArray[0]
      let dataCount = standardSeries.data.length
      for (let i = 0; i < dataCount; i++) {
        renderColumns.push(
          <ColumnChartItem key={i} seriesArray={this.state.sortedData}
            dataIndex={i}
            defaultWidth={this.props.defaultColumnWidth}
            defaultMargin={this.props.defaultColumnMargin}
            isSelected={this.state.selectedIndex === i}
            onClick={(evt) => this.handleClick(evt, i)} />
        )
      }
    }
    return (
      <Animated.View style={[styles.chartView, {transform: [{scaleY: fadeAnim}]}]}>
        {renderColumns}
      </Animated.View>
    )
  }

  handleClick (event, index) {
    console.log('click!!', index)
    this.setState({
      selectedIndex: index
    })
  }
  drawTooltip (selectedIndex) {
    console.log('drawTooltip!!', selectedIndex)
    if (typeof (selectedIndex) === 'number' && selectedIndex >= 0) {
      let standardSeries = this.state.sortedData[0]
      if (!standardSeries) {
        console.warn('standardSeries is null')
        return null
      }

      let seriesCount = this.state.sortedData.length
      let plusGap = 10 * seriesCount
      if (selectedIndex === standardSeries.data.length - 1) {
        plusGap = -50
      }
      // 차트 width를 마지막에 늘려야겠음.

      let left = standardSeries.data[selectedIndex]['gap'] + plusGap
      let tooltipRenders = []
      let tooltipHeight = 30

      if (standardSeries.data[selectedIndex]['x']) {
        tooltipHeight = 40
      }
      tooltipHeight = tooltipHeight * seriesCount

      for (let i = 0; i < this.state.sortedData.length; i++) {
        let series = this.state.sortedData[i]
        if (series.data[selectedIndex]['x']) {
          tooltipRenders.push(<Text>{series.data[selectedIndex]['x']}</Text>)
        }
        tooltipRenders.push(<Text>{numberWithCommas(series.data[selectedIndex]['y'], false)}</Text>)
      }
      return (
        <View style={[styles.tooltipWrapper, { left: left }]}>
          <View style={[styles.tooltip, { height: tooltipHeight }]}>
            {tooltipRenders}
          </View>
        </View>
      )
    } else {
      return null
    }
  }

  render () {
    let {fadeAnim} = this.state
    if (this.state.sortedData && this.state.sortedData.length === 0) return null

    return (
      <View style={{flexDirection: 'row'}}>
        <View style={{paddingRight: 5}}>
          {drawYAxisLabels(this.state.guideArray, this.props.height + 20)}
        </View>
        <View style={styles.mainContainer}>
          <ScrollView horizontal>
            <View>
              <View ref='chartView' style={styles.chartContainer}>
                {drawYAxis()}
                {drawGuideLine(this.state.guideArray)}
                {this.renderColumns(fadeAnim)}
              </View>
              {drawXAxis()}
              <View style={{
                marginLeft: this.props.defaultColumnWidth / 2
              }}>

                {drawXAxisLabels(this.state.sortedData[0].data, this.state.gap)}
              </View>
            </View>
            {this.drawTooltip(this.state.selectedIndex)}
          </ScrollView>
        </View>
      </View>
    )
  }
}

const styles = StyleSheet.create({
  mainContainer: {
    paddingBottom: 0,
    paddingLeft: 0,
    paddingRight: 0,
    height: '100%'
  },
  chartContainer: {
    flexDirection: 'row',
    alignItems: 'flex-end',
    margin: 0,
    paddingRight: 0
  },
  chartView: {
    flexDirection: 'row',
    alignItems: 'flex-end',
    height: '100%',
    paddingTop: 20
  },
  tooltipWrapper: {
    position: 'absolute',
    height: '100%',
    alignItems: 'center',
    justifyContent: 'center'
  },
  tooltip: {
    backgroundColor: '#FFFFFF',
    borderRadius: 5,
    borderColor: '#AAAAAA',
    borderWidth: 1,
    padding: 3,
    alignItems: 'center',
    justifyContent: 'center',
    opacity: 0.8
  }
})

ColumnChart.propTypes = {
  data: PropTypes.array
}
ColumnChart.defaultProps = {
  data: [],
  height: 100,
  defaultColumnWidth: 30,
  defaultColumnMargin: 20,
  primaryColor: '#297AB1'
}
<commit_msg>fix auto js standard<commit_after>import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { View, StyleSheet, Animated, ScrollView, Easing, Text } from 'react-native'
import ColumnChartItem from './column-chart-item'
import {initData, drawYAxis, drawYAxisLabels, drawGuideLine, numberWithCommas, drawXAxis, drawXAxisLabels} from '../common'

export default class ColumnChart extends Component {
  constructor (props) {
    super(props)
    let defaultGap = this.props.defaultColumnWidth + this.props.defaultColumnMargin
    let newState = initData(this.props.data, this.props.height, defaultGap)
    this.state = {
      sortedData: newState.sortedData,
      max: newState.max,
      selectedIndex: null,
      fadeAnim: new Animated.Value(0),
      guideArray: newState.guideArray,
      gap: defaultGap
    }
    this.renderColumns = this.renderColumns.bind(this)
    this.handleClick = this.handleClick.bind(this)
    this.drawTooltip = this.drawTooltip.bind(this)
  }

  componentWillReceiveProps (nextProps) {
    if (nextProps.data !== this.props.data) {
      this.setState(Object.assign({
        fadeAnim: new Animated.Value(0)
      }, initData(nextProps.data, this.props.height, this.state.gap)), () => {
        Animated.timing(this.state.fadeAnim, { toValue: 1, easing: Easing.bounce, duration: 1000, useNativeDriver: true }).start()
      })
    }
  }

  componentDidMount () {
    Animated.timing(this.state.fadeAnim, {
      toValue: 1, easing: Easing.bounce, duration: 1000, useNativeDriver: true
    }).start()
  }

  renderColumns (fadeAnim) {
    let seriesArray = this.state.sortedData
    let seriesCount = seriesArray.length
    let renderColumns = []
    if (seriesCount > 0) {
      let standardSeries = seriesArray[0]
      let dataCount = standardSeries.data.length
      for (let i = 0; i < dataCount; i++) {
        renderColumns.push(
          <ColumnChartItem key={i} seriesArray={this.state.sortedData}
            dataIndex={i}
            defaultWidth={this.props.defaultColumnWidth}
            defaultMargin={this.props.defaultColumnMargin}
            isSelected={this.state.selectedIndex === i}
            onClick={(evt) => this.handleClick(evt, i)} />
        )
      }
    }
    return (
      <Animated.View style={[styles.chartView, {transform: [{scaleY: fadeAnim}]}]}>
        {renderColumns}
      </Animated.View>
    )
  }

  handleClick (event, index) {
    console.log('click!!', index)
    this.setState({
      selectedIndex: index
    })
  }
  drawTooltip (selectedIndex) {
    console.log('drawTooltip!!', selectedIndex)
    if (typeof (selectedIndex) === 'number' && selectedIndex >= 0) {
      let standardSeries = this.state.sortedData[0]
      if (!standardSeries) {
        console.warn('standardSeries is null')
        return null
      }

      let seriesCount = this.state.sortedData.length
      let plusGap = 10 * seriesCount
      if (selectedIndex === standardSeries.data.length - 1) {
        plusGap = -50
      }
      // 차트 width를 마지막에 늘려야겠음.

      let left = standardSeries.data[selectedIndex]['gap'] + plusGap
      let tooltipRenders = []
      let tooltipHeight = 30

      if (standardSeries.data[selectedIndex]['x']) {
        tooltipHeight = 40
      }
      tooltipHeight = tooltipHeight * seriesCount

      for (let i = 0; i < this.state.sortedData.length; i++) {
        let series = this.state.sortedData[i]
        if (series.data[selectedIndex]['x']) {
          tooltipRenders.push(<Text>{series.data[selectedIndex]['x']}</Text>)
        }
        tooltipRenders.push(<Text>{numberWithCommas(series.data[selectedIndex]['y'], false)}</Text>)
      }
      return (
        <View style={[styles.tooltipWrapper, { left: left }]}>
          <View style={[styles.tooltip, { height: tooltipHeight }]}>
            {tooltipRenders}
          </View>
        </View>
      )
    } else {
      return null
    }
  }

  render () {
    let {fadeAnim} = this.state
    if (this.state.sortedData && this.state.sortedData.length === 0) return null

    return (
      <View style={{flexDirection: 'row'}}>
        <View style={{paddingRight: 5}}>
          {drawYAxisLabels(this.state.guideArray, this.props.height + 20)}
        </View>
        <View style={styles.mainContainer}>
          <ScrollView horizontal>
            <View>
              <View ref='chartView' style={styles.chartContainer}>
                {drawYAxis()}
                {drawGuideLine(this.state.guideArray)}
                {this.renderColumns(fadeAnim)}
              </View>
              {drawXAxis()}
              <View style={{ marginLeft: this.props.defaultColumnWidth / 2 }}>
                {drawXAxisLabels(this.state.sortedData[0].data, this.state.gap)}
              </View>
            </View>
            {this.drawTooltip(this.state.selectedIndex)}
          </ScrollView>
        </View>
      </View>
    )
  }
}

const styles = StyleSheet.create({
  mainContainer: {
    paddingBottom: 0,
    paddingLeft: 0,
    paddingRight: 0,
    height: '100%'
  },
  chartContainer: {
    flexDirection: 'row',
    alignItems: 'flex-end',
    margin: 0,
    paddingRight: 0
  },
  chartView: {
    flexDirection: 'row',
    alignItems: 'flex-end',
    height: '100%',
    paddingTop: 20
  },
  tooltipWrapper: {
    position: 'absolute',
    height: '100%',
    alignItems: 'center',
    justifyContent: 'center'
  },
  tooltip: {
    backgroundColor: '#FFFFFF',
    borderRadius: 5,
    borderColor: '#AAAAAA',
    borderWidth: 1,
    padding: 3,
    alignItems: 'center',
    justifyContent: 'center',
    opacity: 0.8
  }
})

ColumnChart.propTypes = {
  data: PropTypes.array
}
ColumnChart.defaultProps = {
  data: [],
  height: 100,
  defaultColumnWidth: 30,
  defaultColumnMargin: 20,
  primaryColor: '#297AB1'
}
<|endoftext|>


<commit_before>/* jshint node: true */

module.exports = function (environment) {
    var ENV = {
        modulePrefix: 'oxide',
        environment: environment,
        baseURL: '/',
        locationType: 'hash',

        EmberENV: {
          FEATURES: {
            // Here you can enable experimental features on an ember canary build
            // e.g. 'with-controller': true
          }
        },

        APP: {
          // Here you can pass flags/options to your application instance
          // when it is created
          nitrogen: {
            host: 'api.nitrogen.io',
            protocol: 'https',
            http_port: 443,
            log_levels: ['warn', 'error']
          }
        },
      };

    ENV['simple-auth'] = {
        routeAfterAuthentication: 'dashboard',
        routeIfAlreadyAuthenticated: 'dashboard'
    };

    ENV['cordova'] = {
        // Rebuild the cordova project on file changes. Blocks the server until it's
        // finished.
        //
        // default: false
        rebuildOnChange: true,

        // Run the cordova emulate command after the build is finished
        //
        // default: false
        emulate: true,

        // Which platform to build and/or emulate
        //
        // default: 'ios'
        platform: 'ios',

        // Which URL the ember server is running on. This is used when using
        // live-reload that comes with the starter kit.
        //
        // default: 'the-device-ip:4200'
        emberUrl: 'http://10.0.1.12:4200',

        // Whether or not to use liveReload on the device simulator. Requires a few
        // plugins to be installed that come with the starter-kit. It will cause your
        // app to not boot up in the browser
        //
        // default: false and iOS
        liveReload: {
            enabled: false,
            platform: 'ios'
        }
    };

    if (environment === 'development') {
        // ENV.APP.LOG_RESOLVER = true;
        ENV.APP.LOG_ACTIVE_GENERATION = true;
        ENV.APP.LOG_TRANSITIONS = true;
        ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
        ENV.APP.LOG_VIEW_LOOKUPS = true;
        ENV.contentSecurityPolicyHeader = 'Disabled-Content-Security-Policy';
    }

    if (environment === 'test') {
        // Testem prefers this...
        ENV.baseURL = '/';
        ENV.locationType = 'auto';

        // keep test console output quieter
        ENV.APP.LOG_ACTIVE_GENERATION = false;
        ENV.APP.LOG_VIEW_LOOKUPS = false;

        ENV.APP.rootElement = '#ember-testing';
    }

    if (environment === 'production') {

    }

    return ENV;
};
<commit_msg>Disable automatic iOS Simulator launch<commit_after>/* jshint node: true */

module.exports = function (environment) {
    var ENV = {
        modulePrefix: 'oxide',
        environment: environment,
        baseURL: '/',
        locationType: 'hash',

        EmberENV: {
          FEATURES: {
            // Here you can enable experimental features on an ember canary build
            // e.g. 'with-controller': true
          }
        },

        APP: {
          // Here you can pass flags/options to your application instance
          // when it is created
          nitrogen: {
            host: 'api.nitrogen.io',
            protocol: 'https',
            http_port: 443,
            log_levels: ['warn', 'error']
          }
        },
      };

    ENV['simple-auth'] = {
        routeAfterAuthentication: 'dashboard',
        routeIfAlreadyAuthenticated: 'dashboard'
    };

    ENV['cordova'] = {
        // Rebuild the cordova project on file changes. Blocks the server until it's
        // finished.
        rebuildOnChange: true,

        // Run the cordova emulate command after the build is finished
        emulate: false,

        // Which platform to build and/or emulate
        platform: 'ios',

        // Which URL the ember server is running on. This is used when using
        // live-reload that comes with the starter kit.
        emberUrl: 'http://10.0.1.12:4200',

        // Whether or not to use liveReload on the device simulator. Requires a few
        // plugins to be installed that come with the starter-kit. It will cause your
        // app to not boot up in the browser
        liveReload: {
            enabled: false,
            platform: 'ios'
        }
    };

    if (environment === 'development') {
        // ENV.APP.LOG_RESOLVER = true;
        ENV.APP.LOG_ACTIVE_GENERATION = true;
        ENV.APP.LOG_TRANSITIONS = true;
        ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
        ENV.APP.LOG_VIEW_LOOKUPS = true;
        ENV.contentSecurityPolicyHeader = 'Disabled-Content-Security-Policy';
    }

    if (environment === 'test') {
        // Testem prefers this...
        ENV.baseURL = '/';
        ENV.locationType = 'auto';

        // keep test console output quieter
        ENV.APP.LOG_ACTIVE_GENERATION = false;
        ENV.APP.LOG_VIEW_LOOKUPS = false;

        ENV.APP.rootElement = '#ember-testing';
    }

    if (environment === 'production') {

    }

    return ENV;
};
<|endoftext|>


<commit_before>/* vi:si:et:sw=4:sts=4:ts=4 */

'use strict';
(function() {

    klp.init = function() {
        klp.accordion.init();
        klp.router = new KLPRouter();
        klp.router.init();
        initSelect2();
        loadData();
        //get JS query params from URL

    }

    function initSelect2() {
        $('#select2search').select2({
            placeholder: 'Search for schools and boundaries',
            minimumInputLength: 3,
            ajax: {
                url: "/api/v1/search",
                quietMillis: 300,
                allowClear: true,
                data: function(term, page) {
                    return {
                        text: term,
                        geometry: 'yes'
                    };
                },
                results: function(data, page) {
                    var searchResponse = {
                        results: [{
                            text: "Pre-Schools",
                            children: makeResults(data.pre_schools.features, 'school')
                        }, {
                            text: "Primary Schools",
                            children: makeResults(data.primary_schools.features, 'school')
                        }, {
                            text: "Boundaries",
                            children: makeResults(data.boundaries.features, 'boundary')
                        }]
                    };
                    return {
                        results: searchResponse.results
                    };
                }
            }
        });
        $('#select2search').on("change", function(choice) {
            console.log(choice);
        });
    }

    function makeResults(array, type) {
        var schoolDistrictMap = {
            'primaryschool': 'Primary School',
            'preschool': 'Preschool'
        };
        return _(array).map(function(obj) {
            var name = obj.properties.name;
            if (type === 'boundary') {
                if (obj.properties.type === 'district') {
                    name = obj.properties.name + ' - ' + schoolDistrictMap[obj.properties.school_type] + ' ' + obj.properties.type;
                } else {
                    name = obj.properties.name + ' - ' + obj.properties.type;
                }
            }

            obj.entity_type = type;
            return {
                id: obj.properties.id,
                text: _.str.titleize(name),
                data: obj
            };
        });
    }

    function loadData() {
        var params = klp.router.getHash().queryParams;
        var metaURL = "stories/meta/"; //FIXME: enter API url
        var $metaXHR = klp.api.do(metaURL, params);

        $metaXHR.done(function(data) {
            console.log("summary data", data);
            renderSummary(data);
            renderRespondentChart(data);
        });

        var detailURL = "stories/details/";
        var $detailXHR = klp.api.do(detailURL, params);

        $detailXHR.done(function(data) {
            console.log("detail data", data);
            renderFeatured(data);
            renderIVRS(data);
            renderSurvey(data);
            renderWeb(data);
            //renderComparison(data);
        });

        var volumeURL = "stories/volume/";
        var $volumeXHR = klp.api.do(volumeURL, params);
        $volumeXHR.done(function(data) {
            renderIVRSVolumeChart(data);
        });

        //TODO: do some loading behaviour

    }

    function renderRespondentChart(data) {
        var labels = _.keys(data.respondents);
        var values = _.values(data.respondents);
        //console.log(labels, values);
        var data_respondent = {
            labels: labels,
            series: [
                values
            ]
        };

        renderBarChart('#chart_respondent', data_respondent);

    }

    function renderIVRSVolumeChart(data) {
        var months = data.volumes['2014']; //FIXME: deal with with academic year.
        var labels = _.keys(months);
        var values = _.values(months);
        var data_ivrs = {
            labels: labels,
            series: [
                values
            ]
        };
        renderBarChart('#chart_ivrs', data_ivrs);
    }

    function renderBarChart(elementId, data) {
        var options = {
            axisX: {
                showGrid: false
            },
            axisY: {
                showGrid: false
            }
        };

        var chart_element = Chartist.Bar(elementId, data, options).on('draw', function(data) {
            if (data.type === 'bar') {
                data.element.attr({
                    style: 'stroke-width: 20px'
                });
            }
        });
    }

    function renderSummary(data) {
        var tplTopSummary = swig.compile($('#tpl-topSummary').html());
        var tplCountSummary = swig.compile($('#tpl-countSummary').html());
        var topSummaryHTML = tplTopSummary(data);
        $('#topSummary').html(topSummaryHTML);

        var summaries = {
            'ivrs': [{
                'label': 'Schools',
                'count': data.total.schools
            }, {
                'label': 'Schools with Stories',
                'count': data.ivrs.schools
            }, {
                'label': 'Calls received',
                'count': data.ivrs.stories
            }, {
                'label': 'Academic Year',
                'count': '2015-2016'
            }],
            'survey': [{
                'label': 'Schools',
                'count': data.total.schools
            }, {
                'label': 'Schools with Stories',
                'count': data.community.schools
            }, {
                'label': 'Stories',
                'count': data.community.stories
            }, {
                'label': 'Academic Year',
                'count': '2015-2016'
            }],
            'web': [{
                'label': 'Schools',
                'count': data.total.schools
            }, {
                'label': 'Schools with Stories',
                'count': data.web.schools
            }, {
                'label': 'Verified Stories',
                'count': data.web.verified_stories
            }, {
                'label': 'Academic Year',
                'count': '2015-2016'
            }]
        };
        var html = tplCountSummary({
            'summary': summaries['ivrs']
        });
        $('#ivrssummary').html(html);
        html = tplCountSummary({
            'summary': summaries['survey']
        });
        $('#surveysummary').html(html);
        html = tplCountSummary({
            'summary': summaries['web']
        });
        $('#websummary').html(html);
    }

    function renderFeatured(data) {
        var tplPercentGraph = swig.compile($('#tpl-percentGraph').html());
        var featuredQuestionsPrimary = [
            {
                'source': 'ivrs',
                'key': 'ivrss-teachers-present',
                'source_prefix': 'IVRS: '
            },
            {
                'source': 'ivrs',
                'key': 'ivrss-classes-proper',
                'source_prefix': 'IVRS: '
            },
            {
                'source': 'community',
                'key': 'comms2-functioning-toilets',
                'source_prefix': 'Surveys: '
            },
            {
                'source': 'community',
                'key': 'comms2-drinking-water',
                'source_prefix': 'Surveys: '
            }
        ];
        var featuredQuestions = featuredQuestionsPrimary; //TODO: add preschool
        var questionObjects = _.map(featuredQuestions, function(obj) {
            return getQuestion(data, obj.source, obj.key);
        });

        var questions = getQuestionsArray(questionObjects);
        var questions = _.map(questions, function(question, seq) {
            question.display_text = featuredQuestions[seq].source_prefix + question.display_text;
            return question;
        });
        var html = ''
        for (var pos in questions) {
            html = html + tplPercentGraph(questions[pos]);
        }
        $('#quicksummary').html(html);

    }

    function getScore(answers, option) {
        if (typeof(option) == 'undefined') {
            option = 'Yes';
        }
        var options = answers.options;
        if (options.hasOwnProperty(option)) {
            return options[option];
        } else {
            return 0;
        }
    }

    function getTotal(answers) {
        return _.reduce(_.keys(answers.options), function(memo, answerKey) {
            return memo + answers.options[answerKey];
        }, 0);
    }

    function getPercent(score, total) {
        if (total == 0) {
            return 0;
        }
        return Math.round((score / total) * 100);
    }

    function getQuestionsArray(questions) {
        return _.map(questions, function(question, seq) {
            var score = getScore(question.answers, 'Yes');
            var total = getTotal(question.answers);
            var percent = getPercent(score, total);
            //var qObj = featuredQuestions[seq];
            //var displayText = qObj.source_prefix + question.question.display_text;
            return {
                'question': question.question.display_text,
                'score': score,
                'total': total,
                'percent': percent
            };
        });
    }

    function renderIVRS(data) {
        var tplGradeGraph = swig.compile($('#tpl-gradeGraph').html());
        var tplPercentGraph = swig.compile($('#tpl-percentGraph').html());
        //define your data
        var gradeQuestion = getQuestion(data, 'ivrs', 'ivrss-grade');
        var gradeAnswers = gradeQuestion.answers;
        var total = getTotal(gradeAnswers);
        var scoreA = getScore(gradeAnswers, "1");
        var scoreB = getScore(gradeAnswers, "2");
        var scoreC = getScore(gradeAnswers, "3");
        var grades = [{
            'value': 'A',
            'score': scoreA,
            'total': total,
            'percent': getPercent(scoreA, total),
            'color': 'green-leaf'
        }, {
            'value': 'B',
            'score': scoreB,
            'total': total,
            'percent': getPercent(scoreB, total),
            'color': 'orange-mild'
        }, {
            'value': 'C',
            'score': scoreC,
            'total': total,
            'percent': getPercent(scoreC, total),
            'color': 'pink-salmon'
        }];

        var html = ''
        for (var pos in grades) {
            html = html + "
" + tplGradeGraph(grades[pos]) + "
";
        }
        $('#ivrsgrades').html(html);

        var IVRSQuestionKeys = [
            'ivrss-school-open',
            'ivrss-headmaster-present',
            'ivrss-toilets-condition'
        ];

        var questionObjects = _.map(IVRSQuestionKeys, function(key) {
            return getQuestion(data, 'ivrs', key);
        });
        //console.log("ivrs question objects", questionObjects);

        var questions = getQuestionsArray(questionObjects);
        //console.log("ivrs questions", questions);

        html = ''
        for (var pos in questions) {
            html = html + tplPercentGraph(questions[pos]);
        }
        $('#ivrsquestions').html(html);
    }

    function getQuestion(data, source, key) {
        for (var i=0, len=data[source].length; i<len; i++) {
            var question = data[source][i];
            if (question.question.key === key) {
                return question;
            }
        }
        return false;
    }

    function renderSurvey(data) {
        var tplPercentGraph = swig.compile($('#tpl-percentGraph').html());
        var surveyQuestionKeys = [
            'comms2-teachers-regular',
            'comms2-sufficient-teachers',
            'comms2-classes-regular',
            'comms2-children-attention',
            'comms2-sdmc-involved',
            'comms2-food-concern'
        ]
        var questionObjects = _.map(surveyQuestionKeys, function(key) {
            return getQuestion(data, 'community', key);
        });
        var questions = getQuestionsArray(questionObjects);

        var html = "
";
        for (var pos in questions) {
            if (pos == questions.length / 2) {
                html = html + "

";
            }
            html = html + tplPercentGraph(questions[pos]);
        }
        html = html + "
";
        $('#surveyquestions').html(html);
    }

    function renderWeb(data) {
        var tplPercentGraph = swig.compile($('#tpl-percentGraph').html());

        var questions = [{
            'question': 'Where there was evidence of a Mid-day meal served:',
            'score': 440,
            'total': 1000,
            'percent': 44
        }, {
            'question': 'Where 50% of children enrolled in the school were present:',
            'score': 260,
            'total': 1000,
            'percent': 26
        }, {
            'question': 'Where all the teachers for all classes were present:',
            'score': 300,
            'total': 1000,
            'percent': 30
        }];

        var html = ''
        for (var pos in questions) {
            html = html + "
" + tplPercentGraph(questions[pos]) + "
";
        }
        $('#webquestions').html(html);

        var tplColorText = swig.compile($('#tpl-colorText').html());

        var facilities = [{
            'facility': 'All weather pucca building',
            'icon': ['fa fa-university'],
            'percent': 44
        }, {
            'facility': 'Playground',
            'icon': ['fa fa-futbol-o'],
            'percent': 45
        }, {
            'facility': 'Drinking Water',
            'icon': ['fa  fa-tint'],
            'percent': 54
        }, {
            'facility': 'Library',
            'icon': ['fa fa-book'],
            'percent': 64
        }, {
            'facility': 'Toilets',
            'icon': ['fa fa-male', 'fa fa-female'],
            'percent': 74
        }, {
            'facility': 'Secure Boundary Wall',
            'icon': ['fa fa-circle-o-notch'],
            'percent': 34
        }];

        var html = ''
        for (var pos in facilities) {
            html = html + tplColorText(facilities[pos]);
        }
        $('#webfacilities').html(html);

    }

    function renderComparison(data) {
        var tplCompareTable = swig.compile($('#tpl-compareTable').html());

        var neighbours = [{
            'name': 'Bangalore North',
            'schools': 1000,
            'stories': 440,
            'needs_volunteer': 'Playground',
            'needs_community': 'Playground',
            'ivrs': 500
        }, {
            'name': 'Bangalore South',
            'schools': 1000,
            'stories': 540,
            'needs_volunteer': 'Drinking Water',
            'needs_community': 'Mid-day Meals',
            'ivrs': 600
        }, {
            'name': 'Bangalore Central',
            'schools': 1000,
            'stories': 640,
            'needs_volunteer': 'Drinking Water',
            'needs_community': 'Playground',
            'ivrs': 600
        }, {
            'name': 'Bangalore Rural',
            'schools': 1000,
            'stories': 740,
            'needs_volunteer': 'Playground',
            'needs_community': 'Mid-day Meals',
            'ivrs': 600
        }];

        var html = tplCompareTable({
            'neighbours': neighbours
        });
        $('#comparison').html(html);

    }

})();<commit_msg>render web charts and facility data<commit_after>/* vi:si:et:sw=4:sts=4:ts=4 */

'use strict';
(function() {

    klp.init = function() {
        klp.accordion.init();
        klp.router = new KLPRouter();
        klp.router.init();
        initSelect2();
        loadData();
        //get JS query params from URL

    }

    function initSelect2() {
        $('#select2search').select2({
            placeholder: 'Search for schools and boundaries',
            minimumInputLength: 3,
            ajax: {
                url: "/api/v1/search",
                quietMillis: 300,
                allowClear: true,
                data: function(term, page) {
                    return {
                        text: term,
                        geometry: 'yes'
                    };
                },
                results: function(data, page) {
                    var searchResponse = {
                        results: [{
                            text: "Pre-Schools",
                            children: makeResults(data.pre_schools.features, 'school')
                        }, {
                            text: "Primary Schools",
                            children: makeResults(data.primary_schools.features, 'school')
                        }, {
                            text: "Boundaries",
                            children: makeResults(data.boundaries.features, 'boundary')
                        }]
                    };
                    return {
                        results: searchResponse.results
                    };
                }
            }
        });
        $('#select2search').on("change", function(choice) {
            console.log(choice);
        });
    }

    function makeResults(array, type) {
        var schoolDistrictMap = {
            'primaryschool': 'Primary School',
            'preschool': 'Preschool'
        };
        return _(array).map(function(obj) {
            var name = obj.properties.name;
            if (type === 'boundary') {
                if (obj.properties.type === 'district') {
                    name = obj.properties.name + ' - ' + schoolDistrictMap[obj.properties.school_type] + ' ' + obj.properties.type;
                } else {
                    name = obj.properties.name + ' - ' + obj.properties.type;
                }
            }

            obj.entity_type = type;
            return {
                id: obj.properties.id,
                text: _.str.titleize(name),
                data: obj
            };
        });
    }

    function loadData() {
        var params = klp.router.getHash().queryParams;
        var metaURL = "stories/meta/"; //FIXME: enter API url
        var $metaXHR = klp.api.do(metaURL, params);

        $metaXHR.done(function(data) {
            console.log("summary data", data);
            renderSummary(data);
            renderRespondentChart(data);
        });

        var detailURL = "stories/details/";
        var $detailXHR = klp.api.do(detailURL, params);

        $detailXHR.done(function(data) {
            console.log("detail data", data);
            renderFeatured(data);
            renderIVRS(data);
            renderSurvey(data);
            renderWeb(data);
            //renderComparison(data);
        });

        var volumeURL = "stories/volume/";
        var $volumeXHR = klp.api.do(volumeURL, params);
        $volumeXHR.done(function(data) {
            renderIVRSVolumeChart(data);
        });

        //TODO: do some loading behaviour

    }

    function renderRespondentChart(data) {
        var labels = _.keys(data.respondents);
        var values = _.values(data.respondents);
        //console.log(labels, values);
        var data_respondent = {
            labels: labels,
            series: [
                values
            ]
        };

        renderBarChart('#chart_respondent', data_respondent);

    }

    function renderIVRSVolumeChart(data) {
        var months = data.volumes['2014']; //FIXME: deal with with academic year.
        var labels = _.keys(months);
        var values = _.values(months);
        var data_ivrs = {
            labels: labels,
            series: [
                values
            ]
        };
        renderBarChart('#chart_ivrs', data_ivrs);
    }

    function renderBarChart(elementId, data) {
        var options = {
            axisX: {
                showGrid: false
            },
            axisY: {
                showGrid: false
            }
        };

        var chart_element = Chartist.Bar(elementId, data, options).on('draw', function(data) {
            if (data.type === 'bar') {
                data.element.attr({
                    style: 'stroke-width: 20px'
                });
            }
        });
    }

    function renderSummary(data) {
        var tplTopSummary = swig.compile($('#tpl-topSummary').html());
        var tplCountSummary = swig.compile($('#tpl-countSummary').html());
        var topSummaryHTML = tplTopSummary(data);
        $('#topSummary').html(topSummaryHTML);

        var summaries = {
            'ivrs': [{
                'label': 'Schools',
                'count': data.total.schools
            }, {
                'label': 'Schools with Stories',
                'count': data.ivrs.schools
            }, {
                'label': 'Calls received',
                'count': data.ivrs.stories
            }, {
                'label': 'Academic Year',
                'count': '2015-2016'
            }],
            'survey': [{
                'label': 'Schools',
                'count': data.total.schools
            }, {
                'label': 'Schools with Stories',
                'count': data.community.schools
            }, {
                'label': 'Stories',
                'count': data.community.stories
            }, {
                'label': 'Academic Year',
                'count': '2015-2016'
            }],
            'web': [{
                'label': 'Schools',
                'count': data.total.schools
            }, {
                'label': 'Schools with Stories',
                'count': data.web.schools
            }, {
                'label': 'Verified Stories',
                'count': data.web.verified_stories
            }, {
                'label': 'Academic Year',
                'count': '2015-2016'
            }]
        };
        var html = tplCountSummary({
            'summary': summaries['ivrs']
        });
        $('#ivrssummary').html(html);
        html = tplCountSummary({
            'summary': summaries['survey']
        });
        $('#surveysummary').html(html);
        html = tplCountSummary({
            'summary': summaries['web']
        });
        $('#websummary').html(html);
    }

    function renderFeatured(data) {
        var tplPercentGraph = swig.compile($('#tpl-percentGraph').html());
        var featuredQuestionsPrimary = [
            {
                'source': 'ivrs',
                'key': 'ivrss-teachers-present',
                'source_prefix': 'IVRS: '
            },
            {
                'source': 'ivrs',
                'key': 'ivrss-classes-proper',
                'source_prefix': 'IVRS: '
            },
            {
                'source': 'community',
                'key': 'comms2-functioning-toilets',
                'source_prefix': 'Surveys: '
            },
            {
                'source': 'community',
                'key': 'comms2-drinking-water',
                'source_prefix': 'Surveys: '
            }
        ];
        var featuredQuestions = featuredQuestionsPrimary; //TODO: add preschool
        var questionObjects = _.map(featuredQuestions, function(obj) {
            return getQuestion(data, obj.source, obj.key);
        });

        var questions = getQuestionsArray(questionObjects);
        var questions = _.map(questions, function(question, seq) {
            question.display_text = featuredQuestions[seq].source_prefix + question.display_text;
            return question;
        });
        var html = ''
        for (var pos in questions) {
            html = html + tplPercentGraph(questions[pos]);
        }
        $('#quicksummary').html(html);

    }

    function renderIVRS(data) {
        var tplGradeGraph = swig.compile($('#tpl-gradeGraph').html());
        var tplPercentGraph = swig.compile($('#tpl-percentGraph').html());
        //define your data
        var gradeQuestion = getQuestion(data, 'ivrs', 'ivrss-grade');
        var gradeAnswers = gradeQuestion.answers;
        var total = getTotal(gradeAnswers);
        var scoreA = getScore(gradeAnswers, "1");
        var scoreB = getScore(gradeAnswers, "2");
        var scoreC = getScore(gradeAnswers, "3");
        var grades = [{
            'value': 'A',
            'score': scoreA,
            'total': total,
            'percent': getPercent(scoreA, total),
            'color': 'green-leaf'
        }, {
            'value': 'B',
            'score': scoreB,
            'total': total,
            'percent': getPercent(scoreB, total),
            'color': 'orange-mild'
        }, {
            'value': 'C',
            'score': scoreC,
            'total': total,
            'percent': getPercent(scoreC, total),
            'color': 'pink-salmon'
        }];

        var html = ''
        for (var pos in grades) {
            html = html + "
" + tplGradeGraph(grades[pos]) + "
";
        }
        $('#ivrsgrades').html(html);

        var IVRSQuestionKeys = [
            'ivrss-school-open',
            'ivrss-headmaster-present',
            'ivrss-toilets-condition'
        ];

        var questionObjects = _.map(IVRSQuestionKeys, function(key) {
            return getQuestion(data, 'ivrs', key);
        });
        //console.log("ivrs question objects", questionObjects);

        var questions = getQuestionsArray(questionObjects);
        //console.log("ivrs questions", questions);

        html = ''
        for (var pos in questions) {
            html = html + tplPercentGraph(questions[pos]);
        }
        $('#ivrsquestions').html(html);
    }

    function renderSurvey(data) {
        var tplPercentGraph = swig.compile($('#tpl-percentGraph').html());
        var surveyQuestionKeys = [
            'comms2-teachers-regular',
            'comms2-sufficient-teachers',
            'comms2-classes-regular',
            'comms2-children-attention',
            'comms2-sdmc-involved',
            'comms2-food-concern'
        ]
        var questionObjects = _.map(surveyQuestionKeys, function(key) {
            return getQuestion(data, 'community', key);
        });
        var questions = getQuestionsArray(questionObjects);

        var html = "
";
        for (var pos in questions) {
            if (pos == questions.length / 2) {
                html = html + "

";
            }
            html = html + tplPercentGraph(questions[pos]);
        }
        html = html + "
";
        $('#surveyquestions').html(html);
    }

    function renderWeb(data) {
        var tplPercentGraph = swig.compile($('#tpl-percentGraph').html());
        var webQuestionKeys = [
            'webs-food-being-cooked',
            'webs-50percent-present',
            'webs-teachers-present'
        ];
        var questionObjects = _.map(webQuestionKeys, function(key) {
            return getQuestion(data, 'web', key);
        });
        var questions = getQuestionsArray(questionObjects);

        var html = ''
        for (var pos in questions) {
            html = html + "
" + tplPercentGraph(questions[pos]) + "
";
        }
        $('#webquestions').html(html);

        var tplColorText = swig.compile($('#tpl-colorText').html());

        var facilityQuestions = [{
            'facility': 'All weather pucca building',
            'icon': ['fa fa-university'],
            'key': 'webs-pucca-building'
        }, {
            'facility': 'Playground',
            'icon': ['fa fa-futbol-o'],
            'key': 'webs-playground'
        }, {
            'facility': 'Drinking Water',
            'icon': ['fa  fa-tint'],
            'key': 'webs-drinking-water'
        }, {
            'facility': 'Library',
            'icon': ['fa fa-book'],
            'key': 'webs-library'
        }, {
            'facility': 'Toilets',
            'icon': ['fa fa-male', 'fa fa-female'],
            'key': 'webs-separate-toilets'
        }, {
            'facility': 'Secure Boundary Wall',
            'icon': ['fa fa-circle-o-notch'],
            'key': 'webs-boundary-wall'
        }];

        var questionObjects = _.map(facilityQuestions, function(question) {
            return getQuestion(data, 'web', question.key);
        });
        console.log("facility question objects", questionObjects);
        var questionsArray = getQuestionsArray(questionObjects);

        var facilities = _.map(questionsArray, function(question, seq) {
            var facility = facilityQuestions[seq];
            facility.percent = question.percent;
            return facility;
        });

        console.log("facilities", facilities);
        var html = ''
        for (var pos in facilities) {
            html = html + tplColorText(facilities[pos]);
        }
        $('#webfacilities').html(html);

    }

    function renderComparison(data) {
        var tplCompareTable = swig.compile($('#tpl-compareTable').html());

        var neighbours = [{
            'name': 'Bangalore North',
            'schools': 1000,
            'stories': 440,
            'needs_volunteer': 'Playground',
            'needs_community': 'Playground',
            'ivrs': 500
        }, {
            'name': 'Bangalore South',
            'schools': 1000,
            'stories': 540,
            'needs_volunteer': 'Drinking Water',
            'needs_community': 'Mid-day Meals',
            'ivrs': 600
        }, {
            'name': 'Bangalore Central',
            'schools': 1000,
            'stories': 640,
            'needs_volunteer': 'Drinking Water',
            'needs_community': 'Playground',
            'ivrs': 600
        }, {
            'name': 'Bangalore Rural',
            'schools': 1000,
            'stories': 740,
            'needs_volunteer': 'Playground',
            'needs_community': 'Mid-day Meals',
            'ivrs': 600
        }];

        var html = tplCompareTable({
            'neighbours': neighbours
        });
        $('#comparison').html(html);

    }

    /*
        Helper functions
            TODO: move to separate file and document.
     */

    function getScore(answers, option) {
        if (typeof(option) == 'undefined') {
            option = 'Yes';
        }
        var options = answers.options;
        if (options.hasOwnProperty(option)) {
            return options[option];
        } else {
            return 0;
        }
    }

    function getTotal(answers) {
        return _.reduce(_.keys(answers.options), function(memo, answerKey) {
            return memo + answers.options[answerKey];
        }, 0);
    }

    function getPercent(score, total) {
        if (total == 0) {
            return 0;
        }
        return Math.round((score / total) * 100);
    }

    function getQuestion(data, source, key) {
        for (var i=0, len=data[source].length; i<len; i++) {
            var question = data[source][i];
            if (question.question.key === key) {
                return question;
            }
        }
        return false;
    }

    function getQuestionsArray(questions) {
        return _.map(questions, function(question, seq) {
            var score = getScore(question.answers, 'Yes');
            var total = getTotal(question.answers);
            var percent = getPercent(score, total);
            //var qObj = featuredQuestions[seq];
            //var displayText = qObj.source_prefix + question.question.display_text;
            return {
                'question': question.question.display_text,
                'score': score,
                'total': total,
                'percent': percent
            };
        });
    }

})();<|endoftext|>