<commit_before>var Rect = cordova.require("com.mirasense.scanditsdk.plugin.Rect");
var Point = cordova.require("com.mirasense.scanditsdk.plugin.Point");
var SymbologySettings = cordova.require("com.mirasense.scanditsdk.plugin.SymbologySettings");
var Barcode = cordova.require("com.mirasense.scanditsdk.plugin.Barcode");

function ScanSettings() {
    this.symbologies = {};

    this.symbologies[Barcode.Symbology.EAN13] = new SymbologySettings();
    this.symbologies[Barcode.Symbology.EAN13].activeSymbolCounts = [12];

    this.symbologies[Barcode.Symbology.EAN8] = new SymbologySettings();
    this.symbologies[Barcode.Symbology.EAN8].activeSymbolCounts = [8];

    this.symbologies[Barcode.Symbology.UPC12] = new SymbologySettings();
    this.symbologies[Barcode.Symbology.UPC12].activeSymbolCounts = [12];

    this.symbologies[Barcode.Symbology.UPCE] = new SymbologySettings();
    this.symbologies[Barcode.Symbology.UPCE].activeSymbolCounts = [6];

    this.symbologies[Barcode.Symbology.CODE11] = new SymbologySettings();
    this.symbologies[Barcode.Symbology.CODE11].activeSymbolCounts = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];

    this.symbologies[Barcode.Symbology.CODE25] = new SymbologySettings();
    this.symbologies[Barcode.Symbology.CODE25].activeSymbolCounts = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];

    this.symbologies[Barcode.Symbology.CODE128] = new SymbologySettings();
    this.symbologies[Barcode.Symbology.CODE128].activeSymbolCounts = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];

    this.symbologies[Barcode.Symbology.CODE39] = new SymbologySettings();
    this.symbologies[Barcode.Symbology.CODE39].activeSymbolCounts = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];

    this.symbologies[Barcode.Symbology.CODE93] = new SymbologySettings();
    this.symbologies[Barcode.Symbology.CODE93].activeSymbolCounts = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22];

    this.symbologies[Barcode.Symbology.ITF] = new SymbologySettings();
    this.symbologies[Barcode.Symbology.ITF].activeSymbolCounts = [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18];

    this.symbologies[Barcode.Symbology.QR] = new SymbologySettings();

    this.symbologies[Barcode.Symbology.DATA_MATRIX] = new SymbologySettings();

    this.symbologies[Barcode.Symbology.PDF417] = new SymbologySettings();
    this.symbologies[Barcode.Symbology.MICRO_PDF417] = new SymbologySettings();

    this.symbologies[Barcode.Symbology.MSI_PLESSEY] = new SymbologySettings();
    this.symbologies[Barcode.Symbology.MSI_PLESSEY].activeSymbolCounts = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];

    this.symbologies[Barcode.Symbology.GS1_DATABAR] = new SymbologySettings();

    this.symbologies[Barcode.Symbology.GS1_DATABAR_LIMITED] = new SymbologySettings();

    this.symbologies[Barcode.Symbology.GS1_DATABAR_EXPANDED] = new SymbologySettings();

    this.symbologies[Barcode.Symbology.CODABAR] = new SymbologySettings();
    this.symbologies[Barcode.Symbology.CODABAR].activeSymbolCounts = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];

    this.symbologies[Barcode.Symbology.AZTEC] = new SymbologySettings();

    this.symbologies[Barcode.Symbology.MAXICODE] = new SymbologySettings();

    this.symbologies[Barcode.Symbology.FIVE_DIGIT_ADD_ON] = new SymbologySettings();
    this.symbologies[Barcode.Symbology.FIVE_DIGIT_ADD_ON].activeSymbolCounts = [5];

    this.symbologies[Barcode.Symbology.TWO_DIGIT_ADD_ON] = new SymbologySettings();
    this.symbologies[Barcode.Symbology.TWO_DIGIT_ADD_ON].activeSymbolCounts = [2];

    this.symbologies[Barcode.Symbology.KIX] = new SymbologySettings();
    this.symbologies[Barcode.Symbology.KIX].activeSymbolCounts = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24];

    this.symbologies[Barcode.Symbology.RM4SCC] = new SymbologySettings();
    this.symbologies[Barcode.Symbology.RM4SCC].activeSymbolCounts = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24];

    this.workingRange = ScanSettings.WorkingRange.STANDARD;

    this.codeCachingDuration = -1;
    this.codeDuplicateFilter = 500;

    this.highDensityModeEnabled = false;

    this.activeScanningAreaPortrait = new Rect(0, 0, 1, 1);
    this.activeScanningAreaLandscape = new Rect(0, 0, 1, 1);

    this.cameraFacingPreference = ScanSettings.CameraFacing.BACK;

    this.scanningHotSpot = new Point(0.5, 0.5);

    this.relativeZoom = 0.0;

    this.maxNumberOfCodesPerFrame = 1;
    this.properties = {
        enable_camera2_api : 0
    }
}

ScanSettings.CameraFacing = {
	BACK: "back",
	FRONT: "front"
}

ScanSettings.WorkingRange = {
	STANDARD: "standard",
	LONG: "long"
}

ScanSettings.prototype.getSymbologySettings = function(symbology) {
	return this.symbologies[symbology];
}

ScanSettings.prototype.setSymbologyEnabled = function(symbology, enabled) {
	var symbologySettings = this.getSymbologySettings(symbology);
	symbologySettings.enabled = enabled;
	this.symbologies[symbology] = symbologySettings;
}

module.exports = ScanSettings;
<commit_msg>Fixed the UPCA default extensions.<commit_after>var Rect = cordova.require("com.mirasense.scanditsdk.plugin.Rect");
var Point = cordova.require("com.mirasense.scanditsdk.plugin.Point");
var SymbologySettings = cordova.require("com.mirasense.scanditsdk.plugin.SymbologySettings");
var Barcode = cordova.require("com.mirasense.scanditsdk.plugin.Barcode");

function ScanSettings() {
    this.symbologies = {};

    this.symbologies[Barcode.Symbology.EAN13] = new SymbologySettings();
    this.symbologies[Barcode.Symbology.EAN13].activeSymbolCounts = [12];

    this.symbologies[Barcode.Symbology.EAN8] = new SymbologySettings();
    this.symbologies[Barcode.Symbology.EAN8].activeSymbolCounts = [8];

    this.symbologies[Barcode.Symbology.UPC12] = new SymbologySettings();
    this.symbologies[Barcode.Symbology.UPC12].activeSymbolCounts = [12];
    this.symbologies[Barcode.Symbology.UPC12].extensions = ["remove_leading_zero"];

    this.symbologies[Barcode.Symbology.UPCE] = new SymbologySettings();
    this.symbologies[Barcode.Symbology.UPCE].activeSymbolCounts = [6];

    this.symbologies[Barcode.Symbology.CODE11] = new SymbologySettings();
    this.symbologies[Barcode.Symbology.CODE11].activeSymbolCounts = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];

    this.symbologies[Barcode.Symbology.CODE25] = new SymbologySettings();
    this.symbologies[Barcode.Symbology.CODE25].activeSymbolCounts = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];

    this.symbologies[Barcode.Symbology.CODE128] = new SymbologySettings();
    this.symbologies[Barcode.Symbology.CODE128].activeSymbolCounts = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];

    this.symbologies[Barcode.Symbology.CODE39] = new SymbologySettings();
    this.symbologies[Barcode.Symbology.CODE39].activeSymbolCounts = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];

    this.symbologies[Barcode.Symbology.CODE93] = new SymbologySettings();
    this.symbologies[Barcode.Symbology.CODE93].activeSymbolCounts = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22];

    this.symbologies[Barcode.Symbology.ITF] = new SymbologySettings();
    this.symbologies[Barcode.Symbology.ITF].activeSymbolCounts = [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18];

    this.symbologies[Barcode.Symbology.QR] = new SymbologySettings();

    this.symbologies[Barcode.Symbology.DATA_MATRIX] = new SymbologySettings();

    this.symbologies[Barcode.Symbology.PDF417] = new SymbologySettings();
    this.symbologies[Barcode.Symbology.MICRO_PDF417] = new SymbologySettings();

    this.symbologies[Barcode.Symbology.MSI_PLESSEY] = new SymbologySettings();
    this.symbologies[Barcode.Symbology.MSI_PLESSEY].activeSymbolCounts = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];

    this.symbologies[Barcode.Symbology.GS1_DATABAR] = new SymbologySettings();

    this.symbologies[Barcode.Symbology.GS1_DATABAR_LIMITED] = new SymbologySettings();

    this.symbologies[Barcode.Symbology.GS1_DATABAR_EXPANDED] = new SymbologySettings();

    this.symbologies[Barcode.Symbology.CODABAR] = new SymbologySettings();
    this.symbologies[Barcode.Symbology.CODABAR].activeSymbolCounts = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];

    this.symbologies[Barcode.Symbology.AZTEC] = new SymbologySettings();

    this.symbologies[Barcode.Symbology.MAXICODE] = new SymbologySettings();

    this.symbologies[Barcode.Symbology.FIVE_DIGIT_ADD_ON] = new SymbologySettings();
    this.symbologies[Barcode.Symbology.FIVE_DIGIT_ADD_ON].activeSymbolCounts = [5];

    this.symbologies[Barcode.Symbology.TWO_DIGIT_ADD_ON] = new SymbologySettings();
    this.symbologies[Barcode.Symbology.TWO_DIGIT_ADD_ON].activeSymbolCounts = [2];

    this.symbologies[Barcode.Symbology.KIX] = new SymbologySettings();
    this.symbologies[Barcode.Symbology.KIX].activeSymbolCounts = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24];

    this.symbologies[Barcode.Symbology.RM4SCC] = new SymbologySettings();
    this.symbologies[Barcode.Symbology.RM4SCC].activeSymbolCounts = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24];

    this.workingRange = ScanSettings.WorkingRange.STANDARD;

    this.codeCachingDuration = -1;
    this.codeDuplicateFilter = 500;

    this.highDensityModeEnabled = false;

    this.activeScanningAreaPortrait = new Rect(0, 0, 1, 1);
    this.activeScanningAreaLandscape = new Rect(0, 0, 1, 1);

    this.cameraFacingPreference = ScanSettings.CameraFacing.BACK;

    this.scanningHotSpot = new Point(0.5, 0.5);

    this.relativeZoom = 0.0;

    this.maxNumberOfCodesPerFrame = 1;
    this.properties = {
        enable_camera2_api : 0
    }
}

ScanSettings.CameraFacing = {
	BACK: "back",
	FRONT: "front"
}

ScanSettings.WorkingRange = {
	STANDARD: "standard",
	LONG: "long"
}

ScanSettings.prototype.getSymbologySettings = function(symbology) {
	return this.symbologies[symbology];
}

ScanSettings.prototype.setSymbologyEnabled = function(symbology, enabled) {
	var symbologySettings = this.getSymbologySettings(symbology);
	symbologySettings.enabled = enabled;
	this.symbologies[symbology] = symbologySettings;
}

module.exports = ScanSettings;
<|endoftext|>


<commit_before>// Copyright (c) Microsoft Corporation. All rights reserved.

var Q = require('q'),
    fs = require('fs'),
    cordovaServe = require('cordova-serve'),
    path = require('path'),
    config = require('./server/config'),
    log = require('./server/log'),
    simServer = require('./server/server'),
    simSocket = require('./server/socket'),
    plugins = require('./server/plugins'),
    dirs = require('./server/dirs');

var server = cordovaServe();

var launchServer = function(opts) {
    opts = opts || {};

    var platform = opts.platform || 'browser';
    var appUrl, simHostUrl, simHostOpts;

    if (opts.simhostui && fs.existsSync(opts.simhostui)) {
        simHostOpts = { simHostRoot: opts.simhostui };
    } else {
        /* use the default simulation UI */
        simHostOpts = { simHostRoot: path.join(__dirname, 'sim-host', 'ui') };
    }

    var middlewarePath = path.join(simHostOpts.simHostRoot, 'server', 'server');
    if (fs.existsSync(middlewarePath + '.js')) {
        require(middlewarePath).attach(server.app, dirs);
    }

    config.platform = platform;
    config.simHostOptions = simHostOpts;
    config.telemetry = opts.telemetry;

    simServer.attach(server.app);

    return server.servePlatform(platform, {
        port: opts.port,
        root: opts.dir,
        noServerInfo: true
    }).then(function () {
        simSocket.init(server.server);
        config.server = server.server;
        var projectRoot = server.projectRoot;
        config.projectRoot = projectRoot;
        config.platformRoot = server.root;
        var urlRoot = 'http://localhost:' + server.port + '/';
        appUrl = urlRoot + parseStartPage(projectRoot);
        simHostUrl = urlRoot + 'simulator/index.html';
        log.log('Server started:\n- App running at: ' + appUrl + '\n- Sim host running at: ' + simHostUrl);
        return {appUrl: appUrl, simHostUrl: simHostUrl};
    }).catch(function (error) {
        // Ensure server is closed, then rethrow so it can be handled by downstream consumers.
        config.server && config.server.close();
        if (error instanceof Error) {
            throw error;
        } else {
            throw new Error(error);
        }
    });
};

var closeServer = function() {
    return server.server && server.server.close();
};

var launchBrowser = function(target, url) {
    return cordovaServe.launchBrowser({ target: target, url: url });
};

var simulate = function(opts) {

    var target = opts.target || 'chrome';
    var simHostUrl;

    return launchServer(opts)
        .then(function(urls) {
            simHostUrl = urls.simHostUrl;
            return launchBrowser(target, urls.appUrl);
        }).then(function() {
            return launchBrowser(target, simHostUrl);
        }).catch(function(error) {
            // Ensure server is closed, then rethrow so it can be handled by downstream consumers.
            closeServer();
            if (error instanceof Error) {
                throw error;
            } else {
                throw new Error(error);
            }
        });
};

var parseStartPage = function(projectRoot) {
    // Start Page is defined as <content src="some_uri" /> in config.xml

    var configFile = path.join(projectRoot, 'config.xml');
    if (!fs.existsSync(configFile)) {
        throw new Error('Cannot find project config file: ' + configFile);
    }

    var startPageRegexp = /<content\s+src\s*=\s*"(.+)"\s*\/>/ig,
        configFileContent = fs.readFileSync(configFile);

    var match = startPageRegexp.exec(configFileContent);
    if (match) {
        return match[1];
    }

    return 'index.html'; // default uri
};

module.exports = simulate;
module.exports.launchBrowser = launchBrowser;
module.exports.launchServer = launchServer;
module.exports.closeServer = closeServer;
module.exports.dirs = dirs;
module.exports.app = server.app;
module.exports.log = log;
<commit_msg>Removed error handler from launchServer.<commit_after>// Copyright (c) Microsoft Corporation. All rights reserved.

var Q = require('q'),
    fs = require('fs'),
    cordovaServe = require('cordova-serve'),
    path = require('path'),
    config = require('./server/config'),
    log = require('./server/log'),
    simServer = require('./server/server'),
    simSocket = require('./server/socket'),
    plugins = require('./server/plugins'),
    dirs = require('./server/dirs');

var server = cordovaServe();

var launchServer = function(opts) {
    opts = opts || {};

    var platform = opts.platform || 'browser';
    var appUrl, simHostUrl, simHostOpts;

    if (opts.simhostui && fs.existsSync(opts.simhostui)) {
        simHostOpts = { simHostRoot: opts.simhostui };
    } else {
        /* use the default simulation UI */
        simHostOpts = { simHostRoot: path.join(__dirname, 'sim-host', 'ui') };
    }

    var middlewarePath = path.join(simHostOpts.simHostRoot, 'server', 'server');
    if (fs.existsSync(middlewarePath + '.js')) {
        require(middlewarePath).attach(server.app, dirs);
    }

    config.platform = platform;
    config.simHostOptions = simHostOpts;
    config.telemetry = opts.telemetry;

    simServer.attach(server.app);

    return server.servePlatform(platform, {
        port: opts.port,
        root: opts.dir,
        noServerInfo: true
    }).then(function () {
        simSocket.init(server.server);
        config.server = server.server;
        var projectRoot = server.projectRoot;
        config.projectRoot = projectRoot;
        config.platformRoot = server.root;
        var urlRoot = 'http://localhost:' + server.port + '/';
        appUrl = urlRoot + parseStartPage(projectRoot);
        simHostUrl = urlRoot + 'simulator/index.html';
        log.log('Server started:\n- App running at: ' + appUrl + '\n- Sim host running at: ' + simHostUrl);
        return {appUrl: appUrl, simHostUrl: simHostUrl};
    });
};

var closeServer = function() {
    return server.server && server.server.close();
};

var launchBrowser = function(target, url) {
    return cordovaServe.launchBrowser({ target: target, url: url });
};

var simulate = function(opts) {

    var target = opts.target || 'chrome';
    var simHostUrl;

    return launchServer(opts)
        .then(function(urls) {
            simHostUrl = urls.simHostUrl;
            return launchBrowser(target, urls.appUrl);
        }).then(function() {
            return launchBrowser(target, simHostUrl);
        }).catch(function(error) {
            // Ensure server is closed, then rethrow so it can be handled by downstream consumers.
            closeServer();
            if (error instanceof Error) {
                throw error;
            } else {
                throw new Error(error);
            }
        });
};

var parseStartPage = function(projectRoot) {
    // Start Page is defined as <content src="some_uri" /> in config.xml

    var configFile = path.join(projectRoot, 'config.xml');
    if (!fs.existsSync(configFile)) {
        throw new Error('Cannot find project config file: ' + configFile);
    }

    var startPageRegexp = /<content\s+src\s*=\s*"(.+)"\s*\/>/ig,
        configFileContent = fs.readFileSync(configFile);

    var match = startPageRegexp.exec(configFileContent);
    if (match) {
        return match[1];
    }

    return 'index.html'; // default uri
};

module.exports = simulate;
module.exports.launchBrowser = launchBrowser;
module.exports.launchServer = launchServer;
module.exports.closeServer = closeServer;
module.exports.dirs = dirs;
module.exports.app = server.app;
module.exports.log = log;
<|endoftext|>


<commit_before>angular.module('VkApp')

.constant('apiConfig', {
	version: '5.52',
})

.factory('$vk', ['$q','$http','$httpParamSerializer', 'storage', 'apiConfig', '$log',
function ($q, $http,$httpParamSerializer, storage, apiConfig, $log) {
	return {
		authUrl:          'https://oauth.vk.com/authorize?' + $httpParamSerializer({
			'redirect_uri':  'https://oauth.vk.com/blank.html',
			'client_id':     4682781,
			'scope':         'offline,friends,messages,notifications,wall',
			'response_type': 'token',
			'display':       'popup',
			'v':             apiConfig.version,
			'state':         'vknotice',
		}),

		isAuth: function () {
			const $vk   = this;
			const ready = $q.defer();
			if ($vk.stg.access_token && $vk.stg.user_id) {
				$vk.api('users.get', {access_token: $vk.stg.access_token}).then(function (resp) {
					ready.resolve(resp && resp[0] && resp[0].id && resp[0].id == $vk.stg.user_id);
				}, function () {
					ready.resolve(false);
				});
			} else {
				ready.resolve(false);
			}
			return ready.promise;
		},

		auth: function () {
			const $vk   = this;
			const ready = $q.defer();
			storage.ready.then(function (stg) {
				$vk.stg = stg;
				$vk.isAuth().then(function (isAuth) {
					if (isAuth) {
						ready.resolve();
					} else {
						chrome.tabs.create({url: $vk.authUrl, active: true}, function (tab) {
							const authTabId = tab.id;
							chrome.tabs.onUpdated.addListener(function tabUpdateListener (tabId, changeInfo) {
								if(tabId === authTabId
									&& angular.isDefined(changeInfo.url)
									&& changeInfo.url.indexOf('oauth.vk.com/blank.html') > -1
								) {
									let authData = $vk.parseHashParams(changeInfo.url);
									$vk.stg.user_id      = authData.user_id;
									$vk.stg.access_token = authData.access_token;

									storage.set({
										user_id:      $vk.stg.user_id,
										access_token: $vk.stg.access_token,
									});

									chrome.tabs.remove(authTabId);
									chrome.tabs.onUpdated.removeListener(tabUpdateListener);
								}
							});
							chrome.tabs.onRemoved.addListener(function tabRemovedListener (tabId) {
								if (authTabId === tabId) {
									$vk.isAuth().then(function (isAuth) {
										ready[ isAuth ? 'resolve' : 'reject' ]();
										chrome.tabs.onRemoved.removeListener(tabRemovedListener);
									});
								}
							});
						});
					}
				});
			});

			return ready.promise;
		},

		parseHashParams: function (url) {
			const ret  = {};
			const hash = url.split('#')[1].split('&');
			for (let i = hash.length; i--;) {
				if (!hash[i]) continue;
				let s = hash[i].split('=');
				ret[s[0]] = s[1];
			}
			return ret;
		},

		api: function (method, data) {
			const ready = $q.defer();
			data.v = apiConfig.version;
			$http.get('https://api.vk.com/method/'+method, {params: data})
				.then(function (API) {
					if (angular.isDefined(API.data.response)) {
						ready.resolve(API.data.response);
					} else {
						$log.error(API.data.error);
						ready.reject('api_error');
					}
				}, function () {
					ready.reject('connect_error');
				});

			return ready.promise;
		},
	};
}]);
<commit_msg>Formated VkApp<commit_after>angular.module('VkApp')

.constant('apiConfig', {
	version: '5.52',
})

.factory('$vk', ['$q', '$http', '$httpParamSerializer', 'storage', 'apiConfig', '$log',
function ($q, $http, $httpParamSerializer, storage, apiConfig, $log) {
	return {
		authUrl:          'https://oauth.vk.com/authorize?' + $httpParamSerializer({
			'redirect_uri':  'https://oauth.vk.com/blank.html',
			'client_id':     4682781,
			'scope':         'offline,friends,messages,notifications,wall',
			'response_type': 'token',
			'display':       'popup',
			'v':             apiConfig.version,
			'state':         'vknotice',
		}),

		isAuth: function () {
			const $vk   = this;
			const ready = $q.defer();

			if ($vk.stg.access_token && $vk.stg.user_id) {
				$vk.api('users.get', {access_token: $vk.stg.access_token}).then(function (resp) {
					ready.resolve(resp && resp[0] && resp[0].id && resp[0].id == $vk.stg.user_id);
				}, function () {
					ready.resolve(false);
				});
			} else {
				ready.resolve(false);
			}

			return ready.promise;
		},

		auth: function () {
			const $vk   = this;
			const ready = $q.defer();

			storage.ready.then(function (stg) {
				$vk.stg = stg;
				$vk.isAuth().then(function (isAuth) {
					if (isAuth) {
						ready.resolve();
					} else {
						chrome.tabs.create({
							url:    $vk.authUrl,
							active: true,
						}, function (tab) {
							const authTabId = tab.id;

							chrome.tabs.onUpdated.addListener(function tabUpdateListener(tabId, changeInfo) {
								if (tabId === authTabId
									&& angular.isDefined(changeInfo.url)
									&& changeInfo.url.indexOf('oauth.vk.com/blank.html') > -1
								) {
									let authData = $vk.parseHashParams(changeInfo.url);

									$vk.stg.user_id      = authData.user_id;
									$vk.stg.access_token = authData.access_token;

									storage.set({
										user_id:      $vk.stg.user_id,
										access_token: $vk.stg.access_token,
									});

									chrome.tabs.remove(authTabId);
									chrome.tabs.onUpdated.removeListener(tabUpdateListener);
								}
							});
							chrome.tabs.onRemoved.addListener(function tabRemovedListener(tabId) {
								if (authTabId === tabId) {
									$vk.isAuth().then(function (isAuth) {
										ready[ isAuth ? 'resolve' : 'reject' ]();
										chrome.tabs.onRemoved.removeListener(tabRemovedListener);
									});
								}
							});
						});
					}
				});
			});

			return ready.promise;
		},

		parseHashParams: function (url) {
			const ret  = {};
			const hash = url.split('#')[1].split('&');

			for (let i = hash.length; i--;) {
				if (!hash[i]) continue;
				let s = hash[i].split('=');

				ret[s[0]] = s[1];
			}

			return ret;
		},

		api: function (method, data) {
			const ready = $q.defer();

			data.v = apiConfig.version;
			$http.get('https://api.vk.com/method/'+method, {params: data})
				.then(function (API) {
					if (angular.isDefined(API.data.response)) {
						ready.resolve(API.data.response);
					} else {
						$log.error(API.data.error);
						ready.reject('api_error');
					}
				}, function () {
					ready.reject('connect_error');
				});

			return ready.promise;
		},
	};
}]);
<|endoftext|>


<commit_before>/**
 * @copyright 2015, Prometheus Research, LLC
 */

import React from 'react';
import ReactDOMServer from 'react-dom/server';
import assert from 'power-assert';
import {style} from 'react-dom-stylesheet';
import Box from '../Box';

describe('Box', function() {

  it('allows to style component', function() {
    let Styled = style(Box, {color: 'red'});
    assert(Styled.stylesheet.style.base.display === 'flex');
    assert(Styled.stylesheet.style.base.color === 'red');
  });

  it('accepts flexbox related style as props', function() {
    let markup = ReactDOMServer.renderToString(<Box flex={1} />);
    assert(/style="flex:1;"/.exec(markup));
  });

});
<commit_msg>test: fixes<commit_after>/**
 * @copyright 2015, Prometheus Research, LLC
 */

import React from 'react';
import ReactDOMServer from 'react-dom/server';
import assert from 'power-assert';
import {style} from 'react-dom-stylesheet';
import Box from '../Box';

describe('Box', function() {

  it('allows to style component', function() {
    let Styled = style(Box, {color: 'red'});
    assert(/flex/.exec(Styled.stylesheet.style.base.display));
    assert(Styled.stylesheet.style.base.color === 'red');
  });

  it('accepts flexbox related style as props', function() {
    let markup = ReactDOMServer.renderToString(<Box flex={1} />);
    assert(/style="flex:1;"/.exec(markup));
  });

});
<|endoftext|>


<commit_before>var express = require('express')
var webpack = require('webpack')
var config = require('./webpack.dev.conf')

var app = express()
var compiler = webpack(config)

// handle fallback for HTML5 history API
app.use(require('connect-history-api-fallback')())

// serve webpack bundle output
app.use(require('webpack-dev-middleware')(compiler, {
  noInfo: true,
  publicPath: config.output.publicPath
}))

// enable hot-reload and state-preserving
// compilation error display
app.use(require('webpack-hot-middleware')(compiler))

app.listen(8080, 'localhost', function (err) {
  if (err) {
    console.log(err)
    return
  }
  console.log('Listening at http://localhost:8080')
})
<commit_msg>better dev server console output<commit_after>var express = require('express')
var webpack = require('webpack')
var config = require('./webpack.dev.conf')

var app = express()
var compiler = webpack(config)

// handle fallback for HTML5 history API
app.use(require('connect-history-api-fallback')())

// serve webpack bundle output
app.use(require('webpack-dev-middleware')(compiler, {
  publicPath: config.output.publicPath,
  stats: {
    colors: true,
    chunks: false
  }
}))

// enable hot-reload and state-preserving
// compilation error display
app.use(require('webpack-hot-middleware')(compiler))

app.listen(8080, 'localhost', function (err) {
  if (err) {
    console.log(err)
    return
  }
  console.log('Listening at http://localhost:8080')
})
<|endoftext|>


<commit_before>/* ------- DEPENDENCIES ------- */

var cheerio = require("cheerio"),
    fs      = require("fs"),
    HTTP    = require("q-io/http"),
    jsdom   = require("jsdom"),
    Q       = require("q"),
    url     = require("url");

var jquery = fs.readFileSync("./jquery-2.0.0.js").toString();

/* ------- EXPORTS ------- */

function huaGetJsdom(url, jsdomCallback) {
    var deferred = Q.defer();
    HTTP.read(url).then(
        function succ(body) {
            jsdom.env({
                html: body,
                src: [jquery],
                url: url,
                done: function (errors, window) {
                    if (errors) {
                        var e = new Error("jsdom errors");
                        e.errors = errors;
                        deferred.reject(e);
                    } else {
                        deferred.resolve(jsdomCallback(window, window.$));
                    }
                }
            });
        },
        function fail(response) {
            var e = new Error("HTTP error");
            e.response = response;
            deferred.reject(e);
        }
    );
    return deferred.promise;
}

exports.huaGetJsdom = huaGetJsdom;

function huaGetCheerio(url, cheerioCallback) {
    var deferred = Q.defer();
    HTTP.read(url).then(
        function succ(body) {
            var $ = cheerio.load(body);
            deferred.resolve(cheerioCallback(url, $));
        },
        function fail(response) {
            var e = new Error("HTTP error");
            e.response = response;
            deferred.reject(e);
        }
    );
    return deferred.promise;
}

exports.huaGet = exports.huaGetCheerio = huaGetCheerio;

function resolveURL(windowORurl, toURL) {
    var fromURL;
    if (typeof windowORurl === "object") {
        fromURL = windowORurl.location.href;
    } else {
        fromURL = windowORurl;
    }
    return url.resolve(fromURL, toURL);
}

exports.resolveURL = resolveURL;

function logCallback(stepNum) {
    console.log("\n*** callback #" + stepNum + " ***\n");
}

exports.logCallback = logCallback;

function logError(err) {
    console.log("ERROR!!!  message: ", err.message);
}

exports.logError = logError;
<commit_msg>revise logging for callbacks<commit_after>/* ------- DEPENDENCIES ------- */

var cheerio = require("cheerio"),
    fs      = require("fs"),
    HTTP    = require("q-io/http"),
    jsdom   = require("jsdom"),
    Q       = require("q"),
    url     = require("url");

var jquery = fs.readFileSync("./jquery-2.0.0.js").toString();

/* ------- EXPORTS ------- */

function huaGetJsdom(url, jsdomCallback) {
    var deferred = Q.defer();
    HTTP.read(url).then(
        function succ(body) {
            jsdom.env({
                html: body,
                src: [jquery],
                url: url,
                done: function (errors, window) {
                    if (errors) {
                        var e = new Error("jsdom errors");
                        e.errors = errors;
                        deferred.reject(e);
                    } else {
                        deferred.resolve(jsdomCallback(window, window.$));
                    }
                }
            });
        },
        function fail(response) {
            var e = new Error("HTTP error");
            e.response = response;
            deferred.reject(e);
        }
    );
    return deferred.promise;
}

exports.huaGetJsdom = huaGetJsdom;

function huaGetCheerio(url, cheerioCallback) {
    var deferred = Q.defer();
    HTTP.read(url).then(
        function succ(body) {
            var $ = cheerio.load(body);
            deferred.resolve(cheerioCallback(url, $));
        },
        function fail(response) {
            var e = new Error("HTTP error");
            e.response = response;
            deferred.reject(e);
        }
    );
    return deferred.promise;
}

exports.huaGet = exports.huaGetCheerio = huaGetCheerio;

function resolveURL(windowORurl, toURL) {
    var fromURL;
    if (typeof windowORurl === "object") {
        fromURL = windowORurl.location.href;
    } else {
        fromURL = windowORurl;
    }
    return url.resolve(fromURL, toURL);
}

exports.resolveURL = resolveURL;

function logCallback(stepNum) {
    console.log("\n*** Step #" + stepNum + " ***\n");
}

exports.logCallback = logCallback;

function logError(err) {
    console.log("ERROR!!!  message: ", err.message);
}

exports.logError = logError;
<|endoftext|>


<commit_before>'use strict';

/* eslint-disable no-extend-native */

/* ---------------------------------------------------------------
  String functions
  For velocity templates to access java functions, to mimick AWS
--------------------------------------------------------------- */

String.prototype.contains = value => this.indexOf(value) >= 0;

String.prototype.replaceAll = (oldValue, newValue) => this.replace(new RegExp(oldValue, 'gm'), newValue);

String.prototype.replaceFirst = (oldValue, newValue) => this.replace(new RegExp(oldValue, 'm'), newValue);

String.prototype.matches = value => this.match(new RegExp(value, 'm'));

String.prototype.regionMatches = (ignoreCase, toffset, other, ooffset, len) => {
  /*
   * Support different method signatures
   */
  if (typeof ignoreCase === 'number' || (ignoreCase !== true && ignoreCase !== false)) {
    len = ooffset;
    ooffset = other;
    other = toffset;
    toffset = ignoreCase;
    ignoreCase = false;
  }

  // Note: toffset, ooffset, or len might be near -1>>>1.
  if ((ooffset < 0) || (toffset < 0) || (toffset > this.length - len) || (ooffset > other.length - len)) {
    return false;
  }

  let s1 = this.substring(toffset, toffset + len);
  let s2 = other.substring(ooffset, ooffset + len);

  if (ignoreCase) {
    s1 = s1.toLowerCase();
    s2 = s2.toLowerCase();
  }

  return s1 == s2; // eslint-disable-line eqeqeq
};

String.prototype.equals = anObject => this.toString() === anObject.toString();

String.prototype.equalsIgnoreCase = anotherString => anotherString === null ?
  false :
  this === anotherString || this.toLowerCase() === anotherString.toLowerCase();

// No particular exports
module.exports = null;
<commit_msg>replaces fat arrows with functions so 'this' refers to global String object<commit_after>'use strict';

/* eslint no-extend-native:0 func-names:0 */

/* ---------------------------------------------------------------
  String functions
  For velocity templates to access java functions, to mimick AWS
--------------------------------------------------------------- */

String.prototype.contains = function (value) {
  return this.indexOf(value) >= 0;
};

String.prototype.replaceAll = function (oldValue, newValue) {
  return this.replace(new RegExp(oldValue, 'gm'), newValue);
};

String.prototype.replaceFirst = function (oldValue, newValue) {
  return this.replace(new RegExp(oldValue, 'm'), newValue);
};

String.prototype.matches = function (value) {
  return this.match(new RegExp(value, 'm'));
};

String.prototype.regionMatches = function (ignoreCase, toffset, other, ooffset, len) {
  /*
   * Support different method signatures
   */
  if (typeof ignoreCase === 'number'
    || (ignoreCase !== true && ignoreCase !== false)) {
    len = ooffset;
    ooffset = other;
    other = toffset;
    toffset = ignoreCase;
    ignoreCase = false;
  }

  // Note: toffset, ooffset, or len might be near -1>>>1.
  if ((ooffset < 0) || (toffset < 0) || (toffset > this.length - len) ||
      (ooffset > other.length - len)) {
    return false;
  }

  let s1 = this.substring(toffset, toffset + len);
  let s2 = other.substring(ooffset, ooffset + len);

  if (ignoreCase) {
    s1 = s1.toLowerCase();
    s2 = s2.toLowerCase();
  }

  return s1 == s2; // eslint-disable-line eqeqeq
};

String.prototype.equals = function (anObject) {
  return this.toString() === anObject.toString();
};

String.prototype.equalsIgnoreCase = function (anotherString) {
  return (anotherString === null) ? false :
    (this === anotherString || this.toLowerCase() === anotherString.toLowerCase());
};

// No particular exports
module.exports = null;
<|endoftext|>


<commit_before>export default {
    "$schema": "http://json-schema.org/draft-04/schema#",
    "definitions": {
        "formula": {
            "type": "object",
            "properties": {
                "formula": {
                    "type": "string"
                },
                "start": {
                    "type": "string",
                    "format": "date-time"
                },
                "end": {
                    "type": "string",
                    "format": "date-time"
                },
                "variables": {
                    "type": "array",
                    "uniqueItems": true,
                    "items": {
                        "type": "string"
                    }
                },
                "measurementType": {
                    "type": "array",
                    "uniqueItems": true,
                    "items": {
                        "type": "string"
                    }
                }
            },
            "required": ["formula", "start", "end", "variables", "measurementType"]
        }
    },
    "type": "object",
    "properties": {
        "id": {
            "type": "string"
        },
        "name": {
            "type": "string"
        },
        "type": {
            "type": "string"
        },
        "description": {
            "type": "string"
        },
        "shortDescription": {
            "type": "string"
        },
        "sampleDeltaInMS": {
            "type": "integer",
            "minimum": 10000
        },
        "unitOfMeasurement": {
            "type": "string"
        },
        "virtual": {
            "type": "boolean"
        },
        "formulas": {
            "type": "array",
            "items": {
                "$ref": "#/definitions/formula"
            }
        },
        "tags": {
            "type": "array",
            "uniqueItems": true,
            "items": {
                "type": "string"
            }
        },
        "siteId": {
            "type": "string"
        },
        "userId": {
            "type": "string"
        },
        "parentSensorId": {
            "type": "string"
        }
    },
    "additionalProperties": false,
    "required": [
        "id",
        "name",
        "type"
    ]
};
<commit_msg>Add primaryTags to sensors JSON schema<commit_after>export default {
    "$schema": "http://json-schema.org/draft-04/schema#",
    "definitions": {
        "formula": {
            "type": "object",
            "properties": {
                "formula": {
                    "type": "string"
                },
                "start": {
                    "type": "string",
                    "format": "date-time"
                },
                "end": {
                    "type": "string",
                    "format": "date-time"
                },
                "variables": {
                    "type": "array",
                    "uniqueItems": true,
                    "items": {
                        "type": "string"
                    }
                },
                "measurementType": {
                    "type": "array",
                    "uniqueItems": true,
                    "items": {
                        "type": "string"
                    }
                }
            },
            "required": ["formula", "start", "end", "variables", "measurementType"]
        }
    },
    "type": "object",
    "properties": {
        "id": {
            "type": "string"
        },
        "name": {
            "type": "string"
        },
        "type": {
            "type": "string"
        },
        "description": {
            "type": "string"
        },
        "shortDescription": {
            "type": "string"
        },
        "sampleDeltaInMS": {
            "type": "integer",
            "minimum": 10000
        },
        "unitOfMeasurement": {
            "type": "string"
        },
        "virtual": {
            "type": "boolean"
        },
        "formulas": {
            "type": "array",
            "items": {
                "$ref": "#/definitions/formula"
            }
        },
        "tags": {
            "type": "array",
            "uniqueItems": true,
            "items": {
                "type": "string"
            }
        },
        "primaryTags": {
            "type": "array",
            "uniqueItems": true,
            "items": {
                "type": "string"
            }
        },
        "siteId": {
            "type": "string"
        },
        "userId": {
            "type": "string"
        },
        "parentSensorId": {
            "type": "string"
        }
    },
    "additionalProperties": false,
    "required": [
        "id",
        "name",
        "type"
    ]
};
<|endoftext|>


<commit_before>define(['jquery', 'underscore','moment'],
function($, _, moment) {
  'use strict';

  var kbn = {};

  kbn.get_object_fields = function(obj) {
    var field_array = [];
    obj = kbn.flatten_json(obj._source);
    for (var field in obj) {
      field_array.push(field);
    }
    return field_array.sort();
  };

  kbn.get_all_fields = function(data) {
    var _d = data;
    var fields = [];
    _.each(_d,function(hit) {
      fields = _.uniq(fields.concat(_.keys(kbn.flatten_json(hit._source))));
    });
    // Remove stupid angular key
    fields = _.without(fields,'$$hashKey');
    return fields;
  };

  kbn.has_field = function(obj,field) {
    var obj_fields = kbn.get_object_fields(obj);
    if (_.inArray(obj_fields,field) < 0) {
      return false;
    } else {
      return true;
    }
  };

  kbn.get_related_fields = function(docs,field) {
    var field_array = [];
    _.each(docs, function(doc) {
      var keys = _.keys(doc);
      if(_.contains(keys,field)) {
        field_array = field_array.concat(keys);
      }
    });
    var counts = _.countBy(_.without(field_array,field),function(field){return field;});
    return _.map(counts, function(num, key){return {name:key,count:num};});
  };

  kbn.recurse_field_dots = function(object,field) {
    var value = null;
    var nested;
    if (typeof object[field] !== 'undefined') {
      value = object[field];
    }
    else if (nested = field.match(/(.*?)\.(.*)/)) {
      if(typeof object[nested[1]] !== 'undefined') {
        value = (typeof object[nested[1]][nested[2]] !== 'undefined') ?
          object[nested[1]][nested[2]] : kbn.recurse_field_dots(
            object[nested[1]],nested[2]);
      }
    }

    return value;
  };

  kbn.top_field_values = function(docs,field,count,grouped) {
    var all_values = _.pluck(docs,field),
      groups = {},
      counts,
      hasArrays;
    // manually grouping into pairs allows us to keep the original value,
    _.each(all_values, function (value) {
      var k;
      if(_.isArray(value)) {
        hasArrays =  true;
      }
      if(_.isArray(value) && !grouped) {
        k = value;
      } else {
        k = _.isUndefined(value) ? '' : [value.toString()];
      }
      _.each(k, function(key) {
        if (_.has(groups, key)) {
          groups[key][1] ++;
        } else {
          groups[key] = [(grouped ? value : key), 1];
        }
      });
    });

    counts = _.values(groups).sort(function(a, b) {
      return a[1] - b[1];
    }).reverse().slice(0,count);

    return {
      counts: counts,
      hasArrays : hasArrays
    };
  };

   /**
     * Calculate a graph interval
     *
     * from::           Date object containing the start time
     * to::             Date object containing the finish time
     * size::           Calculate to approximately this many bars
     * user_interval::  User specified histogram interval
     *
     */
  kbn.calculate_interval = function(from,to,size,user_interval) {
    if(_.isObject(from)) {
      from = from.valueOf();
    }
    if(_.isObject(to)) {
      to = to.valueOf();
    }
    return user_interval === 0 ? kbn.round_interval((to - from)/size) : user_interval;
  };

  kbn.round_interval = function(interval) {
    switch (true) {
    // 0.5s
    case (interval <= 500):
      return 100;       // 0.1s
    // 5s
    case (interval <= 5000):
      return 1000;      // 1s
    // 7.5s
    case (interval <= 7500):
      return 5000;      // 5s
    // 15s
    case (interval <= 15000):
      return 10000;     // 10s
    // 45s
    case (interval <= 45000):
      return 30000;     // 30s
    // 3m
    case (interval <= 180000):
      return 60000;     // 1m
    // 9m
    case (interval <= 450000):
      return 300000;    // 5m
    // 20m
    case (interval <= 1200000):
      return 600000;    // 10m
    // 45m
    case (interval <= 2700000):
      return 1800000;   // 30m
    // 2h
    case (interval <= 7200000):
      return 3600000;   // 1h
    // 6h
    case (interval <= 21600000):
      return 10800000;  // 3h
    // 24h
    case (interval <= 86400000):
      return 43200000;  // 12h
    // 48h
    case (interval <= 172800000):
      return 86400000;  // 24h
    // 1w
    case (interval <= 604800000):
      return 86400000;  // 24h
    // 3w
    case (interval <= 1814400000):
      return 604800000; // 1w
    // 2y
    case (interval < 3628800000):
      return 2592000000; // 30d
    default:
      return 31536000000; // 1y
    }
  };

  kbn.secondsToHms = function(seconds){
    var numyears = Math.floor(seconds / 31536000);
    if(numyears){
      return numyears + 'y';
    }
    var numdays = Math.floor((seconds % 31536000) / 86400);
    if(numdays){
      return numdays + 'd';
    }
    var numhours = Math.floor(((seconds % 31536000) % 86400) / 3600);
    if(numhours){
      return numhours + 'h';
    }
    var numminutes = Math.floor((((seconds % 31536000) % 86400) % 3600) / 60);
    if(numminutes){
      return numminutes + 'm';
    }
    var numseconds = (((seconds % 31536000) % 86400) % 3600) % 60;
    if(numseconds){
      return numseconds + 's';
    }
    return 'less then a second'; //'just now' //or other string you like;
  };

  kbn.to_percent = function(number,outof) {
    return Math.floor((number/outof)*10000)/100 + "%";
  };

  kbn.addslashes = function(str) {
    str = str.replace(/\\/g, '\\\\');
    str = str.replace(/\'/g, '\\\'');
    str = str.replace(/\"/g, '\\"');
    str = str.replace(/\0/g, '\\0');
    return str;
  };

  kbn.interval_regex = /(\d+(?:\.\d+)?)([Mwdhmsy])/;

  // histogram & trends
  kbn.intervals_in_seconds = {
    y: 31536000,
    M: 2592000,
    w: 604800,
    d: 86400,
    h: 3600,
    m: 60,
    s: 1
  };

  kbn.describe_interval = function (string) {
    var matches = string.match(kbn.interval_regex);
    if (!matches || !_.has(kbn.intervals_in_seconds, matches[2])) {
      throw new Error('Invalid interval string, expexcting a number followed by one of "Mwdhmsy"');
    } else {
      return {
        sec: kbn.intervals_in_seconds[matches[2]],
        type: matches[2],
        count: parseInt(matches[1], 10)
      };
    }
  };

  kbn.interval_to_ms = function(string) {
    var info = kbn.describe_interval(string);
    return info.sec * 1000 * info.count;
  };

  kbn.interval_to_seconds = function (string) {
    var info = kbn.describe_interval(string);
    return info.sec * info.count;
  };

  // This should go away, moment.js can do this
  kbn.time_ago = function(string) {
    return new Date(new Date().getTime() - (kbn.interval_to_ms(string)));
  };

  /* This is a simplified version of elasticsearch's date parser */
  kbn.parseDate = function(text) {
    if(_.isDate(text)) {
      return text;
    }
    var time,
      mathString = "",
      index,
      parseString;
    if (text.substring(0,3) === "now") {
      time = new Date();
      mathString = text.substring("now".length);
    } else {
      index = text.indexOf("||");
      parseString;
      if (index === -1) {
        parseString = text;
        mathString = ""; // nothing else
      } else {
        parseString = text.substring(0, index);
        mathString = text.substring(index + 2);
      }
      // We're going to just require ISO8601 timestamps, k?
      time = new Date(parseString);
    }

    if (!mathString.length) {
      return time;
    }

    //return [time,parseString,mathString];
    return kbn.parseDateMath(mathString, time);
  };

  kbn.parseDateMath = function(mathString, time, roundUp) {
    var dateTime = moment(time);
    for (var i = 0; i < mathString.length; ) {
      var c = mathString.charAt(i++),
        type,
        num,
        unit;
      if (c === '/') {
        type = 0;
      } else if (c === '+') {
        type = 1;
      } else if (c === '-') {
        type = 2;
      } else {
        return false;
      }

      if (isNaN(mathString.charAt(i))) {
        num = 1;
      } else {
        var numFrom = i;
        while (!isNaN(mathString.charAt(i))) {
          i++;
        }
        num = parseInt(mathString.substring(numFrom, i),10);
      }
      if (type === 0) {
        // rounding is only allowed on whole numbers
        if (num !== 1) {
          return false;
        }
      }
      unit = mathString.charAt(i++);
      switch (unit) {
      case 'M':
        if (type === 0) {
          roundUp ? dateTime.endOf('month') : dateTime.startOf('month');
        } else if (type === 1) {
          dateTime.add('months',num);
        } else if (type === 2) {
          dateTime.subtract('months',num);
        }
        break;
      case 'w':
        if (type === 0) {
          roundUp ? dateTime.endOf('week') : dateTime.startOf('week');
        } else if (type === 1) {
          dateTime.add('weeks',num);
        } else if (type === 2) {
          dateTime.subtract('weeks',num);
        }
        break;
      case 'd':
        if (type === 0) {
          roundUp ? dateTime.endOf('day') : dateTime.startOf('day');
        } else if (type === 1) {
          dateTime.add('days',num);
        } else if (type === 2) {
          dateTime.subtract('days',num);
        }
        break;
      case 'h':
      case 'H':
        if (type === 0) {
          roundUp ? dateTime.endOf('hour') : dateTime.startOf('hour');
        } else if (type === 1) {
          dateTime.add('hours',num);
        } else if (type === 2) {
          dateTime.subtract('hours',num);
        }
        break;
      case 'm':
        if (type === 0) {
          roundUp ? dateTime.endOf('minute') : dateTime.startOf('minute');
        } else if (type === 1) {
          dateTime.add('minutes',num);
        } else if (type === 2) {
          dateTime.subtract('minutes',num);
        }
        break;
      case 's':
        if (type === 0) {
          roundUp ? dateTime.endOf('second') : dateTime.startOf('second');
        } else if (type === 1) {
          dateTime.add('seconds',num);
        } else if (type === 2) {
          dateTime.subtract('seconds',num);
        }
        break;
      default:
        return false;
      }
    }
    return dateTime.toDate();
  };

  // LOL. hahahahaha. DIE.
  kbn.flatten_json = function(object,root,array) {
    if (typeof array === 'undefined') {
      array = {};
    }
    if (typeof root === 'undefined') {
      root = '';
    }
    for(var index in object) {
      var obj = object[index];
      var rootname = root.length === 0 ? index : root + '.' + index;
      if(typeof obj === 'object' ) {
        if(_.isArray(obj)) {
          if(obj.length > 0 && typeof obj[0] === 'object') {
            var strval = '';
            for (var objidx = 0, objlen = obj.length; objidx < objlen; objidx++) {
              if (objidx > 0) {
                strval = strval + ', ';
              }

              strval = strval + JSON.stringify(obj[objidx]);
            }
            array[rootname] = strval;
          } else if(obj.length === 1 && _.isNumber(obj[0])) {
            array[rootname] = parseFloat(obj[0]);
          } else {
            array[rootname] = typeof obj === 'undefined' ? null : obj;
          }
        } else {
          kbn.flatten_json(obj,rootname,array);
        }
      } else {
        array[rootname] = typeof obj === 'undefined' ? null : obj;
      }
    }
    return kbn.sortObj(array);
  };

  kbn.xmlEnt = function(value) {
    if(_.isString(value)) {
      var stg1 = value.replace(/</g, '<')
        .replace(/>/g, '>')
        .replace(/\r\n/g, '
')
        .replace(/\r/g, '
')
        .replace(/\n/g, '
')
        .replace(/\t/g, '    ')
        .replace(/  /g, '  ')
        .replace(/<del>/g, '')
        .replace(/<\/del>/g, '');
      return stg1;
    } else {
      return value;
    }
  };

  kbn.sortObj = function(arr) {
    // Setup Arrays
    var sortedKeys = [];
    var sortedObj = {};
    var i;
    // Separate keys and sort them
    for (i in arr) {
      sortedKeys.push(i);
    }
    sortedKeys.sort();

    // Reconstruct sorted obj based on keys
    for (i in sortedKeys) {
      sortedObj[sortedKeys[i]] = arr[sortedKeys[i]];
    }
    return sortedObj;
  };

  kbn.query_color_dot = function (color, diameter) {
    return '

';
  };

  return kbn;
});<commit_msg>Added year/y to date math parser<commit_after>define(['jquery', 'underscore','moment'],
function($, _, moment) {
  'use strict';

  var kbn = {};

  kbn.get_object_fields = function(obj) {
    var field_array = [];
    obj = kbn.flatten_json(obj._source);
    for (var field in obj) {
      field_array.push(field);
    }
    return field_array.sort();
  };

  kbn.get_all_fields = function(data) {
    var _d = data;
    var fields = [];
    _.each(_d,function(hit) {
      fields = _.uniq(fields.concat(_.keys(kbn.flatten_json(hit._source))));
    });
    // Remove stupid angular key
    fields = _.without(fields,'$$hashKey');
    return fields;
  };

  kbn.has_field = function(obj,field) {
    var obj_fields = kbn.get_object_fields(obj);
    if (_.inArray(obj_fields,field) < 0) {
      return false;
    } else {
      return true;
    }
  };

  kbn.get_related_fields = function(docs,field) {
    var field_array = [];
    _.each(docs, function(doc) {
      var keys = _.keys(doc);
      if(_.contains(keys,field)) {
        field_array = field_array.concat(keys);
      }
    });
    var counts = _.countBy(_.without(field_array,field),function(field){return field;});
    return _.map(counts, function(num, key){return {name:key,count:num};});
  };

  kbn.recurse_field_dots = function(object,field) {
    var value = null;
    var nested;
    if (typeof object[field] !== 'undefined') {
      value = object[field];
    }
    else if (nested = field.match(/(.*?)\.(.*)/)) {
      if(typeof object[nested[1]] !== 'undefined') {
        value = (typeof object[nested[1]][nested[2]] !== 'undefined') ?
          object[nested[1]][nested[2]] : kbn.recurse_field_dots(
            object[nested[1]],nested[2]);
      }
    }

    return value;
  };

  kbn.top_field_values = function(docs,field,count,grouped) {
    var all_values = _.pluck(docs,field),
      groups = {},
      counts,
      hasArrays;
    // manually grouping into pairs allows us to keep the original value,
    _.each(all_values, function (value) {
      var k;
      if(_.isArray(value)) {
        hasArrays =  true;
      }
      if(_.isArray(value) && !grouped) {
        k = value;
      } else {
        k = _.isUndefined(value) ? '' : [value.toString()];
      }
      _.each(k, function(key) {
        if (_.has(groups, key)) {
          groups[key][1] ++;
        } else {
          groups[key] = [(grouped ? value : key), 1];
        }
      });
    });

    counts = _.values(groups).sort(function(a, b) {
      return a[1] - b[1];
    }).reverse().slice(0,count);

    return {
      counts: counts,
      hasArrays : hasArrays
    };
  };

   /**
     * Calculate a graph interval
     *
     * from::           Date object containing the start time
     * to::             Date object containing the finish time
     * size::           Calculate to approximately this many bars
     * user_interval::  User specified histogram interval
     *
     */
  kbn.calculate_interval = function(from,to,size,user_interval) {
    if(_.isObject(from)) {
      from = from.valueOf();
    }
    if(_.isObject(to)) {
      to = to.valueOf();
    }
    return user_interval === 0 ? kbn.round_interval((to - from)/size) : user_interval;
  };

  kbn.round_interval = function(interval) {
    switch (true) {
    // 0.5s
    case (interval <= 500):
      return 100;       // 0.1s
    // 5s
    case (interval <= 5000):
      return 1000;      // 1s
    // 7.5s
    case (interval <= 7500):
      return 5000;      // 5s
    // 15s
    case (interval <= 15000):
      return 10000;     // 10s
    // 45s
    case (interval <= 45000):
      return 30000;     // 30s
    // 3m
    case (interval <= 180000):
      return 60000;     // 1m
    // 9m
    case (interval <= 450000):
      return 300000;    // 5m
    // 20m
    case (interval <= 1200000):
      return 600000;    // 10m
    // 45m
    case (interval <= 2700000):
      return 1800000;   // 30m
    // 2h
    case (interval <= 7200000):
      return 3600000;   // 1h
    // 6h
    case (interval <= 21600000):
      return 10800000;  // 3h
    // 24h
    case (interval <= 86400000):
      return 43200000;  // 12h
    // 48h
    case (interval <= 172800000):
      return 86400000;  // 24h
    // 1w
    case (interval <= 604800000):
      return 86400000;  // 24h
    // 3w
    case (interval <= 1814400000):
      return 604800000; // 1w
    // 2y
    case (interval < 3628800000):
      return 2592000000; // 30d
    default:
      return 31536000000; // 1y
    }
  };

  kbn.secondsToHms = function(seconds){
    var numyears = Math.floor(seconds / 31536000);
    if(numyears){
      return numyears + 'y';
    }
    var numdays = Math.floor((seconds % 31536000) / 86400);
    if(numdays){
      return numdays + 'd';
    }
    var numhours = Math.floor(((seconds % 31536000) % 86400) / 3600);
    if(numhours){
      return numhours + 'h';
    }
    var numminutes = Math.floor((((seconds % 31536000) % 86400) % 3600) / 60);
    if(numminutes){
      return numminutes + 'm';
    }
    var numseconds = (((seconds % 31536000) % 86400) % 3600) % 60;
    if(numseconds){
      return numseconds + 's';
    }
    return 'less then a second'; //'just now' //or other string you like;
  };

  kbn.to_percent = function(number,outof) {
    return Math.floor((number/outof)*10000)/100 + "%";
  };

  kbn.addslashes = function(str) {
    str = str.replace(/\\/g, '\\\\');
    str = str.replace(/\'/g, '\\\'');
    str = str.replace(/\"/g, '\\"');
    str = str.replace(/\0/g, '\\0');
    return str;
  };

  kbn.interval_regex = /(\d+(?:\.\d+)?)([Mwdhmsy])/;

  // histogram & trends
  kbn.intervals_in_seconds = {
    y: 31536000,
    M: 2592000,
    w: 604800,
    d: 86400,
    h: 3600,
    m: 60,
    s: 1
  };

  kbn.describe_interval = function (string) {
    var matches = string.match(kbn.interval_regex);
    if (!matches || !_.has(kbn.intervals_in_seconds, matches[2])) {
      throw new Error('Invalid interval string, expexcting a number followed by one of "Mwdhmsy"');
    } else {
      return {
        sec: kbn.intervals_in_seconds[matches[2]],
        type: matches[2],
        count: parseInt(matches[1], 10)
      };
    }
  };

  kbn.interval_to_ms = function(string) {
    var info = kbn.describe_interval(string);
    return info.sec * 1000 * info.count;
  };

  kbn.interval_to_seconds = function (string) {
    var info = kbn.describe_interval(string);
    return info.sec * info.count;
  };

  // This should go away, moment.js can do this
  kbn.time_ago = function(string) {
    return new Date(new Date().getTime() - (kbn.interval_to_ms(string)));
  };

  /* This is a simplified version of elasticsearch's date parser */
  kbn.parseDate = function(text) {
    if(_.isDate(text)) {
      return text;
    }
    var time,
      mathString = "",
      index,
      parseString;
    if (text.substring(0,3) === "now") {
      time = new Date();
      mathString = text.substring("now".length);
    } else {
      index = text.indexOf("||");
      parseString;
      if (index === -1) {
        parseString = text;
        mathString = ""; // nothing else
      } else {
        parseString = text.substring(0, index);
        mathString = text.substring(index + 2);
      }
      // We're going to just require ISO8601 timestamps, k?
      time = new Date(parseString);
    }

    if (!mathString.length) {
      return time;
    }

    //return [time,parseString,mathString];
    return kbn.parseDateMath(mathString, time);
  };

  kbn.parseDateMath = function(mathString, time, roundUp) {
    var dateTime = moment(time);
    for (var i = 0; i < mathString.length; ) {
      var c = mathString.charAt(i++),
        type,
        num,
        unit;
      if (c === '/') {
        type = 0;
      } else if (c === '+') {
        type = 1;
      } else if (c === '-') {
        type = 2;
      } else {
        return false;
      }

      if (isNaN(mathString.charAt(i))) {
        num = 1;
      } else {
        var numFrom = i;
        while (!isNaN(mathString.charAt(i))) {
          i++;
        }
        num = parseInt(mathString.substring(numFrom, i),10);
      }
      if (type === 0) {
        // rounding is only allowed on whole numbers
        if (num !== 1) {
          return false;
        }
      }
      unit = mathString.charAt(i++);
      switch (unit) {
      case 'y':
        if (type === 0) {
          roundUp ? dateTime.endOf('year') : dateTime.startOf('year');
        } else if (type === 1) {
          dateTime.add('years',num);
        } else if (type === 2) {
          dateTime.subtract('years',num);
        }
        break;
      case 'M':
        if (type === 0) {
          roundUp ? dateTime.endOf('month') : dateTime.startOf('month');
        } else if (type === 1) {
          dateTime.add('months',num);
        } else if (type === 2) {
          dateTime.subtract('months',num);
        }
        break;
      case 'w':
        if (type === 0) {
          roundUp ? dateTime.endOf('week') : dateTime.startOf('week');
        } else if (type === 1) {
          dateTime.add('weeks',num);
        } else if (type === 2) {
          dateTime.subtract('weeks',num);
        }
        break;
      case 'd':
        if (type === 0) {
          roundUp ? dateTime.endOf('day') : dateTime.startOf('day');
        } else if (type === 1) {
          dateTime.add('days',num);
        } else if (type === 2) {
          dateTime.subtract('days',num);
        }
        break;
      case 'h':
      case 'H':
        if (type === 0) {
          roundUp ? dateTime.endOf('hour') : dateTime.startOf('hour');
        } else if (type === 1) {
          dateTime.add('hours',num);
        } else if (type === 2) {
          dateTime.subtract('hours',num);
        }
        break;
      case 'm':
        if (type === 0) {
          roundUp ? dateTime.endOf('minute') : dateTime.startOf('minute');
        } else if (type === 1) {
          dateTime.add('minutes',num);
        } else if (type === 2) {
          dateTime.subtract('minutes',num);
        }
        break;
      case 's':
        if (type === 0) {
          roundUp ? dateTime.endOf('second') : dateTime.startOf('second');
        } else if (type === 1) {
          dateTime.add('seconds',num);
        } else if (type === 2) {
          dateTime.subtract('seconds',num);
        }
        break;
      default:
        return false;
      }
    }
    return dateTime.toDate();
  };

  // LOL. hahahahaha. DIE.
  kbn.flatten_json = function(object,root,array) {
    if (typeof array === 'undefined') {
      array = {};
    }
    if (typeof root === 'undefined') {
      root = '';
    }
    for(var index in object) {
      var obj = object[index];
      var rootname = root.length === 0 ? index : root + '.' + index;
      if(typeof obj === 'object' ) {
        if(_.isArray(obj)) {
          if(obj.length > 0 && typeof obj[0] === 'object') {
            var strval = '';
            for (var objidx = 0, objlen = obj.length; objidx < objlen; objidx++) {
              if (objidx > 0) {
                strval = strval + ', ';
              }

              strval = strval + JSON.stringify(obj[objidx]);
            }
            array[rootname] = strval;
          } else if(obj.length === 1 && _.isNumber(obj[0])) {
            array[rootname] = parseFloat(obj[0]);
          } else {
            array[rootname] = typeof obj === 'undefined' ? null : obj;
          }
        } else {
          kbn.flatten_json(obj,rootname,array);
        }
      } else {
        array[rootname] = typeof obj === 'undefined' ? null : obj;
      }
    }
    return kbn.sortObj(array);
  };

  kbn.xmlEnt = function(value) {
    if(_.isString(value)) {
      var stg1 = value.replace(/</g, '<')
        .replace(/>/g, '>')
        .replace(/\r\n/g, '
')
        .replace(/\r/g, '
')
        .replace(/\n/g, '
')
        .replace(/\t/g, '    ')
        .replace(/  /g, '  ')
        .replace(/<del>/g, '')
        .replace(/<\/del>/g, '');
      return stg1;
    } else {
      return value;
    }
  };

  kbn.sortObj = function(arr) {
    // Setup Arrays
    var sortedKeys = [];
    var sortedObj = {};
    var i;
    // Separate keys and sort them
    for (i in arr) {
      sortedKeys.push(i);
    }
    sortedKeys.sort();

    // Reconstruct sorted obj based on keys
    for (i in sortedKeys) {
      sortedObj[sortedKeys[i]] = arr[sortedKeys[i]];
    }
    return sortedObj;
  };

  kbn.query_color_dot = function (color, diameter) {
    return '

';
  };

  return kbn;
});<|endoftext|>


<commit_before>'use strict';

import winston from 'winston';

module.exports = new winston.Logger({
  transports: [
    new winston.transports.Console({
      level: (process.env.NODE_ENV === 'production') ? 'info' : 'debug',
      timestamp: true,
      stderrLevels: ['error'],
      colorize: true
    })
  ]
});
<commit_msg>export winston logger as default<commit_after>'use strict';

import winston from 'winston';

export default new winston.Logger({
  transports: [
    new winston.transports.Console({
      level: (process.env.NODE_ENV === 'production') ? 'info' : 'debug',
      timestamp: true,
      stderrLevels: ['error'],
      colorize: true
    })
  ]
});
<|endoftext|>


<commit_before>var BrowserWindow = require('browser-window');
var WindowState = require('electron-window-state');
var Shell = require('shell');

function WindowManager(dirs) {
    this.mainWindow = null;
    this.app_dir = dirs.app;
    this.index_location = dirs.index;
    this.logo_location = dirs.logo;
}

WindowManager.prototype.getMainWindow = function() {
    return this.mainWindow;
};

WindowManager.prototype.createMainWindow = function() {
    LOG.verbose('Opening new window');
    var self = this;
    var windowState = WindowState({
        defaultWidth: 800,
        defaultHeigth: 600,
        path: this.app_dir
    });

    this.mainWindow = new BrowserWindow({
        width: windowState.width,
        height: windowState.heigth,
        y: windowState.y,
        x: windowState.x,
        'auto-hide-menu-bar': true,
        icon: this.logo_location
    });

    this.mainWindow.loadURL('file://' + this.index_location);
    this.mainWindow.on('closed', function() {
        self.mainWindow = null;
    });

    this.mainWindow.webContents.on('new-window', function(ev, url) {
        ev.preventDefault();
        Shell.openExternal(url);
    });

    windowState.manage(this.mainWindow);
};

module.exports = WindowManager;
<commit_msg>Woops, typo.<commit_after>var BrowserWindow = require('browser-window');
var WindowState = require('electron-window-state');
var Shell = require('shell');

function WindowManager(dirs) {
    this.mainWindow = null;
    this.app_dir = dirs.app;
    this.index_location = dirs.index;
    this.logo_location = dirs.logo;
}

WindowManager.prototype.getMainWindow = function() {
    return this.mainWindow;
};

WindowManager.prototype.createMainWindow = function() {
    LOG.verbose('Opening new window');
    var self = this;
    var windowState = WindowState({
        defaultWidth: 800,
        defaultHeigth: 600,
        path: this.app_dir
    });

    this.mainWindow = new BrowserWindow({
        width: windowState.width,
        height: windowState.height,
        y: windowState.y,
        x: windowState.x,
        'auto-hide-menu-bar': true,
        icon: this.logo_location
    });

    this.mainWindow.loadURL('file://' + this.index_location);
    this.mainWindow.on('closed', function() {
        self.mainWindow = null;
    });

    this.mainWindow.webContents.on('new-window', function(ev, url) {
        ev.preventDefault();
        Shell.openExternal(url);
    });

    windowState.manage(this.mainWindow);
};

module.exports = WindowManager;
<|endoftext|>


<commit_before>var tristis_config = {
        base: "../node_modules/yui/",
        filter: "raw",
        groups: {
            "template": {
                patterns: {
                    "template-": {
                        configFn: function (me) {
                            "use strict";
                            me.fullpath = "templates/compiled/" + me.name.replace(me.group + "-", "") + ".js";
                            me.requires = ["template"];
                        }
                    }
                }
            },
            "/": {
                base: "js/",
                modules: {
                    "app-tristis": {
                        path: "app-tristis.js",
                        requires: [
                            "base-build",
                            "app",
                            "extension-view-classes",
                            "extension-view-parent",
                            "extension-tristis-events",
                            "extension-tristis-routes",
                            "model-user",
                            "model-list-timelines",
                            "view-nav",
                            "stream-user",
                            "stream-users"
                        ]
                    },
                    "extension-list-users": {
                        path: "extension-list-users.js",
                        requires: ["stream-users"]
                    },
                    "extension-tristis-events": {
                        path: "extension-tristis-events.js",
                        requires: []
                    },
                    "extension-tristis-routes": {
                        path: "extension-tristis-routes.js",
                        requires: ["gallery-lazy-load"]
                    },
                    "model-list-timelines": {
                        path: "model-list-timelines.js",
                        requires: [
                            "base-build",
                            "model-list",
                            "model-timeline-home",
                            "model-timeline-mentions",
                            "model-timeline-list",
                            "extension-list-users"
                        ]
                    },
                    "model-list-tweets": {
                        path: "model-list-tweets.js",
                        requires: [
                            "base-build",
                            "lazy-model-list",
                            "extension-model-list-more"
                        ]
                    },
                    "model-timeline-base": {
                        path: "model-timeline-base.js",
                        requires: [
                            "base-build",
                            "model",
                            "model-list-tweets"
                        ]
                    },
                    "model-timeline-home": {
                        path: "model-timeline-home.js",
                        requires: [
                            "base-build",
                            "model-timeline-base",
                            "stream-user"
                        ]
                    },
                    "model-timeline-list": {
                        path: "model-timeline-list.js",
                        requires: [
                            "base-build",
                            "model-timeline-base"
                        ]
                    },
                    "model-timeline-mentions": {
                        path: "model-timeline-mentions.js",
                        requires: [
                            "base-build",
                            "model-timeline-base"
                        ]
                    },
                    "model-user": {
                        path: "model-user.js",
                        requires: [
                            "base-build",
                            "model"
                        ]
                    },
                    "stream-base": {
                        path: "stream-base.js",
                        requires: [
                            "oop",
                            "event-custom"
                        ]
                    },
                    "stream-user": {
                        path: "stream-user.js",
                        requires: [
                            "oop",
                            "event-custom",
                            "stream-base"
                        ]
                    },
                    "stream-users": {
                        path: "stream-users.js",
                        requires: [
                            "oop",
                            "event-custom",
                            "stream-base"
                        ]
                    },
                    "view-list": {
                        path: "view-list.js",
                        requires: [
                            "base-build",
                            "view",
                            "template-timeline",
                            "template-tweet"
                        ]
                    },
                    "view-nav": {
                        path: "view-nav.js",
                        requires: [
                            "base-build",
                            "view",
                            "template-nav",
                            "template-nav-lists"
                        ]
                    },
                    "view-timeline": {
                        path: "view-timeline.js",
                        requires: [
                            "base-build",
                            "view",
                            "template-timeline",
                            "template-tweet"
                        ]
                    }
                }
            },
            "/extensions/": {
                base: "js/extensions/",
                modules: {
                    "extension-model-list-more": { path: "extension-model-list-more.js" },
                    "extension-view-classes": {
                        path: "extension-view-classes.js",
                        requires: ["event-custom"]
                    },
                    "extension-view-parent": {
                        path: "extension-view-parent.js",
                        requires: [
                            "view",
                            "event-custom"
                        ]
                    }
                }
            },
            "/gallery/": {
                base: "js/gallery/",
                modules: {
                    "gallery-debounce": { path: "gallery-debounce.js" },
                    "gallery-lazy-load": {
                        path: "gallery-lazy-load.js",
                        requires: ["oop"]
                    }
                }
            },
            "/oauth/": {
                base: "js/oauth/",
                modules: {
                    "model-oauth": {
                        path: "model-oauth.js",
                        requires: [
                            "base-build",
                            "model"
                        ]
                    },
                    "view-link": {
                        path: "view-link.js",
                        requires: [
                            "base-build",
                            "view",
                            "model-oauth",
                            "template-oauth-link"
                        ]
                    }
                }
            }
        }
    };<commit_msg>Module meta build<commit_after>var tristis_config = {
        base: "../node_modules/yui/",
        filter: "raw",
        groups: {
            "template": {
                patterns: {
                    "template-": {
                        configFn: function (me) {
                            "use strict";
                            me.fullpath = "templates/compiled/" + me.name.replace(me.group + "-", "") + ".js";
                            me.requires = ["template"];
                        }
                    }
                }
            },
            "/": {
                base: "js/",
                modules: {
                    "app-tristis": {
                        path: "app-tristis.js",
                        requires: [
                            "base-build",
                            "app",
                            "extension-view-classes",
                            "extension-view-parent",
                            "extension-tristis-events",
                            "extension-tristis-routes",
                            "model-user",
                            "model-list-timelines",
                            "view-nav",
                            "stream-user",
                            "stream-users"
                        ]
                    },
                    "extension-list-users": {
                        path: "extension-list-users.js",
                        requires: ["stream-users"]
                    },
                    "extension-tristis-events": {
                        path: "extension-tristis-events.js",
                        requires: []
                    },
                    "extension-tristis-routes": {
                        path: "extension-tristis-routes.js",
                        requires: ["gallery-lazy-load"]
                    },
                    "model-list-timelines": {
                        path: "model-list-timelines.js",
                        requires: [
                            "base-build",
                            "model-list",
                            "model-timeline-home",
                            "model-timeline-mentions",
                            "model-timeline-list",
                            "extension-list-users"
                        ]
                    },
                    "model-list-tweets": {
                        path: "model-list-tweets.js",
                        requires: [
                            "base-build",
                            "lazy-model-list",
                            "extension-model-list-more"
                        ]
                    },
                    "model-timeline-base": {
                        path: "model-timeline-base.js",
                        requires: [
                            "base-build",
                            "model",
                            "model-list-tweets"
                        ]
                    },
                    "model-timeline-home": {
                        path: "model-timeline-home.js",
                        requires: [
                            "base-build",
                            "model-timeline-base",
                            "stream-user"
                        ]
                    },
                    "model-timeline-list": {
                        path: "model-timeline-list.js",
                        requires: [
                            "base-build",
                            "model-timeline-base"
                        ]
                    },
                    "model-timeline-mentions": {
                        path: "model-timeline-mentions.js",
                        requires: [
                            "base-build",
                            "model-timeline-base"
                        ]
                    },
                    "model-user": {
                        path: "model-user.js",
                        requires: [
                            "base-build",
                            "model"
                        ]
                    },
                    "stream-base": {
                        path: "stream-base.js",
                        requires: [
                            "oop",
                            "event-custom"
                        ]
                    },
                    "stream-user": {
                        path: "stream-user.js",
                        requires: [
                            "oop",
                            "event-custom",
                            "stream-base"
                        ]
                    },
                    "stream-users": {
                        path: "stream-users.js",
                        requires: [
                            "oop",
                            "event-custom",
                            "stream-base"
                        ]
                    },
                    "view-list": {
                        path: "view-list.js",
                        requires: [
                            "base-build",
                            "view",
                            "template-timeline",
                            "template-tweet"
                        ]
                    },
                    "view-nav": {
                        path: "view-nav.js",
                        requires: [
                            "base-build",
                            "view",
                            "template-nav",
                            "template-nav-timelines"
                        ]
                    },
                    "view-timeline": {
                        path: "view-timeline.js",
                        requires: [
                            "base-build",
                            "view",
                            "template-timeline",
                            "template-tweet"
                        ]
                    }
                }
            },
            "/extensions/": {
                base: "js/extensions/",
                modules: {
                    "extension-model-list-more": { path: "extension-model-list-more.js" },
                    "extension-view-classes": {
                        path: "extension-view-classes.js",
                        requires: ["event-custom"]
                    },
                    "extension-view-parent": {
                        path: "extension-view-parent.js",
                        requires: [
                            "view",
                            "event-custom"
                        ]
                    }
                }
            },
            "/gallery/": {
                base: "js/gallery/",
                modules: {
                    "gallery-debounce": { path: "gallery-debounce.js" },
                    "gallery-lazy-load": {
                        path: "gallery-lazy-load.js",
                        requires: ["oop"]
                    }
                }
            },
            "/oauth/": {
                base: "js/oauth/",
                modules: {
                    "model-oauth": {
                        path: "model-oauth.js",
                        requires: [
                            "base-build",
                            "model"
                        ]
                    },
                    "view-link": {
                        path: "view-link.js",
                        requires: [
                            "base-build",
                            "view",
                            "model-oauth",
                            "template-oauth-link"
                        ]
                    }
                }
            }
        }
    };<|endoftext|>


<commit_before>import $ from 'jquery'
import { year } from '../actions/currentYear'
import { getDataFromDB } from '../dispatchers/database'
import { drawCharts } from '../actions/chartDrawer'

function chartsOf(year){
  //Get datas from API
  getDataFromDB(year)
  .then(response => {
    drawCharts(response)
    console.log(response);
  })
  .catch(err => {
    console.log(err);
  })
}

chartsOf(year);
<commit_msg>Retour des erreurs d esholag<commit_after>import $ from 'jquery'
import { year } from '../actions/currentYear'
import { getDataFromDB } from '../dispatchers/database'
import { drawCharts } from '../actions/chartDrawer'

import { appleTvAgora } from '../views/appleTvAgora'
import { showMovieSheet } from '../animations/showMovieSheet'
import { hideMovieSheet } from '../animations/showMovieSheet'

function chartsOf(year){
  //Get datas from API
  getDataFromDB(year)
  .then(response => {
    drawCharts(response)
    console.log(response);
  })
  .catch(err => {
    console.log(err);
  })
}

chartsOf(year);

// //agora Apple Tv
// let years = document.querySelectorAll('.years .year')
// document.onmousemove = appleTvAgora

let hostname = window.location.hostname;
console.log('hostname');

let winnersPosters = document.querySelector("section.winners-posters a")
winnersPosters.addEventListener('click', showMovieSheet)

let goBackMovies = document.querySelector("section.movie-sheet a.go-back")
goBackMovies.addEventListener('click', hideMovieSheet)
<|endoftext|>


<commit_before>;(function(){//IIFE

angular.module('brewKeeper')
      .controller('brewIt', function($scope, $http, $routeParams){
        // console.log("firing brewIt controller")
          var id = $routeParams.id;
          $http.get('api/users/1/recipes/'+ id + '/recipe.json')
            .then(function(response){
              $scope.detail = response.data;
              $scope.steps = response.data.steps;
              $scope.notes = response.data.brewnotes;
              $scope.countdownVal = response.data.total_duration;
              // $scope.countdownVal = 10;
              // $scope.timerRunning = false;
            })
            var timerRunning = false
          //start brew function
          $scope.startBrew = function(id){
            console.log(timerRunning)
            if(timerRunning){
              // console.log("dear god please stop")
              return;
            }
            console.log("starting brew");
            // $scope.$broadcast('timer-start');
            // $(".timer").addClass("red");
            $(".1").addClass("red")
            $('timer')[0].start();
            $('timer')[1].start();
            timerRunning = true;
            console.log(timerRunning);
          };
          $scope.stopBrew = function(){
            console.log("pause button pressed");
            $scope.$broadcast('timer-stop');
            // $(".timer").removeClass("red");
          };
          $scope.resetBrew = function(timerTime){
            console.log("reset button pressed");
            $scope.$broadcast('timer-reset');
            // $(".timer").removeClass("red");
            // $scope.$broadcast('timer-start');
          };
          $scope.finishBrew = function(id){
            console.log("Brew complete");
            // $(".timer").removeClass("red");
            console.log("id = " + id)
            nextStep(id);
            $("."+id).removeClass("red");
          };
          nextStep = function(id){
            var nextId = id + 1;
            console.log($scope.steps.length)
            if(nextId > $scope.steps.length){
              timerRunning = false;
              return
            }
            $("."+ nextId).addClass("red");
            $('timer')[nextId].start();
          };
      }) // end brewIt controller

})();//END Angular IIFE
<commit_msg>completed steps are now hidden<commit_after>;(function(){//IIFE

angular.module('brewKeeper')
      .controller('brewIt', function($scope, $http, $routeParams){
        // console.log("firing brewIt controller")
          var id = $routeParams.id;
          $http.get('api/users/1/recipes/'+ id + '/recipe.json')
            .then(function(response){
              $scope.detail = response.data;
              $scope.steps = response.data.steps;
              $scope.notes = response.data.brewnotes;
              $scope.countdownVal = response.data.total_duration;
              // $scope.countdownVal = 10;
              // $scope.timerRunning = false;
            })
            var timerRunning = false
          //start brew function
          $scope.startBrew = function(id){
            console.log(timerRunning)
            if(timerRunning){
              // console.log("dear god please stop")
              return;
            }
            console.log("starting brew");
            // $scope.$broadcast('timer-start');
            // $(".timer").addClass("red");
            $(".1").addClass("red")
            $('timer')[0].start();
            $('timer')[1].start();
            timerRunning = true;
            console.log(timerRunning);
          };
          $scope.stopBrew = function(){
            console.log("pause button pressed");
            $scope.$broadcast('timer-stop');
            // $(".timer").removeClass("red");
          };
          $scope.resetBrew = function(timerTime){
            console.log("reset button pressed");
            $scope.$broadcast('timer-reset');
            // $(".timer").removeClass("red");
            // $scope.$broadcast('timer-start');
          };
          $scope.finishBrew = function(id){
            console.log("Brew complete");
            // $(".timer").removeClass("red");
            console.log("id = " + id)
            nextStep(id);
            $("."+id).removeClass("red");
             $("."+id).addClass("hidden")
          };
          nextStep = function(id){
            var nextId = id + 1;
            console.log($scope.steps.length)
            if(nextId > $scope.steps.length){
              timerRunning = false;
              $(".hidden").removeClass("hidden")
              return
            }
            $("."+ nextId).addClass("red");
            $('timer')[nextId].start();
          };
      }) // end brewIt controller

})();//END Angular IIFE
<|endoftext|>