<commit_before>//Global variables
var destiations = {};
var targets = {};
var links = [];
var timer;

//Resets the timer and causes populateDestinations() to be called after a delay
function resetDestinations(){
	destinations = {};
	if(timer){
		clearTimeout(timer);
	}
	timer = setTimeout(populateDestinations, 50);
}

//Populates the list of destinations
function populateDestinations(){ 

	//Reset the timer
	if(timer){
		clearTimeout(timer);
	}
	timer = null;
	
	//Reset the list of destinations
	destinations = {
		prev: null,
		next: null,
		up: null,
		top: null
	};
	targets = {
		prev: null,
		next: null,
		up: null,
		top: null
	};
	
	//Search through elements in document order
	links = [].concat(
		Array.prototype.slice.call(document.getElementsByTagName("LINK")),
		Array.prototype.slice.call(document.getElementsByTagName("A"))
	);
	
	//Determine the destinations of the rels we care about
	for(var i in links){
		if(!links[i].rel || !links[i].href) continue;
		for(var dest in destinations){
			if(links[i].rel.toLowerCase() == dest){
				destinations[dest] = links[i].href;
				if(links[i].tagName == "A") targets[dest] = links[i];
			}
		}
	}
	
	//Flip the links to now search bottom-up
	links = links.reverse();
	
	//Search for destinations based on link contents
	for(var dest in destinations){
	
		//Skip destinations that have already been matched to an A-link
		if(destinations[dest] && targets[dest]) continue;
	
		//Track an expression matching array
		var regexes = [];
	
		if(dest == "next"){
			regexes.push(/^next/i);
		}
		if(dest == "prev"){
			regexes.push(/^prev/i);
		}
		if(dest == "up"){
			regexes.push(/^up\b/i);
		}
		if(dest == "top"){
			regexes.push(/^home/i);
		}
	
		//Attempt to match links based on text (first match wins)
		(function(){
			for(var r in regexes){
				for(var i in links){
					if(links[i].href && links[i].innerText.replace(/[^a-z]/i, "").trim().match(regexes[r])){
						destinations[dest] = links[i].href;
						targets[dest] = links[i];
						return;
					}
				}
			}
		})();
	
	}

}
	
//Keyboard event handler
function keyListener(e){

	//Assume windows settings by default
	var cmdKey = e.ctrlKey;
	var ignoreKey = e.altKey;
	
	//Detect the shortcut sequence based on OS<commit_msg>Can now pick up nav links based on class name<commit_after>//Global variables
var destiations = {};
var targets = {};
var links = [];
var timer;

//Resets the timer and causes populateDestinations() to be called after a delay
function resetDestinations(){
	destinations = {};
	if(timer){
		clearTimeout(timer);
	}
	timer = setTimeout(populateDestinations, 50);
}

//Populates the list of destinations
function populateDestinations(){ 

	//Reset the timer
	if(timer){
		clearTimeout(timer);
	}
	timer = null;
	
	//Reset the list of destinations
	destinations = {
		prev: null,
		next: null,
		up: null,
		top: null
	};
	targets = {
		prev: null,
		next: null,
		up: null,
		top: null
	};
	
	//Search through elements in document order
	links = [].concat(
		Array.prototype.slice.call(document.getElementsByTagName("LINK")),
		Array.prototype.slice.call(document.getElementsByTagName("A"))
	);
	
	//Determine the destinations of the rels we care about
	for(var i in links){
		if(!links[i].rel || !links[i].href) continue;
		for(var dest in destinations){
			if(links[i].rel.toLowerCase() == dest){
				destinations[dest] = links[i].href;
				if(links[i].tagName == "A") targets[dest] = links[i];
			}
		}
	}
	
	//Flip the links to now search bottom-up
	links = links.reverse();
	
	//Search for destinations based on link contents
	for(var dest in destinations){
	
		//Skip destinations that have already been matched to an A-link
		if(destinations[dest] && targets[dest]) continue;
	
		//Track an expression matching array
		var regexes = [];
	
		if(dest == "next"){
			regexes.push(/^next/i);
		}
		if(dest == "prev"){
			regexes.push(/^prev/i);
		}
		if(dest == "up"){
			regexes.push(/^up\b/i);
		}
		if(dest == "top"){
			regexes.push(/^home/i);
		}
	
		//Attempt to match links based on text or class name (first match wins)
		(function(){
			for(var r in regexes){
				for(var i in links){
					if(
						links[i].href 
						&& (
							links[i].innerText.replace(/[^a-z]/i, "").trim().match(regexes[r])
							|| links[i].className.trim().match(regexes[r])
						)
					){
						destinations[dest] = links[i].href;
						targets[dest] = links[i];
						return;
					}
				}
			}
		})();
	
	}

}
	
//Keyboard event handler
function keyListener(e){

	//Assume windows settings by default
	var cmdKey = e.ctrlKey;
	var ignoreKey = e.altKey;
	
	//Detect the shortcut sequence based on OS
{'fraction_non_alphanumeric': 0.15190691661279895, 'fraction_numerical': 0.0008618832148243913, 'mean_word_length': 3.250915750915751, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5585152', 'n_tokens_mistral': 1819, 'n_tokens_neox': 1541, 'n_words': 427}