<commit_before>// ==UserScript==
// @name		Booru Mass Uploader
// @description	Add ability to bulk upload images to your booru
// @namespace 	https://github.com/Seedmanc/Booru-mass-uploader
// @version     1.3.2
// @author		Seedmanc
// @include     http://*.booru.org/index.php*
// @include     http://rule34.xxx/index.php*
// @include 	http://gelbooru.com/index.php*
// @include     http://safebooru.org/index.php*
// @include		https://moe.dev.myconan.net/*
// @include		http://behoimi.org/*
// @include		https://chan.sankakucomplex.com/*
// @include		http://atfbooru.ninja/*
// @include		http://danbooru.donmai.us/*

// you can add any boorus of your choice by following the pattern

// @grant 		none
// @run-at		document-end
// @noframes

// @require  	https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js
// ==/UserScript==

if (window.top != window.self) {
	throw 'no iframes';
}

var corses = ['www.whateverorigin.org/get?url=', 'crossorigin.me/'];

function onSuccess(response) {
	var scripts;

	document.getElementsByTagName('body')[0].innerHTML = response;
	scripts = document.getElementsByTagName('script');

	for (var i = 0; i < scripts.length; i++) {
		var node = scripts[i], parent = node.parentElement, d = document.createElement('script');

		d.async = node.async;
		d.src = node.src;
		parent.insertBefore(d, node);
		parent.removeChild(node);
	}
}

function tryCors(idx) {

	idx = idx || 0;

	if (!corses[idx]) {
		document.write('Ran out of CORS engines, try later');
		return;
	}

	(idx ? $.get : $.getJSON)(location.protocol + '//' + corses[idx] + 'http://seedmanc.github.io/Booru-mass-uploader/index.html' + (idx ? '' : '&callback=?'))
		.done(function (response) {
			onSuccess(response.contents || response);
		})
		.fail(function (response) {
			if (response.status == 200 && response.readyState == 4) {
				onSuccess(response.responseText);
			} else {
				console.log(response);
				tryCors(idx + 1);
			}
		});
}

if (~document.location.href.indexOf('s=mass_upload')) {
	document.write('');
	tryCors();

} else {
	var navbar = $('#navbar')[0] ||
		$('.flat-list2')[0] ||
		$('#main-menu > ul')[0] ||
		$('nav > menu')[0];
	var li = document.createElement("li");
	var a = document.createElement("a");
	var token = $('meta[name="csrf-token"]')[0];

	token = token && token.content;
	if (token) {
		localStorage.setItem('auth_token', token);
	}

	if ($('[src*="moe-legacy"]').length || $('html.action-post').length || $('[href*="/post/upload"]').length) {
		localStorage.setItem('current', 'moebooru');
	} else if ($('[href*="/uploads/new"]').length || ~document.documentElement.innerHTML.indexOf('Running Danbooru')) {
		localStorage.setItem('current', 'danbooru');
	}

	if (!navbar) {
		throw "can't link the uploader";
	}

	a.style.fontWeight = 'bold';
	a.appendChild(document.createTextNode('Mass Upload'));
	a.href = document.location.protocol + '//' + document.location.hostname + '/index.php?page=post&s=mass_upload';
	li.appendChild(a);
	navbar.appendChild(li);
}
<commit_msg>In Firfox, gets stuck on "Read seedmanc.github.io", this might fix that<commit_after>// ==UserScript==
// @name		Booru Mass Uploader
// @description	Add ability to bulk upload images to your booru
// @namespace 	https://github.com/Seedmanc/Booru-mass-uploader
// @version     1.3.2
// @author		Seedmanc
// @include     http://*.booru.org/index.php*
// @include     http://rule34.xxx/index.php*
// @include 	http://gelbooru.com/index.php*
// @include     http://safebooru.org/index.php*
// @include		https://moe.dev.myconan.net/*
// @include		http://behoimi.org/*
// @include		https://chan.sankakucomplex.com/*
// @include		http://atfbooru.ninja/*
// @include		http://danbooru.donmai.us/*

// you can add any boorus of your choice by following the pattern

// @grant 		none
// @run-at		document-end
// @noframes

// @require  	https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js
// ==/UserScript==

if (window.top != window.self) {
	throw 'no iframes';
}

var corses = ['www.whateverorigin.org/get?url=', 'crossorigin.me/'];

function onSuccess(response) {
	var scripts;

	document.getElementsByTagName('body')[0].innerHTML = response;
	scripts = document.getElementsByTagName('script');

	for (var i = 0; i < scripts.length; i++) {
		var node = scripts[i], parent = node.parentElement, d = document.createElement('script');

		d.async = node.async;
		d.src = node.src;
		parent.insertBefore(d, node);
		parent.removeChild(node);
	}
}

function tryCors(idx) {

	idx = idx || 0;

	if (!corses[idx]) {
		document.write('Ran out of CORS engines, try later');
		return;
	}

	(idx ? $.get : $.getJSON)(location.protocol + '//' + corses[idx] + 'http://proximanova.github.io/Booru-mass-uploader/index.html' + (idx ? '' : '&callback=?'))
		.done(function (response) {
			onSuccess(response.contents || response);
		})
		.fail(function (response) {
			if (response.status == 200 && response.readyState == 4) {
				onSuccess(response.responseText);
			} else {
				console.log(response);
				tryCors(idx + 1);
			}
		});
}

if (~document.location.href.indexOf('s=mass_upload')) {
	document.write('');
	tryCors();

} else {
	var navbar = $('#navbar')[0] ||
		$('.flat-list2')[0] ||
		$('#main-menu > ul')[0] ||
		$('nav > menu')[0];
	var li = document.createElement("li");
	var a = document.createElement("a");
	var token = $('meta[name="csrf-token"]')[0];

	token = token && token.content;
	if (token) {
		localStorage.setItem('auth_token', token);
	}

	if ($('[src*="moe-legacy"]').length || $('html.action-post').length || $('[href*="/post/upload"]').length) {
		localStorage.setItem('current', 'moebooru');
	} else if ($('[href*="/uploads/new"]').length || ~document.documentElement.innerHTML.indexOf('Running Danbooru')) {
		localStorage.setItem('current', 'danbooru');
	}

	if (!navbar) {
		throw "can't link the uploader";
	}

	a.style.fontWeight = 'bold';
	a.appendChild(document.createTextNode('Mass Upload'));
	a.href = document.location.protocol + '//' + document.location.hostname + '/index.php?page=post&s=mass_upload';
	li.appendChild(a);
	navbar.appendChild(li);
}
<|endoftext|>


<commit_before>/**
 * Reports Collection
 */

Reports = new Meteor.Collection('reports');

createMofidiers = function(modifier, tmpl) {
    "use strict";

    var coords = locationObject.getCoordinates();
    var lat = "";
    var lng = "";

    if(coords.lat && coords.lng) {
        lat = coords.lat.toString();
        lng = coords.lng.toString();
    }

    var productivityValue = parseInt(tmpl.find('input[name="num-eval-productivity"]:checked').value);
    var achievementValue = parseInt(tmpl.find('input[name="num-eval-achievement"]:checked').value);
    var effectsValue = parseInt(tmpl.find('input[name="num-eval-effects"]:checked').value);
    var relevanceValue = parseInt(tmpl.find('input[name="num-eval-relevance"]:checked').value);
    var viabilityValue = parseInt(tmpl.find('input[name="num-eval-viability"]:checked').value);
    var profitabilityValue = parseInt(tmpl.find('input[name="num-eval-profitability"]:checked').value);

    // determine success category by calculating the mean score and map to three equal intervals
    //1 - 2.66 is RED (1), 2.66 - 4.32 is ORANGE (2), and 4.32-6 is GREEN (3)
    var criteriaCount = (productivityValue && 1) + (achievementValue && 1) + (effectsValue && 1) + (relevanceValue && 1) + (viabilityValue && 1) + (profitabilityValue && 1);
    //RED by default
    var success = 1;
    var meanScore = (productivityValue + achievementValue + effectsValue + relevanceValue + viabilityValue + profitabilityValue)/criteriaCount;
    if(meanScore > (8/3) && meanScore <= (13/3))
      success = 2;
    else if(meanScore > (13/3))
      success = 3;

    var mods = {
        "project.location.coordinates.lat": lat,
        "project.location.coordinates.lng": lng,
        "project.successCategory": success,
        "evaluation.productivity.value": productivityValue,
        "evaluation.achievement.value": achievementValue,
        "evaluation.effects.value": effectsValue,
        "evaluation.relevance.value": relevanceValue,
        "evaluation.viability.value": viabilityValue,
        "evaluation.profitability.value": profitabilityValue,
        "_public": parseInt(tmpl.find('input[name="public-var"]:checked').value) === 1
    };

    var imgsIds = uploadObject.getImages();
    var imgs = [];

    if(imgsIds.length > 0) {
      for (var i = 0; i < imgsIds.length; i++){
        var img = {
            fileId: imgsIds[i],
            title: tmpl.find('#title-' + imgsIds[i]) && tmpl.find('#title-' + imgsIds[i]).value || null,
            copyright: tmpl.find('#copyright-' + imgsIds[i]) && tmpl.find('#copyright-' + imgsIds[i]).value || null,
            link: tmpl.find('#link-' + imgsIds[i]) &&  tmpl.find('#link-' + imgsIds[i]).value || null
        };
        if(Images.findOne({ _id: imgsIds[i]}))
          imgs.push(img);
      }
    }

    mods.images = imgs;

    var filesIds = uploadObject.getReferences();
    var files = [];

    if(filesIds.length > 0) {
      for (var i = 0; i < filesIds.length; i++){
        var file = {
            fileId: filesIds[i],
            title: tmpl.find('#title-' + filesIds[i]) && tmpl.find('#title-' + filesIds[i]).value || null,
            typedoc: tmpl.find('#typedoc-' + filesIds[i]) && tmpl.find('#typedoc-' + filesIds[i]).value || null,
            date: tmpl.find('#date-' + filesIds[i]) && tmpl.find('#date-' + filesIds[i]).value || null
        };
      if(Files.findOne({ _id: filesIds[i]}))
        files.push(file);
      }
    }

    mods.references = files;

    modifier.$set = _.extend(modifier.$set, mods);
    return modifier;
};

createReport = function(tmpl) {
    "use strict";

    // our report document
    var report = {
        project: {},
        evaluation: {}
    };

    // get all variables, and build the document
    report.project.name = tmpl.find('#name').value;
    report.project.projectNumber = parseInt(tmpl.find('#project-num').value);
    report.project.sector = tmpl.find('#sector').value;

    report.project.location = {};

    report.project.location.name = tmpl.find('#location').value || "";

    var coords = locationObject.getCoordinates();

    report.project.location.coordinates = {};

    report.project.location.coordinates.lat = coords.lat;
    report.project.location.coordinates.lng = coords.lng;

    report.project.projectDescription = {};
    report.project.projectDescription.short = tmpl.find('#project-desc-short').value;
    report.project.projectDescription.long = tmpl.find('#project-desc-long').value;

    report.project.finishingYear = parseInt(tmpl.find('#finishing-year').value) || null;
    report.project.evaluationYear = parseInt(tmpl.find('#eval-year').value) || null;
    report.project.decisionYear = parseInt(tmpl.find('#decision-year').value) || null;

    report.project.managementBudget = {};
    report.project.costBudget = {};
    report.project.costFinal = {};

    report.project.managementBudget.year = parseInt(tmpl.find('#management-budget-year').value) || null;
    report.project.costBudget.year = parseInt(tmpl.find('#cost-budget-year').value) || null;
    report.project.costFinal.year = parseInt(tmpl.find('#cost-final-year').value) || null;

    report.project.managementBudget.amount = parseInt(tmpl.find('#management-budget').value) || null;
    report.project.costBudget.amount = parseInt(tmpl.find('#cost-budget').value) || null;
    report.project.costFinal.amount = parseInt(tmpl.find('#cost-final').value) || null;

    report.responsible = {};
    report.responsible.organization = tmpl.find('#eval-responsible-org').value || "";
    report.responsible.person = tmpl.find('#eval-responsible-person').value || "";

    report.evaluation.overall = {};
    report.evaluation.productivity = {};
    report.evaluation.achievement = {};
    report.evaluation.effects = {};
    report.evaluation.relevance = {};
    report.evaluation.viability = {};
    report.evaluation.profitability = {};

    report.evaluation.overall.short = tmpl.find('#eval-overall-short').value || "";
    report.evaluation.overall.long = tmpl.find('#eval-overall-long').value || "";

    report.evaluation.productivity.short = tmpl.find('#eval-productivity-short').value || "";
    report.evaluation.productivity.long = tmpl.find('#eval-productivity-long').value || "";

    report.evaluation.achievement.short = tmpl.find('#eval-achievement-short').value || "";
    report.evaluation.achievement.long = tmpl.find('#eval-achievement-long').value || "";

    report.evaluation.effects.short = tmpl.find('#eval-effects-short').value || "";
    report.evaluation.effects.long = tmpl.find('#eval-effects-long').value || "";

    report.evaluation.relevance.short = tmpl.find('#eval-relevance-short').value || "";
    report.evaluation.relevance.long = tmpl.find('#eval-relevance-long').value || "";

    report.evaluation.viability.short = tmpl.find('#eval-viability-short').value || "";
    report.evaluation.viability.long = tmpl.find('#eval-viability-long').value || "";

    report.evaluation.profitability.short = tmpl.find('#eval-profitability-short').value || "";
    report.evaluation.profitability.long = tmpl.find('#eval-profitability-long').value || "";

    var productivityValue = parseInt(tmpl.find('input[name="num-eval-productivity"]:checked').value);
    var achievementValue = parseInt(tmpl.find('input[name="num-eval-achievement"]:checked').value);
    var effectsValue = parseInt(tmpl.find('input[name="num-eval-effects"]:checked').value);
    var relevanceValue = parseInt(tmpl.find('input[name="num-eval-relevance"]:checked').value);
    var viabilityValue = parseInt(tmpl.find('input[name="num-eval-viability"]:checked').value);
    var profitabilityValue = parseInt(tmpl.find('input[name="num-eval-profitability"]:checked').value);

    report.evaluation.productivity.value = productivityValue;
    report.evaluation.achievement.value = achievementValue;
    report.evaluation.effects.value = effectsValue;
    report.evaluation.relevance.value = relevanceValue;
    report.evaluation.viability.value = viabilityValue;
    report.evaluation.profitability.value = profitabilityValue;

    // determine success category by calculating the mean score and map to three equal intervals
    //1 - 2.66 is RED (1), 2.66 - 4.32 is ORANGE (2), and 4.32-6 is GREEN (3)
    var criteriaCount = (productivityValue && 1) + (achievementValue && 1) + (effectsValue && 1) + (relevanceValue && 1) + (viabilityValue && 1) + (profitabilityValue && 1);
    //RED by default
    var success = 1;
    var meanScore = (productivityValue + achievementValue + effectsValue + relevanceValue + viabilityValue + profitabilityValue)/criteriaCount;
    if(meanScore > (8/3) && meanScore <= (13/3))
      success = 2;
    else if(meanScore > (13/3))
      success = 3;

    report.project.successCategory = success;

    var imgsIds = uploadObject.getImages();
    var imgs = [];

    if(imgsIds.length > 0) {
      for (var i = 0; i < imgsIds.length; i++){
        var img = {
            fileId: imgsIds[i],
            title: tmpl.find('#title-' + imgsIds[i]).value,
            copyright: tmpl.find('#copyright-' + imgsIds[i]).value,
            link: tmpl.find('#link-' + imgsIds[i]).value
        };
        imgs.push(img);
      }
    }

    report.images = imgs;

    var filesIds = uploadObject.getReferences();
    var files = [];

    if(filesIds.length > 0) {
      for (var i = 0; i < filesIds.length; i++){
        var file = {
            fileId: filesIds[i],
            title: tmpl.find('#title-' + filesIds[i]).value,
            typedoc: tmpl.find('#typedoc-' + filesIds[i]).value,
            date: tmpl.find('#date-' + filesIds[i]).value
        };
        files.push(file);
      }
    }

    report.references = files;
    report._public = parseInt(tmpl.find('input[name="public-var"]:checked').value) === 1;

    return report;
};
<commit_msg>Fix #93. Evaluation is done inside a new function<commit_after>/**
 * Reports Collection
 */

Reports = new Meteor.Collection('reports');

evaluateProject = function(evaluations) {
  // determine success category by calculating the mean score and map to three equal intervals
  //1 - 2.66 is RED (1), 2.66 - 4.32 is ORANGE (2), and 4.32-6 is GREEN (3)
  var criteriaCount = (evaluations[0] && 1) + (evaluations[1] && 1) + (evaluations[2] && 1) + (evaluations[3] && 1) + (evaluations[4] && 1) + (evaluations[5] && 1);
  //RED by default
  var success = 1;

  var k;
  var lessThanFour = false;
  var reds = 0;

  for(k = 0; k < evaluations.length; k++) {
    var val = evaluations[k];
    if(val < 4) {
      lessThanFour = true;
    }
    if(val < 3) {
      reds++;
    }
  }

  var meanScore = (evaluations[0] + evaluations[1] + evaluations[2] + evaluations[3] + evaluations[3] + evaluations[4])/criteriaCount;
  if(meanScore > (8/3) && meanScore <= (13/3))
    success = 2;
  else if(meanScore > (13/3) && !lessThanFour)
    success = 3;

  if(reds >= 3) {
    success = 1;
  }

  return success;
}

createMofidiers = function(modifier, tmpl) {
    "use strict";

    var coords = locationObject.getCoordinates();
    var lat = "";
    var lng = "";

    if(coords.lat && coords.lng) {
        lat = coords.lat.toString();
        lng = coords.lng.toString();
    }

    var productivityValue = parseInt(tmpl.find('input[name="num-eval-productivity"]:checked').value);
    var achievementValue = parseInt(tmpl.find('input[name="num-eval-achievement"]:checked').value);
    var effectsValue = parseInt(tmpl.find('input[name="num-eval-effects"]:checked').value);
    var relevanceValue = parseInt(tmpl.find('input[name="num-eval-relevance"]:checked').value);
    var viabilityValue = parseInt(tmpl.find('input[name="num-eval-viability"]:checked').value);
    var profitabilityValue = parseInt(tmpl.find('input[name="num-eval-profitability"]:checked').value);

    var evaluations = [productivityValue, achievementValue, effectsValue, relevanceValue, viabilityValue, profitabilityValue];

    var success = evaluateProject(evaluations);

    var mods = {
        "project.location.coordinates.lat": lat,
        "project.location.coordinates.lng": lng,
        "project.successCategory": success,
        "evaluation.productivity.value": productivityValue,
        "evaluation.achievement.value": achievementValue,
        "evaluation.effects.value": effectsValue,
        "evaluation.relevance.value": relevanceValue,
        "evaluation.viability.value": viabilityValue,
        "evaluation.profitability.value": profitabilityValue,
        "_public": parseInt(tmpl.find('input[name="public-var"]:checked').value) === 1
    };

    var imgsIds = uploadObject.getImages();
    var imgs = [];

    if(imgsIds.length > 0) {
      for (var i = 0; i < imgsIds.length; i++){
        var img = {
            fileId: imgsIds[i],
            title: tmpl.find('#title-' + imgsIds[i]) && tmpl.find('#title-' + imgsIds[i]).value || null,
            copyright: tmpl.find('#copyright-' + imgsIds[i]) && tmpl.find('#copyright-' + imgsIds[i]).value || null,
            link: tmpl.find('#link-' + imgsIds[i]) &&  tmpl.find('#link-' + imgsIds[i]).value || null
        };
        if(Images.findOne({ _id: imgsIds[i]}))
          imgs.push(img);
      }
    }

    mods.images = imgs;

    var filesIds = uploadObject.getReferences();
    var files = [];

    if(filesIds.length > 0) {
      for (var i = 0; i < filesIds.length; i++){
        var file = {
            fileId: filesIds[i],
            title: tmpl.find('#title-' + filesIds[i]) && tmpl.find('#title-' + filesIds[i]).value || null,
            typedoc: tmpl.find('#typedoc-' + filesIds[i]) && tmpl.find('#typedoc-' + filesIds[i]).value || null,
            date: tmpl.find('#date-' + filesIds[i]) && tmpl.find('#date-' + filesIds[i]).value || null
        };
      if(Files.findOne({ _id: filesIds[i]}))
        files.push(file);
      }
    }

    mods.references = files;

    modifier.$set = _.extend(modifier.$set, mods);
    return modifier;
};

createReport = function(tmpl) {
    "use strict";

    // our report document
    var report = {
        project: {},
        evaluation: {}
    };

    // get all variables, and build the document
    report.project.name = tmpl.find('#name').value;
    report.project.projectNumber = parseInt(tmpl.find('#project-num').value);
    report.project.sector = tmpl.find('#sector').value;

    report.project.location = {};

    report.project.location.name = tmpl.find('#location').value || "";

    var coords = locationObject.getCoordinates();

    report.project.location.coordinates = {};

    report.project.location.coordinates.lat = coords.lat;
    report.project.location.coordinates.lng = coords.lng;

    report.project.projectDescription = {};
    report.project.projectDescription.short = tmpl.find('#project-desc-short').value;
    report.project.projectDescription.long = tmpl.find('#project-desc-long').value;

    report.project.finishingYear = parseInt(tmpl.find('#finishing-year').value) || null;
    report.project.evaluationYear = parseInt(tmpl.find('#eval-year').value) || null;
    report.project.decisionYear = parseInt(tmpl.find('#decision-year').value) || null;

    report.project.managementBudget = {};
    report.project.costBudget = {};
    report.project.costFinal = {};

    report.project.managementBudget.year = parseInt(tmpl.find('#management-budget-year').value) || null;
    report.project.costBudget.year = parseInt(tmpl.find('#cost-budget-year').value) || null;
    report.project.costFinal.year = parseInt(tmpl.find('#cost-final-year').value) || null;

    report.project.managementBudget.amount = parseInt(tmpl.find('#management-budget').value) || null;
    report.project.costBudget.amount = parseInt(tmpl.find('#cost-budget').value) || null;
    report.project.costFinal.amount = parseInt(tmpl.find('#cost-final').value) || null;

    report.responsible = {};
    report.responsible.organization = tmpl.find('#eval-responsible-org').value || "";
    report.responsible.person = tmpl.find('#eval-responsible-person').value || "";

    report.evaluation.overall = {};
    report.evaluation.productivity = {};
    report.evaluation.achievement = {};
    report.evaluation.effects = {};
    report.evaluation.relevance = {};
    report.evaluation.viability = {};
    report.evaluation.profitability = {};

    report.evaluation.overall.short = tmpl.find('#eval-overall-short').value || "";
    report.evaluation.overall.long = tmpl.find('#eval-overall-long').value || "";

    report.evaluation.productivity.short = tmpl.find('#eval-productivity-short').value || "";
    report.evaluation.productivity.long = tmpl.find('#eval-productivity-long').value || "";

    report.evaluation.achievement.short = tmpl.find('#eval-achievement-short').value || "";
    report.evaluation.achievement.long = tmpl.find('#eval-achievement-long').value || "";

    report.evaluation.effects.short = tmpl.find('#eval-effects-short').value || "";
    report.evaluation.effects.long = tmpl.find('#eval-effects-long').value || "";

    report.evaluation.relevance.short = tmpl.find('#eval-relevance-short').value || "";
    report.evaluation.relevance.long = tmpl.find('#eval-relevance-long').value || "";

    report.evaluation.viability.short = tmpl.find('#eval-viability-short').value || "";
    report.evaluation.viability.long = tmpl.find('#eval-viability-long').value || "";

    report.evaluation.profitability.short = tmpl.find('#eval-profitability-short').value || "";
    report.evaluation.profitability.long = tmpl.find('#eval-profitability-long').value || "";

    var productivityValue = parseInt(tmpl.find('input[name="num-eval-productivity"]:checked').value);
    var achievementValue = parseInt(tmpl.find('input[name="num-eval-achievement"]:checked').value);
    var effectsValue = parseInt(tmpl.find('input[name="num-eval-effects"]:checked').value);
    var relevanceValue = parseInt(tmpl.find('input[name="num-eval-relevance"]:checked').value);
    var viabilityValue = parseInt(tmpl.find('input[name="num-eval-viability"]:checked').value);
    var profitabilityValue = parseInt(tmpl.find('input[name="num-eval-profitability"]:checked').value);

    report.evaluation.productivity.value = productivityValue;
    report.evaluation.achievement.value = achievementValue;
    report.evaluation.effects.value = effectsValue;
    report.evaluation.relevance.value = relevanceValue;
    report.evaluation.viability.value = viabilityValue;
    report.evaluation.profitability.value = profitabilityValue;

    var evaluations = [productivityValue, achievementValue, effectsValue, relevanceValue, viabilityValue, profitabilityValue];

    var success = evaluateProject(evaluations);

    report.project.successCategory = success;

    var imgsIds = uploadObject.getImages();
    var imgs = [];

    if(imgsIds.length > 0) {
      for (var i = 0; i < imgsIds.length; i++){
        var img = {
            fileId: imgsIds[i],
            title: tmpl.find('#title-' + imgsIds[i]).value,
            copyright: tmpl.find('#copyright-' + imgsIds[i]).value,
            link: tmpl.find('#link-' + imgsIds[i]).value
        };
        imgs.push(img);
      }
    }

    report.images = imgs;

    var filesIds = uploadObject.getReferences();
    var files = [];

    if(filesIds.length > 0) {
      for (var i = 0; i < filesIds.length; i++){
        var file = {
            fileId: filesIds[i],
            title: tmpl.find('#title-' + filesIds[i]).value,
            typedoc: tmpl.find('#typedoc-' + filesIds[i]).value,
            date: tmpl.find('#date-' + filesIds[i]).value
        };
        files.push(file);
      }
    }

    report.references = files;
    report._public = parseInt(tmpl.find('input[name="public-var"]:checked').value) === 1;

    return report;
};
<|endoftext|>


<commit_before><commit_msg>Get user gender from backend<commit_after><|endoftext|>


<commit_before>/**
* Jquery Multilevel Menu from JSON String
* 2017 - youtube.com/user/davicotico
* @autor David Ticona Saravia
* @version 1.0
* @abstract Create Multilevel Menu from JSON String.
* Formats availables: Vertical menu(Unordered list), Horizontal menu(Unorder list) and Select (Combobox)
*
*/
(function($){
	$.fn.jsontomenu = function(options){
		var settings = $.extend({
			data: null,
			active: window.location.href,
			title: '',
			type: 'list'
		}, options);
		try {
			var objJson = jQuery.parseJSON(settings.data);
		} catch (e) {
			var objJson = null;
		}
		if(objJson!==null){
			switch (settings.type){
				case 'list' :
					var result = create_vmenu(objJson, settings.active);
					this.append(result);
					jQuery('li.active').parents('.treeview').addClass('active');
					break;
				case 'fill_select' :
					var result = fill_select(objJson, settings.active);
					this.append(result);
					break;
                case 'select' :
					var result = create_select(objJson, settings.active);
					this.append(result);
					break;
				default : var result = create_vmenu(objJson, settings.active);
			}
			return this;
		}else{
			console.log('Error: JSON Format Incorrect');
		}
		/* Create a Select (Combobox) */
		function create_select(options, active){
			var html = '<select id="'+ settings.id +'" class="form-control">';
            if(settings.title !== ''){
                html += '<option>'+ settings.title +'</option>';
            }
			html += fill_select(options, active);
			html += '</select>';
            return html;
		}
		/* Fill a Select (Combobox) */
		function fill_select(arrayItem, active, level){
			var html = '';
			var level = (typeof(level)==='undefined') ? 0 : level;
			$.each(arrayItem, function(k, v){
				html += '<option ';
				if (active===v.value){
					html += 'selected class="active" ';
				}
				if(level===0){ bullet = '';} else{ bullet = '- ';}
				html += ' value="'+ v.value +'">'+ str_repeat(" " , level ) + bullet +v.text +'</option>';
				if ((typeof(v.children) !== "undefined") && ($.isArray(v.children))){
					html += fill_select(v.children, active, level+2);
				}
			});
			return html;
		}
		/*Private Function: Vertical Menu*/
		function create_vmenu(arrayItem, active, level){
			var html = '', has_child = false;
			var level = (typeof(level)==='undefined') ? 0 : level;
			if (level===0){
				html = '
';
                html +=(settings.title!=='') ? '
'+ settings.title +'
' : '';
			}else{
				html = '
';
			}
			$.each(arrayItem, function(k, v){
				if ((typeof(v.children) !== "undefined") && ($.isArray(v.children))){
					html += '
';
					html += '';
					html += ''+ v.text +'';
					has_child = true;
				}else{
					html += '
';
					html += '';
					html += ''+ v.text +'';
					has_child = false;
				}
				if (has_child === true){
					html += create_vmenu(v.children, active, level+1);
				}
				html +=  '
';
			});
			html += '
';
			return html;
		}
		function str_repeat(input, multiplier) {
			var y = '';
			while (true) {
				if (multiplier & 1){
					y += input;
				}
				multiplier >>= 1;
				if (multiplier){
					input += input;
				} else {
					break;
				}
			}
			return y;
		}
	};
}(jQuery));
<commit_msg>deprecated<commit_after>/**
* DEPRECATED
* Jquery Multilevel Menu from JSON String
* 2017 - youtube.com/user/davicotico
* @autor David Ticona Saravia
* @version 0.0
* @abstract Create Multilevel Menu from JSON String.
* Formats availables: Vertical menu(Unordered list), Horizontal menu(Unorder list) and Select (Combobox)
*
*/
(function($){
	$.fn.jsontomenu = function(options){
		var settings = $.extend({
			data: null,
			active: window.location.href,
			title: '',
			type: 'list'
		}, options);
		try {
			var objJson = jQuery.parseJSON(settings.data);
		} catch (e) {
			var objJson = null;
		}
		if(objJson!==null){
			switch (settings.type){
				case 'list' :
					var result = create_vmenu(objJson, settings.active);
					this.append(result);
					jQuery('li.active').parents('.treeview').addClass('active');
					break;
				case 'fill_select' :
					var result = fill_select(objJson, settings.active);
					this.append(result);
					break;
                case 'select' :
					var result = create_select(objJson, settings.active);
					this.append(result);
					break;
				default : var result = create_vmenu(objJson, settings.active);
			}
			return this;
		}else{
			console.log('Error: JSON Format Incorrect');
		}
		/* Create a Select (Combobox) */
		function create_select(options, active){
			var html = '<select id="'+ settings.id +'" class="form-control">';
            if(settings.title !== ''){
                html += '<option>'+ settings.title +'</option>';
            }
			html += fill_select(options, active);
			html += '</select>';
            return html;
		}
		/* Fill a Select (Combobox) */
		function fill_select(arrayItem, active, level){
			var html = '';
			var level = (typeof(level)==='undefined') ? 0 : level;
			$.each(arrayItem, function(k, v){
				html += '<option ';
				if (active===v.value){
					html += 'selected class="active" ';
				}
				if(level===0){ bullet = '';} else{ bullet = '- ';}
				html += ' value="'+ v.value +'">'+ str_repeat(" " , level ) + bullet +v.text +'</option>';
				if ((typeof(v.children) !== "undefined") && ($.isArray(v.children))){
					html += fill_select(v.children, active, level+2);
				}
			});
			return html;
		}
		/*Private Function: Vertical Menu*/
		function create_vmenu(arrayItem, active, level){
			var html = '', has_child = false;
			var level = (typeof(level)==='undefined') ? 0 : level;
			if (level===0){
				html = '
';
                html +=(settings.title!=='') ? '
'+ settings.title +'
' : '';
			}else{
				html = '
';
			}
			$.each(arrayItem, function(k, v){
				if ((typeof(v.children) !== "undefined") && ($.isArray(v.children))){
					html += '
';
					html += '';
					html += ''+ v.text +'';
					has_child = true;
				}else{
					html += '
';
					html += '';
					html += ''+ v.text +'';
					has_child = false;
				}
				if (has_child === true){
					html += create_vmenu(v.children, active, level+1);
				}
				html +=  '
';
			});
			html += '
';
			return html;
		}
		function str_repeat(input, multiplier) {
			var y = '';
			while (true) {
				if (multiplier & 1){
					y += input;
				}
				multiplier >>= 1;
				if (multiplier){
					input += input;
				} else {
					break;
				}
			}
			return y;
		}
	};
}(jQuery));
<|endoftext|>


<commit_before>/**
Copyright 2016 Autodesk,Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

*/
import createComponent from '../../../adapters/createComponent';
import HIGElement from '../../HIGElement';

export class Tab extends HIGElement {
  componentDidMount() {
    if (this.initialProps.active) {
      this.hig.activate();
    } else {
      this.hig.deactivate();
    }
  }

  commitUpdate(updatePayload, oldProps, newProp) {
    for (let i = 0; i < updatePayload.length; i += 2) {
      const propKey = updatePayload[i];
      const propValue = updatePayload[i + 1];

      switch (propKey) {
        case 'label':
          this.hig.setTabel(propValue);
          break;
        case 'active':
          if (propValue) {
            this.hig.activate();
          } else {
            this.hig.deactivate();
          }
          break;
        case 'onClick': {
          const dispose = this._disposeFunctions.get('onClickDispose');

          if (dispose) {
            dispose();
          }

          this._disposeFunctions.set(
            'onClickDispose',
            this.hig.onClick(propValue)
          );
          break;
        }

        default: {
          console.warn(`${propKey} is unknown`);
        }
      }
    }
  }
}

const TabComponent = createComponent(Tab);

export default TabComponent;
<commit_msg>Fix typo<commit_after>/**
Copyright 2016 Autodesk,Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

*/
import createComponent from '../../../adapters/createComponent';
import HIGElement from '../../HIGElement';

export class Tab extends HIGElement {
  componentDidMount() {
    if (this.initialProps.active) {
      this.hig.activate();
    } else {
      this.hig.deactivate();
    }
  }

  commitUpdate(updatePayload, oldProps, newProp) {
    for (let i = 0; i < updatePayload.length; i += 2) {
      const propKey = updatePayload[i];
      const propValue = updatePayload[i + 1];

      switch (propKey) {
        case 'label':
          this.hig.setLabel(propValue);
          break;
        case 'active':
          if (propValue) {
            this.hig.activate();
          } else {
            this.hig.deactivate();
          }
          break;
        case 'onClick': {
          const dispose = this._disposeFunctions.get('onClickDispose');

          if (dispose) {
            dispose();
          }

          this._disposeFunctions.set(
            'onClickDispose',
            this.hig.onClick(propValue)
          );
          break;
        }

        default: {
          console.warn(`${propKey} is unknown`);
        }
      }
    }
  }
}

const TabComponent = createComponent(Tab);

export default TabComponent;
<|endoftext|>


<commit_before>var roleHauler = {

	/** @param {Creep} creep **/
	run: function(creep) {

		if (creep.memory.harvesting && (creep.carry.energy == creep.carryCapacity) {
	  	creep.memory.harvesting = false;
	  	creep.say('Depositing');
		}
		if (!(creep.memory.hauling) && (creep.carry.energy == 0) {
		  creep.memory.harvesting = true;
		  creep.say('Harvesting');
		}

		if (creep.memory.harvesting) {
			var energy = creep.room.find(FIND_DROPPED_ENERGY, {
				filter: (res) => {
					return (res.amount > 50)
				}
			});

			if (energy.length == 0) {
				var storage = creep.room.find(FIND_STRUCTURES, {
					filter: (structure) => {
						return (
							(structure.structureType == STRUCTURE_CONTAINER) &&
							(structure.store[RESOURCE_ENERGY] > creep.carryCapacity) &&
							(structure.pos.findInRange(FIND_SOURCES, 2).length != 0));
					}
				});
				if (storage.length) {
					var target = creep.pos.findClosestByRange(storage);

					if (!(creep.pos.isNearTo(target))) {
						creep.moveTo(target);
					}
					else {
						creep.withdraw(target, RESOURCE_ENERGY,
													(creep.carryCapacity - _.sum(creep.carry)));
					}
				}
			}
			else {
				var target = creep.pos.findClosestByRange(energy);

				if (!(creep.pos.isNearTo(target))) {
					creep.moveTo(target);
				}
				else {
					creep.pickup(target);
				}
			}
		}
		else {
			var targets = creep.room.find(FIND_STRUCTURES, {
				filter: (structure) => {
					return (
								((structure.structureType == STRUCTURE_SPAWN) ||
								 (structure.structureType == STRUCTURE_EXTENSION)) &&
								 (structure.energy < structure.energyCapacity));
				}
			});

			if (targets.length == 0) {
				var targets = creep.room.find(FIND_STRUCTURES, {
					filter: (structure) => {
						return (
							((structure.structureType == STRUCTURE_CONTAINER) &&
								(_.sum(structure.store) < (structure.storeCapacity - creep.carry.energy)) &&
								structure.pos.findInRange(FIND_SOURCES, 2).length == 0));
					}
				});
			}
			if (targets.length == 0) {
				var targets = creep.room.find(FIND_STRUCTURES, {
					filter: (structure) => {
						return (
							(structure.structureType == STRUCTURE_STORAGE) &&
							(_.sum(structure.store) < structure.storeCapacity));
					}
				});
			}
			if (targets.length > 0) {
				var target = creep.pos.findClosestByRange(targets);
				if (creep.transfer(target, RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
					creep.moveTo(target);
				}
			}
		}

	} // function

}; // roleHauler

module.exports = roleHauler;<commit_msg>Minor changes<commit_after>var roleHauler = {

	/** @param {Creep} creep **/
	run: function(creep) {

		if (creep.memory.harvesting && (creep.carry.energy == creep.carryCapacity)) {
	  	creep.memory.harvesting = false;
	  	creep.say('Depositing');
		}
		if (!(creep.memory.hauling) && (creep.carry.energy == 0)) {
		  creep.memory.harvesting = true;
		  creep.say('Harvesting');
		}

		if (creep.memory.harvesting) {
			var energy = creep.room.find(FIND_DROPPED_ENERGY, {
				filter: (res) => {
					return (res.amount > 50)
				}
			});

			if (energy.length == 0) {
				var storage = creep.room.find(FIND_STRUCTURES, {
					filter: (structure) => {
						return (
							(structure.structureType == STRUCTURE_CONTAINER) &&
							(structure.store[RESOURCE_ENERGY] > creep.carryCapacity) &&
							(structure.pos.findInRange(FIND_SOURCES, 2).length != 0));
					}
				});
				if (storage.length) {
					var target = creep.pos.findClosestByRange(storage);

					if (!(creep.pos.isNearTo(target))) {
						creep.moveTo(target);
					}
					else {
						creep.withdraw(target, RESOURCE_ENERGY,
													(creep.carryCapacity - _.sum(creep.carry)));
					}
				}
			}
			else {
				var target = creep.pos.findClosestByRange(energy);

				if (!(creep.pos.isNearTo(target))) {
					creep.moveTo(target);
				}
				else {
					creep.pickup(target);
				}
			}
		}
		else {
			var targets = creep.room.find(FIND_STRUCTURES, {
				filter: (structure) => {
					return (
								((structure.structureType == STRUCTURE_SPAWN) ||
								 (structure.structureType == STRUCTURE_EXTENSION)) &&
								 (structure.energy < structure.energyCapacity));
				}
			});

			if (targets.length == 0) {
				var targets = creep.room.find(FIND_STRUCTURES, {
					filter: (structure) => {
						return (
							((structure.structureType == STRUCTURE_CONTAINER) &&
								(_.sum(structure.store) < (structure.storeCapacity - creep.carry.energy)) &&
								structure.pos.findInRange(FIND_SOURCES, 2).length == 0));
					}
				});
			}
			if (targets.length == 0) {
				var targets = creep.room.find(FIND_STRUCTURES, {
					filter: (structure) => {
						return (
							(structure.structureType == STRUCTURE_STORAGE) &&
							(_.sum(structure.store) < structure.storeCapacity));
					}
				});
			}
			if (targets.length > 0) {
				var target = creep.pos.findClosestByRange(targets);
				if (creep.transfer(target, RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
					creep.moveTo(target);
				}
			}
		}

	} // function

}; // roleHauler

module.exports = roleHauler;<|endoftext|>


<commit_before>var roleHauler = {

	/** @param {Creep} creep **/
	run: function(creep) {

		if (creep.memory.harvesting) {
			var energy = creep.pos.findInRange(FIND_DROPPED_ENERGY, 3);

			if (energy.length <1 ) {
				var storage = creep.room.find(FIND_STRUCTURES, {
					filter: (structure) => {
						return (
							(structure.structureType == STRUCTURE_CONTAINER) &&
							(structure.store[RESOURCE_ENERGY] > creep.carryCapacity) &&
							(structure.pos.findInRange(FIND_SOURCES, 2).length != 0));
					}
				});
				if (storage.length > 0) {
					var targets = storage.sort(function(store1, store2) {
						return (
							parseFloat(store2.store[RESOURCE_ENERGY]) -
							parseFloat(store1.store[RESOURCE_ENERGY]));
					});
					var target = targets[0];

					if (!(creep.pos.isNearTo(target))) {
						creep.moveTo(target);
					}
					else {
						creep.withdraw(target, RESOURCE_ENERGY,
													(creep.carryCapacity - _.sum(creep.carry)));
					}
				}
			}
			else {
				if (creep.pickup(energy[0]) == ERR_NOT_IN_RANGE) {
					creep.moveTo(energy[0]);
				}
			}
			if (creep.carry.energy == creep.carryCapacity) {
				creep.say('HL Depositing');
		  	creep.memory.harvesting = false;
			}
		}
		else {
			var targets = creep.room.find(FIND_STRUCTURES, {
				filter: (structure) => {
					return (
								((structure.structureType == STRUCTURE_SPAWN) ||
								 (structure.structureType == STRUCTURE_EXTENSION)) &&
								 (structure.energy < structure.energyCapacity));
				}
			});

			if (targets.length == 0) {
				var targets = creep.room.find(FIND_STRUCTURES, {
					filter: (structure) => {
						return (
							(structure.structureType == STRUCTURE_TOWER) &&
							(structure.energy < (structure.energyCapacity - 1500)));
					}
				});
			}
			if (targets.length == 0) {
				var targets = creep.room.find(FIND_STRUCTURES, {
					filter: (structure) => {
						return (
							((structure.structureType == STRUCTURE_CONTAINER) &&
								(_.sum(structure.store) < (structure.storeCapacity - creep.carry.energy)) &&
								structure.pos.findInRange(FIND_SOURCES, 2).length == 0));
					}
				});
			}
			if (targets.length == 0) {
				var targets = creep.room.find(FIND_STRUCTURES, {
					filter: (structure) => {
						return (
							(structure.structureType == STRUCTURE_STORAGE) &&
							(_.sum(structure.store) < structure.storeCapacity));
					}
				});
			}
			if (targets.length > 0) {
				var target = creep.pos.findClosestByRange(targets);
				if (creep.transfer(target, RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
					creep.moveTo(target);
				}
			}
			if (creep.carry.energy == 0) {
				creep.say('HL Collecting');
			  creep.memory.harvesting = true;
			}
		}

	} // function

}; // roleHauler

module.exports = roleHauler;<commit_msg>Minor changes<commit_after>var roleHauler = {

	/** @param {Creep} creep **/
	run: function(creep) {

		if (creep.memory.harvesting) {
			var energy = creep.pos.findInRange(FIND_DROPPED_ENERGY, 3);

			if (energy.length <1 ) {
				var storage = creep.room.find(FIND_STRUCTURES, {
					filter: (structure) => {
						return (
							(structure.structureType == STRUCTURE_CONTAINER) &&
							(structure.store[RESOURCE_ENERGY] > creep.carryCapacity) &&
							(structure.pos.findInRange(FIND_SOURCES, 2).length != 0));
					}
				});
				if (storage.length > 0) {
					var targets = storage.sort(function(store1, store2) {
						return (
							parseFloat(store2.store[RESOURCE_ENERGY]) -
							parseFloat(store1.store[RESOURCE_ENERGY]));
					});
					var target = targets[0];

					if (!(creep.pos.isNearTo(target))) {
						creep.moveTo(target);
					}
					else {
						creep.withdraw(target, RESOURCE_ENERGY,
													(creep.carryCapacity - _.sum(creep.carry)));
					}
				}
			}
			else {
				if (creep.pickup(energy[0]) == ERR_NOT_IN_RANGE) {
					creep.moveTo(energy[0]);
				}
			}
			if (creep.carry.energy == creep.carryCapacity) {
				creep.say('HL Depositing');
		  	creep.memory.harvesting = false;
			}
		}
		else {
			var targets = creep.room.find(FIND_STRUCTURES, {
				filter: (structure) => {
					return (
								((structure.structureType == STRUCTURE_SPAWN) ||
								 (structure.structureType == STRUCTURE_EXTENSION)) &&
								 (structure.energy < structure.energyCapacity));
				}
			});

			if (targets.length == 0) {
				var targets = creep.room.find(FIND_STRUCTURES, {
					filter: (structure) => {
						return (
							(structure.structureType == STRUCTURE_TOWER) &&
							(structure.energy < (structure.energyCapacity - 500)));
					}
				});
			}
			if (targets.length == 0) {
				var targets = creep.room.find(FIND_STRUCTURES, {
					filter: (structure) => {
						return (
							((structure.structureType == STRUCTURE_CONTAINER) &&
								(_.sum(structure.store) < (structure.storeCapacity - creep.carry.energy)) &&
								structure.pos.findInRange(FIND_SOURCES, 2).length == 0));
					}
				});
			}
			if (targets.length == 0) {
				var targets = creep.room.find(FIND_STRUCTURES, {
					filter: (structure) => {
						return (
							(structure.structureType == STRUCTURE_STORAGE) &&
							(_.sum(structure.store) < structure.storeCapacity));
					}
				});
			}
			if (targets.length > 0) {
				var target = creep.pos.findClosestByRange(targets);
				if (creep.transfer(target, RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
					creep.moveTo(target);
				}
			}
			if (creep.carry.energy == 0) {
				creep.say('HL Collecting');
			  creep.memory.harvesting = true;
			}
		}

	} // function

}; // roleHauler

module.exports = roleHauler;<|endoftext|>


<commit_before>export default {
  locationBased: {
    denmark: [
      {
        name: 'DevDK',
        description:
          'Dansk digitalt community — Arrangør af One Day Out, stifter af #devdk — For et bedre community i Danmark',
        url: 'http://slack.devdk.org/',
      },
    ],
    'united states': [
      {
        alabama: [
          {
            name: '',
            description: '',
            url: '',
          },
        ],
      },
      {
        california: [
          {
            name: '',
            description: '',
            url: '',
          },
        ],
      },
      {
        colorado: [
          {
            name: '',
            description: '',
            url: '',
          },
        ],
      },
      {
        florida: [
          {
            name: '',
            description: '',
            url: '',
          },
        ],
      },
      {
        georgia: [
          {
            name: '',
            description: '',
            url: '',
          },
        ],
      },
      {
        kentucky: [
          {
            name: '',
            description: '',
            url: '',
          },
        ],
      },
      {
        midwest: [
          {
            name: '',
            description: '',
            url: '',
          },
        ],
      },
      {
        'new york': [
          {
            name: '',
            description: '',
            url: '',
          },
        ],
      },
      {
        oregon: [
          {
            name: '',
            description: '',
            url: '',
          },
        ],
      },
      {
        pennsylvania: [
          {
            name: '',
            description: '',
            url: '',
          },
        ],
      },
      {
        'south carolina': [
          {
            name: '',
            description: '',
            url: '',
          },
        ],
      },
      {
        tennessee: [
          {
            name: '',
            description: '',
            url: '',
          },
          {
            name: '',
            description: '',
            url: '',
          },
          {
            name: '',
            description: '',
            url: '',
          },
        ],
      },
      {
        texas: [
          {
            name: '',
            description: '',
            url: '',
          },
          {
            name: '',
            description: '',
            url: '',
          },
        ],
      },
    ],
  },
  itBased: [
    {
      name: '',
      description: '',
      url: '',
    },
    {
      name: '',
      description: '',
      url: '',
    },
    {
      name: '',
      description: '',
      url: '',
    },
    {
      name: '',
      description: '',
      url: '',
    },
    {
      name: '',
      description: '',
      url: '',
    },
  ],
  productBased: [],
  programmingBased: [
    {
      name: '',
      description: '',
      url: '',
    },
  ],
  hardwareBased: [],
  financeAndMarketingBased: [],
  miscellaneousBased: [],
}
<commit_msg>Finish filling in JSON data<commit_after>export default {
  locationBased: {
    denmark: [
      {
        name: 'DevDK',
        description: 'Dansk digitalt community — Arrangør af One Day Out, stifter af #devdk — For et bedre community i Danmark',
        url: 'http://slack.devdk.org/',
      },
    ],
    'united states': [
      {
        alabama: [
          {
            name: 'Magic City Tech',
            description: 'Magic City Tech is a group for Birmingham area developers, designers, marketers, business people, hobbyists, students, and other professionals involved in technology.',
            url: 'http://magiccitytech.org/',
          },
        ],
      },
      {
        california: [
          {
            name: 'Software Craftsmanship',
            description: 'A network for the Los Angeles tech community',
            url: 'http://slack.softwarecraftsmanship.org/',
          },
        ],
      },
      {
        colorado: [
          {
            name: 'NewTech Colorado',
            description: 'New Tech is a community of 12,000 geeks who live and work in Colorado.',
            url: 'https://reichrobert.typeform.com/to/V0WnZf',
          },
        ],
      },
      {
        florida: [
          {
            name: 'Suncoast Developers Guild',
            description: 'We are a collective of software engineers, programmers, and designers in the Tampa Bay Area.',
            url: 'https://suncoast.io/',
          },
        ],
      },
      {
        georgia: [
          {
            name: 'TECH404',
            description: 'Chat channels for Atlanta area developers, designers, marketers, business people, hobbyists, students, and other professionals involved in technology.',
            url: 'http://tech404.io/',
          },
        ],
      },
      {
        kentucky: [
          {
            name: 'Louisville Tech / Louisville.IO',
            description: 'a community of technology user groups and meetups in Louisville, Kentucky.',
            url: 'https://slackin.louisvilletech.org/',
          },
        ],
      },
      {
        midwest: [
          {
            name: 'MidWestDevChat.com',
            description: 'An awesome group of developers (software, web, etc) from the midwest who hang out daily using the great Slack messaging app.',
            url: 'https://midwestdevchat.com/',
          },
        ],
      },
      {
        'new york': [
          {
            name: 'New York Tech',
            description: 'A network for the New York Tech scene.',
            url: 'http://www.nyctechslack.com/',
          },
        ],
      },
      {
        oregon: [
          {
            name: 'Portland Tech',
            description: 'A network for the Portland Tech scene.',
            url: 'http://pdx-startups-slack.herokuapp.com/',
          },
        ],
      },
      {
        pennsylvania: [
          {
            name: 'Philadelphia Startup Leaders',
            description: 'Philadelphia Startup Leaders',
            url: 'https://www.sendgrowth.com/psl',
          },
        ],
      },
      {
        'south carolina': [
          {
            name: 'Charleston Tech',
            description: 'A network for the Charleston Tech scene.',
            url: 'http://charlestontechnology.com/slack/',
          },
        ],
      },
      {
        tennessee: [
          {
            name: 'memtech',
            description: 'Memphis technical community chat.',
            url: 'http://slack.memphistechnology.org/',
          },
          {
            name: 'NashDev',
            description: 'A network for Nashville developers.',
            url: 'https://nashdev.com',
          },
          {
            name: 'KnoxDev',
            description: 'Knoxvilles Development Gathering',
            url: 'https://knoxdevs.com',
          },
        ],
      },
      {
        texas: [
          {
            name: 'DFWStartupCommunity',
            description: 'A network for the Dallas-Fort Worth Area.',
            url: 'http://slack.dfwstartupcommunity.com/',
          },
          {
            name: 'Open Austin',
            description: 'For people interested in open government and civic technology.',
            url: 'https://slack.open-austin.org/',
          },
        ],
      },
    ],
  },
  itBased: [
    {
      name: 'Android United',
      description: 'A friendly Slack community of Android developers. We unite people from all over the world. We share our experience, knowledge and relevant news about Android and mobile. We help each other.',
      url: 'http://android-united.community/',
    },
    {
      name: "APIs You Won't Hate",
      description: "Get your API, REST and HTTP questions answered! We're the larrgest API-centric Slack channel around.",
      url: 'https://slack.apisyouwonthate.com/',
    },
    {
      name: 'HackerX',
      description: "A community of hackers and makers from all over the world to facilitate networking, Q&A's, feedback and more.",
      url: 'https://karangoel.typeform.com/to/mEl3P9',
    },
    {
      name: 'Hangops',
      description: 'Awesome discussion with the DevOps community.',
      url: 'https://signup.hangops.com/',
    },
    {
      name: 'iOS Developers',
      description: 'A Slack community for iOS developers.',
      url: 'https://ios-developers.io/',
    },
  ],
  productBased: [],
  programmingBased: [
    {
      name: 'Larachat',
      description: 'Talk to some of the best Laravel minds on the web today.',
      url: 'https://larachat.co/slack',
    },
  ],
  hardwareBased: [],
  financeAndMarketingBased: [],
  miscellaneousBased: [],
}
<|endoftext|>


<commit_before>var settings;

function detectBrowser() {
	try {
		if (window && window.chrome) {
			return 'Chrome';
		}
		if (window && window.safari) {
			return 'Safari';
		}
	} catch (e) {
		// I hate developing Firefox extensions.
		return 'Firefox';
	}
}

var browser = detectBrowser();

function chromeMessageHandler(message, sender, sendResponse) {
	if (message === 'getSettings') {
		sendResponse({data: localStorage.settings});
	} else {
		sendResponse({}); // send a blank reply.
	}
}

function parseSettings() {
	var parsedSettings;

	if (!localStorage || !localStorage.settings) {
		parsedSettings = defaultSettings;
	} else {
		try {
			parsedSettings = JSON.parse(localStorage.settings);
		} catch (e) {
			parsedSettings = defaultSettings;
		}
	}

	return parsedSettings;
}

function checkurl(url, filter) {
	var f, filterRegex, re;

	if (url === undefined || url === null) {
		return false;
	}

	for (f = 0; f < filter.length; f++) {
		filterRegex = filter[f].replace(/\x2a/g, '(.*?)');
		re = new RegExp(filterRegex);
		if (url.match(re)) {
			return true;
		}
	}
	return false;
}

function addToBlackList(theword) {
	var oldSettings, v;

	oldSettings = parseSettings();

	for (v = 0; v < oldSettings.listBlack.length; v++) {
		if (oldSettings.listBlack[v].toLowerCase() === theword.toLowerCase()) {
			alert('\'' + theword + '\' is already on your black list.');
			return false;
		}
	}

	oldSettings.listBlack.push(theword.toLowerCase());
	localStorage.settings = JSON.stringify(oldSettings);

	return true;
}

function chromeAddToBlackList(info, tab) {
	var theword, chromeViews, chromeView;
	theword = info.selectionText;

	if (theword && addToBlackList(theword)) {
		chromeViews = chrome.extension.getViews();
		for (chromeView = 0; chromeView < chromeViews.length; chromeView++) {
			if (chromeViews[chromeView].location === chrome.extension.getURL('data/options.html')) {
				chromeViews[chromeView].location.reload();
			}
		}
		if (chrome.tabs.sendMessage !== undefined) {
			chrome.tabs.sendMessage(tab.id, 'refreshSettings');
		} else if (chrome.tabs.sendRequest !== undefined) {
			chrome.tabs.sendRequest(tab.id, 'refreshSettings');
		}
	}
}

function safariMessageHandler(event) {
	var tab;

	switch (event.name) {
	case 'getSettings':
		event.target.page.dispatchMessage('settings', localStorage.settings);
		break;
	case 'refreshSettings':
		localStorage.settings = JSON.stringify(event.message);
		for (tab = 0; tab < safari.application.activeBrowserWindow.tabs.length; tab++) {
			if (checkurl(safari.application.activeBrowserWindow.tabs[tab].url, ['http://www.tumblr.com/*', 'https://www.tumblr.com/*'])) {
				safari.application.activeBrowserWindow.tabs[tab].page.dispatchMessage('refreshSettings');
			}
		}
		break;
	default:
		event.target.page.dispatchMessage({}); // send a blank reply.
		break;
	}
}

function safariCommandHandler(event) {
	var tabAlreadyOpened, tab, newTab, theword;

	switch (event.command) {
	case 'options':
		for (tab = 0; tab < safari.application.activeBrowserWindow.tabs.length; tab++) {
			if (safari.application.activeBrowserWindow.tabs[tab].url === safari.extension.baseURI + 'data/options.html') {
				tabAlreadyOpened = tab;
			}
		}
		if (tabAlreadyOpened === undefined) {
			newTab = safari.application.activeBrowserWindow.openTab();
			newTab.url = safari.extension.baseURI + 'data/options.html';
		} else {
			safari.application.activeBrowserWindow.tabs[tabAlreadyOpened].activate();
		}
		break;
	case 'addToBlackList':
		theword = event.userInfo;
		if (theword && addToBlackList(theword)) {
			for (tab = 0; tab < safari.application.activeBrowserWindow.tabs.length; tab++) {
				if (checkurl(safari.application.activeBrowserWindow.tabs[tab].url, ['http://www.tumblr.com/*', 'https://www.tumblr.com/*'])) {
					safari.application.activeBrowserWindow.tabs[tab].page.dispatchMessage('refreshSettings');
				}
				if (safari.application.activeBrowserWindow.tabs[tab].url === safari.extension.baseURI + 'data/options.html') {
					safari.application.activeBrowserWindow.tabs[tab].page.dispatchMessage('settings', localStorage.settings);
				}
			}
		}
		break;
	}
}

function safariContextMenuHandler(event) {
	var wordBlack, settings;

	wordBlack = event.userInfo;
	settings = parseSettings();

	if (settings.context_menu && wordBlack) {
		if (wordBlack.length > 25) {
			wordBlack = wordBlack.substr(0, 25);
			wordBlack = wordBlack.replace(/^\s+|\s+$/g, '');
			wordBlack = wordBlack + '...';
		}
		event.contextMenu.appendContextMenuItem('addToBlackList', 'Add \'' + wordBlack + '\' to Tumblr Savior black list');
	}
}

function safariValidateHandler(event) {
	var settings;

	if (event.command === 'addToBlackList') {
		settings = parseSettings();
		if (!settings.context_menu || event.userInfo === null) {
			event.target.disabled = true
		}
	}
}

switch (browser) {
case 'Chrome':
	console.log('Setting up the',browser,'backend.');
	if (chrome.extension.onMessage !== undefined) {
		chrome.extension.onMessage.addListener(chromeMessageHandler);
	} else if (chrome.extension.onRequest !== undefined) {
		chrome.extension.onRequest.addListener(chromeMessageHandler);
	}

	settings = parseSettings();

	if (settings.context_menu === 'true' || settings.context_menu === true) {
		chrome.contextMenus.create({
			'type': 'normal',
			'title': 'Add \'%s\' to Tumblr Savior black list',
			'contexts': ['selection'],
			'documentUrlPatterns': ['http://www.tumblr.com/*', 'https://www.tumblr.com/*'],
			'onclick': chromeAddToBlackList
		});
	}
	break;
case 'Safari':
	console.log('Setting up the',browser,'backend.');
	safari.application.addEventListener('message', safariMessageHandler, false);
	safari.application.addEventListener('command', safariCommandHandler, false);
	safari.application.addEventListener('contextmenu', safariContextMenuHandler, false);
	safari.application.addEventListener('validate', safariValidateHandler, false);
	break;
case 'Firefox':
	console.log('Setting up the',browser,'backend.');
	// Developing extensions for this browser sucks...
	exports.main = require('./firefox.js');
	break;
default:
	console.error('I\'m sorry, but your browser extension system was not detected correctly.');
}
<commit_msg>Use typographic double quotes in the Safari context menu<commit_after>var settings;

function detectBrowser() {
	try {
		if (window && window.chrome) {
			return 'Chrome';
		}
		if (window && window.safari) {
			return 'Safari';
		}
	} catch (e) {
		// I hate developing Firefox extensions.
		return 'Firefox';
	}
}

var browser = detectBrowser();

function chromeMessageHandler(message, sender, sendResponse) {
	if (message === 'getSettings') {
		sendResponse({data: localStorage.settings});
	} else {
		sendResponse({}); // send a blank reply.
	}
}

function parseSettings() {
	var parsedSettings;

	if (!localStorage || !localStorage.settings) {
		parsedSettings = defaultSettings;
	} else {
		try {
			parsedSettings = JSON.parse(localStorage.settings);
		} catch (e) {
			parsedSettings = defaultSettings;
		}
	}

	return parsedSettings;
}

function checkurl(url, filter) {
	var f, filterRegex, re;

	if (url === undefined || url === null) {
		return false;
	}

	for (f = 0; f < filter.length; f++) {
		filterRegex = filter[f].replace(/\x2a/g, '(.*?)');
		re = new RegExp(filterRegex);
		if (url.match(re)) {
			return true;
		}
	}
	return false;
}

function addToBlackList(theword) {
	var oldSettings, v;

	oldSettings = parseSettings();

	for (v = 0; v < oldSettings.listBlack.length; v++) {
		if (oldSettings.listBlack[v].toLowerCase() === theword.toLowerCase()) {
			alert('\'' + theword + '\' is already on your black list.');
			return false;
		}
	}

	oldSettings.listBlack.push(theword.toLowerCase());
	localStorage.settings = JSON.stringify(oldSettings);

	return true;
}

function chromeAddToBlackList(info, tab) {
	var theword, chromeViews, chromeView;
	theword = info.selectionText;

	if (theword && addToBlackList(theword)) {
		chromeViews = chrome.extension.getViews();
		for (chromeView = 0; chromeView < chromeViews.length; chromeView++) {
			if (chromeViews[chromeView].location === chrome.extension.getURL('data/options.html')) {
				chromeViews[chromeView].location.reload();
			}
		}
		if (chrome.tabs.sendMessage !== undefined) {
			chrome.tabs.sendMessage(tab.id, 'refreshSettings');
		} else if (chrome.tabs.sendRequest !== undefined) {
			chrome.tabs.sendRequest(tab.id, 'refreshSettings');
		}
	}
}

function safariMessageHandler(event) {
	var tab;

	switch (event.name) {
	case 'getSettings':
		event.target.page.dispatchMessage('settings', localStorage.settings);
		break;
	case 'refreshSettings':
		localStorage.settings = JSON.stringify(event.message);
		for (tab = 0; tab < safari.application.activeBrowserWindow.tabs.length; tab++) {
			if (checkurl(safari.application.activeBrowserWindow.tabs[tab].url, ['http://www.tumblr.com/*', 'https://www.tumblr.com/*'])) {
				safari.application.activeBrowserWindow.tabs[tab].page.dispatchMessage('refreshSettings');
			}
		}
		break;
	default:
		event.target.page.dispatchMessage({}); // send a blank reply.
		break;
	}
}

function safariCommandHandler(event) {
	var tabAlreadyOpened, tab, newTab, theword;

	switch (event.command) {
	case 'options':
		for (tab = 0; tab < safari.application.activeBrowserWindow.tabs.length; tab++) {
			if (safari.application.activeBrowserWindow.tabs[tab].url === safari.extension.baseURI + 'data/options.html') {
				tabAlreadyOpened = tab;
			}
		}
		if (tabAlreadyOpened === undefined) {
			newTab = safari.application.activeBrowserWindow.openTab();
			newTab.url = safari.extension.baseURI + 'data/options.html';
		} else {
			safari.application.activeBrowserWindow.tabs[tabAlreadyOpened].activate();
		}
		break;
	case 'addToBlackList':
		theword = event.userInfo;
		if (theword && addToBlackList(theword)) {
			for (tab = 0; tab < safari.application.activeBrowserWindow.tabs.length; tab++) {
				if (checkurl(safari.application.activeBrowserWindow.tabs[tab].url, ['http://www.tumblr.com/*', 'https://www.tumblr.com/*'])) {
					safari.application.activeBrowserWindow.tabs[tab].page.dispatchMessage('refreshSettings');
				}
				if (safari.application.activeBrowserWindow.tabs[tab].url === safari.extension.baseURI + 'data/options.html') {
					safari.application.activeBrowserWindow.tabs[tab].page.dispatchMessage('settings', localStorage.settings);
				}
			}
		}
		break;
	}
}

function safariContextMenuHandler(event) {
	var wordBlack, settings;

	wordBlack = event.userInfo;
	settings = parseSettings();

	if (settings.context_menu && wordBlack) {
		if (wordBlack.length > 25) {
			wordBlack = wordBlack.substr(0, 25);
			wordBlack = wordBlack.replace(/^\s+|\s+$/g, '');
			wordBlack = wordBlack + '...';
		}
		event.contextMenu.appendContextMenuItem('addToBlackList', 'Add \u201c' + wordBlack + '\u201d to Tumblr Savior black list');
	}
}

function safariValidateHandler(event) {
	var settings;

	if (event.command === 'addToBlackList') {
		settings = parseSettings();
		if (!settings.context_menu || event.userInfo === null) {
			event.target.disabled = true
		}
	}
}

switch (browser) {
case 'Chrome':
	console.log('Setting up the',browser,'backend.');
	if (chrome.extension.onMessage !== undefined) {
		chrome.extension.onMessage.addListener(chromeMessageHandler);
	} else if (chrome.extension.onRequest !== undefined) {
		chrome.extension.onRequest.addListener(chromeMessageHandler);
	}

	settings = parseSettings();

	if (settings.context_menu === 'true' || settings.context_menu === true) {
		chrome.contextMenus.create({
			'type': 'normal',
			'title': 'Add \'%s\' to Tumblr Savior black list',
			'contexts': ['selection'],
			'documentUrlPatterns': ['http://www.tumblr.com/*', 'https://www.tumblr.com/*'],
			'onclick': chromeAddToBlackList
		});
	}
	break;
case 'Safari':
	console.log('Setting up the',browser,'backend.');
	safari.application.addEventListener('message', safariMessageHandler, false);
	safari.application.addEventListener('command', safariCommandHandler, false);
	safari.application.addEventListener('contextmenu', safariContextMenuHandler, false);
	safari.application.addEventListener('validate', safariValidateHandler, false);
	break;
case 'Firefox':
	console.log('Setting up the',browser,'backend.');
	// Developing extensions for this browser sucks...
	exports.main = require('./firefox.js');
	break;
default:
	console.error('I\'m sorry, but your browser extension system was not detected correctly.');
}
<|endoftext|>


<commit_before>function onLoad() {
    loadData();
    blinkBackground();
    setInterval(loadData, 60000);

    if (location.search.indexOf("embed") >= 0) {
        document.getElementById("infoLink").remove();
    }
};

var timeDisplay;
var timeUnitsDisplay;
var alarmCountDisplay;

var updateInterval;
var alarmNow = false;

var DEBUG = false;

function loadData() {
    console.log("Querying for new alarms...");
    timeDisplay = document.getElementById("timeSinceLast");
    timeUnitsDisplay = document.getElementById("timeSinceLastUnits");
    alarmCountDisplay = document.getElementById("alarmCount");

    fetch("https://associationfireaccountability.azurewebsites.net/api/frontend/location/1/summary")
        .then(response => response.json())
        .then(json => {
            clearInterval(updateInterval);
            if (DEBUG) {
                json = debugAlarm(json);
            }
            updateInterval = setInterval(() => displayData(json), 1000);
        });
}

//
// Uncomment for debugging
//
// DEBUG = true;
// const DEBUG_ALARM_SUMMARY = {
//     lastAlarmTimestamp: new Date((new Date().valueOf()) + 30000),
//     alarmsThisYear: 10
// };

// function debugAlarm(realSummary) {
//     if(DEBUG_ALARM_SUMMARY.lastAlarmTimestamp > (new Date()).valueOf()) {
//         console.log("Date in future");
//         return realSummary;
//     }

//     console.log("Date in past");
//     return DEBUG_ALARM_SUMMARY;
// }

function displayData(alarmSummary) {
    let timestamp = new Date(alarmSummary.lastAlarmTimestamp);
    let count = alarmSummary.alarmsThisYear;

    alarmCountDisplay.textContent = count;

    let timeDifference = new TimeSpan(Date.now(), timestamp);

    if (timeDifference.totalSeconds < 120 && !alarmNow) {
        console.log("Alarm happening now!");
        alarmNow = true;
    } else if (timeDifference.totalSeconds > 120 && alarmNow) {
        console.log("Alarm over");
        alarmNow = false;
    }

    let amount = timeDifference.getLargestUnit();
    timeDisplay.textContent = amount;
    timeUnitsDisplay.textContent = timeDifference.getLargestUnitText(amount === 1);
}

function getTint(MIN_TINT = 150) {
    let time = new Date();
    if (time.getSeconds() % 4 < 3) {
        return MIN_TINT + Math.floor((time.getMilliseconds() / 1000) * (255 - MIN_TINT));
    }
    return 255;
}

function blinkBackground() {
    const background = document.getElementById("background");

    tintInterval = setInterval(() => {
        let tint = alarmNow ? getTint() : 255;
        background.style.backgroundColor = `rgb(255, ${tint}, ${tint})`;
    }, 5);
}<commit_msg>Changed update interval from 60 to 30 seconds<commit_after>function onLoad() {
    loadData();
    blinkBackground();
    setInterval(loadData, 30000);

    if (location.search.indexOf("embed") >= 0) {
        document.getElementById("infoLink").remove();
    }
};

var timeDisplay;
var timeUnitsDisplay;
var alarmCountDisplay;

var updateInterval;
var alarmNow = false;

var DEBUG = false;

function loadData() {
    console.log("Querying for new alarms...");
    timeDisplay = document.getElementById("timeSinceLast");
    timeUnitsDisplay = document.getElementById("timeSinceLastUnits");
    alarmCountDisplay = document.getElementById("alarmCount");

    fetch("https://associationfireaccountability.azurewebsites.net/api/frontend/location/1/summary")
        .then(response => response.json())
        .then(json => {
            clearInterval(updateInterval);
            if (DEBUG) {
                json = debugAlarm(json);
            }
            updateInterval = setInterval(() => displayData(json), 1000);
        });
}

//
// Uncomment for debugging
//
// DEBUG = true;
// const DEBUG_ALARM_SUMMARY = {
//     lastAlarmTimestamp: new Date((new Date().valueOf()) + 30000),
//     alarmsThisYear: 10
// };

// function debugAlarm(realSummary) {
//     if(DEBUG_ALARM_SUMMARY.lastAlarmTimestamp > (new Date()).valueOf()) {
//         console.log("Date in future");
//         return realSummary;
//     }

//     console.log("Date in past");
//     return DEBUG_ALARM_SUMMARY;
// }

function displayData(alarmSummary) {
    let timestamp = new Date(alarmSummary.lastAlarmTimestamp);
    let count = alarmSummary.alarmsThisYear;

    alarmCountDisplay.textContent = count;

    let timeDifference = new TimeSpan(Date.now(), timestamp);

    if (timeDifference.totalSeconds < 120 && !alarmNow) {
        console.log("Alarm happening now!");
        alarmNow = true;
    } else if (timeDifference.totalSeconds > 120 && alarmNow) {
        console.log("Alarm over");
        alarmNow = false;
    }

    let amount = timeDifference.getLargestUnit();
    timeDisplay.textContent = amount;
    timeUnitsDisplay.textContent = timeDifference.getLargestUnitText(amount === 1);
}

function getTint(MIN_TINT = 150) {
    let time = new Date();
    if (time.getSeconds() % 4 < 3) {
        return MIN_TINT + Math.floor((time.getMilliseconds() / 1000) * (255 - MIN_TINT));
    }
    return 255;
}

function blinkBackground() {
    const background = document.getElementById("background");

    tintInterval = setInterval(() => {
        let tint = alarmNow ? getTint() : 255;
        background.style.backgroundColor = `rgb(255, ${tint}, ${tint})`;
    }, 5);
}<|endoftext|>


<commit_before>var Notifier = require('../../components/notifier/notifier');
var errorParser = require('../../helpers/error-parser');

module.exports = function (opts) {
  if (!opts.visDefinitionExportModel) throw new Error('visDefinitionExportModel is required');

  var visDefinitionExportModel = opts.visDefinitionExportModel;
  var successCallback = opts.onSuccess;
  var errorCallback = opts.onError;

  visDefinitionExportModel.requestExport({
    wait: true,
    success: function (mdl, attrs) {
      successCallback && successCallback(mdl, attrs);
    },
    error: function (mdl, e) {
      errorCallback && errorCallback(mdl, e);
      Notifier.addNotification({
        status: 'error',
        info: _t('editor.maps.delete.error', {name: name, error: errorParser(e)}),
        closable: true
      });
    }
  });
};
<commit_msg>remove export-map abstraction<commit_after><|endoftext|>


<commit_before>const { getBabelLoader } = require('./webpack.helpers');

// Karma configuration
module.exports = (config) => {
  config.set({
    basePath: __dirname,
    frameworks: ['mocha', 'sinon-chai'],
    files: [
      'source/**/*.spec.js',
    ],
    exclude: [],

    preprocessors: {
      'source/**/*.js': ['webpack', 'sourcemap'],
    },
    reporters: ['coverage', 'progress', 'coveralls'],
    coverageReporter: {
      type: 'lcov',
      dir: 'coverage/'
    },
    webpack: {
      resolve: {
        extensions: ['.js']
      },
      module: {
        rules: [
          {
            test: /\.js$/,
            use: getBabelLoader(['babel-plugin-istanbul']),
          },
        ]
      },
      devtool: 'inline-source-map',
    },
    webpackMiddleware: {
      noInfo: true,
      stats: {
        chunks: false,
        colors: true
      },
      stats: 'errors-only'
    },
    plugins: [
      require('karma-webpack'),
      require('karma-coverage'),
      require('karma-coveralls'),
      require('karma-firefox-launcher'),
      require('karma-sourcemap-loader'),
      require('karma-mocha'),
      require('karma-sinon-chai'),
    ],
    port: 9876,
    colors: true,
    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,
    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,
    browsers: ['Firefox'],
    //browsers: ['Chrome', 'IE', 'Firefox'],
    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: true
  });
};
<commit_msg>exclude *.spec.js files from coverage reports<commit_after>const { getBabelLoader } = require('./webpack.helpers');

// Karma configuration
module.exports = (config) => {
  config.set({
    basePath: __dirname,
    frameworks: ['mocha', 'sinon-chai'],
    files: [
      'source/**/*.spec.js',
    ],
    exclude: [],

    preprocessors: {
      'source/**/*.js': ['webpack', 'sourcemap'],
    },
    reporters: ['coverage', 'progress', 'coveralls'],
    coverageReporter: {
      type: 'lcov',
      dir: 'coverage/'
    },
    webpack: {
      resolve: {
        extensions: ['.js']
      },
      module: {
        rules: [
          {
            test: /\.spec\.js$/,
            use: getBabelLoader(),
          },
          {
            test: /\.js$/,
            exclude: /\.spec\.js$/,
            use: getBabelLoader(['babel-plugin-istanbul']),
          },
        ],
      },
      devtool: 'inline-source-map',
    },
    webpackMiddleware: {
      noInfo: true,
      stats: {
        chunks: false,
        colors: true
      },
      stats: 'errors-only'
    },
    plugins: [
      require('karma-webpack'),
      require('karma-coverage'),
      require('karma-coveralls'),
      require('karma-firefox-launcher'),
      require('karma-sourcemap-loader'),
      require('karma-mocha'),
      require('karma-sinon-chai'),
    ],
    port: 9876,
    colors: true,
    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,
    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,
    browsers: ['Firefox'],
    //browsers: ['Chrome', 'IE', 'Firefox'],
    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: true
  });
};
<|endoftext|>


<commit_before>// Karma configuration
// Generated on Wed May 27 2015 21:40:46 GMT+0200 (CEST)

module.exports = function (config) {

    config.set({

        // base path that will be used to resolve all patterns (eg. files, exclude)
        basePath: '',

        // frameworks to use
        // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
        frameworks: ['mocha'],

        // list of files / patterns to load in the browser
        files: [
            './test/build/**/test-*.js'
        ],

        // list of files to exclude
        exclude: [],

        // preprocess matching files before serving them to the browser
        // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
        preprocessors: {},

        // test results reporter to use
        // possible values: 'dots', 'progress'
        // available reporters: https://npmjs.org/browse/keyword/karma-reporter
        reporters: ['progress', 'coverage'],

        // web server port
        port: 9876,

        // enable / disable colors in the output (reporters and logs)
        colors: true,

        // level of logging
        // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
        logLevel: config.LOG_INFO,

        // start these browsers
        // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
        browsers: ['PhantomJS'],

        // Sauce Labs configuration
        sauceLabs: {
            testName: 'dolphin-platform-angularjs Unit Tests',
            tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER,
            recordScreenshots: true,
            recordVideo: false
            // startConnect: false
        },
        captureTimeout: 120000,
        browserDisconnectTimeout: 10 * 1000,
        browserDisconnectTolerance: 3,
        browserNoActivityTimeout: 30 * 1000,

        // Coverage configuration
        coverageReporter: {
            subdir: '.'
        }
    });
};
<commit_msg>Saucelabs<commit_after>// Karma configuration
// Generated on Wed May 27 2015 21:40:46 GMT+0200 (CEST)

module.exports = function (config) {

    config.set({

        // base path that will be used to resolve all patterns (eg. files, exclude)
        basePath: '',

        // frameworks to use
        // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
        frameworks: ['mocha'],

        // list of files / patterns to load in the browser
        files: [
            './test/build/**/test-*.js'
        ],

        // list of files to exclude
        exclude: [],

        client: {
            mocha: {
                timeout: 20000 // 20 seconds
            }
        },
        // preprocess matching files before serving them to the browser
        // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
        preprocessors: {},

        // test results reporter to use
        // possible values: 'dots', 'progress'
        // available reporters: https://npmjs.org/browse/keyword/karma-reporter
        reporters: ['progress', 'coverage'],

        // web server port
        port: 9876,

        // enable / disable colors in the output (reporters and logs)
        colors: true,

        // level of logging
        // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
        logLevel: config.LOG_INFO,

        // start these browsers
        // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
        browsers: ['PhantomJS'],

        // Sauce Labs configuration
        sauceLabs: {
            testName: 'dolphin-platform-angularjs Unit Tests',
            tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER,
            recordScreenshots: true,
            recordVideo: false,
            startConnect: false
        },
        captureTimeout: 5 * 60 * 1000,
        browserDisconnectTimeout: 20 * 1000,
        browserDisconnectTolerance: 3,
        browserNoActivityTimeout: 5 * 60 * 1000,

        // Coverage configuration
        coverageReporter: {
            subdir: '.'
        }
    });
};
<|endoftext|>


<commit_before>// Karma configuration
module.exports = function(config) {
	config.set({

		// base path that will be used to resolve all patterns (eg. files, exclude)
		basePath: '',

		// frameworks to use
		// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
		frameworks: ['jasmine', 'commonjs'],

		// list of files / patterns to load in the browser
		files: [
			{pattern: 'node_modules/jquery/dist/jquery.js', included: true},
			{pattern: 'lib/**/*.js', included: true},
			{pattern: 'test/**/*spec.js', included: true}
		],

		// list of files to exclude
		exclude: [],

		// preprocess matching files before serving them to the browser
		// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
		preprocessors: {
			'jquery': ['commonjs'],
			'lib/**/*.js': ['commonjs'],
			'test/**/*spec.js': ['commonjs'],
//			'lib/utils/**/*.js': ['coverage'],
		},
		commonjsPreprocessor: {
			modulesRoot: 'test'
		},

		// test results reporter to use
		// possible values: 'dots', 'progress'
		// available reporters: https://npmjs.org/browse/keyword/karma-reporter
		reporters: [
			'dots',
//			'progress',
//			'coverage'
		],

		// web server port
		port: 9876,

		// enable / disable colors in the output (reporters and logs)
		colors: true,

		// level of logging
		// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
		logLevel: config.LOG_INFO,

		// enable / disable watching file and executing tests whenever any file changes
		autoWatch: true,

		// start these browsers
		// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
		//npm install karma-firefox-launcher karma-safari-launcher karma-edge-launcher karma-ie-launcher
		browsers: [
			'Chrome',
//			'Firefox',
//			'Safari',
//			'Edge',
//			'IE',
		],

		// Continuous Integration mode
		// if true, Karma captures browsers, runs the tests and exits
		singleRun: false,

		// Concurrency level
		// how many browser should be started simultaneous
		concurrency: Infinity
	})
};
<commit_msg>Change karma port: conflict with idea<commit_after>// Karma configuration
module.exports = function(config) {
	config.set({

		// base path that will be used to resolve all patterns (eg. files, exclude)
		basePath: '',

		// frameworks to use
		// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
		frameworks: ['jasmine', 'commonjs'],

		// list of files / patterns to load in the browser
		files: [
			{pattern: 'node_modules/jquery/dist/jquery.js', included: true},
			{pattern: 'lib/**/*.js', included: true},
			{pattern: 'test/**/*spec.js', included: true}
		],

		// list of files to exclude
		exclude: [],

		// preprocess matching files before serving them to the browser
		// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
		preprocessors: {
			'jquery': ['commonjs'],
			'lib/**/*.js': ['commonjs'],
			'test/**/*spec.js': ['commonjs'],
//			'lib/utils/**/*.js': ['coverage'],
		},
		commonjsPreprocessor: {
			modulesRoot: 'test'
		},

		// test results reporter to use
		// possible values: 'dots', 'progress'
		// available reporters: https://npmjs.org/browse/keyword/karma-reporter
		reporters: [
			'dots',
//			'progress',
//			'coverage'
		],

		// web server port
		port: 9877,

		// enable / disable colors in the output (reporters and logs)
		colors: true,

		// level of logging
		// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
		logLevel: config.LOG_INFO,

		// enable / disable watching file and executing tests whenever any file changes
		autoWatch: true,

		// start these browsers
		// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
		//npm install karma-firefox-launcher karma-safari-launcher karma-edge-launcher karma-ie-launcher
		browsers: [
			'Chrome',
//			'Firefox',
//			'Safari',
//			'Edge',
//			'IE',
		],

		// Continuous Integration mode
		// if true, Karma captures browsers, runs the tests and exits
		singleRun: false,

		// Concurrency level
		// how many browser should be started simultaneous
		concurrency: Infinity
	})
};
<|endoftext|>


<commit_before>// the 'require' parameter is in the context of front-cli, not the application
module.exports = function(require) {
	var path = require('path');
	var HtmlWebpackPlugin = require('html-webpack-plugin');

	return {
		entry: [
			path.resolve(__dirname, '../application/main.js')
		],

		output: {
			path: path.resolve(__dirname, '../dist'),
			filename: 'application-[hash].js'
		},

		module: {
			loaders: [
				{
					test: /\.vue$/i,
					loader: 'vue-loader',
					exclude: /node_modules/
				},
				{
					test: /\.js$/i,
					loader: 'babel-loader',
					exclude: /node_modules/
				},
				{
					test: /\.css$/i,
					loaders: ['style-loader', 'css-loader']
				},
				{
					test: /\.(eot|woff2?|ttf|svg|png|jpg|gif|bmp)(\?.*)*$/i,
					loader: 'file-loader',
					query: {
						name: 'assets/img/[name].[ext]'
					}
				},
				{
					test: /\.json$/i,
					loader: 'json-loader',
					exclude: /node_modules/
				}
			]
		},

		babel: {
			presets: [require.resolve('babel-preset-es2015')],
			plugins: [require.resolve('babel-plugin-transform-runtime')],
			compact: true
		},

		resolve: {
			root: [
				path.resolve(__dirname, '../'),
				path.resolve(__dirname, '../application'),
				path.resolve(__dirname, '../node_modules')
			],
			extensions: ['', '.js', '.vue']
		},

		plugins: [
			new HtmlWebpackPlugin({
				filename: 'index.html',
				template: 'index.html',
				favicon: 'favicon.ico'
			})
		],

		devtool: 'cheap-module-eval-source-map',

		devServer: {
			hot: true,
			quiet: true,
			clientLogLevel: 'error'
		}
	};
};<commit_msg>provide custom proxy configuration.<commit_after>// the 'require' parameter is in the context of front-cli, not the application
module.exports = function(require) {
	var path = require('path');
	var HtmlWebpackPlugin = require('html-webpack-plugin');

	return {
		entry: [
			path.resolve(__dirname, '../application/main.js')
		],

		output: {
			path: path.resolve(__dirname, '../dist'),
			filename: 'application-[hash].js'
		},

		module: {
			loaders: [
				{
					test: /\.vue$/i,
					loader: 'vue-loader',
					exclude: /node_modules/
				},
				{
					test: /\.js$/i,
					loader: 'babel-loader',
					exclude: /node_modules/
				},
				{
					test: /\.css$/i,
					loaders: ['style-loader', 'css-loader']
				},
				{
					test: /\.(eot|woff2?|ttf|svg|png|jpg|gif|bmp)(\?.*)*$/i,
					loader: 'file-loader',
					query: {
						name: 'assets/img/[name].[ext]'
					}
				},
				{
					test: /\.json$/i,
					loader: 'json-loader',
					exclude: /node_modules/
				}
			]
		},

		babel: {
			presets: [require.resolve('babel-preset-es2015')],
			plugins: [require.resolve('babel-plugin-transform-runtime')],
			compact: true
		},

		resolve: {
			root: [
				path.resolve(__dirname, '../'),
				path.resolve(__dirname, '../application'),
				path.resolve(__dirname, '../node_modules')
			],
			extensions: ['', '.js', '.vue']
		},

		plugins: [
			new HtmlWebpackPlugin({
				filename: 'index.html',
				template: 'index.html',
				favicon: 'favicon.ico'
			})
		],

		devtool: 'cheap-module-eval-source-map',

		devServer: {
			hot: true,
			quiet: true,
			clientLogLevel: 'error',

			// uncomment the following lines to enable proxy

			// proxy: {
			// 	'/api': {
			// 		target: 'http://PROXY_URL',
			// 		changeOrigin: true,
			// 		pathRewrite: {'^/api' : ''},
			// 		logLevel: 'error'
			// 	}
			// }
		}
	};
};<|endoftext|>


<commit_before>const webpackConfig = require('./webpack.config')

// eslint-disable-next-line no-process-env
process.env.BABEL_ENV = 'test' // so we load the correct babel plugins
const testGlob = '**/*-spec.js'

module.exports = function setKarmaConfig(config) {
  config.set({
    autoWatch: false,
    basePath: 'client',
    browsers: ['Chrome'],
    colors: true,
    concurrency: Infinity,
    coverageReporter: {
      reporters: [
        { type: 'lcov', dir: '../coverage/', subdir: '.' },
        { type: 'json', dir: '../coverage/', subdir: '.' },
        { type: 'text-summary' }
      ]
    },
    files: [{
      pattern: testGlob,
      watched: false,
      served: true,
      included: true
    }, testGlob],
    frameworks: ['mocha', 'chai-as-promised', 'chai'],
    logLevel: config.LOG_INFO,
    port: 9876,
    preprocessors: {
      [testGlob]: ['webpack']
    },
    reporters: ['mocha', 'coverage'],
    singleRun: true,
    webpack: webpackConfig,
    webpackMiddleware: { noInfo: true }
  })
}
<commit_msg>Remove duplicate testGlob entry<commit_after>const webpackConfig = require('./webpack.config')

// eslint-disable-next-line no-process-env
process.env.BABEL_ENV = 'test' // so we load the correct babel plugins
const testGlob = '**/*-spec.js'

module.exports = function setKarmaConfig(config) {
  config.set({
    autoWatch: false,
    basePath: 'client',
    browsers: ['Chrome'],
    colors: true,
    concurrency: Infinity,
    coverageReporter: {
      reporters: [
        { type: 'lcov', dir: '../coverage/', subdir: '.' },
        { type: 'json', dir: '../coverage/', subdir: '.' },
        { type: 'text-summary' }
      ]
    },
    files: [{
      pattern: testGlob,
      watched: false,
      served: true,
      included: true
    }],
    frameworks: ['mocha', 'chai-as-promised', 'chai'],
    logLevel: config.LOG_INFO,
    port: 9876,
    preprocessors: {
      [testGlob]: ['webpack']
    },
    reporters: ['mocha', 'coverage'],
    singleRun: true,
    webpack: webpackConfig,
    webpackMiddleware: { noInfo: true }
  })
}
<|endoftext|>


<commit_before>// Karma configuration
// Generated on Thu Dec 25 2014 00:07:22 GMT+0300 (MSK)

module.exports = function(config) {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',

    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['jasmine'],

    // list of files / patterns to load in the browser
    files: [
      'test/**/*Spec.js.coffee'
    ],

    // list of files to exclude
    exclude: [
    ],

    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
      '**/*.coffee': ['coffee']
    },

    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['progress'],

    // web server port
    port: 9876,

    // enable / disable colors in the output (reporters and logs)
    colors: true,

    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,

    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,

    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['Chrome', 'Firefox', 'Safari'],

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false
  });
};
<commit_msg>karma.conf.js updated<commit_after>// Karma configuration
// Generated on Thu Dec 25 2014 00:07:22 GMT+0300 (MSK)

module.exports = function(config) {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',

    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['jasmine'],

    // list of files / patterns to load in the browser
    files: [
      'test/**/*Spec.js.coffee'
    ],

    // list of files to exclude
    exclude: [
    ],

    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
      '**/*.coffee': ['coffee']
    },

    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['progress'],

    // web server port
    port: 9876,

    // enable / disable colors in the output (reporters and logs)
    colors: true,

    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,

    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,

    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['Chrome'],

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false
  });
};
<|endoftext|>


<commit_before>// Karma configuration
// http://karma-runner.github.io/0.10/config/configuration-file.html

module.exports = function(config) {
  config.set({
    // base path, that will be used to resolve files and exclude
    basePath: '',

    // testing framework to use (jasmine/mocha/qunit/...)
    frameworks: ['jasmine'],

    // list of files / patterns to load in the browser
    files: [
      'app/bower_components/angular/angular.js',
      'app/bower_components/angular-mocks/angular-mocks.js',
      'app/bower_components/angular-resource/angular-resource.js',
      'app/bower_components/angular-cookies/angular-cookies.js',
      'app/bower_components/angular-sanitize/angular-sanitize.js',
      'app/bower_components/angular-route/angular-route.js',
      'app/bower_components/angular-touch/angular-touch.js',
      'app/scripts/*.js',
      'app/scripts/**/*.js',
      'test/mock/**/*.js',
      'test/spec/**/*.js'
    ],

    // list of files / patterns to exclude
    exclude: [],

    // web server port
    port: 8080,

    // level of logging
    // possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
    logLevel: config.LOG_INFO,

    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: false,

    // Start these browsers, currently available:
    // - Chrome
    // - ChromeCanary
    // - Firefox
    // - Opera
    // - Safari (only Mac)
    // - PhantomJS
    // - IE (only Windows)
    browsers: ['Chrome'],

    // Continuous Integration mode
    // if true, it capture browsers, run tests and exit
    singleRun: false
  });
};
<commit_msg>sorry for the travis spam<commit_after>// Karma configuration
// http://karma-runner.github.io/0.10/config/configuration-file.html

module.exports = function(config) {
  config.set({
    // base path, that will be used to resolve files and exclude
    basePath: '',

    // testing framework to use (jasmine/mocha/qunit/...)
    frameworks: ['jasmine'],

    // list of files / patterns to load in the browser
    files: [
      'app/bower_components/angular/angular.js',
      'app/bower_components/angular-mocks/angular-mocks.js',
      'app/bower_components/angular-resource/angular-resource.js',
      'app/bower_components/angular-cookies/angular-cookies.js',
      'app/bower_components/angular-sanitize/angular-sanitize.js',
      'app/bower_components/angular-route/angular-route.js',
      'app/bower_components/angular-touch/angular-touch.js',
      'app/scripts/*.js',
      'app/scripts/**/*.js',
      'test/mock/**/*.js',
      'test/spec/**/*.js'
    ],

    // list of files / patterns to exclude
    exclude: [],

    // web server port
    port: 8080,

    // level of logging
    // possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
    logLevel: config.LOG_INFO,

    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: false,

    // Start these browsers, currently available:
    // - Chrome
    // - ChromeCanary
    // - Firefox
    // - Opera
    // - Safari (only Mac)
    // - PhantomJS
    // - IE (only Windows)
    browsers: ['PhantomJS'],

    // Continuous Integration mode
    // if true, it capture browsers, run tests and exit
    singleRun: false
  });
};
<|endoftext|>


<commit_before>// @AngularClass
// Look in config for karma.conf.js
module.exports = require('./config/karma.conf.js');
<commit_msg>Try to use simple-ssh to initiallize<commit_after>// @AngularClass
// Look in config for karma.conf.js
module.exports = require('./config/karma.conf.js');
<|endoftext|>