<commit_before>/**
 * Component Loader  
 * 
 * - All components on the site are registered using this object
 * - Automatically initializes components that exist on current page
 * 
 * To create a component the markup needs to have a class name  
 * using the format component-{component name}
 * 
 *  Example: <div class="js-component-header" >
 *  
 * To register a component the register function needs to be called
 * with a parameters for {component name} and { initiation funciton }
 *  
 *  Example: componentLoader.register("header", Components.Header);
 *  
 *  
 * @author <NAME>
 * @author <NAME>
 * @author <NAME>
 * @author <NAME>
 * 
 * @version 0.1
 * 
 * @uses js/jquery-1.4.3.js
 * 
 * @method
 * componentLoader.initializeComponents();
 * - To detect and load components on the page
 * 
 * @method
 * componentLoader.register();
 * - To register a component
 * 
 * @method
 * componentLoader.checkForNewComponents
 * - To detect new components injected after page load
 * 
 */

/*global jQuery: true  */	

/**
 * Global instance of the component loader
 **/
componentLoader = (function ($) {
	'use strict';

	// this scope
	var api = {};

	/**
	 * Hash that stores all components on a page
	 **/
	var _componentsHash = {};
	
	
	/**
	 * Hash of all the components and their
	 * api generators. Used when we want
	 * to instantiate components after
	 * the initial page render.
	 */
	var _availableComponents = [];
	
	/**
	 * Hash of registered instances of components
	 * to be called outside of the instance
	 * preferably by flash
	 */
	var _registeredComponents = {};
	
	
	/**
	 * Array of components that have registered
	 * for notifications on the basis that could
	 * not render when initialized
	 */
	var _registeredForNotifications = [];
	
	
	/**
	 * Scans for components on a page and add each
	 * instance to the component hash
	 * 
	 * Components are specified in the markup with a class name  
	 * using the format component-{component name}
	 * 
	 *  Example: <div class="js-component-header" >
	 *  
	 * @author <NAME>
	 * @author <NAME>
	 * @author <NAME>
	 * @author <NAME>
	 * 
	 * @param {Object} The context from which to begin the search (optional)
	 **/
	function scan( context ) {
		
		context = context || document.body;
		
		var COMPONENT_PREFIX = "js-component-";
			
		// loops through all component instances on page
		$("[class*='"+ COMPONENT_PREFIX +"']", context).each(function() {
		
			var sName = "";
			var element = $(this);
			
			// check this hasn't already been added to
			// the array of elements
			if (!element.data("componentized")) {
			
				// find the name of the component instance
				var aClassList = element.attr("class").split(" ");
				$.each(aClassList, function(){
				
					var iIndex = this.indexOf(COMPONENT_PREFIX);
					
					// if component instance exists
					if (iIndex > -1) {
						sName = this.slice(COMPONENT_PREFIX.length);
						
						var elementInstanceArray = [];
						
						// if component already exists inside hash
						// get the its instance array
						if (_componentsHash[sName]) {
							elementInstanceArray = _componentsHash[sName];
						}
						
						elementInstanceArray.push(element);
						_componentsHash[sName] = elementInstanceArray;
						
						return;
					}
					
				});
			}
		}); 
	}
	
	/**
	 * Rescans from the context provided
	 * for any components 
	 * 
	 * @param {Object} The context from which to start scanning
	 */
	api.checkForNewComponents = function (context) 
	{
		context = context || document.body;
		
		// look for new components
		scan(context);
		
		// and init them if you find any
		api.initializeComponents();
	};
	
	
	/**
	 * Initializes any components in the page
	 * that have yet to be initialized
	 */
	api.initializeComponents = function () {
		
		// go through all the available components
		for (var c = 0; c < _availableComponents.length; c++) {
		
			// grab the component
			var component 	= _availableComponents[c],
				sName		= component.name,
				oFunction	= component.func;
		
			// checks if component exist the page
			if (_componentsHash[sName]) {
			
				// get the instance array for the component
				var elementInstanceArray = _componentsHash[sName];
				
				// loop through all instances
				$.each(elementInstanceArray, function(index, element){
				
					var $element = $(element);
				
					// execute instance of component
					if (oFunction !== undefined && !$element.data('componentized')) {
					
						// flag this as componentized so we don't
						// do it a second time
						$element.data('componentized', true);
					
						// create the component
						var componentAPI = new oFunction(element);

						// create a random id for the component
						// we also add some characters in front of the id 
						// because ie needs all ids of elements to start 
						// with a character<commit_msg>fixed indentation<commit_after>/**
 * Component Loader  
 * 
 * - All components on the site are registered using this object
 * - Automatically initializes components that exist on current page
 * 
 * To create a component the markup needs to have a class name  
 * using the format component-{component name}
 * 
 *  Example: <div class="js-component-header" >
 *  
 * To register a component the register function needs to be called
 * with a parameters for {component name} and { initiation funciton }
 *  
 *  Example: componentLoader.register("header", Components.Header);
 *  
 *  
 * @author <NAME>
 * @author <NAME>
 * @author <NAME>
 * @author <NAME>
 * 
 * @version 0.1
 * 
 * @uses js/jquery-1.4.3.js
 * 
 * @method
 * componentLoader.initializeComponents();
 * - To detect and load components on the page
 * 
 * @method
 * componentLoader.register();
 * - To register a component
 * 
 * @method
 * componentLoader.checkForNewComponents
 * - To detect new components injected after page load
 * 
 */

/*global jQuery: true  */	

/**
 * Global instance of the component loader
 **/
componentLoader = (function ($) {
	'use strict';
	// this scope
	var api = {};

	/**
	 * Hash that stores all components on a page
	 **/
	var _componentsHash = {};
	
	
	/**
	 * Hash of all the components and their
	 * api generators. Used when we want
	 * to instantiate components after
	 * the initial page render.
	 */
	var _availableComponents = [];
	
	/**
	 * Hash of registered instances of components
	 * to be called outside of the instance
	 * preferably by flash
	 */
	var _registeredComponents = {};
	
	
	/**
	 * Array of components that have registered
	 * for notifications on the basis that could
	 * not render when initialized
	 */
	var _registeredForNotifications = [];
	
	
	/**
	 * Scans for components on a page and add each
	 * instance to the component hash
	 * 
	 * Components are specified in the markup with a class name  
	 * using the format component-{component name}
	 * 
	 *  Example: <div class="js-component-header" >
	 *  
	 * @author <NAME>
	 * @author <NAME>
	 * @author <NAME>
	 * @author <NAME>
	 * 
	 * @param {Object} The context from which to begin the search (optional)
	 **/
	function scan( context ) {
		
		context = context || document.body;
		
		var COMPONENT_PREFIX = "js-component-";
			
		// loops through all component instances on page
		$("[class*='"+ COMPONENT_PREFIX +"']", context).each(function() {
		
			var sName = "";
			var element = $(this);
			
			// check this hasn't already been added to
			// the array of elements
			if (!element.data("componentized")) {
			
				// find the name of the component instance
				var aClassList = element.attr("class").split(" ");
				$.each(aClassList, function(){
				
					var iIndex = this.indexOf(COMPONENT_PREFIX);
					
					// if component instance exists
					if (iIndex > -1) {
						sName = this.slice(COMPONENT_PREFIX.length);
						
						var elementInstanceArray = [];
						
						// if component already exists inside hash
						// get the its instance array
						if (_componentsHash[sName]) {
							elementInstanceArray = _componentsHash[sName];
						}
						
						elementInstanceArray.push(element);
						_componentsHash[sName] = elementInstanceArray;
						
						return;
					}
					
				});
			}
		}); 
	}
	
	/**
	 * Rescans from the context provided
	 * for any components 
	 * 
	 * @param {Object} The context from which to start scanning
	 */
	api.checkForNewComponents = function (context) 
	{
		context = context || document.body;
		
		// look for new components
		scan(context);
		
		// and init them if you find any
		api.initializeComponents();
	};
	
	
	/**
	 * Initializes any components in the page
	 * that have yet to be initialized
	 */
	api.initializeComponents = function () {
		
		// go through all the available components
		for (var c = 0; c < _availableComponents.length; c++) {
		
			// grab the component
			var component = _availableComponents[c],
			    sName     = component.name,
			    oFunction = component.func;
		
			// checks if component exist the page
			if (_componentsHash[sName]) {
			
				// get the instance array for the component
				var elementInstanceArray = _componentsHash[sName];
				
				// loop through all instances
				$.each(elementInstanceArray, function(index, element) {
				
					var $element = $(element);
				
					// execute instance of component
					if (oFunction !== undefined && !$element.data('componentized')) {
					
						// flag this as componentized so we don't
						// do it a second time
						$element.data('componentized', true);
					
						// create the component
						var componentAPI = new oFunction(element);

						// create a random id for the component
						// we also add some characters in front of the id 
						// because ie needs all ids of elements to start 
						// with a character
{'fraction_non_alphanumeric': 0.10452961672473868, 'fraction_numerical': 0.0014347202295552368, 'mean_word_length': 2.6495886312640238, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '724046', 'n_tokens_mistral': 3327, 'n_tokens_neox': 2591, 'n_words': 962}