<commit_before>
function Help () {
	
	this.HELP_POPUP_COUNT = 5

}


//find a line close to the starting tree that is > min length, and add the popover to it
//for both red and blue
// breath first search using stack
Help.prototype.showInitialPrereqHelp = function(tree) {

	var foundRed=false;
	var foundBlue=false;

	var stack = [tree];
	while (stack.length>0) {


		// remove the first element
		var currTree = stack.shift();

		if (currTree.values) {
			stack = stack.concat(currTree.values)
		}

		//the top most panel has no parent
		if (!currTree.lowestParent) {
			continue
		};


		if (currTree.lineToParent.offsetWidth>250) {
			

			//show max 1 of each type
			if (currTree.lowestParent.type=='or') {
				if (foundBlue) {
					continue;
				}
				else {
					foundBlue = true;
				}
			}

			if (currTree.lowestParent.type == 'and') {
				if (foundRed) {
					continue;
				}
				else {
					foundRed = true;
				}
			};



			//get midpoint of line
			var lineCoords = currTree.lineToParent.getBoundingClientRect();
			
			var panelCoords = currTree.panel.getBoundingClientRect();

			//put the help 200px away from the panel
			if (lineCoords.width>400) {

				//need to figure out if line goes up/right or up/left
				var lineCenter = lineCoords.left+lineCoords.width/2;
				var panelCenter = panelCoords.left + lineCoords.width/2;


				var x;
				var y;
				var percent;
				//line goes up/right
				if (lineCenter>panelCenter) {
					x = lineCoords.right - 200;
					percent = 1-(x-lineCoords.left)/lineCoords.width;
					// console.log('line was up/right')
				}

				//line goes up/left, get offset left+200
				else {
					x = lineCoords.left + 200;
					percent = (x-lineCoords.left)/lineCoords.width;
					// console.log('line was up/left')
				}

				// percent=percent*2-.2;
				y = percent*lineCoords.height+lineCoords.top;

				//move the panel down a little
				// y+=100;

				// console.log('setting to ',x,y,percent)
				this.activateHelpPopup(currTree,x,y);

			}
			else {
				//put the help in the middle of the line
				this.activateHelpPopup(currTree,lineCoords.left+lineCoords.width/2,lineCoords.top+lineCoords.height/2);
				
			}
		}

		if (foundRed && foundBlue) {
			return;
		};
	}
}
Help.prototype.activateHelpPopup = function(tree,x,y) {
	
	if (tree.allParents[0].type=='or'){
		if (localStorage.orPopupCount>this.HELP_POPUP_COUNT) {
			return;<commit_msg>progress not showing when lines hidden, but computed before display =none<commit_after>
function Help () {
	
	this.HELP_POPUP_COUNT = 5

}


//find a line close to the starting tree that is > min length, and add the popover to it
//for both red and blue
// breath first search using stack
Help.prototype.showInitialPrereqHelp = function(tree) {

	//if visit the site a lot, dont compute where we need to put the popups
	if (localStorage.orPopupCount>this.HELP_POPUP_COUNT && localStorage.andPopupCount>this.HELP_POPUP_COUNT) {
		return;
	};
	

	var foundRed=false;
	var foundBlue=false;

	var stack = [tree];
	while (stack.length>0) {


		// remove the first element
		var currTree = stack.shift();

		if (currTree.values) {
			stack = stack.concat(currTree.values)
		}

		//the top most panel has no parent
		if (!currTree.lowestParent) {
			continue
		};


		if (currTree.lineToParent.offsetWidth>250) {
			

			//show max 1 of each type
			if (currTree.lowestParent.type=='or') {
				if (foundBlue) {
					continue;
				}
				else {
					foundBlue = true;
				}
			}

			if (currTree.lowestParent.type == 'and') {
				if (foundRed) {
					continue;
				}
				else {
					foundRed = true;
				}
			};



			//get midpoint of line
			var lineCoords = currTree.lineToParent.getBoundingClientRect();
			
			var panelCoords = currTree.panel.getBoundingClientRect();

			//put the help 200px away from the panel
			if (lineCoords.width>400) {

				//need to figure out if line goes up/right or up/left
				var lineCenter = lineCoords.left+lineCoords.width/2;
				var panelCenter = panelCoords.left + lineCoords.width/2;


				var x;
				var y;
				var percent;
				//line goes up/right
				if (lineCenter>panelCenter) {
					x = lineCoords.right - 200;
					percent = 1-(x-lineCoords.left)/lineCoords.width;
				}

				//line goes up/left, get offset left+200
				else {
					x = lineCoords.left + 200;
					percent = (x-lineCoords.left)/lineCoords.width;
				}

				y = percent*lineCoords.height+lineCoords.top;
				this.activateHelpPopup(currTree,x,y);

			}
			else {
				//put the help in the middle of the line
				this.activateHelpPopup(currTree,lineCoords.left+lineCoords.width/2,lineCoords.top+lineCoords.height/2);
				
			}
		}

		if (foundRed && foundBlue) {
			return;
		};
	}
}
Help.prototype.activateHelpPopup = function(tree,x,y) {

	if (tree.lineToParentLink.style.display=='none') {
		return
	}
	
	if (tree.allParents[0].type=='or'){
		if (localStorage.orPopupCount>this.HELP_POPUP_COUNT) {
			return;
{'fraction_non_alphanumeric': 0.11881993896236012, 'fraction_numerical': 0.01200406917599186, 'mean_word_length': 2.8020108275328695, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1957634', 'n_tokens_mistral': 2113, 'n_tokens_neox': 1691, 'n_words': 408}