<commit_before>////////////////////////////////////////////////////////////////////////////////
// Control Base
//
// 'Abstract' base class for UI controls.
////////////////////////////////////////////////////////////////////////////////
var controls = function (controls, $) {
	var LAST_ID = 0;
	
	controls.id = function () {
		return LAST_ID++;
	};
	
	controls.base = function () {
		var self =  {
			// properties
			id: controls.id(),	// id is automatically assigned
			parent: null,				// parent control
			children: [],				// child controls
	
			// adds a child to the control
			append: function (child) {
				this.children.push(child);
				child.parent = this;
			},
			
			// removes child controls
			clear: function () {
				this.children.length = 0;
			},
			
			// initializes the control
			// e.g. adding data, events, etc.
			init: null,
			
			// produces the control's html
			html: function () {
				throw "Abstract";
			},
			
			// renders the control
			// -parent: parent jQuery object
			render: function (parent) {
				// initializing jQuery object from full control markup
				var elem = $(this.html()),
						target = $('#' + this.id);

				// adding control to dom
				if (target.length) {
					target.replaceWith(elem);
				} else if (parent) {
					parent.append(elem);
				}

				// walking control tree initializing nodes
				(function inner(control) {
					var selector = '#' + control.id,
							i,
					// initializing current control
					result = control.init ? control.init(elem.is(selector) ? elem : elem.find(selector)) : true;
					// initializing children
					if (control.children.length) {
						for (i = 0; i < control.children.length; i++) {
							// when a control.init() returns false, it breaks the init cycle
							if (inner(control.children[i]) === false) {
								break;
							}
						}
					}
					return result;
				}(this));
				
				return parent || elem;
			}			
		};

		return self;
	};

	return controls;<commit_msg>added control lookup<commit_after>////////////////////////////////////////////////////////////////////////////////
// Control Base
//
// 'Abstract' base class for UI controls.
////////////////////////////////////////////////////////////////////////////////
var controls = function (controls, $) {
	var LAST_ID = 0;
	
	// generates a new, unique control id
	controls.id = function () {
		return LAST_ID++;
	};
	
	// control lookup (id -> control)
	controls.lookup = {};
	
	// base control class
	controls.base = function () {
		var id = controls.id(),
		
		self =  {
			// properties
			id: id,							// id is automatically assigned
			parent: null,				// parent control
			children: [],				// child controls
			data: [],						// data associated with control
	
			// adds a child to the control
			append: function (child) {
				this.children.push(child);
				child.parent = this;
			},
			
			// removes child controls
			clear: function () {
				this.children.length = 0;
			},
			
			// initializes the control
			// e.g. adding data, events, etc.
			init: null,
			
			// produces the control's html
			html: function () {
				throw "Abstract";
			},
			
			// renders the control
			// -parent: parent jQuery object
			render: function (parent) {
				// initializing jQuery object from full control markup
				var elem = $(this.html()),
						target = $('#' + this.id);

				// adding control to dom
				if (target.length) {
					target.replaceWith(elem);
				} else if (parent) {
					parent.append(elem);
				}

				// walking control tree initializing nodes
				(function inner(control) {
					var selector = '#' + control.id,
							i,
					// initializing current control
					result = control.init ? control.init(elem.is(selector) ? elem : elem.find(selector)) : true;
					// initializing children
					if (control.children.length) {
						for (i = 0; i < control.children.length; i++) {
							// when a control.init() returns false, it breaks the init cycle
							// for its siblings -> useful in conj. with jQuery.live()
							if (inner(control.children[i]) === false) {
								break;
							}
						}
					}
					return result;
				}(this));
				
				return parent || elem;
			}			
		};
		
		// adding control to lookup
		controls.lookup[id] = self;

		return self;
	};

	return controls;
{'fraction_non_alphanumeric': 0.1971995332555426, 'fraction_numerical': 0.0014002333722287048, 'mean_word_length': 1.7126582278481013, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '92123', 'n_tokens_mistral': 1601, 'n_tokens_neox': 1159, 'n_words': 360}