<commit_before>// jQuery reqs
if (typeof jQuery == 'undefined') {
	throw new Error("ƒ missing jQuery!");
} else {
	if (jQuery().jquery < '1.4.1') {
		throw new Error("ƒ jQuery >= 1.4.1 required");
	}
}
// the prefix
var im;
if (!im) {
    im = {};
    if (window.console && window.console.firebug) { // 'attach' Firebug
    	console.log("ƒ InterMine JavaScript Library loaded");
    	im.firebug = true;
    	jQuery.error = console.error;
    }
} else if (typeof org != 'object') throw new Error("ƒ InterMine JavaScript Library cannot be loaded, 'var im' is already in use");

//check if element exists
im.exists = function(e) {
	return (jQuery(e).length > 0);
};

// (on all IE only), will apply .odd/.even classes to "known" tables (see Wiki for those)
im.alternatingColors = function() {
	if (jQuery.browser.msie) {
		jQuery.each(['collection-table'], function(index, imTable) {
			jQuery('div.' + imTable + ' table tbody tr:nth-child(2n)').addClass('odd');
			jQuery('div.' + imTable + '.column-border table tbody tr td:nth-child(n+2)').addClass('left-column-border');
			jQuery('div.' + imTable + '.column-border-by-2 table tbody tr td:nth-child(2n+3)').addClass('left-column-border');
		});
	}
};

// will turn thead.persistent into persistent header 
im.persistentTableHeaders = function(e) {
	
	function makeEm(collection) {
		var collection = jQuery(collection),
			table 	   = collection.find('table'),
			head  	   = table.find('thead tr');
		// continue only if we have exactly one <tr> element in the head
		// ... and at least two elements in the actual table
		if (head.length == 1 && table.find('tbody tr').length > 1) {
			// duplicate the row and apply different classes to static/fixed positioned elements
			fixed = head.addClass('static-header').clone().attr('class', 'fixed-header').appendTo(head.parent());
			// apply fixed positioning
			fixed.css({'position':'fixed', 'top':'21px', 'z-index':2, 'width':"100%"}).hide();
			
			// now we need to fix the width of the columns much like in the original head
			head.find('th').each(function(i) {				
				jQuery(fixed.find('th')[i]).css('width', jQuery(this).width());
			});
		}		
	}
	
	function monitorEm(collection) {
		var collection = jQuery(collection);
		collection.find('div.toggle').click(function() {
			// ... and resize the head as we have different number of rows now
			var head = collection.find('table thead');
			
			head.find('tr.static-header th').each(function(i) {
				jQuery(head.find('tr.fixed-header th')[i]).css('width', jQuery(this).width());
			});
		});		
	}
	
	// undefined, grab them all
	if (e == undefined) {
		// traverse all 'collection' tables that have a .persistent class
		// monitor the showing/hiding of table rows throw more/collapse
		jQuery('div.collection-table.persistent').each(function(i) {
			makeEm(this);
			monitorEm(this);
		});
	} else {
		// make them and monitor them e
		makeEm(e);
		monitorEm(e);
	}
	
	// monitor scroll events and see if we no longer see the static one
	jQuery(window).scroll(function() {
		jQuery('div.collection-table.persistent').each(function(i) {
			var table  = jQuery(this).find('table'),
				offset = table.offset(),
				top    = jQuery(window).scrollTop() + 21,
				fixed  = table.find('thead tr.fixed-header');
		
			// then swap the 'visibility' of the fixed head
			if (table.length > 0) {
				if ((top > offset.top) && (top < offset.top + table.height() - fixed.height())) {
					if (!fixed.is(':visible')) {
						fixed.show();
						
						// recalculate their width for good measure
						table.find('thead tr.static-header th').each(function(i) {
							jQuery(table.find('thead tr.fixed-header th')[i]).css('width', jQuery(this).width());
						});
					}
				} else {
					fixed.hide();
				}
			}
		});
	}).trigger("scroll");
}
<commit_msg>onscroll event only if we have anything to monitor<commit_after>// jQuery reqs
if (typeof jQuery == 'undefined') {
	throw new Error("ƒ missing jQuery!");
} else {
	if (jQuery().jquery < '1.4.1') {
		throw new Error("ƒ jQuery >= 1.4.1 required");
	}
}
// the prefix
var im;
if (!im) {
    im = {};
    if (window.console && window.console.firebug) { // 'attach' Firebug
    	console.log("ƒ InterMine JavaScript Library loaded");
    	im.firebug = true;
    	jQuery.error = console.error;
    }
} else if (typeof org != 'object') throw new Error("ƒ InterMine JavaScript Library cannot be loaded, 'var im' is already in use");

//check if element exists
im.exists = function(e) {
	return (jQuery(e).length > 0);
};

// (on all IE only), will apply .odd/.even classes to "known" tables (see Wiki for those)
im.alternatingColors = function() {
	if (jQuery.browser.msie) {
		jQuery.each(['collection-table'], function(index, imTable) {
			jQuery('div.' + imTable + ' table tbody tr:nth-child(2n)').addClass('odd');
			jQuery('div.' + imTable + '.column-border table tbody tr td:nth-child(n+2)').addClass('left-column-border');
			jQuery('div.' + imTable + '.column-border-by-2 table tbody tr td:nth-child(2n+3)').addClass('left-column-border');
		});
	}
};

// will turn thead.persistent into persistent header 
im.persistentTableHeaders = function(e) {
	
	function makeEm(collection) {
		var collection = jQuery(collection),
			table 	   = collection.find('table'),
			head  	   = table.find('thead tr');
		// continue only if we have exactly one <tr> element in the head
		// ... and at least two elements in the actual table
		if (head.length == 1 && table.find('tbody tr').length > 1) {
			// duplicate the row and apply different classes to static/fixed positioned elements
			fixed = head.addClass('static-header').clone().attr('class', 'fixed-header').appendTo(head.parent());
			// apply fixed positioning
			fixed.css({'position':'fixed', 'top':'21px', 'z-index':2, 'width':"100%"}).hide();
			
			// now we need to fix the width of the columns much like in the original head
			head.find('th').each(function(i) {				
				jQuery(fixed.find('th')[i]).css('width', jQuery(this).width());
			});
		}		
	}
	
	function monitorEm(collection) {
		var collection = jQuery(collection);
		collection.find('div.toggle').click(function() {
			// ... and resize the head as we have different number of rows now
			var head = collection.find('table thead');
			
			head.find('tr.static-header th').each(function(i) {
				jQuery(head.find('tr.fixed-header th')[i]).css('width', jQuery(this).width());
			});
		});		
	}
	
	// undefined, grab them all
	if (e == undefined) {
		// traverse all 'collection' tables that have a .persistent class
		// monitor the showing/hiding of table rows throw more/collapse
		jQuery('div.collection-table.persistent').each(function(i) {
			makeEm(this);
			monitorEm(this);
		});
	} else {
		// make them and monitor them e
		makeEm(e);
		monitorEm(e);
	}
	
	// monitor scroll events and see if we no longer see the static one
	if (jQuery('div.collection-table.persistent').length > 0) {
		jQuery(window).scroll(function() {
			jQuery('div.collection-table.persistent').each(function(i) {
				var table  = jQuery(this).find('table'),
					offset = table.offset(),
					top    = jQuery(window).scrollTop() + 21,
					fixed  = table.find('thead tr.fixed-header');
			
				// then swap the 'visibility' of the fixed head
				if (table.length > 0) {
					if ((top > offset.top) && (top < offset.top + table.height() - fixed.height())) {
						if (!fixed.is(':visible')) {
							fixed.show();
							
							// recalculate their width for good measure
							table.find('thead tr.static-header th').each(function(i) {
								jQuery(table.find('thead tr.fixed-header th')[i]).css('width', jQuery(this).width());
							});
						}
					} else {
						fixed.hide();
					}
				}
			});
		}).trigger("scroll");
	}
}

{'fraction_non_alphanumeric': 0.16996251777174615, 'fraction_numerical': 0.0060747059583818016, 'mean_word_length': 3.320491345616974, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 16, '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': '2887314', 'n_tokens_mistral': 2784, 'n_tokens_neox': 2415, 'n_words': 661}