<commit_before>// ==UserScript==
// @name        Alt+Num Extended Char Entry
// @namespace   https://stackapps.org/
// @description hold Alt while pressing numbers to make extended characters
// @match       *://*/*
// @version     1.2.2
// @grant       none
// @downloadURL https://github.com/calraith/gm_scripts/raw/master/Alt+Num_Extended_Char_Entry.user.js
// @run-at      document-end
// ==/UserScript==

if (self != top) return; // only run in parent window

var codepage = 0; // Leave 0 to attempt autodetect, or specify with "var codepage = 437" or similar.

// If you're curious about the source of this list, I used a PowerShell command similar
// to the following: (new-object System.Globalization.CultureInfo($locale)).TextInfo.OEMCodePage
// with language tags from the MS-LCID reference at https://msdn.microsoft.com/en-us/library/cc233965.aspx
if (!codepage) codepage = {'ar':720,'bg':866,'ca':850,'zh-hans':936,'cs':852,'da':850,'de':850,'el':737,'en':437,
	'es':850,'fi':850,'fr':850,'he':862,'hu':852,'is':850,'it':850,'ja':932,'ko':949,'nl':850,'no':850,'pl':852,
	'pt':850,'ro':852,'ru':866,'sk':852,'sq':852,'sv':850,'th':874,'tr':857,'ur':720,'id':850,'uk':866,'be':866,
	'sl':852,'et':775,'lv':775,'lt':775,'fa':720,'vi':1258,'hy':1,'az':857,'eu':850,'mk':866,'af':850,'ka':1,
	'fo':850,'hi':1,'ms':850,'kk':866,'ky':866,'sw':437,'uz':857,'tt':866,'pa':1,'gu':1,'ta':1,'te':1,'kn':1,
	'mr':1,'sa':1,'mn':866,'gl':850,'kok':1,'syr':1,'dv':1,'ar-sa':720,'bg-bg':866,'ca-es':850,'zh-tw':950,
	'cs-cz':852,'da-dk':850,'de-de':850,'el-gr':737,'en-us':437,'es-es_tradnl':850,'fi-fi':850,'fr-fr':850,
	'he-il':862,'hu-hu':852,'is-is':850,'it-it':850,'ja-jp':932,'ko-kr':949,'nl-nl':850,'nb-no':850,'pl-pl':852,
	'pt-br':850,'rm-ch':850,'ro-ro':852,'ru-ru':866,'hr-hr':852,'sk-sk':852,'sq-al':852,'sv-se':850,'th-th':874,
	'tr-tr':857,'ur-pk':720,'id-id':850,'uk-ua':866,'be-by':866,'sl-si':852,'et-ee':775,'lv-lv':775,'lt-lt':775,
	'tg-cyrl-tj':866,'fa-ir':720,'vi-vn':1258,'hy-am':1,'az-latn-az':857,'eu-es':850,'hsb-de':850,'mk-mk':866,
	'tn-za':850,'xh-za':850,'zu-za':850,'af-za':850,'ka-ge':1,'fo-fo':850,'hi-in':1,'mt-mt':1,'se-no':850,
	'ms-my':850,'kk-kz':866,'ky-kg':866,'sw-ke':437,'tk-tm':852,'uz-latn-uz':857,'tt-ru':866,'bn-in':1,'pa-in':1,
	'gu-in':1,'or-in':1,'ta-in':1,'te-in':1,'kn-in':1,'ml-in':1,'as-in':1,'mr-in':1,'sa-in':1,'mn-mn':866,
	'bo-cn':1,'cy-gb':850,'km-kh':1,'lo-la':1,'gl-es':850,'kok-in':1,'syr-sy':1,'si-lk':1,'iu-cans-ca':1,
	'am-et':1,'ne-np':1,'fy-nl':850,'ps-af':1,'fil-ph':437,'dv-mv':1,'ha-latn-ng':437,'yo-ng':437,'quz-bo':850,
	'nso-za':850,'ba-ru':866,'lb-lu':850,'kl-gl':850,'ig-ng':437,'ii-cn':1,'arn-cl':850,'moh-ca':850,'br-fr':850,
	'ug-cn':720,'mi-nz':1,'oc-fr':850,'co-fr':850,'gsw-fr':850,'sah-ru':866,'qut-gt':850,'rw-rw':437,'wo-sn':850,
	'prs-af':720,'gd-gb':850,'ar-iq':720,'zh-cn':936,'de-ch':850,'en-gb':850,'es-mx':850,'fr-be':850,'it-ch':850,
	'nl-be':850,'nn-no':850,'pt-pt':850,'sr-latn-cs':852,'sv-fi':850,'az-cyrl-az':866,'dsb-de':850,'se-se':850,
	'ga-ie':850,'ms-bn':850,'uz-cyrl-uz':866,'bn-bd':1,'mn-mong-cn':1,'iu-latn-ca':437,'tzm-latn-dz':850,
	'quz-ec':850,'ar-eg':720,'zh-hk':950,'de-at':850,'en-au':850,'es-es':850,'fr-ca':850,'sr-cyrl-cs':855,
	'se-fi':850,'quz-pe':850,'ar-ly':720,'zh-sg':936,'de-lu':850,'en-ca':850,'es-gt':850,'fr-ch':850,'hr-ba':852,
	'smj-no':850,'ar-dz':720,'zh-mo':950,'de-li':850,'en-nz':850,'es-cr':850,'fr-lu':850,'bs-latn-ba':852,
	'smj-se':850,'ar-ma':720,'en-ie':850,'es-pa':850,'fr-mc':850,'sr-latn-ba':852,'sma-no':850,'ar-tn':720,
	'en-za':437,'es-do':850,'sr-cyrl-ba':855,'sma-se':850,'ar-om':720,'en-jm':850,'es-ve':850,'bs-cyrl-ba':855,
	'sms-fi':850,'ar-ye':720,'en-029':850,'es-co':850,'sr-latn-rs':852,'smn-fi':850,'ar-sy':720,'en-bz':850,
	'es-pe':850,'sr-cyrl-rs':855,'ar-jo':720,'en-tt':850,'es-ar':850,'sr-latn-me':852,'ar-lb':720,'en-zw':437,
	'es-ec':850,'sr-cyrl-me':855,'ar-kw':720,'en-ph':437,'es-cl':850,'ar-ae':720,'es-uy':850,'ar-bh':720,
	'es-py':850,'ar-qa':720,'en-in':437,'es-bo':850,'en-my':437,'es-sv':850,'en-sg':437,'es-hn':850,'es-ni':850,
	'es-pr':850,'es-us':850,'zh-hant':950,'sr':855}[navigator.language.toLowerCase()] || 437; // (default en-US)

// holds a list of number keys pressed while alt is held down
var combo = [],
	clicked; // Chrome failsafe

addEventListener('keyup', safeSimulateNumPad);
addEventListener('load', iFramesToo);

function iFramesToo() {
	var iframes = document.getElementsByTagName('iframe');
	for (var i=iframes.length; i--;) {
		// try-catch block to avoid cross domain errors halting execution
		try {
			if (iframes[i].contentWindow) {
				iframes[i].contentWindow.addEventListener('keyup', safeSimulateNumPad);
				// Chrome failsafe
				iframes[i].contentWindow.addEventListener('click', function(e) { clicked = e.target; });
			}
		}
		catch (err) {}
	}
}

// import codepage abstractions
// Credit: https://github.com/SheetJS/js-codepage
function init(obj) {
	if (obj.idx >= obj.src.length) return;
	try {
		var src = obj.src[obj.idx++],
			script = document.createElement('script');

		script.contentType = 'application/javascript;charset=utf-8';
		script.onload = function(){ init(obj); };
		script.src = 'https://cdn.rawgit.com/SheetJS/js-codepage/14644b57/' + src;

		document.getElementsByTagName('HEAD')[0].appendChild(script);
		console.log('Alt+Num_Extended_Char_Entry: ' + src + ' ready');
	}
	catch(err) {
		console.log(err.message);
		console.log('Codepage translations unavailable.  Only Unicode key combos will work.');
	}
}
init({src: ["cptable.js","cputils.js"], idx: 0});

function safeSimulateNumPad(e) {
	try { simulateNumPad(e); }
	catch(err) { console.log(err.message); }
}

function simulateNumPad(e) {

	var el = getActiveElement() || clicked,
		start = el.selectionStart,
		end = el.selectionEnd,
		symbol;

	if (!el) console.log('unable to determine focus');

	// Chrome doesn't reliably bubble up the .isContentEditable property
	if (!/chrome/i.test(navigator.userAgent) && !/textarea|input/i.test(el.nodeName) &&
		!el.isContentEditable) return;

	if (e.altKey) {

		// if alt key is pressed, prevent browser menubar from appearing
		e.preventDefault();

		// keyCode 48 = 0, 49 = 1, 50 = 2, etc.
		if (e.keyCode >= 48 && e.keyCode <= 57) combo.push(e.keyCode - 48);

	} else if (combo.length) {

		// if key combo doesn't start with a zero, retrieve codepage table glyph
		// alt+0176 = °, whereas alt+234 = Ω (for codepage 437)
		symbol = (combo[0] && (combo.join('') * 1 <= 255)) ?
			cptable[codepage].dec[combo.join('')] : String.fromCharCode(combo.join(''));

		console.log('symbol: ' + symbol);

		// purge key sequence
		combo = [];

		// insert symbol at current caret pos and advance caret
		if (el.setSelectionRange) {

			// textarea or input
			el.value = el.value.substring(0, start) + symbol + el.value.substring(end);
			el.setSelectionRange(++start, start);

		} else {

			// contentEditable node
			var sel = el.ownerDocument.defaultView.getSelection(),
				range;

			// hack for Chrome
			if (!sel.rangeCount)
				sel = clicked.ownerDocument.defaultView.getSelection();

			range = sel.getRangeAt(0);
			range.deleteContents();
			range.insertNode(document.createTextNode(symbol));
			sel.collapseToEnd();
		}
	}
}

// credit: https://stackoverflow.com/a/25420726/1683264
function getActiveElement(document) {

	document = document || window.document;
	var el = document.activeElement;

	// if target is an iframe or is the document body with no slection
	// (defaultView seems to be required for Chrome.)
	if (el.tagName == 'IFRAME' ||
		(el === document.body && !el.ownerDocument.defaultView.getSelection())) {

		// enumerate all iframes and test recursively
		var iframes = document.getElementsByTagName('iframe');
		for (var i = iframes.length; i--;) {

			// try-catch to avoid cross domain errors halting execution
			try {
				if (iframes[i].contentDocument)
					var focused = getActiveElement(iframes[i].contentDocument);

				if (focused) return focused;
			}
			catch (err) {}
		}
	}
	else return el;

	return false;
};
<commit_msg>version 1.2.3<commit_after>// ==UserScript==
// @name        Alt+Num Extended Char Entry
// @namespace   https://stackapps.org/
// @description hold Alt while pressing numbers to make extended characters
// @match       *://*/*
// @version     1.2.3
// @grant       none
// @downloadURL https://github.com/calraith/gm_scripts/raw/master/Alt+Num_Extended_Char_Entry.user.js
// @run-at      document-end
// ==/UserScript==

if (self != top) return; // only run in parent window

var codepage = 0; // Leave 0 to attempt autodetect, or specify with "var codepage = 437" or similar.

// If you're curious about the source of this list, I used a PowerShell command similar
// to the following: (new-object System.Globalization.CultureInfo($locale)).TextInfo.OEMCodePage
// with language tags from the MS-LCID reference at https://msdn.microsoft.com/en-us/library/cc233965.aspx
var OEMCodePages = {'437':['ha-latn-gh','ha-latn-ne','ngo','ngo-gn','swc','swc-cd','sw-tz','sw-ug','yo-bj','yue',
	'yue-hk','en','sw','iu','fil','ha','yo','ig','haw','rw','en-us','sw-ke','fil-ph','ha-latn-ng','yo-ng','ig-ng',
	'haw-us','rw-rw','iu-latn-ca','en-za','en-zw','en-ph','en-in','en-my','en-sg','iu-latn','ha-latn'],'720':[
	'ar-001','ar-dj','ar-er','ar-il','ar-km','ar-mr','ar-ps','ar-sd','ar-so','ar-ss','ar-td','fa-af','ar','ur',
	'fa','sd','ug','prs','ku','ar-sa','ur-pk','fa-ir','ug-cn','prs-af','ku-arab-iq','ar-iq','ur-in','pa-arab-pk',
	'sd-arab-pk','qps-plocm','ar-eg','ar-ly','ar-dz','ar-ma','ar-tn','ar-om','ar-ye','ar-sy','ar-jo','ar-lb',
	'ar-kw','ar-ae','ar-bh','ar-qa','pa-arab','sd-arab','ku-arab'],'737':['el-cy','el','el-gr'],'775':['et','lv',
	'lt','et-ee','lv-lv','lt-lt'],'852':['sq-mk','cs','hu','pl','ro','sk','sq','sl','tk','cs-cz','hu-hu','pl-pl',
	'ro-ro','hr-hr','sk-sk','sq-al','sl-si','tk-tm','qps-ploc','ro-md','sr-latn-cs','hr-ba','bs-latn-ba',
	'sr-latn-ba','sr-latn-rs','sr-latn-me','bs-latn','sr-latn','bs','sr'],'855':['sr-cyrl-cs','sr-cyrl-ba',
	'bs-cyrl-ba','sr-cyrl-rs','sr-cyrl-me','bs-cyrl','sr-cyrl'],'857':['tr-cy','tr','az','uz','tr-tr',
	'az-latn-az','uz-latn-uz','az-latn','uz-latn'],'862':['he','he-il'],'866':['ru-by','ru-kg','ru-kz','ru-ua',
	'bg','ru','uk','be','tg','mk','ky','tt','mn','ba','sah','bg-bg','ru-ru','uk-ua','be-by','tg-cyrl-tj','mk-mk',
	'ky-kg','tt-ru','mn-mn','ba-ru','sah-ru','ru-md','az-cyrl-az','uz-cyrl-uz','az-cyrl','uz-cyrl','mn-cyrl',
	'tg-cyrl'],'874':['th','th-th'],'932':['ja','ja-jp','qps-ploca'],'936':['zh-hans','zh-cn','zh-sg','zh'],
	'949':['ko','ko-kr'],'950':['zh-tw','zh-hk','zh-mo','zh-hant'],'1258':['vi','vi-vn']};

var MacCodePages = {'10001':['ja','ja-jp','qps-ploca'],'10081':['tr','az','tr-tr','az-latn-az','az-latn','tr-cy'],
	'10008':['zh-hans','zh-cn','zh-sg','zh'],'10006':['el','el-gr','el-cy'],'10079':['is','fo','is-is','fo-fo'],
	'10007':['bg','ru','be','tg','mk','ky','tt','mn','ba','sah','bg-bg','ru-ru','be-by','tg-cyrl-tj','mk-mk',
	'ky-kg','tt-ru','mn-mn','ba-ru','sah-ru','az-cyrl-az','uz-cyrl-uz','sr-cyrl-cs','sr-cyrl-ba','sr-cyrl-rs',
	'sr-cyrl-me','sr-cyrl','az-cyrl','uz-cyrl','mn-cyrl','tg-cyrl'],'10004':['ar','ur','fa','sd','ug','prs','ku',
	'ar-sa','ur-pk','fa-ir','ug-cn','prs-af','ku-arab-iq','ar-iq','pa-arab-pk','sd-arab-pk','qps-plocm','ar-eg',
	'ar-ly','ar-dz','ar-ma','ar-tn','ar-om','ar-ye','ar-sy','ar-jo','ar-lb','ar-kw','ar-ae','ar-bh','ar-qa',
	'pa-arab','sd-arab','ku-arab','ar-001','ar-dj','ar-er','ar-il','ar-km','ar-mr','ar-ps','ar-sd','ar-so',
	'ar-ss','ar-td','fa-af'],'10003':['ko','ko-kr'],'10005':['he','he-il'],'10029':['cs','hu','pl','ro','sk','sq',
	'sl','et','lv','lt','tk','uz','cs-cz','hu-hu','pl-pl','ro-ro','sk-sk','sq-al','sl-si','et-ee','lv-lv','lt-lt',
	'tk-tm','uz-latn-uz','qps-ploc','sr-latn-cs','sr-latn-rs','sr-latn-me','sr-latn','sr','uz-latn','sq-mk'],
	'10002':['zh-tw','zh-hk','zh-mo','zh-hant'],'10021':['th','th-th'],'10082':['hr-hr','hr-ba','bs-latn-ba',
	'sr-latn-ba','bs-cyrl-ba','bs-cyrl','bs-latn','bs'],'10017':['uk','uk-ua']};

// default codepage to that which contains the greatest number of locales per platform to reduce table sizes
var cp = /mac/i.test(navigator.platform) ? { t: MacCodePages, d: 10000 } : { t: OEMCodePages, d: 850 };

if (!codepage) codepage = Object.keys(cp.t).filter(function(key) {
	return cp.t[key].indexOf(navigator.language.toLowerCase()) > -1;
}) * 1 || cp.d;

// holds a list of number keys pressed while alt is held down
var combo = [],
	clicked; // Chrome failsafe

addEventListener('keyup', safeSimulateNumPad);
addEventListener('load', iFramesToo);

function iFramesToo() {
	var iframes = document.getElementsByTagName('iframe');
	for (var i=iframes.length; i--;) {
		// try-catch block to avoid cross domain errors halting execution
		try {
			if (iframes[i].contentWindow) {
				iframes[i].contentWindow.addEventListener('keyup', safeSimulateNumPad);
				// Chrome failsafe
				iframes[i].contentWindow.addEventListener('click', function(e) { clicked = e.target; });
			}
		}
		catch (err) {}
	}
}

// import codepage abstractions
// Credit: https://github.com/SheetJS/js-codepage
function init(obj) {
	if (obj.idx >= obj.src.length) return;
	try {
		var src = obj.src[obj.idx++],
			script = document.createElement('script');

		script.contentType = 'application/javascript;charset=utf-8';
		script.onload = function(){ init(obj); };
		script.src = 'https://cdn.rawgit.com/SheetJS/js-codepage/14644b57/' + src;

		document.getElementsByTagName('HEAD')[0].appendChild(script);
		console.log('Alt+Num_Extended_Char_Entry: ' + src + ' ready');
	}
	catch(err) {
		console.log(err.message);
		console.log('Codepage translations unavailable.  Only Unicode key combos will work.');
	}
}
init({src: ["cptable.js","cputils.js"], idx: 0});

function safeSimulateNumPad(e) {
	try { simulateNumPad(e); }
	catch(err) { console.log(err.message); }
}

function simulateNumPad(e) {

	var el = getActiveElement() || clicked,
		start = el.selectionStart,
		end = el.selectionEnd,
		symbol;

	if (!el) console.log('unable to determine focus');

	// Chrome doesn't reliably bubble up the .isContentEditable property
	if (!/chrome/i.test(navigator.userAgent) && !/textarea|input/i.test(el.nodeName) &&
		!el.isContentEditable) return;

	if (e.altKey) {

		// if alt key is pressed, prevent browser menubar from appearing
		e.preventDefault();

		// keyCode 48 = 0, 49 = 1, 50 = 2, etc.
		if (e.keyCode >= 48 && e.keyCode <= 57) combo.push(e.keyCode - 48);

	} else if (combo.length) {

		// if key combo doesn't start with a zero, retrieve codepage table glyph
		// alt+0176 = °, whereas alt+234 = Ω (for codepage 437)
		symbol = (combo[0] && (combo.join('') * 1 <= 255)) ?
			cptable[codepage].dec[combo.join('')] : String.fromCharCode(combo.join(''));

		console.log('symbol: ' + symbol);

		// purge key sequence
		combo = [];

		// insert symbol at current caret pos and advance caret
		if (el.setSelectionRange) {

			// textarea or input
			el.value = el.value.substring(0, start) + symbol + el.value.substring(end);
			el.setSelectionRange(++start, start);

		} else {

			// contentEditable node
			var sel = el.ownerDocument.defaultView.getSelection(),
				range;

			// hack for Chrome
			if (!sel.rangeCount)
				sel = clicked.ownerDocument.defaultView.getSelection();

			range = sel.getRangeAt(0);
			range.deleteContents();
			range.insertNode(document.createTextNode(symbol));
			sel.collapseToEnd();
		}
	}
}

// credit: https://stackoverflow.com/a/25420726/1683264
function getActiveElement(document) {

	document = document || window.document;
	var el = document.activeElement;

	// if target is an iframe or is the document body with no slection
	// (defaultView seems to be required for Chrome.)
	if (el.tagName == 'IFRAME' ||
		(el === document.body && !el.ownerDocument.defaultView.getSelection())) {

		// enumerate all iframes and test recursively
		var iframes = document.getElementsByTagName('iframe');
		for (var i = iframes.length; i--;) {

			// try-catch to avoid cross domain errors halting execution
			try {
				if (iframes[i].contentDocument)
					var focused = getActiveElement(iframes[i].contentDocument);

				if (focused) return focused;
			}
			catch (err) {}
		}
	}
	else return el;

	return false;
};
<|endoftext|>


<commit_before>function reset_map ()
{
	konsole.print("Person: let's reset and try again..")
	reset(murderer)
}
function wait_for_reset()
{
	konsole.over_ride_func = function ()
	{
		if(konsole.input_field.value.toLowerCase() == "reset")
		{

			konsole.out.innerHTML = ""
			konsole.input_field.value = ""
			extra_digit =  Math.floor((Math.random() * 98) + 1);

			reset(0)
		} else {
			konsole.print("Type reset.")
		}
}
}
function freeze()
{
	konsole.over_ride_func = function () {}
}
/*******************************************
  * DEATH: Jumped out of window.
  * This is an ending. This does NOT loop.
  *******************************************/
var time_reaction = []
// time, text, reaction, function, used
time_reaction[0] = [0, " ", "",freeze,false]
time_reaction[1] = [2, "", "Did you really think you could get away with that?",no_function,false]
time_reaction[2] = [4, "", "Your actions resulted in your character plummeting to his death. The game is over.  You are a monster.",no_function,false]
time_reaction[3] = [6, "Type reset to reset the game and restart..", "",wait_for_reset,false]
map.death_jump = {enter: "" , enter_again: "", description : ["You are dead",""], directions: [], objects : [] , image: "", cond: {dead: 1}, action_reaction : {},time_reaction: time_reaction}

for (var key in map) {
  	if (map.hasOwnProperty(key)) {
  		map[key].text = key
  	}
}

/*******************************************
  * DEATH: Killed, innocent
  * This loops back.
  *******************************************/
var time_reaction = []
// time, text, reaction, function, used
time_reaction[0] = [0, " ", "",freeze,false]
time_reaction[1] = [2, "", "I am put on a stretcher and moved somewhere. I can't make up where I'm going.",no_function,false]
time_reaction[2] = [4, "", "I see the lights on the ceiling flashing.",no_function,false]
time_reaction[3] = [6, "You start to lose consciousness.", "",reset_map,false]
map.death_killed_innocent = {enter: "" , enter_again: "" ,description : ["", ""], directions: [], objects : [] , image: "", cond: {dead: 1}, action_reaction : {},time_reaction: time_reaction}

for (var key in map) {
  	if (map.hasOwnProperty(key)) {
  		map[key].text = key
  	}
}

/*******************************************
  * DEATH: Killed, guilty
  *
  *******************************************/
var time_reaction = []
// time, text, reaction, function, used
time_reaction[0] = [0, " ", "",freeze,false]
time_reaction[1] = [2, "", "I am put on a stretcher and moved somewhere. I can't make up where I'm going.",no_function,false]
time_reaction[2] = [4, "", "I see the lights on the ceiling flashing.",no_function,false]
time_reaction[3] = [6, "You start to lose consciousness.", "",reset_map,false]
map.death_killed_guilty = {enter: "The ground is approaching you in an increasing pace." , enter_again: "This is really strange, why am I here again?", description : ["You are dead",""], directions: [], objects : [] , image: "", cond: {dead: 1}, action_reaction : {},time_reaction: time_reaction}

for (var key in map) {
  	if (map.hasOwnProperty(key)) {
  		map[key].text = key
  	}
}

/*******************************************
  * DEATH: Boom
  *
  *******************************************/
var time_reaction = []
// time, text, reaction, function, used
time_reaction[0] = [1, "A timer is counting down from 10.", "",freeze,false]
time_reaction[1] = [2, "9 -  I don't think this is going to end well ", "",no_function,false]
time_reaction[2] = [3, "8", "",no_function,false]
time_reaction[3] = [4, "7 -  I feel relieved, knowing that I managed to end the madness. ", "",no_function,false]
time_reaction[4] = [5, "6", "",no_function,false]
time_reaction[5] = [6, "5", "",no_function,false]
time_reaction[6] = [7, "4", "",no_function,false]
time_reaction[7] = [8, "3", "",no_function,false]
time_reaction[8] = [9, "2", "",no_function,false]
time_reaction[9] = [10, "1", "",no_function,false]
time_reaction[10] = [11, "The building exploded. You are dead.", "",no_function,false]
time_reaction[10] = [12, "
", "",no_function,false]

time_reaction[11] = [14, "", "You killed a lot of innocent people, along with some criminals. Does this make you a hero? I don't think so. Congratultions,  you are a monster .",wait_for_reset,false]
map.death_boom = {enter: "The ground is approaching you in an increasing pace." , enter_again: "This is really strange, why am I here again?", description : ["You are dead",""], directions: [], objects : [] , image: "", cond: {dead: 1}, action_reaction : {},time_reaction: time_reaction}

for (var key in map) {
  	if (map.hasOwnProperty(key)) {
  		map[key].text = key
  	}
}

/*******************************************
  * DEATH: escape_guilty
  *
  *******************************************/
var time_reaction = []
// time, text, reaction, function, used
time_reaction[0] = [2, "Your parachute opens", "",no_function,false]
time_reaction[1] = [4, "You go to the police. However, they have already been notified of the fact that you are a murderer.", "",no_function,false]
time_reaction[2] = [6, "You spend the rest of your life in jail. Congratulations, thanks to you your character spends the rest of his life in jail. You are a monster .", "",wait_for_reset,false]
map.death_escape_guilty = {enter: "The ground is approaching you in an increasing pace." , enter_again: "This is really strange, why am I here again?", description : ["You are dead",""], directions: [], objects : [] , image: "", cond: {dead: 1}, action_reaction : {},time_reaction: time_reaction}

for (var key in map) {
  	if (map.hasOwnProperty(key)) {
  		map[key].text = key
  	}
}

/*******************************************
  * DEATH: escape_innocent, default: no evidence
  *
  *******************************************/
var time_reaction = []
// time, text, reaction, function, used
time_reaction[0] = [2, "Your parachute opens", "",no_function,false]
time_reaction[1] = [4, "", "You go to the police.",switch_evidence,false]
map.death_escape_innocent = {enter: "The ground is approaching you in an increasing pace." , enter_again: "This is really strange, why am I here again?", description : ["You are dead",""], directions: [], objects : [] , image: "", cond: {dead: 1}, action_reaction : {},time_reaction: time_reaction}

function switch_evidence()
{
	var count = 0
  debugger;
   if(find_in_inventory(words.log))
   {
    count ++
   }
   if(find_in_inventory(words.document))
   {
    count ++
   }
   switch(count){
   case 0: change_map("escape_no_evidence")();break;
   case 1: change_map("escape_one_evidence")();break;
   case 2: default: change_map("escape_two_evidence")();
	}
}
/*******************************************
  * DEATH: escape_no_evidence
  *
  *******************************************/
var time_reaction = []
// time, text, reaction, function, used
time_reaction[0] = [2, "The police sees a distressed man. They received a phonecall from a mental hospital, with your description and the information that you are missing. They call the hospital.", "",no_function,false]
time_reaction[1] = [4, "", "Once you are back you are knocked unconscious.",reset_map,false]
map.escape_no_evidence = {enter: "The ground is approaching you in an increasing pace." , enter_again: "This is really strange, why am I here again?", description : ["You are dead",""], directions: [], objects : [] , image: "", cond: {dead: 1}, action_reaction : {},time_reaction: time_reaction}

/*******************************************
  * DEATH: escape_one_evidence
  *
  *******************************************/
var time_reaction = []
// time, text, reaction, function, used
time_reaction[0] = [2, "The police sees a distressed man. Despite the 'evidence' he hands over, they are not convinced. They received a phonecall from a mental hospital, with your description and the information that you are missing.", "",no_function,false]
time_reaction[1] = [4, "", "Once you are back in your room you are knocked unconscious.",reset_map,false]
map.escape_one_evidence = {enter: "The ground is approaching you in an increasing pace." , enter_again: "This is really strange, why am I here again?", description : ["You are dead",""], directions: [], objects : [] , image: "", cond: {dead: 1}, action_reaction : {},time_reaction: time_reaction}

/*******************************************
  * DEATH: escape_two_evidence
  *
  *******************************************/
var time_reaction = []
// time, text, reaction, function, used
time_reaction[0] = [2, "The police sees a distressed man, but once you hand over the evidence, they have no choice but to believe you.", "",no_function,false]
time_reaction[1] = [4, "The research laboratory is shut down. You are free.", " ",no_function,false]
time_reaction[2] = [6, "", "Congratulations:  You are not a monster ",no_function,false]
time_reaction[3] = [8, "", " ",no_function,false]
time_reaction[4] = [10, "", " ",no_function,false]
time_reaction[5] = [10, "", "Thank you for playing our game. We hope you enjoyed it.",no_function,false]
time_reaction[6] = [12, "", "~ Tim & Nander.",no_function,false]

map.escape_two_evidence = {enter: "The ground is approaching you in an increasing pace." , enter_again: "This is really strange, why am I here again?", description : ["You are dead",""], directions: [], objects : [] , image: "", cond: {dead: 1}, action_reaction : {},time_reaction: time_reaction}

for (var key in map) {
  	if (map.hasOwnProperty(key)) {
  		map[key].text = key
  	}
}<commit_msg>Ending changed drastically<commit_after>function reset_map ()
{
	konsole.print("Person: let's reset and try again..")
	reset(murderer)
}
function wait_for_reset()
{
	konsole.over_ride_func = function ()
	{
		if(konsole.input_field.value.toLowerCase() == "reset")
		{

			konsole.out.innerHTML = ""
			konsole.input_field.value = ""
			extra_digit =  Math.floor((Math.random() * 98) + 1);

			reset(0)
		} else {
			konsole.print("Type reset.")
		}
}
}
function freeze()
{
	konsole.over_ride_func = function () {}
}
/*******************************************
  * DEATH: Jumped out of window.
  * This is an ending. This does NOT loop.
  *******************************************/
var time_reaction = []
// time, text, reaction, function, used
time_reaction[0] = [0, " ", "",freeze,false]
time_reaction[1] = [2, "", "Did you really think you could get away with that?",no_function,false]
time_reaction[2] = [4, "", "Your actions resulted in your character plummeting to his death. The game is over.  You are a monster.",no_function,false]
time_reaction[3] = [6, "Type reset to reset the game and restart..", "",wait_for_reset,false]
map.death_jump = {enter: "" , enter_again: "", description : ["You are dead",""], directions: [], objects : [] , image: "", cond: {dead: 1}, action_reaction : {},time_reaction: time_reaction}

for (var key in map) {
  	if (map.hasOwnProperty(key)) {
  		map[key].text = key
  	}
}

/*******************************************
  * DEATH: Killed, innocent
  * This loops back.
  *******************************************/
var time_reaction = []
// time, text, reaction, function, used
time_reaction[0] = [0, " ", "",freeze,false]
time_reaction[1] = [2, "", "I am put on a stretcher and moved somewhere. I can't make up where I'm going.",no_function,false]
time_reaction[2] = [4, "", "I see the lights on the ceiling flashing.",no_function,false]
time_reaction[3] = [6, "You start to lose consciousness.", "",reset_map,false]
map.death_killed_innocent = {enter: "" , enter_again: "" ,description : ["", ""], directions: [], objects : [] , image: "", cond: {dead: 1}, action_reaction : {},time_reaction: time_reaction}

for (var key in map) {
  	if (map.hasOwnProperty(key)) {
  		map[key].text = key
  	}
}

/*******************************************
  * DEATH: Killed, guilty
  *
  *******************************************/
var time_reaction = []
// time, text, reaction, function, used
time_reaction[0] = [0, " ", "",freeze,false]
time_reaction[1] = [2, "", "I am put on a stretcher and moved somewhere. I can't make up where I'm going.",no_function,false]
time_reaction[2] = [4, "", "I see the lights on the ceiling flashing.",no_function,false]
time_reaction[3] = [6, "You start to lose consciousness.", "",reset_map,false]
map.death_killed_guilty = {enter: "The ground is approaching you in an increasing pace." , enter_again: "This is really strange, why am I here again?", description : ["You are dead",""], directions: [], objects : [] , image: "", cond: {dead: 1}, action_reaction : {},time_reaction: time_reaction}

for (var key in map) {
  	if (map.hasOwnProperty(key)) {
  		map[key].text = key
  	}
}

/*******************************************
  * DEATH: Boom
  *
  *******************************************/
var time_reaction = []
// time, text, reaction, function, used
time_reaction[0] = [1, "A timer is counting down from 10.", "",freeze,false]
time_reaction[1] = [2, "9 -  I don't think this is going to end well ", "",no_function,false]
time_reaction[2] = [3, "8", "",no_function,false]
time_reaction[3] = [4, "7 -  I feel relieved, knowing that I managed to end the madness. ", "",no_function,false]
time_reaction[4] = [5, "6", "",no_function,false]
time_reaction[5] = [6, "5", "",no_function,false]
time_reaction[6] = [7, "4", "",no_function,false]
time_reaction[7] = [8, "3", "",no_function,false]
time_reaction[8] = [9, "2", "",no_function,false]
time_reaction[9] = [10, "1", "",no_function,false]
time_reaction[10] = [11, "The building exploded. You are dead.", "",no_function,false]
time_reaction[10] = [12, "
", "",no_function,false]

time_reaction[11] = [14, "", "You killed a lot of innocent people, along with some criminals. Does this make you a hero? I don't think so. Congratultions,  you are a monster .",wait_for_reset,false]
map.death_boom = {enter: "The ground is approaching you in an increasing pace." , enter_again: "This is really strange, why am I here again?", description : ["You are dead",""], directions: [], objects : [] , image: "", cond: {dead: 1}, action_reaction : {},time_reaction: time_reaction}

for (var key in map) {
  	if (map.hasOwnProperty(key)) {
  		map[key].text = key
  	}
}

/*******************************************
  * DEATH: escape_guilty
  *
  *******************************************/
var time_reaction = []
// time, text, reaction, function, used
time_reaction[0] = [2, "Your parachute opens", "",no_function,false]
time_reaction[1] = [4, "You go to the police. However, they have already been notified of the fact that you are a murderer.", "",no_function,false]
time_reaction[2] = [6, "You spend the rest of your life in jail. Congratulations, thanks to you your character spends the rest of his life in jail. You are a monster .", "",wait_for_reset,false]
map.death_escape_guilty = {enter: "The ground is approaching you in an increasing pace." , enter_again: "This is really strange, why am I here again?", description : ["You are dead",""], directions: [], objects : [] , image: "", cond: {dead: 1}, action_reaction : {},time_reaction: time_reaction}

for (var key in map) {
  	if (map.hasOwnProperty(key)) {
  		map[key].text = key
  	}
}

/*******************************************
  * DEATH: escape_innocent, default: no evidence
  *
  *******************************************/
var time_reaction = []
// time, text, reaction, function, used
time_reaction[0] = [2, "Your parachute opens", "",switch_evidence,false]
map.death_escape_innocent = {enter: "The ground is approaching you in an increasing pace." , enter_again: "This is really strange, why am I here again?", description : ["You are dead",""], directions: [], objects : [] , image: "", cond: {dead: 1}, action_reaction : {},time_reaction: time_reaction}

function switch_evidence()
{
	var count = 0
  debugger;
   if(find_in_inventory(words.log))
   {
    count ++
   }
   if(find_in_inventory(words.document))
   {
    count ++
   }
   switch(count){
   default: case 0: case 1: change_map("escape_no_evidence")();break;
   case 2:  change_map("escape_two_evidence")();
	}
}
/*******************************************
  * DEATH: escape_no_evidence
  *
  *******************************************/
var time_reaction = []
// time, text, reaction, function, used
time_reaction[0] = [2, "You run away. You are free from the researchers..", "",no_function,false]
time_reaction[1] = [5, "", "Congratulations:  You are not a monster ",no_function,false]
time_reaction[2] = [6, "", " ",no_function,false]
time_reaction[3] = [7, "", " ",no_function,false]
time_reaction[4] = [8, "", "Thank you for playing our game. We hope you enjoyed it.",no_function,false]
time_reaction[5] = [9, "", "~ Tim & Nander.",no_function,false]
map.escape_no_evidence = {enter: "The ground is approaching you in an increasing pace." , enter_again: "This is really strange, why am I here again?", description : ["You are dead",""], directions: [], objects : [] , image: "", cond: {dead: 1}, action_reaction : {},time_reaction: time_reaction}

/*******************************************
  * DEATH: escape_two_evidence
  *
  *******************************************/
var time_reaction = []
// time, text, reaction, function, used
time_reaction[0] = [2, "The police sees a distressed man, but once you hand over the evidence, they have no choice but to believe you.", "",no_function,false]
time_reaction[1] = [4, "The research laboratory is shut down. You are free.", " ",no_function,false]
time_reaction[2] = [6, "", "Congratulations:  You are not a monster ",no_function,false]
time_reaction[3] = [8, "", " ",no_function,false]
time_reaction[4] = [10, "", " ",no_function,false]
time_reaction[5] = [10, "", "Thank you for playing our game. We hope you enjoyed it.",no_function,false]
time_reaction[6] = [12, "", "~ Tim & Nander.",no_function,false]

map.escape_two_evidence = {enter: "The ground is approaching you in an increasing pace." , enter_again: "This is really strange, why am I here again?", description : ["You are dead",""], directions: [], objects : [] , image: "", cond: {dead: 1}, action_reaction : {},time_reaction: time_reaction}

for (var key in map) {
  	if (map.hasOwnProperty(key)) {
  		map[key].text = key
  	}
}<|endoftext|>


<commit_before>/*globals describe it beforeEach afterEach */
require("should");
var path = require("path");
var fs = require("fs");
var chokidar = require("chokidar");
var TestHelper = require("./helpers/TestHelper");
var Watchpack = require("../lib/watchpack");

var fixtures = path.join(__dirname, "fixtures");
var testHelper = new TestHelper(fixtures);

describe("Assumption", function() {
	this.timeout(10000);
	var watcher = null;

	beforeEach(testHelper.before);
	afterEach(function(done) {
		if(watcher) {
			watcher.close();
			watcher = null;
		}
		testHelper.after(done);
	});

	it("should have a file system with correct mtime behavior (stats)", function(done) {
		var i = 60;
		var count = 60;
		var minDiffBefore = +Infinity;
		var maxDiffBefore = -Infinity;
		var sumDiffBefore = 0;
		var minDiffAfter = +Infinity;
		var maxDiffAfter = -Infinity;
		var sumDiffAfter = 0;
		testHelper.tick(100, function checkMtime() {
			var before = Date.now();
			testHelper.file("a");
			var after = Date.now();
			var s = fs.statSync(path.join(fixtures, "a"));
			var diffBefore = +s.mtime - before;
			if(diffBefore < minDiffBefore) minDiffBefore = diffBefore;
			if(diffBefore > maxDiffBefore) maxDiffBefore = diffBefore;
			sumDiffBefore += diffBefore;
			var diffAfter = +s.mtime - after;
			if(diffAfter < minDiffAfter) minDiffAfter = diffAfter;
			if(diffAfter > maxDiffAfter) maxDiffAfter = diffAfter;
			sumDiffAfter += diffAfter;
			if(i-- === 0) {
				afterMeassure();
			} else {
				testHelper.tick(100, checkMtime);
			}
		});

		function afterMeassure() {
			console.log("mtime stats accuracy (before): [" + minDiffBefore + " ; " + maxDiffBefore + "] avg " + Math.round(sumDiffBefore / count));
			console.log("mtime stats accuracy (after): [" + minDiffAfter + " ; " + maxDiffAfter + "] avg " + Math.round(sumDiffAfter / count));
			minDiffBefore.should.be.aboveOrEqual(-2000);
			maxDiffBefore.should.be.below(2000);
			minDiffAfter.should.be.aboveOrEqual(-2000);
			maxDiffAfter.should.be.below(2000);
			done();
		}
	});

	it("should have a file system with correct mtime behavior (chokidar)", function(done) {
		testHelper.file("a");
		var i = 60;
		var count = 60;
		var before;
		var after;
		var minDiffBefore = +Infinity;
		var maxDiffBefore = -Infinity;
		var sumDiffBefore = 0;
		var minDiffAfter = +Infinity;
		var maxDiffAfter = -Infinity;
		var sumDiffAfter = 0;
		var watcher = chokidar.watch(fixtures, {
			ignoreInitial: true,
			persistent: true,
			followSymlinks: false,
			depth: 0,
			atomic: false,
			alwaysStat: true,
			ignorePermissionErrors: true
		});
		testHelper.tick(100, function() {
			watcher.on("change", function(path, s) {
				if(before && after) {
					var diffBefore = +s.mtime - before;
					if(diffBefore < minDiffBefore) minDiffBefore = diffBefore;
					if(diffBefore > maxDiffBefore) maxDiffBefore = diffBefore;
					sumDiffBefore += diffBefore;
					var diffAfter = +s.mtime - after;
					if(diffAfter < minDiffAfter) minDiffAfter = diffAfter;
					if(diffAfter > maxDiffAfter) maxDiffAfter = diffAfter;
					sumDiffAfter += diffAfter;
					before = after = undefined;
					if(i-- === 0) {
						afterMeassure();
					} else {
						testHelper.tick(100, checkMtime);
					}
				}
			});
			testHelper.tick(100, checkMtime);
		});

		function checkMtime() {
			before = Date.now();
			testHelper.file("a");
			after = Date.now();
		}

		function afterMeassure() {
			console.log("mtime chokidar accuracy (before): [" + minDiffBefore + " ; " + maxDiffBefore + "] avg " + Math.round(sumDiffBefore / count));
			console.log("mtime chokidar accuracy (after): [" + minDiffAfter + " ; " + maxDiffAfter + "] avg " + Math.round(sumDiffAfter / count));
			minDiffBefore.should.be.aboveOrEqual(-2000);
			maxDiffBefore.should.be.below(2000);
			minDiffAfter.should.be.aboveOrEqual(-2000);
			maxDiffAfter.should.be.below(2000);
			done();
		}
	});

	it("should not fire events in subdirectories", function(done) {
		testHelper.dir("watch-test-directory");
		watcher = chokidar.watch(fixtures, {
			ignoreInitial: true,
			persistent: true,
			followSymlinks: false,
			depth: 0,
			atomic: false,
			alwaysStat: true,
			ignorePermissionErrors: true
		});
		watcher.on("add", function(arg) {
			done(new Error("should not be emitted " + arg));
			done = function() {};
		});
		watcher.on("change", function(arg) {
			done(new Error("should not be emitted " + arg));
			done = function() {};
		});
		watcher.on("error", function(err) {
			done(err);
			done = function() {};
		});
		testHelper.tick(500, function() {
			testHelper.file("watch-test-directory/watch-test-file");
			testHelper.tick(500, function() {
				watcher.close();
				watcher = null;
				done();
			});
		});
	});

	[0, 1, 5, 10, 20, 50, 100, 200, 300, 500, 700, 1000].reverse().forEach(function(delay) {
		it("should fire events not after start and " + delay + "ms delay", function(done) {
			testHelper.file("watch-test-file-" + delay);
			testHelper.tick(delay, function() {
				watcher = chokidar.watch(fixtures, {
					ignoreInitial: true,
					persistent: true,
					followSymlinks: false,
					depth: 0,
					atomic: false,
					alwaysStat: true,
					ignorePermissionErrors: true
				});
				watcher.on("add", function(arg) {
					done(new Error("should not be emitted " + arg));
					done = function() {};
				});
				watcher.on("change", function(arg) {
					done(new Error("should not be emitted " + arg));
					done = function() {};
				});
				watcher.on("error", function(err) {
					done(err);
					done = function() {};
				});
				testHelper.tick(500, function() {
					watcher.close();
					watcher = null;
					done();
				});
			});
		});
	});

	it("should not fire events after start", function(done) {
		testHelper.file("watch-test-file-a");
		watcher = chokidar.watch(fixtures, {
			ignoreInitial: true,
			persistent: true,
			followSymlinks: false,
			depth: 0,
			atomic: false,
			alwaysStat: true,
			ignorePermissionErrors: true
		});
		watcher.on("add", function(arg) {
			done(new Error("should not be emitted " + arg));
			done = function() {};
		});
		watcher.on("change", function(arg) {
			done(new Error("should not be emitted " + arg));
			done = function() {};
		});
		watcher.on("error", function(err) {
			done(err);
			done = function() {};
		});
		testHelper.tick(500, function() {
			watcher.close();
			watcher = null;
			done();
		});
	});
});

<commit_msg>better code to close watcher after testing<commit_after>/*globals describe it beforeEach afterEach */
require("should");
var path = require("path");
var fs = require("fs");
var chokidar = require("chokidar");
var TestHelper = require("./helpers/TestHelper");
var Watchpack = require("../lib/watchpack");

var fixtures = path.join(__dirname, "fixtures");
var testHelper = new TestHelper(fixtures);

describe("Assumption", function() {
	this.timeout(10000);
	var watcherToClose = null;

	beforeEach(testHelper.before);
	afterEach(function(done) {
		if(watcherToClose) {
			watcherToClose.close();
			watcherToClose = null;
		}
		testHelper.after(done);
	});

	it("should have a file system with correct mtime behavior (stats)", function(done) {
		var i = 60;
		var count = 60;
		var minDiffBefore = +Infinity;
		var maxDiffBefore = -Infinity;
		var sumDiffBefore = 0;
		var minDiffAfter = +Infinity;
		var maxDiffAfter = -Infinity;
		var sumDiffAfter = 0;
		testHelper.tick(100, function checkMtime() {
			var before = Date.now();
			testHelper.file("a");
			var after = Date.now();
			var s = fs.statSync(path.join(fixtures, "a"));
			var diffBefore = +s.mtime - before;
			if(diffBefore < minDiffBefore) minDiffBefore = diffBefore;
			if(diffBefore > maxDiffBefore) maxDiffBefore = diffBefore;
			sumDiffBefore += diffBefore;
			var diffAfter = +s.mtime - after;
			if(diffAfter < minDiffAfter) minDiffAfter = diffAfter;
			if(diffAfter > maxDiffAfter) maxDiffAfter = diffAfter;
			sumDiffAfter += diffAfter;
			if(i-- === 0) {
				afterMeassure();
			} else {
				testHelper.tick(100, checkMtime);
			}
		});

		function afterMeassure() {
			console.log("mtime stats accuracy (before): [" + minDiffBefore + " ; " + maxDiffBefore + "] avg " + Math.round(sumDiffBefore / count));
			console.log("mtime stats accuracy (after): [" + minDiffAfter + " ; " + maxDiffAfter + "] avg " + Math.round(sumDiffAfter / count));
			minDiffBefore.should.be.aboveOrEqual(-2000);
			maxDiffBefore.should.be.below(2000);
			minDiffAfter.should.be.aboveOrEqual(-2000);
			maxDiffAfter.should.be.below(2000);
			done();
		}
	});

	it("should have a file system with correct mtime behavior (chokidar)", function(done) {
		testHelper.file("a");
		var i = 60;
		var count = 60;
		var before;
		var after;
		var minDiffBefore = +Infinity;
		var maxDiffBefore = -Infinity;
		var sumDiffBefore = 0;
		var minDiffAfter = +Infinity;
		var maxDiffAfter = -Infinity;
		var sumDiffAfter = 0;
		var watcher = watcherToClose = chokidar.watch(fixtures, {
			ignoreInitial: true,
			persistent: true,
			followSymlinks: false,
			depth: 0,
			atomic: false,
			alwaysStat: true,
			ignorePermissionErrors: true
		});
		testHelper.tick(100, function() {
			watcher.on("change", function(path, s) {
				if(before && after) {
					var diffBefore = +s.mtime - before;
					if(diffBefore < minDiffBefore) minDiffBefore = diffBefore;
					if(diffBefore > maxDiffBefore) maxDiffBefore = diffBefore;
					sumDiffBefore += diffBefore;
					var diffAfter = +s.mtime - after;
					if(diffAfter < minDiffAfter) minDiffAfter = diffAfter;
					if(diffAfter > maxDiffAfter) maxDiffAfter = diffAfter;
					sumDiffAfter += diffAfter;
					before = after = undefined;
					if(i-- === 0) {
						afterMeassure();
					} else {
						testHelper.tick(100, checkMtime);
					}
				}
			});
			testHelper.tick(100, checkMtime);
		});

		function checkMtime() {
			before = Date.now();
			testHelper.file("a");
			after = Date.now();
		}

		function afterMeassure() {
			console.log("mtime chokidar accuracy (before): [" + minDiffBefore + " ; " + maxDiffBefore + "] avg " + Math.round(sumDiffBefore / count));
			console.log("mtime chokidar accuracy (after): [" + minDiffAfter + " ; " + maxDiffAfter + "] avg " + Math.round(sumDiffAfter / count));
			minDiffBefore.should.be.aboveOrEqual(-2000);
			maxDiffBefore.should.be.below(2000);
			minDiffAfter.should.be.aboveOrEqual(-2000);
			maxDiffAfter.should.be.below(2000);
			done();
		}
	});

	it("should not fire events in subdirectories", function(done) {
		testHelper.dir("watch-test-directory");
		var watcher = watcherToClose = chokidar.watch(fixtures, {
			ignoreInitial: true,
			persistent: true,
			followSymlinks: false,
			depth: 0,
			atomic: false,
			alwaysStat: true,
			ignorePermissionErrors: true
		});
		watcher.on("add", function(arg) {
			done(new Error("should not be emitted " + arg));
			done = function() {};
		});
		watcher.on("change", function(arg) {
			done(new Error("should not be emitted " + arg));
			done = function() {};
		});
		watcher.on("error", function(err) {
			done(err);
			done = function() {};
		});
		testHelper.tick(500, function() {
			testHelper.file("watch-test-directory/watch-test-file");
			testHelper.tick(500, function() {
				done();
			});
		});
	});

	[0, 1, 5, 10, 20, 50, 100, 200, 300, 500, 700, 1000].reverse().forEach(function(delay) {
		it("should fire events not after start and " + delay + "ms delay", function(done) {
			testHelper.file("watch-test-file-" + delay);
			testHelper.tick(delay, function() {
				var watcher = watcherToClose = chokidar.watch(fixtures, {
					ignoreInitial: true,
					persistent: true,
					followSymlinks: false,
					depth: 0,
					atomic: false,
					alwaysStat: true,
					ignorePermissionErrors: true
				});
				watcher.on("add", function(arg) {
					done(new Error("should not be emitted " + arg));
					done = function() {};
				});
				watcher.on("change", function(arg) {
					done(new Error("should not be emitted " + arg));
					done = function() {};
				});
				watcher.on("error", function(err) {
					done(err);
					done = function() {};
				});
				testHelper.tick(500, function() {
					done();
				});
			});
		});
	});

	it("should not fire events after start", function(done) {
		testHelper.file("watch-test-file-a");
		var watcher = watcherToClose = chokidar.watch(fixtures, {
			ignoreInitial: true,
			persistent: true,
			followSymlinks: false,
			depth: 0,
			atomic: false,
			alwaysStat: true,
			ignorePermissionErrors: true
		});
		watcher.on("add", function(arg) {
			done(new Error("should not be emitted " + arg));
			done = function() {};
		});
		watcher.on("change", function(arg) {
			done(new Error("should not be emitted " + arg));
			done = function() {};
		});
		watcher.on("error", function(err) {
			done(err);
			done = function() {};
		});
		testHelper.tick(500, function() {
			done();
		});
	});
});

<|endoftext|>


<commit_before>exports.create = {
  id: 100,
  slug: 'A Panhandlers Guide to Business, Life & Love',
  title: "Pay People What They're Worth",
  video: ['youtube player', 'vimeo player'],
  text: " I spend my days \"dashing\" from meeting to meeting, putting out fires, returning phone calls. I spend my meetings **reviewing designs**, **assessing concepts** and **directing my team**.  \n\n\n I spend my mornings reading the Wall Street Journal and my evenings watching the news.\nI'd say I'm *connected*. I'd say I'm successful. I'd say I'm spent!\n\nI drive to work. On a good day it's thirty minutes each way. On a bad day it's an hour and thirty minutes. If I leave early enough I can get there in twenty minutes (c) - now that's time management. \n\n  ",
  author: 'Alexey Simonenko',
  params: 'more parameters',
  tags: 'business'
};

exports.update = {
  _id: 100,
  slug: 'a-panhandlers-guide-to-business-life-love',
  title: "Pay People What They’re Worth",
  video: ['youtube player', 'vimeo player'],
  preview: "I spend my days «dashing» from meeting to meeting, putting out fires, returning phone calls. I spend my meetings **reviewing designs**, **assessing concepts** and **directing my team**.",
  text: "I spend my mornings reading the Wall Street Journal and my evenings watching the news.\nI’d say I’m *connected*. I’d say I’m successful. I’d say I’m spent!\n\nI drive to work. On a good day it’s thirty minutes each way. http://simonenko.su for more info. On a bad day it’s an hour and thirty minutes. If I leave early enough I can get there in twenty minutes © — now that’s time management.",
  author: {
    name: 'Alexey Simonenko',
    email: 'alexey@simonenko.su'
  },
  params: 'more parameters',
  tags: ['business'],
  created: '2013-12-23 18:59',
  active: true
};<commit_msg>Update test data<commit_after>exports.create = {
  id: 100,
  slug: 'A Panhandlers Guide to Business, Life & Love',
  title: "Pay People What They're Worth",
  video: ['youtube player', 'vimeo player'],
  text: " I spend my days \"dashing\" from meeting to meeting, putting out fires, returning phone calls. I spend my meetings **reviewing designs**, **assessing concepts** and **directing my team**.  \n\n\n I spend my mornings reading the Wall Street Journal and my evenings watching the news.\nI'd say I'm *connected*. I'd say I'm successful. I'd say I'm spent!\n\nI drive to work. On a good day it's thirty minutes each way. On a bad day it's an hour and thirty minutes. If I leave early enough I can get there in twenty minutes (c) - now that's time management. \n\n  ",
  author: 'Alexey Simonenko',
  params: 'more parameters',
  tags: 'business',
  stats: {
    views: '10',
    unique: 5
  }
};

exports.update = {
  _id: 100,
  slug: 'a-panhandlers-guide-to-business-life-love',
  title: "Pay People What They’re Worth",
  video: ['youtube player', 'vimeo player'],
  preview: "I spend my days «dashing» from meeting to meeting, putting out fires, returning phone calls. I spend my meetings **reviewing designs**, **assessing concepts** and **directing my team**.",
  text: "I spend my mornings reading the Wall Street Journal and my evenings watching the news.\nI’d say I’m *connected*. I’d say I’m successful. I’d say I’m spent!\n\nI drive to work. On a good day it’s thirty minutes each way. http://simonenko.su for more info. On a bad day it’s an hour and thirty minutes. If I leave early enough I can get there in twenty minutes © — now that’s time management.",
  author: {
    name: 'Alexey Simonenko',
    email: 'alexey@simonenko.su'
  },
  params: 'more parameters',
  tags: ['business'],
  created: '2013-12-23 18:59',
  active: true,
  stats: {
    views: 10,
    likes: 5,
    comments: 20
  }
};<|endoftext|>


<commit_before>var should = require('should');
var assert = require('assert');
var request = require('supertest');
var httpReq =  require('request');

describe('Routing', function() {
  var url = 'http://foodsafety.ibacorp.us';
  //var url = 'http://www.google.com';
  // within before() you can run all the operations that are needed to setup your tests.
  // when you are  done, call done().
  before(function(done) {
    // do the pre test setup
    done();
  });
  // use describe to give a title to your test suite, in this case the tile is "FoodREcallTests"
  // and then specify a function in which we are going to declare all the tests
  // we want to run. Each test starts with the function it() and as a first argument
  // we have to provide a meaningful title for it, whereas as the second argument we
  // specify a function that takes a single parameter, "done", that we will use
  // to specify when our test is completed, and that's what makes easy
  // to perform async test!
  describe('FoodRecallTests', function() {
       it('should return error if FoodSafety Site is NOT Alive!', function(done) {

       // once we have specified the info we want to send to the server via POST verb,
       // we need to actually perform the action on the resource, in this case we want to
       // POST on /api/profiles and we want to send some info
       // We do this using the request object, requiring supertest!
            request(url)
 	      .get('/')
              // end handles the response
	      .end(function(err, res) {
                 if (err) {
                    throw err;
                 }
                 // this is should.js syntax, very clear
                 res.should.have.status(200);
                 done();
              });
       });
       it('should return error if can not fecth the deafult page', function(done){
	var body = { };
        request(url)
           .get('/pages/default.htm')
	   .end(function(err,res) {
	      if (err) {
	         throw err;
	      }
	      done();
               // this is should.js syntax, very clear
               res.should.have.status(200);
	   });
      });
      it('should return error if can not fecth the contact page', function(done){
        var body = { };
        request(url)
           .get('/pages/contact.htm')
           .end(function(err,res) {
              if (err) {
                 throw err;
              }
              done();
               // this is should.js syntax, very clear
               //console.log(res);
               res.should.have.status(200);
           });
      });
      it('should return error if can not fecth the about page', function(done){
        var body = { };
        request(url)
           .get('/pages/about.htm')
           .end(function(err,res) {
              if (err) {
                 throw err;
              }
              done();
               // this is should.js syntax, very clear
               res.should.have.status(200);
           });
      });
      it('should return error if can not select region to check food recalls', function(done){
        var body = { };
        request(url)
           .get('/#/form/Viginia/va')
           .end(function(err,res) {
              if (err) {
                 throw err;
              }
              done();
               // this is should.js syntax, very clear
               //console.log(res);
               res.should.have.status(200);
           });
      });
      it('should return error trying to save duplicate username', function(done) {
      var profile = {
          params:  {
            product_description: 'Cheese',
            recalling_firm: 'Kraft' },
          distribution_pattern: 'VA',
          status: 'Ongoing'
      };
    // once we have specified the info we want to send to the server via POST verb,
    // we need to actually perform the action on the resource, in this case we want to
    // POST on /api/profiles and we want to send some info
    // We do this using the request object, requiring supertest!
    request(url)
        .post('/foodQuery')
        .send(profile)
    // end handles the response
        .end(function(err, res) {
          if (err) {
            throw err;
          }
          // this is should.js syntax, very clear
          //console.log(res.body);
          res.should.have.status(200);
          done();
        });
    });

      it('should return error if can not fecth the recalls page', function(done){
        var body = { };
        request(url)
           .get('/#/recalls/')
           .end(function(err,res) {
              if (err) {
                 throw err;
              }
              done();
               // this is should.js syntax, very clear
               //console.log(res);
               res.should.have.status(200);
           });
      });
      it('should return error if can not fecth the about page', function(done){
        var body = { };
        request(url)
           .get('#/recall/1')
           .end(function(err,res) {
              if (err) {
                 throw err;
              }
              done();
               // this is should.js syntax, very clear
               res.should.have.status(200);
           });
      });

  });
});
<commit_msg>minor update test cases<commit_after>var should = require('should');
var assert = require('assert');
var request = require('supertest');
var httpReq =  require('request');

describe('Routing', function() {
  var url = 'http://foodsafety.ibacorp.us';
  //var url = 'http://www.google.com';
  // within before() you can run all the operations that are needed to setup your tests.
  // when you are  done, call done().
  before(function(done) {
    // do the pre test setup
    done();
  });
  // use describe to give a title to your test suite, in this case the tile is "FoodREcallTests"
  // and then specify a function in which we are going to declare all the tests
  // we want to run. Each test starts with the function it() and as a first argument
  // we have to provide a meaningful title for it, whereas as the second argument we
  // specify a function that takes a single parameter, "done", that we will use
  // to specify when our test is completed, and that's what makes easy
  // to perform async test!
  describe('FoodRecallTests', function() {
       it('should return error if FoodSafety Site is NOT Alive!', function(done) {

       // once we have specified the info we want to send to the server via POST verb,
       // we need to actually perform the action on the resource, in this case we want to
       // GET and we want to send some info
       // We do this using the request object, requiring supertest!
            request(url)
 	      .get('/')
              // end handles the response
	      .end(function(err, res) {
                 if (err) {
                    throw err;
                 }
                 // this is should.js syntax, very clear
                 res.should.have.status(200);
                 done();
              });
       });
       it('should return error if can not fecth the deafult page', function(done){
	var body = { };
        request(url)
           .get('/pages/default.htm')
	   .end(function(err,res) {
	      if (err) {
	         throw err;
	      }
	      done();
               // this is should.js syntax, very clear
               res.should.have.status(200);
	   });
      });
      it('should return error if can not fecth the contact page', function(done){
        var body = { };
        request(url)
           .get('/pages/contact.htm')
           .end(function(err,res) {
              if (err) {
                 throw err;
              }
              done();
               // this is should.js syntax, very clear
               //console.log(res);
               res.should.have.status(200);
           });
      });
      it('should return error if can not fecth the about page', function(done){
        var body = { };
        request(url)
           .get('/pages/about.htm')
           .end(function(err,res) {
              if (err) {
                 throw err;
              }
              done();
               // this is should.js syntax, very clear
               res.should.have.status(200);
           });
      });
      it('should return error if can not select region to check food recalls', function(done){
        var body = { };
        request(url)
           .get('/#/form/Viginia/va')
           .end(function(err,res) {
              if (err) {
                 throw err;
              }
              done();
               // this is should.js syntax, very clear
               //console.log(res);
               res.should.have.status(200);
           });
      });
      it('should return error trying to post and get data from openFDA', function(done) {
      var profile = {
          params:  {
            product_description: 'Cheese',
            recalling_firm: 'Kraft' },
          distribution_pattern: 'VA',
          status: 'Ongoing'
      };
    // once we have specified the info we want to send to the server via POST verb,
    // we need to actually perform the action on the resource, in this case we want to
    // POST on /api/profiles and we want to send some info
    // We do this using the request object, requiring supertest!
    request(url)
        .post('/foodQuery')
        .send(profile)
    // end handles the response
        .end(function(err, res) {
          if (err) {
            throw err;
          }
          // this is should.js syntax, very clear
          //console.log(res.body);
          res.should.have.status(200);
          done();
        });
    });

      it('should return error if can not fecth the recalls page', function(done){
        var body = { };
        request(url)
           .get('/#/recalls/')
           .end(function(err,res) {
              if (err) {
                 throw err;
              }
              done();
               // this is should.js syntax, very clear
               //console.log(res);
               res.should.have.status(200);
           });
      });
      it('should return error if can not fecth the about page', function(done){
        var body = { };
        request(url)
           .get('#/recall/1')
           .end(function(err,res) {
              if (err) {
                 throw err;
              }
              done();
               // this is should.js syntax, very clear
               res.should.have.status(200);
           });
      });

  });
});
<|endoftext|>


<commit_before>var request 	= require('supertest'),
		should 		= require('chai').should(),
		express 	= require('express'),
		mongoose 	= require('mongoose'),
		app				= express();

require('../api/routes')(app);

var db = require('./config/db');

describe('API Routing', function() {
	before(function(done) {
		mongoose.createConnection(db.url);
		done();
  });

	describe('Media', function () {
		it('should add new photo to database with call to POST /api/v1/media', function(done) {
			var photo = {
				title: 'Test Photo',
				type: 'photo',
				tags: ['test', 'test2', 'asdf'],
				filename: 'test-photo.jpg',
				description: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque maximus euismod orci, eu tempus turpis dictum in. Phasellus eget consequat lacus.'
			}

			request(app)
				.post('/api/v1/media')
				.send(photo)
				.set('Accept', 'application/json')
				.end(function(err, res) {
					if (err) {
						throw err
					}

					res.status.should.equal(200);
					done();
				});
		});

		// it('should respond to GET /api/v1/media with all media as JSON', function() {
		// 	request(app)
		// 		.get('/api/v1/media')
		// 		.set('Accept', 'application/json')
		// 		.end(function(err, res) {
		// 			if (err) {
		// 				throw err
		// 			}

		// 			res.status.should.equal(200);
		// 			done();
		// 		});
		// });

	});

	describe('Photos', function () {
		// it('should respond to GET /api/v1/photos with all photos as JSON', function() {
		// 	request(app)
		// 		.get('/api/v1/photos')
		// 		.set('Accept', 'application/json')
		// 		.end(function(err, res) {
		// 			if (err) {
		// 				throw err
		// 			}

		// 			res.status.should.equal(200);
		// 			done();
		// 		});
		// });
	});

	describe('Videos', function () {

	});

	describe('Users', function () {

	});
});<commit_msg>Updating mock data<commit_after>var request 	= require('supertest'),
		should 		= require('chai').should(),
		express 	= require('express'),
		mongoose 	= require('mongoose'),
		app				= express();

require('../api/routes')(app);

var db = require('./config/db');

describe('API Routing', function() {
	before(function(done) {
		mongoose.createConnection(db.url);
		done();
  });

	describe('Media', function () {
		it('should add new photo to database with call to POST /api/v1/media', function(done) {
			var photo = {
				title: 'Test Photo',
				type: 'photo',
				tags: ['test', 'test2', 'asdf'],
				filename: 'test-photo.jpg',
				description: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque maximus euismod orci, eu tempus turpis dictum in. Phasellus eget consequat lacus.'
			};

			request(app)
				.post('/api/v1/media')
				.send(photo)
				.set('Accept', 'application/json')
				.end(function(err, res) {
					if (err) {
						throw err
					}

					res.status.should.equal(200);
					done();
				});
		});

		// it('should respond to GET /api/v1/media with all media as JSON', function() {
		// 	request(app)
		// 		.get('/api/v1/media')
		// 		.set('Accept', 'application/json')
		// 		.end(function(err, res) {
		// 			if (err) {
		// 				throw err
		// 			}

		// 			res.status.should.equal(200);
		// 			done();
		// 		});
		// });

	});

	describe('Photos', function () {
		// it('should respond to GET /api/v1/photos with all photos as JSON', function() {
		// 	request(app)
		// 		.get('/api/v1/photos')
		// 		.set('Accept', 'application/json')
		// 		.end(function(err, res) {
		// 			if (err) {
		// 				throw err
		// 			}

		// 			res.status.should.equal(200);
		// 			done();
		// 		});
		// });
	});

	describe('Videos', function () {

	});

	describe('Users', function () {

	});
});<|endoftext|>


<commit_before>var app = require('app');  // Module to control application life.
var BrowserWindow = require('browser-window');  // Module to create native browser window.

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
var mainWindow = null;

// Quit when all windows are closed.
app.on('window-all-closed', function() {
  // On OS X it is common for applications and their menu bar
  // to stay active until the user quits explicitly with Cmd + Q
  if (process.platform != 'darwin') {
    app.quit();
  }
});

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
app.on('ready', function() {
  // Create the browser window.
  mainWindow = new BrowserWindow({
    width: 1000,
    height: 700,
    'accept-first-mouse': true,
    'title-bar-style': 'hidden'
  });

  // and load the index.html of the app.
  mainWindow.loadUrl('file://' + __dirname + '/index.html');

  // Open the DevTools.
  //mainWindow.openDevTools();

  // Emitted when the window is closed.
  mainWindow.on('closed', function() {
    // Dereference the window object, usually you would store windows
    // in an array if your app supports multi windows, this is the time
    // when you should delete the corresponding element.
    mainWindow = null;
  });
});
<commit_msg>min-width<commit_after>var app = require('app');  // Module to control application life.
var BrowserWindow = require('browser-window');  // Module to create native browser window.

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
var mainWindow = null;

// Quit when all windows are closed.
app.on('window-all-closed', function() {
  // On OS X it is common for applications and their menu bar
  // to stay active until the user quits explicitly with Cmd + Q
  if (process.platform != 'darwin') {
    app.quit();
  }
});

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
app.on('ready', function() {
  // Create the browser window.
  mainWindow = new BrowserWindow({
    width: 1000,
    height: 700,
    'min-width': 500,
    'accept-first-mouse': true,
    'title-bar-style': 'hidden'
  });

  // and load the index.html of the app.
  mainWindow.loadUrl('file://' + __dirname + '/index.html');

  // Open the DevTools.
  //mainWindow.openDevTools();

  // Emitted when the window is closed.
  mainWindow.on('closed', function() {
    // Dereference the window object, usually you would store windows
    // in an array if your app supports multi windows, this is the time
    // when you should delete the corresponding element.
    mainWindow = null;
  });
});
<|endoftext|>


<commit_before>var should = require("should");

describe("basic", function() {
	it("should compile basic stylus", function() {
		var css = require("!raw-loader!../!./fixtures/basic.styl");
		(typeof css).should.be.eql("string");
		css.should.match(/font:\s?12px Helvetica,\s?Arial,\s?sans-serif;/);
		css.should.match(/-webkit-border-radius:\s?5px;/);
	});
	it("shouldn't import css", function() {
		var css = require("!raw-loader!../!./fixtures/import-css.styl");
		(typeof css).should.be.eql("string");
		css.should.not.match(/\.imported-css/);
	});
	it("should import css with the css-loader", function() {
		var css = require("!css-loader!../!./fixtures/import-css.styl");
		(typeof css).should.be.eql("string");
		css.should.match(/\.imported-css/);
	});
	it("should import stylus", function() {
		var css = require("!css-loader!../!./fixtures/import-styl.styl");
		(typeof css).should.be.eql("string");
		css.should.match(/\.imported-stylus/);
	});
	it("shouldn't process urls", function() {
		var css = require("!raw-loader!../!./fixtures/urls.styl");
		(typeof css).should.be.eql("string");
		css.should.match(/\url\(\"?img.png\"?\)/);
	});
	it("with option, should resolve urls relatively", function() {
		var css = require(
			"!raw-loader!../?{\"resolve url\":true}!./fixtures/shallow.styl"
		);
		(typeof css).should.be.eql("string");
		css.should.match(/\url\(\"img.png\"\)/);
		css.should.match(/\url\(\"deep\/deep-img.png\"\)/);
		css.should.match(/\url\(\"!!deep\/deep-img.png\"\)/);
		css.should.match(/\url\(\"file!deep\/deep-img.png\"\)/);
		css.should.match(/\url\(\"file\?foo!deep\/deep-img.png\"\)/);
	});
	it("with paths, find deps and load like normal stylus", function() {
		var css = require(
			"!raw-loader!../?paths=test/fixtures/paths!./fixtures/import-paths.styl"
		);
		(typeof css).should.be.eql("string");
		css.should.match(/.other/);
		css.should.match(/font-family/);
	});
	it("stylus can find modules in node_modules", function() {
		var css = require("!raw-loader!../!./fixtures/import-fakenib.styl");
		(typeof css).should.be.eql("string");
		css.should.match(/.not-real-nib/);
	});
	it("resolve with webpack if stylus can't find it", function() {
		var css = require("!raw-loader!../!./fixtures/import-webpack.styl");
		(typeof css).should.be.eql("string");
		css.should.match(/.other/);
		css.should.match(/font-size/);
	});
	it("in a nested import load module from paths", function() {
		var css = require(
			"!raw-loader!../?paths=test/fixtures/paths!./fixtures/shallow-paths.styl"
		);
		(typeof css).should.be.eql("string");
		css.should.match(/.other/);
		css.should.match(/font-family/);
	});
	it("in a nested import load module from node_modules", function() {
		var css = require("!raw-loader!../!./fixtures/shallow-fakenib.styl");
		(typeof css).should.be.eql("string");
		css.should.match(/.not-real-nib/);
	});
	it("in a nested import load module from webpack", function() {
		var css = require("!raw-loader!../!./fixtures/shallow-webpack.styl");
		(typeof css).should.be.eql("string");
		css.should.match(/.other/);
		css.should.match(/font-size/);
	});
	it("resolves css with webpack but does not import it", function() {
		var css = require("!raw-loader!../!./fixtures/import-webpack-css.styl");
		(typeof css).should.be.eql("string");
		css.should.not.match(/\.imported-css/);
	});
	it("in a nested import resolve css with webpack but not import", function() {
		var css = require("!raw-loader!../!./fixtures/import-webpack-css.styl");
		(typeof css).should.be.eql("string");
		css.should.not.match(/\.imported-css/);
	});
	it("should allow stylus plugins to be configured in webpack.config.js", function() {
		var css = require("!raw-loader!../!./fixtures/webpack.config-plugin.styl");
		(typeof css).should.be.eql("string");
		css.should.match(/width:\s?100%;/);
	});
	it("correctly compiles mixin calls inside imported files", function () {
		var css = require("!raw-loader!../!./fixtures/import-mixins/index.styl");
		(typeof css).should.be.eql("string");
		var regexp = new RegExp('body{color:#639;}.rule{color:#639;}main{color:#639;}');
		css.replace(/\s/g, '').should.match(regexp);
	});
	it("should compile an @import URL through the CSS loader", function () {
		var css = require("!css-loader!../!./fixtures/import-google-font.styl");
		(typeof css).should.be.eql("string");
		css.should.be.eql('@import url(http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic);\n');
	});
});
<commit_msg>Fixing tests<commit_after>var should = require("should");

describe("basic", function() {
	it("should compile basic stylus", function() {
		var css = require("!raw-loader!../!./fixtures/basic.styl");
		(typeof css).should.be.eql("string");
		css.should.match(/font:\s?12px Helvetica,\s?Arial,\s?sans-serif;/);
		css.should.match(/-webkit-border-radius:\s?5px;/);
	});
	it("shouldn't import css", function() {
		var css = require("!raw-loader!../!./fixtures/import-css.styl");
		(typeof css).should.be.eql("string");
		css.should.not.match(/\.imported-css/);
	});
	it("should import css with the css-loader", function() {
		var css = require("!css-loader!../!./fixtures/import-css.styl").toString();
		(typeof css).should.be.eql("string");
		css.should.match(/\.imported-css/);
	});
	it("should import stylus", function() {
		var css = require("!css-loader!../!./fixtures/import-styl.styl").toString();
		(typeof css).should.be.eql("string");
		css.should.match(/\.imported-stylus/);
	});
	it("shouldn't process urls", function() {
		var css = require("!raw-loader!../!./fixtures/urls.styl");
		(typeof css).should.be.eql("string");
		css.should.match(/\url\(\"?img.png\"?\)/);
	});
	it("with option, should resolve urls relatively", function() {
		var css = require(
			"!raw-loader!../?{\"resolve url\":true}!./fixtures/shallow.styl"
		);
		(typeof css).should.be.eql("string");
		css.should.match(/\url\(\"img.png\"\)/);
		css.should.match(/\url\(\"deep\/deep-img.png\"\)/);
		css.should.match(/\url\(\"!!deep\/deep-img.png\"\)/);
		css.should.match(/\url\(\"file!deep\/deep-img.png\"\)/);
		css.should.match(/\url\(\"file\?foo!deep\/deep-img.png\"\)/);
	});
	it("with paths, find deps and load like normal stylus", function() {
		var css = require(
			"!raw-loader!../?paths=test/fixtures/paths!./fixtures/import-paths.styl"
		);
		(typeof css).should.be.eql("string");
		css.should.match(/.other/);
		css.should.match(/font-family/);
	});
	it("stylus can find modules in node_modules", function() {
		var css = require("!raw-loader!../!./fixtures/import-fakenib.styl");
		(typeof css).should.be.eql("string");
		css.should.match(/.not-real-nib/);
	});
	it("resolve with webpack if stylus can't find it", function() {
		var css = require("!raw-loader!../!./fixtures/import-webpack.styl");
		(typeof css).should.be.eql("string");
		css.should.match(/.other/);
		css.should.match(/font-size/);
	});
	it("in a nested import load module from paths", function() {
		var css = require(
			"!raw-loader!../?paths=test/fixtures/paths!./fixtures/shallow-paths.styl"
		);
		(typeof css).should.be.eql("string");
		css.should.match(/.other/);
		css.should.match(/font-family/);
	});
	it("in a nested import load module from node_modules", function() {
		var css = require("!raw-loader!../!./fixtures/shallow-fakenib.styl");
		(typeof css).should.be.eql("string");
		css.should.match(/.not-real-nib/);
	});
	it("in a nested import load module from webpack", function() {
		var css = require("!raw-loader!../!./fixtures/shallow-webpack.styl");
		(typeof css).should.be.eql("string");
		css.should.match(/.other/);
		css.should.match(/font-size/);
	});
	it("resolves css with webpack but does not import it", function() {
		var css = require("!raw-loader!../!./fixtures/import-webpack-css.styl");
		(typeof css).should.be.eql("string");
		css.should.not.match(/\.imported-css/);
	});
	it("in a nested import resolve css with webpack but not import", function() {
		var css = require("!raw-loader!../!./fixtures/import-webpack-css.styl");
		(typeof css).should.be.eql("string");
		css.should.not.match(/\.imported-css/);
	});
	it("should allow stylus plugins to be configured in webpack.config.js", function() {
		var css = require("!raw-loader!../!./fixtures/webpack.config-plugin.styl");
		(typeof css).should.be.eql("string");
		css.should.match(/width:\s?100%;/);
	});
	it("correctly compiles mixin calls inside imported files", function () {
		var css = require("!raw-loader!../!./fixtures/import-mixins/index.styl");
		(typeof css).should.be.eql("string");
		var regexp = new RegExp('body{color:#639;}.rule{color:#639;}main{color:#639;}');
		css.replace(/\s/g, '').should.match(regexp);
	});
	it("should compile an @import URL through the CSS loader", function () {
		var css = require("!css-loader!../!./fixtures/import-google-font.styl").toString();
		(typeof css).should.be.eql("string");
		css.should.be.eql('@import url(http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic);\n');
	});
});
<|endoftext|>


<commit_before>var drawScrollBar = function(canvas, context, scrollPosition, maxScroll){
	var height = 400;
	var width = 20;
	var distanceFromTop = 100;

	context.strokeStyle=staveColour;
	context.rect(canvas.width - width, distanceFromTop, width, height);
	context.stroke();

	context.beginPath();
	context.strokeStyle=noteColour;
	context.lineWidth =4;
	context.moveTo(canvas.width - width, scrollPosition * height / maxScroll + distanceFromTop);
	context.lineTo(canvas.width, scrollPosition * height / maxScroll + distanceFromTop);
	context.stroke();
	context.lineWidth = 1;
}
<commit_msg>Update scrollbar.js<commit_after>var isInScrollBar(canvas, context, x, y){
	var height = 400;
	var width = 20;
	var distanceFromTop = 100;

	return x > canvas.width - width && y > distanceFromTop && y < distanceFromTop + height;
}

var getScrollPositionFromScrollBar(canvas, context, y, maxScroll){
	var height = 400;
	var width = 20;
	var distanceFromTop = 100;

	return (y - distanceFromTop) * maxScroll / height;
}

var drawScrollBar = function(canvas, context, scrollPosition, maxScroll){
	var height = 400;
	var width = 20;
	var distanceFromTop = 100;

	context.strokeStyle=staveColour;
	context.rect(canvas.width - width, distanceFromTop, width, height);
	context.stroke();

	context.beginPath();
	context.strokeStyle=noteColour;
	context.lineWidth =4;
	context.moveTo(canvas.width - width, scrollPosition * height / maxScroll + distanceFromTop);
	context.lineTo(canvas.width, scrollPosition * height / maxScroll + distanceFromTop);
	context.stroke();
	context.lineWidth = 1;
}
<|endoftext|>


<commit_before>var json_driver = require("./json-driver");

function playlists_driver(type) {
    var self = this;

    this.driver                = undefined;
    this.newPlaylistCallback    = undefined;
    this.updatePlaylistCallback = undefined;
    this.removePlaylistCallback = undefined;
    this.playlistsProvider      = undefined;

    console.log("mbc-mosto: [INFO] Creating playlists driver for type [" + type + "]");

    if (type === 'json') {
        this.driver = new json_driver();
    } else {
        var err = new Error("mbc-mosto: [ERROR] Unknown type of driver [" + type + "]");
        console.error(err);
        throw err;
    }

    playlists_driver.prototype.start = function() {
        console.log("mbc-mosto: [INFO] Starting playlists driver");
        self.driver.start();
    };
    playlists_driver.prototype.registerNewPlaylistListener = function(newPlaylistCallback) {
        self.newPlaylistCallback = newPlaylistCallback;
        self.driver.registerNewPlaylistListener(self.addPlaylist);
    };
    playlists_driver.prototype.registerUpdatePlaylistListener = function(updatePlaylistCallback) {
        self.updatePlaylistCallback = updatePlaylistCallback;
        self.driver.registerUpdatePlaylistListener(self.updatePlaylist);
    };
    playlists_driver.prototype.registerRemovePlaylistListener = function(removePlaylistCallback) {
        self.removePlaylistCallback = removePlaylistCallback;
        self.driver.registerRemovePlaylistListener(self.removePlaylist);
    };
    playlists_driver.prototype.registerPlaylistsProvider = function(playlistsProvider) {
        self.driver.registerPlaylistsProvider(playlistsProvider);
    };

    playlists_driver.prototype.addPlaylist = function(playlist) {
        self.newPlaylistCallback(playlist);
    };
    playlists_driver.prototype.updatePlaylist = function(playlist) {
        self.updatePlaylistCallback(playlist);
    };
    playlists_driver.prototype.removePlaylist = function(playlist) {
        self.removePlaylistCallback(playlist);
    };

}

exports = module.exports = function(type) {
    var driver = new playlists_driver(type);
    return driver;
};
<commit_msg>Removed playlists provider since the intelligence of sync should be in the main class not in the driver<commit_after>var json_driver = require("./json-driver");

function playlists_driver(type) {
    var self = this;

    this.driver                = undefined;
    this.newPlaylistCallback    = undefined;
    this.updatePlaylistCallback = undefined;
    this.removePlaylistCallback = undefined;

    console.log("mbc-mosto: [INFO] Creating playlists driver for type [" + type + "]");

    if (type === 'json') {
        this.driver = new json_driver();
    } else {
        var err = new Error("mbc-mosto: [ERROR] Unknown type of driver [" + type + "]");
        console.error(err);
        throw err;
    }

    playlists_driver.prototype.start = function() {
        console.log("mbc-mosto: [INFO] Starting playlists driver");
        self.driver.start();
    };
    playlists_driver.prototype.registerNewPlaylistListener = function(newPlaylistCallback) {
        self.newPlaylistCallback = newPlaylistCallback;
        self.driver.registerNewPlaylistListener(self.addPlaylist);
    };
    playlists_driver.prototype.registerUpdatePlaylistListener = function(updatePlaylistCallback) {
        self.updatePlaylistCallback = updatePlaylistCallback;
        self.driver.registerUpdatePlaylistListener(self.updatePlaylist);
    };
    playlists_driver.prototype.registerRemovePlaylistListener = function(removePlaylistCallback) {
        self.removePlaylistCallback = removePlaylistCallback;
        self.driver.registerRemovePlaylistListener(self.removePlaylist);
    };

    playlists_driver.prototype.addPlaylist = function(playlist) {
        self.newPlaylistCallback(playlist);
    };
    playlists_driver.prototype.updatePlaylist = function(playlist) {
        self.updatePlaylistCallback(playlist);
    };
    playlists_driver.prototype.removePlaylist = function(playlist) {
        self.removePlaylistCallback(playlist);
    };

}

exports = module.exports = function(type) {
    var driver = new playlists_driver(type);
    return driver;
};
<|endoftext|>


<commit_before>var assert = require('assert');
var numbers = require('../index.js');
var basic = numbers.basic;

suite('numbers', function() {

  console.log('\n\n\033[34mTesting Standard Mathematics\033[0m');

  // basic.sum
  test('sum should return the sum of items in an array', function (done) {
    assert.equal(6, basic.sum([0,1,2,3]));
    assert.equal(0, basic.sum([0,-3,5,-2]));
    done();
  });

  test('sum should throw an exception when given anything but an array', function (done) {
    assert.throws(
      function() {
        basic.sum(1);
      },
      /Input must be of type Array/
    );
    done();
  });

  test('sum should throw an exception when given anything objects other than numbers', function (done) {
    assert.throws(
      function() {
        basic.sum([1,2,"error"]);
      },
      /All elements in array must be numbers/
    );
    done();
  });

  // basic.substraction
  test('subtraction should return the difference of items in an array', function (done) {
    assert.equal(0, basic.subtraction([0,1,2,3]));
    done();
  });

  test('subtraction should throw an exception when given anything but an array', function (done) {
    assert.throws(
      function() {
        basic.subtraction(1);
      },
      /Input must be of type Array/
    );
    done();
  });

  test('subtraction should throw an exception when given anything objects other than numbers', function (done) {
    assert.throws(
      function() {
        basic.subtraction(["test",1,1,2]);
      },
      /All elements in array must be numbers/
    );
    done();
  });

  // basic.product
  test('product should return the product of items in an array', function (done) {
    assert.equal(24, basic.product([1,2,3,4]));
    assert.equal(-6, basic.product([-3,2]));
    done();
  });

  test('product should throw an exception when given anything but an array', function (done) {
    assert.throws(
      function() {
        basic.product(1);
      },
      /Input must be of type Array/
    );
    done();
  });

  test('product should throw an exception when given anything objects other than numbers', function (done) {
    assert.throws(
      function() {
        basic.product([1,2,"error"]);
      },
      /All elements in array must be numbers/
    );
    done();
  });

  test('square should return the square of a number', function(done) {
    assert.equal(16, basic.square(4));
    done();
  });

  // basic.binomial
  test('binomial should return the binomial coefficient (n choose k) of two numbers', function(done) {
    assert.equal(10, basic.binomial(5, 3));
    done();
  });

  // basic.factorial
  test('factorial should return the product of n * (n - 1) * (n - 2) * ... * 1', function (done) {
    assert.equal(24, basic.factorial(4));
    assert.equal(120, basic.factorial(5));
    done();
  });

  // basic.gcd
  test('gcd should return the greatest common denominator of two integers', function (done) {
    assert.equal(6, basic.gcd(1254, 5298));
    assert.equal(1, basic.gcd(78699786, 78978965));
    done();
  });

  // basic.lcm
  test('lcm should return the least common multiple of two integers', function (done) {
    assert.equal(240, basic.lcm(12, 80));
    done();
  });

  // basic.max
  test('max should return the biggest number in an array', function (done) {
    assert.equal(42, basic.max([1,2,3,42]));
    done();
  });

  // basic.min
  test('min should return the smallest number in an array', function (done) {
    assert.equal(1, basic.min([2,1,3,42]));
    done();
  });

  // basic.range
  test('range should return an appropriate range for the given start, stop, and step parameters', function (done) {
    assert.deepEqual([1,2,3,4,5,6,7,8,9,10],basic.range(1,10));
    assert.deepEqual([10,9,8,7,6,5,4,3,2,1],basic.range(10,1));
    assert.deepEqual([1,1.5,2,2.5,3,3.5,4,4.5,5],basic.range(1,5,.5));
    assert.deepEqual([5,4.5,4,3.5,3,2.5,2,1.5,1],basic.range(5,1,.5));
    done();

  });

  // basic.isInt
  test('isInt checks for an integer', function (done) {
    assert.equal(false, basic.isInt(2.32));
    assert.equal(false, basic.isInt("true"));
    assert.equal(true, basic.isInt("2")); //based off impelementation change
    assert.equal(true, basic.isInt(2));
    done();
  });

  // basic.divMod
  test('divMod should return an array of both the division and modulus values of two integers', function (done) {
    assert.deepEqual([2, 0], basic.divMod(12, 6));
    assert.deepEqual([3, 1], basic.divMod(10, 3));
    done();
  });

  // basic.egcd
  test('egcd should return the array [a, x, y] which is the solved linear equation for GCD', function(done) {
    assert.deepEqual([5, -3, 5], basic.egcd(65, 40));
    assert.deepEqual([5, 5, -3], basic.egcd(40, 65));
    assert.deepEqual([21, -16, 27], basic.egcd(1239, 735));
    assert.deepEqual([21, 5, -2], basic.egcd(105, 252));
    assert.deepEqual([21, -2, 5], basic.egcd(252, 105));
    done();
  });

  // basic.modInverse
  test('modInverse will return the modulo m inverse of a', function(done) {
    assert.equal(1, basic.modInverse(1, 5));
    done();
  });

  test('modInverse will throw an exception if no modular inverse exists', function(done) {
    assert.throws(
      function() {
        basic.modInverse(65, 40);
      },
      /No modular inverse exists/
    );
    done();
  });

  // basic.powerMod
  test('powerMod should return the answer to a^b mod m', function (done) {
    assert.equal(1, basic.powerMod(1, -1, 5));
    assert.equal(1, basic.powerMod(2, 10, 3));
    assert.equal(16, basic.powerMod(2, Math.pow(10, 9), 18));
    assert.equal(6, basic.powerMod(6, .5, 10));
    done();
  });

});

<commit_msg>Add powerMod test from https://github.com/sjkaliski/numbers.js/pull/60<commit_after>var assert = require('assert');
var numbers = require('../index.js');
var basic = numbers.basic;

suite('numbers', function() {

  console.log('\n\n\033[34mTesting Standard Mathematics\033[0m');

  // basic.sum
  test('sum should return the sum of items in an array', function (done) {
    assert.equal(6, basic.sum([0,1,2,3]));
    assert.equal(0, basic.sum([0,-3,5,-2]));
    done();
  });

  test('sum should throw an exception when given anything but an array', function (done) {
    assert.throws(
      function() {
        basic.sum(1);
      },
      /Input must be of type Array/
    );
    done();
  });

  test('sum should throw an exception when given anything objects other than numbers', function (done) {
    assert.throws(
      function() {
        basic.sum([1,2,"error"]);
      },
      /All elements in array must be numbers/
    );
    done();
  });

  // basic.substraction
  test('subtraction should return the difference of items in an array', function (done) {
    assert.equal(0, basic.subtraction([0,1,2,3]));
    done();
  });

  test('subtraction should throw an exception when given anything but an array', function (done) {
    assert.throws(
      function() {
        basic.subtraction(1);
      },
      /Input must be of type Array/
    );
    done();
  });

  test('subtraction should throw an exception when given anything objects other than numbers', function (done) {
    assert.throws(
      function() {
        basic.subtraction(["test",1,1,2]);
      },
      /All elements in array must be numbers/
    );
    done();
  });

  // basic.product
  test('product should return the product of items in an array', function (done) {
    assert.equal(24, basic.product([1,2,3,4]));
    assert.equal(-6, basic.product([-3,2]));
    done();
  });

  test('product should throw an exception when given anything but an array', function (done) {
    assert.throws(
      function() {
        basic.product(1);
      },
      /Input must be of type Array/
    );
    done();
  });

  test('product should throw an exception when given anything objects other than numbers', function (done) {
    assert.throws(
      function() {
        basic.product([1,2,"error"]);
      },
      /All elements in array must be numbers/
    );
    done();
  });

  test('square should return the square of a number', function(done) {
    assert.equal(16, basic.square(4));
    done();
  });

  // basic.binomial
  test('binomial should return the binomial coefficient (n choose k) of two numbers', function(done) {
    assert.equal(10, basic.binomial(5, 3));
    done();
  });

  // basic.factorial
  test('factorial should return the product of n * (n - 1) * (n - 2) * ... * 1', function (done) {
    assert.equal(24, basic.factorial(4));
    assert.equal(120, basic.factorial(5));
    done();
  });

  // basic.gcd
  test('gcd should return the greatest common denominator of two integers', function (done) {
    assert.equal(6, basic.gcd(1254, 5298));
    assert.equal(1, basic.gcd(78699786, 78978965));
    done();
  });

  // basic.lcm
  test('lcm should return the least common multiple of two integers', function (done) {
    assert.equal(240, basic.lcm(12, 80));
    done();
  });

  // basic.max
  test('max should return the biggest number in an array', function (done) {
    assert.equal(42, basic.max([1,2,3,42]));
    done();
  });

  // basic.min
  test('min should return the smallest number in an array', function (done) {
    assert.equal(1, basic.min([2,1,3,42]));
    done();
  });

  // basic.range
  test('range should return an appropriate range for the given start, stop, and step parameters', function (done) {
    assert.deepEqual([1,2,3,4,5,6,7,8,9,10],basic.range(1,10));
    assert.deepEqual([10,9,8,7,6,5,4,3,2,1],basic.range(10,1));
    assert.deepEqual([1,1.5,2,2.5,3,3.5,4,4.5,5],basic.range(1,5,.5));
    assert.deepEqual([5,4.5,4,3.5,3,2.5,2,1.5,1],basic.range(5,1,.5));
    done();

  });

  // basic.isInt
  test('isInt checks for an integer', function (done) {
    assert.equal(false, basic.isInt(2.32));
    assert.equal(false, basic.isInt("true"));
    assert.equal(true, basic.isInt("2")); //based off impelementation change
    assert.equal(true, basic.isInt(2));
    done();
  });

  // basic.divMod
  test('divMod should return an array of both the division and modulus values of two integers', function (done) {
    assert.deepEqual([2, 0], basic.divMod(12, 6));
    assert.deepEqual([3, 1], basic.divMod(10, 3));
    done();
  });

  // basic.egcd
  test('egcd should return the array [a, x, y] which is the solved linear equation for GCD', function(done) {
    assert.deepEqual([5, -3, 5], basic.egcd(65, 40));
    assert.deepEqual([5, 5, -3], basic.egcd(40, 65));
    assert.deepEqual([21, -16, 27], basic.egcd(1239, 735));
    assert.deepEqual([21, 5, -2], basic.egcd(105, 252));
    assert.deepEqual([21, -2, 5], basic.egcd(252, 105));
    done();
  });

  // basic.modInverse
  test('modInverse will return the modulo m inverse of a', function(done) {
    assert.equal(1, basic.modInverse(1, 5));
    done();
  });

  test('modInverse will throw an exception if no modular inverse exists', function(done) {
    assert.throws(
      function() {
        basic.modInverse(65, 40);
      },
      /No modular inverse exists/
    );
    done();
  });

  // basic.powerMod
  test('powerMod should return the answer to a^b mod m', function (done) {
    assert.equal(1, basic.powerMod(1, -1, 5));
    assert.equal(1, basic.powerMod(2, 10, 3));
    assert.equal(16, basic.powerMod(2, Math.pow(10, 9), 18));
    assert.equal(6, basic.powerMod(6, .5, 10));
    assert.equal(445, basic.powerMod(4, 13, 497));
    done();
  });

});

<|endoftext|>


<commit_before>import { test } from 'qunit';
import moduleForAcceptance from 'ember-2015-tdd-by-example/tests/helpers/module-for-acceptance';

moduleForAcceptance('Acceptance | assignment');

test('visiting /assignment', function(assert) {
  visit('/');

  andThen(function() {
    var unassigned = find('.unassigned .cards');
    assert.equal(unassigned.length, 3);
    var project = find('.unassigned .cards:eq(0) .todo_project');
    assert.equal(project.text(), 'first');
  });
});

test('assigned items are grouped together', function(assert) {
  visit('/');

  andThen(function() {
    var assigned = find('.assigned .cards');
    assert.equal(assigned.length, 1);
    var project = find('.assigned .cards:eq(0) .todo_project');
    assert.equal(project.text(), 'last');
  });
});
<commit_msg>Check for status<commit_after>import { test } from 'qunit';
import moduleForAcceptance from 'ember-2015-tdd-by-example/tests/helpers/module-for-acceptance';

moduleForAcceptance('Acceptance | assignment');

test('visiting /assignment', function(assert) {
  visit('/');
  andThen(function() {
    var unassigned = find('.unassigned .cards');
    assert.equal(unassigned.length, 3);
    var project = find('.unassigned .cards:eq(0) .todo_project');
    assert.equal(project.text(), 'first');
  });
});

test('assigned items are grouped together', function(assert) {
  visit('/');
  andThen(function() {
    var assigned = find('.assigned .cards');
    assert.equal(assigned.length, 1);
    var project = find('.assigned .cards:eq(0) .todo_project');
    assert.equal(project.text(), 'last');
  });
});

test('status is shown in plain english', function(assert) {
  visit('/');
  andThen(function() {
    var status = find('.assigned .cards:eq(0) .todo_status');
    assert.equal(status.text(), 'Assigned');
  });
});
<|endoftext|>