<commit_before>/**
 * UTILTY FUNCTIONS
 * 
 * @author <NAME> 12-05-2009
 * 
 * Big Block Framework
 * Copyright (C) 2011 Foldi, LLC
 * 
 */
						
Math.degreesToRadians = function (degrees) {	
	return (Math.PI / 180.0) * degrees;
};
	
Math.radiansToDegrees = function (radians) {	
	return (180.0 / Math.PI) * radians;
};

Math.getRandomNumber = function (low, high) {
	return Math.floor(Math.random()*(high-(low-1))) + low;
};

Math.getDistanceBwTwoPts = function (x1, y1, x2, y2) {	
	d = Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2));	
	return d;
};

BigBlock.clone = function(object) {
    function F() {}
    F.prototype = object;
    return F;
};
/**
 * Returns the grid index of the x,y coordinate
 * 
 * @param {Number} x
 * @param {Number} y
 */
BigBlock.getPixIndex = function (x,y) {
	
	// uses BigBlock.Grid.width/2; = quad width
	// uses BigBlock.Grid.height/2; = quad height
	// uses BigBlock.Grid.total_quad_cols = total quad grid columns
	
	if (x >= BigBlock.Grid.width/2) {
		x -= BigBlock.Grid.width/2;
	}
	
	if (y >= BigBlock.Grid.height/2) {
		y -= BigBlock.Grid.height/2;
	}	
		
	var target_x = Math.floor(x / BigBlock.Grid.blk_dim);
	var target_y = Math.floor(y / BigBlock.Grid.blk_dim);
	
	return target_x + (BigBlock.Grid.total_quad_cols * target_y);
			
};

/**
 * Returns the global x,y coordinate of a block based on its Block's pix_index 
 * @param {String} type
 * @param {Number} val
 * @param {Number} pix_index_offset
 * 
 */	
BigBlock.getPixLoc = function (type, val, pix_index_offset) {
	
	// uses Math.round(BigBlock.Grid.width/BigBlock.Grid.blk_dim); = total global grid columns
	var loc;
	if (type === 'x') {
		pix_index_offset = pix_index_offset % BigBlock.Grid.total_global_cols;
		loc = val + (pix_index_offset * BigBlock.Grid.blk_dim);
	}
	
	if (type === 'y') {
		var offset_y;
		if (pix_index_offset > 0) {
			offset_y = Math.floor(pix_index_offset / BigBlock.Grid.total_global_cols);
		} else {
			offset_y = Math.ceil(pix_index_offset / BigBlock.Grid.total_global_cols);
		}
		
		loc = val + (offset_y * BigBlock.Grid.blk_dim);
	}	
	return loc;
};		

/**
 * Returns the column index of a Block based on its x, y coordinate. 
 * @param {Number} x
 * @param {Number} y
 * 
 */	
BigBlock.getColIndex = function (x, y) {
	var totalCols = BigBlock.Grid.width/BigBlock.Grid.blk_dim;
	return BigBlock.getFullGridIndex(x, y) % totalCols;
};

/**
 * Returns the index of a Block based on its x, y coordinate relative to the full viewport. 
 * @param {Number} x
 * @param {Number} y
 * 
 */	
BigBlock.getFullGridIndex = function (x, y) {
	if (BigBlock.Grid.blk_dim !== 0) {
				
		var target_x = Math.floor(x / BigBlock.Grid.blk_dim);
		var target_y = Math.floor(y / BigBlock.Grid.blk_dim);
		
		return target_x + (Math.round((BigBlock.Grid.width)/BigBlock.Grid.blk_dim) * target_y);
	} else {
		return 1;
	}				
};
/**
 * Returns the first index of the passed alias in the Blocks array.  
 * 
 * @param {String} alias
 */
BigBlock.getBlock = function (alias) {
	var i;
	for (i = 0; i < BigBlock.Blocks.length; i++) {
		if (BigBlock.Blocks[i].alias === alias) {
			return i;
		}
	}
	return false;
};
/**
 * Returns the first index of the passed word_id in the Blocks array.
 * 
 * @param {String} word_id
 */
BigBlock.getWord = function (word_id) {
	var i;
	for (i = 0; i < BigBlock.Blocks.length; i++) {
		if (BigBlock.Blocks[i].word_id === word_id) {
			return i;
		}
	}
	return false;
};
/**
 * Remove static Blocks from Static Grid.
 * 
 * @param {String} alias
 * @param {Function} callback
 */
BigBlock.removeStaticBlock = function (alias, callback) { 
	
	var i, x, y, gs, nodes, tmp;
		
	/*
	 * Requires alias; callback is optional
	 */
	
	try {
		if (typeof(alias) === "undefined") {
			throw new Error("BigBlock.removeStatic(alias): requires an alias.");
		}
		if (typeof(alias) !== "string") {
			throw new Error("utility: removeStatic(): arguement 'alias' must be a string.");
		}
		if (typeof(callback) !== "undefined" && typeof(callback) !== "function") { 
			throw new Error("utility: removeStatic(): arguement 'callback' must be a function.");
		}
	} catch(e) {
			BigBlock.Log.display(e.name + ": " + e.message);
	}	

	for (i = 0; i < BigBlock.GridStatic.quads.length; i++) {
			
		gs = document.getElementById(BigBlock.GridStatic.quads[i].id);
		
		if (gs.hasChildNodes()) {

			nodes = gs.childNodes; // get a collection of all children in BigBlock.GridText.id;

			tmp = [];
			
			// DOM collections are live; iterating over a static array is faster than iterating over a live DOM collection
			 
			for(x = 0; x < nodes.length; x++ ) { // make copy of DOM collection
				tmp[tmp.length] = nodes[x]; 
			}
								
			for (y = 0; j < tmp.length; y++) { // loop thru children
				if (alias === tmp[y].getAttribute("name")) {
					gs.removeChild(tmp[y]);
				}
			}
			
			tmp = null;			
		}
			<commit_msg>corrected var name error in BigBlock.removeStaticBlock()<commit_after>/**
 * UTILTY FUNCTIONS
 * 
 * @author <NAME> 12-05-2009
 * 
 * Big Block Framework
 * Copyright (C) 2011 Foldi, LLC
 * 
 */
						
Math.degreesToRadians = function (degrees) {	
	return (Math.PI / 180.0) * degrees;
};
	
Math.radiansToDegrees = function (radians) {	
	return (180.0 / Math.PI) * radians;
};

Math.getRandomNumber = function (low, high) {
	return Math.floor(Math.random()*(high-(low-1))) + low;
};

Math.getDistanceBwTwoPts = function (x1, y1, x2, y2) {	
	d = Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2));	
	return d;
};

BigBlock.clone = function(object) {
    function F() {}
    F.prototype = object;
    return F;
};
/**
 * Returns the grid index of the x,y coordinate
 * 
 * @param {Number} x
 * @param {Number} y
 */
BigBlock.getPixIndex = function (x,y) {
	
	// uses BigBlock.Grid.width/2; = quad width
	// uses BigBlock.Grid.height/2; = quad height
	// uses BigBlock.Grid.total_quad_cols = total quad grid columns
	
	if (x >= BigBlock.Grid.width/2) {
		x -= BigBlock.Grid.width/2;
	}
	
	if (y >= BigBlock.Grid.height/2) {
		y -= BigBlock.Grid.height/2;
	}	
		
	var target_x = Math.floor(x / BigBlock.Grid.blk_dim);
	var target_y = Math.floor(y / BigBlock.Grid.blk_dim);
	
	return target_x + (BigBlock.Grid.total_quad_cols * target_y);
			
};

/**
 * Returns the global x,y coordinate of a block based on its Block's pix_index 
 * @param {String} type
 * @param {Number} val
 * @param {Number} pix_index_offset
 * 
 */	
BigBlock.getPixLoc = function (type, val, pix_index_offset) {
	
	// uses Math.round(BigBlock.Grid.width/BigBlock.Grid.blk_dim); = total global grid columns
	var loc;
	if (type === 'x') {
		pix_index_offset = pix_index_offset % BigBlock.Grid.total_global_cols;
		loc = val + (pix_index_offset * BigBlock.Grid.blk_dim);
	}
	
	if (type === 'y') {
		var offset_y;
		if (pix_index_offset > 0) {
			offset_y = Math.floor(pix_index_offset / BigBlock.Grid.total_global_cols);
		} else {
			offset_y = Math.ceil(pix_index_offset / BigBlock.Grid.total_global_cols);
		}
		
		loc = val + (offset_y * BigBlock.Grid.blk_dim);
	}	
	return loc;
};		

/**
 * Returns the column index of a Block based on its x, y coordinate. 
 * @param {Number} x
 * @param {Number} y
 * 
 */	
BigBlock.getColIndex = function (x, y) {
	var totalCols = BigBlock.Grid.width/BigBlock.Grid.blk_dim;
	return BigBlock.getFullGridIndex(x, y) % totalCols;
};

/**
 * Returns the index of a Block based on its x, y coordinate relative to the full viewport. 
 * @param {Number} x
 * @param {Number} y
 * 
 */	
BigBlock.getFullGridIndex = function (x, y) {
	if (BigBlock.Grid.blk_dim !== 0) {
				
		var target_x = Math.floor(x / BigBlock.Grid.blk_dim);
		var target_y = Math.floor(y / BigBlock.Grid.blk_dim);
		
		return target_x + (Math.round((BigBlock.Grid.width)/BigBlock.Grid.blk_dim) * target_y);
	} else {
		return 1;
	}				
};
/**
 * Returns the first index of the passed alias in the Blocks array.  
 * 
 * @param {String} alias
 */
BigBlock.getBlock = function (alias) {
	var i;
	for (i = 0; i < BigBlock.Blocks.length; i++) {
		if (BigBlock.Blocks[i].alias === alias) {
			return i;
		}
	}
	return false;
};
/**
 * Returns the first index of the passed word_id in the Blocks array.
 * 
 * @param {String} word_id
 */
BigBlock.getWord = function (word_id) {
	var i;
	for (i = 0; i < BigBlock.Blocks.length; i++) {
		if (BigBlock.Blocks[i].word_id === word_id) {
			return i;
		}
	}
	return false;
};
/**
 * Remove static Blocks from Static Grid.
 * 
 * @param {String} alias
 * @param {Function} callback
 */
BigBlock.removeStaticBlock = function (alias, callback) { 
	
	var i, x, y, gs, nodes, tmp;
		
	/*
	 * Requires alias; callback is optional
	 */
	
	try {
		if (typeof(alias) === "undefined") {
			throw new Error("BigBlock.removeStatic(alias): requires an alias.");
		}
		if (typeof(alias) !== "string") {
			throw new Error("utility: removeStatic(): arguement 'alias' must be a string.");
		}
		if (typeof(callback) !== "undefined" && typeof(callback) !== "function") { 
			throw new Error("utility: removeStatic(): arguement 'callback' must be a function.");
		}
	} catch(e) {
			BigBlock.Log.display(e.name + ": " + e.message);
	}	

	for (i = 0; i < BigBlock.GridStatic.quads.length; i++) {
			
		gs = document.getElementById(BigBlock.GridStatic.quads[i].id);
		
		if (gs.hasChildNodes()) {

			nodes = gs.childNodes; // get a collection of all children in BigBlock.GridText.id;

			tmp = [];
			
			// DOM collections are live; iterating over a static array is faster than iterating over a live DOM collection
			 
			for(x = 0; x < nodes.length; x++ ) { // make copy of DOM collection
				tmp[tmp.length] = nodes[x]; 
			}
								
			for (y = 0; y < tmp.length; y++) { // loop thru children
				if (alias === tmp[y].getAttribute("name")) {
					gs.removeChild(tmp[y]);
				}
			}
			
			tmp = null;			
		}
			
{'fraction_non_alphanumeric': 0.15281610957783912, 'fraction_numerical': 0.00919963201471941, 'mean_word_length': 3.1195789473684212, 'pattern_counts': {'":': 2, '<': 15, '<?xml version=': 0, '>': 11, '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': '4575169', 'n_tokens_mistral': 3888, 'n_tokens_neox': 3484, 'n_words': 911}