<commit_before>function ComponentCombobox( id ) {
	var self = ComponentTextfield(id);
	
	self.wrapperNode = document.getElementById( id + '_wrapper' );
	self.iconNode = document.getElementById( id + '_icon' );
	self.listNode = document.getElementById( id + '_list' );
	self.showingList = false;
	self.selectedItem = -1;
	
	self.show = function() {
		Element.show(self.wrapperNode);
	};
	self.hide = function() {
		Element.hide(self.wrapperNode);
		Element.hide(self.listNode);
	};
	
	self.enable = function() {
		self._enabled = true;
		self.node().readOnly = false;
		self.node().className = 'wfComboboxTextfield';
		self.iconNode.className = 'wfComboboxIcon';
	};
	self.disable = function() {
		self._enabled = false;
		self.node().readOnly = true;
		self.node().className = 'wfComboboxTextfieldDisabled';
		self.iconNode.className = 'wfComboboxIconDisabled';
	};
	self.enabled = function() {
		return self._enabled;
	};
	
	self.showList = function( searchTerm ) {
		var iconWidth = 0;
		if( self.iconNode ) {
			iconWidth = self.iconNode.offsetWidth;
		}
		self.selectedItem = -1;
		if( searchTerm ) {
			var size = self.listNode.childNodes[0].childNodes.length;
			for( var i = 0; i < size; i++ ) {
				var text = self.listNode.childNodes[0].childNodes[i]._itemLabel;
				var index = text.toLowerCase().search(searchTerm);
				var display = 'none';
				var className = '';
				if( index > -1 ) {
					var start = text.substring(0, index);
					var middle = text.substring(index, index + searchTerm.length);
					var end = text.substring(index + searchTerm.length, text.length);
					//alert('Search term: ' + searchTerm + ', Search term length: ' + searchTerm.length + ', Index: ' + index + ', Start: ' + start + ', Middle: ' + middle + ', End: ' + end);
					text = start + '<b>' + middle + '</b>' + end;
					display = '';
					if( self.selectedItem == -1 ) {
						className = 'selected';
						self.selectedItem = i;
					}
				}
				self.listNode.childNodes[0].childNodes[i].style.display = display;
				self.listNode.childNodes[0].childNodes[i].className = className;
				self.listNode.childNodes[0].childNodes[i].innerHTML = text;
			}
		} else {
			var size = self.listNode.childNodes[0].childNodes.length;
			for( var i = 0; i < size; i++ ) {
				self.listNode.childNodes[0].childNodes[i].style.display = '';
				self.listNode.childNodes[0].childNodes[i].className = '';
				self.listNode.childNodes[0].childNodes[i].innerHTML = self.listNode.childNodes[0].childNodes[i]._itemLabel;
			}
		}
		Position.clone( self.node(), self.listNode, { setWidth: false, setHeight: false, offsetTop: 0 + self.node().clientHeight + 1 } );
		self.listNode.style.minWidth = self.node().offsetWidth + iconWidth - 1 + 'px';
		self.listNode.style.display = 'block';
		self.showingList = true;
	};
	
	self.hideList = function() {
		self.listNode.style.display = 'none';
		self.showingList = false;
	};
	
	self.clearTextfield = function() {
		self.node().value = '';
	};
	
	var previousActivate = self.activate;
	self.activate = function activate() {
		self.node().style.cursor = 'text';
		if( self.getState('list-enabled') ) {
			if( self.iconNode ) {
				self.iconNode.onclick = function( event ) {
					if( self._enabled ) {
						if( self.showingList ) {
							self.hideList();
						} else {
							self.showList();
						}
					}
				};
			} else {
				/* Tobias 2012-01-30: Trying to disable code to fix an issue.
				self.node().onclick = function( event ) {
					if( self._enabled ) {
						if( self.showingList ) {
							self.hideList();
						} else {
							self.showList();
						}
					}
				}; */
			}
		}
		if( self.getState('textfield-enabled') == false ) {
			self.node().onfocus = function( event ) {
				Hotkeys.add('Backspace', function() {
					self.clearTextfield();
				});
				Hotkeys.add('Delete', function() {
					self.clearTextfield();
				});
			};
			var previousOnBlur = self.node().onblur;
			self.node().onblur = function( event ) {
				Hotkeys.remove('Backspace');
				Hotkeys.remove('Delete');
				if( previousOnBlur ) {
					previousOnBlur();
				}
			};
		} else if( self.getState('autocomplete') == true ) {
			var getCaretPosition = function( o ) {
				if( o.createTextRange ) {
					var r = document.selection.createRange().duplicate();
					r.moveEnd('character', o.value.length);
					if( r.text == '' )
						return o.value.length
					return o.value.lastIndexOf(r.text)
				}
				return o.selectionStart;
			};
			self.node().onfocus = function( event ) {
				self.node().onkeypress = function( keyEvent ) {
					keyEvent = keyEvent || window.event;
					if( keyEvent.keyCode != 9 /* tab */ &&
						keyEvent.keyCode != 38 /* up */ &&
						keyEvent.keyCode != 40 /* down */ &&
						keyEvent.keyCode != 13 /* return/enter */ )
					{
						if( keyEvent.keyCode != 27 /* esc */ ) {
							setTimeout(function() {
								var value = self.node().value;
								if( getCaretPosition(self.node()) == value.length /* at the end of the text */ ) {
									var items = value.split(',');
									var lastItem = items.length - 1;
									var searchTerm = items[lastItem].strip();
									if( searchTerm ) {
										self.showList(searchTerm);
									} else {
										self.hideList();
									}
								} else {
									self.hideList();
								}
							}, 100);
						} else {
							self.hideList();
						}
					}
					return true;
				};
				Hotkeys.add('up', function( hotkeyEvent ) {
					if( self.showingList ) {
						if( self.selectedItem > 0 ) {
							var previousItem = self.selectedItem - 1;<commit_msg>Fix issue with Combobox component not autocompleting if using capital letters.<commit_after>function ComponentCombobox( id ) {
	var self = ComponentTextfield(id);
	
	self.wrapperNode = document.getElementById( id + '_wrapper' );
	self.iconNode = document.getElementById( id + '_icon' );
	self.listNode = document.getElementById( id + '_list' );
	self.showingList = false;
	self.selectedItem = -1;
	
	self.show = function() {
		Element.show(self.wrapperNode);
	};
	self.hide = function() {
		Element.hide(self.wrapperNode);
		Element.hide(self.listNode);
	};
	
	self.enable = function() {
		self._enabled = true;
		self.node().readOnly = false;
		self.node().className = 'wfComboboxTextfield';
		self.iconNode.className = 'wfComboboxIcon';
	};
	self.disable = function() {
		self._enabled = false;
		self.node().readOnly = true;
		self.node().className = 'wfComboboxTextfieldDisabled';
		self.iconNode.className = 'wfComboboxIconDisabled';
	};
	self.enabled = function() {
		return self._enabled;
	};
	
	self.showList = function( searchTerm ) {
		var iconWidth = 0;
		if( self.iconNode ) {
			iconWidth = self.iconNode.offsetWidth;
		}
		self.selectedItem = -1;
		if( searchTerm ) {
			var size = self.listNode.childNodes[0].childNodes.length;
			for( var i = 0; i < size; i++ ) {
				var text = self.listNode.childNodes[0].childNodes[i]._itemLabel;
				var index = text.toLowerCase().search(searchTerm);
				var display = 'none';
				var className = '';
				if( index > -1 ) {
					var start = text.substring(0, index);
					var middle = text.substring(index, index + searchTerm.length);
					var end = text.substring(index + searchTerm.length, text.length);
					//alert('Search term: ' + searchTerm + ', Search term length: ' + searchTerm.length + ', Index: ' + index + ', Start: ' + start + ', Middle: ' + middle + ', End: ' + end);
					text = start + '<b>' + middle + '</b>' + end;
					display = '';
					if( self.selectedItem == -1 ) {
						className = 'selected';
						self.selectedItem = i;
					}
				}
				self.listNode.childNodes[0].childNodes[i].style.display = display;
				self.listNode.childNodes[0].childNodes[i].className = className;
				self.listNode.childNodes[0].childNodes[i].innerHTML = text;
			}
		} else {
			var size = self.listNode.childNodes[0].childNodes.length;
			for( var i = 0; i < size; i++ ) {
				self.listNode.childNodes[0].childNodes[i].style.display = '';
				self.listNode.childNodes[0].childNodes[i].className = '';
				self.listNode.childNodes[0].childNodes[i].innerHTML = self.listNode.childNodes[0].childNodes[i]._itemLabel;
			}
		}
		Position.clone( self.node(), self.listNode, { setWidth: false, setHeight: false, offsetTop: 0 + self.node().clientHeight + 1 } );
		self.listNode.style.minWidth = self.node().offsetWidth + iconWidth - 1 + 'px';
		self.listNode.style.display = 'block';
		self.showingList = true;
	};
	
	self.hideList = function() {
		self.listNode.style.display = 'none';
		self.showingList = false;
	};
	
	self.clearTextfield = function() {
		self.node().value = '';
	};
	
	var previousActivate = self.activate;
	self.activate = function activate() {
		self.node().style.cursor = 'text';
		if( self.getState('list-enabled') ) {
			if( self.iconNode ) {
				self.iconNode.onclick = function( event ) {
					if( self._enabled ) {
						if( self.showingList ) {
							self.hideList();
						} else {
							self.showList();
						}
					}
				};
			} else {
				/* Tobias 2012-01-30: Trying to disable code to fix an issue.
				self.node().onclick = function( event ) {
					if( self._enabled ) {
						if( self.showingList ) {
							self.hideList();
						} else {
							self.showList();
						}
					}
				}; */
			}
		}
		if( self.getState('textfield-enabled') == false ) {
			self.node().onfocus = function( event ) {
				Hotkeys.add('Backspace', function() {
					self.clearTextfield();
				});
				Hotkeys.add('Delete', function() {
					self.clearTextfield();
				});
			};
			var previousOnBlur = self.node().onblur;
			self.node().onblur = function( event ) {
				Hotkeys.remove('Backspace');
				Hotkeys.remove('Delete');
				if( previousOnBlur ) {
					previousOnBlur();
				}
			};
		} else if( self.getState('autocomplete') == true ) {
			var getCaretPosition = function( o ) {
				if( o.createTextRange ) {
					var r = document.selection.createRange().duplicate();
					r.moveEnd('character', o.value.length);
					if( r.text == '' )
						return o.value.length
					return o.value.lastIndexOf(r.text)
				}
				return o.selectionStart;
			};
			self.node().onfocus = function( event ) {
				self.node().onkeypress = function( keyEvent ) {
					keyEvent = keyEvent || window.event;
					if( keyEvent.keyCode != 9 /* tab */ &&
						keyEvent.keyCode != 38 /* up */ &&
						keyEvent.keyCode != 40 /* down */ &&
						keyEvent.keyCode != 13 /* return/enter */ )
					{
						if( keyEvent.keyCode != 27 /* esc */ ) {
							setTimeout(function() {
								var value = self.node().value;
								if( getCaretPosition(self.node()) == value.length /* at the end of the text */ ) {
									var items = value.split(',');
									var lastItem = items.length - 1;
									var searchTerm = items[lastItem].strip();
									if( searchTerm ) {
										self.showList(searchTerm.toLowerCase());
									} else {
										self.hideList();
									}
								} else {
									self.hideList();
								}
							}, 100);
						} else {
							self.hideList();
						}
					}
					return true;
				};
				Hotkeys.add('up', function( hotkeyEvent ) {
					if( self.showingList ) {
						if( self.selectedItem > 0 ) {
							var previousItem = self.selectedItem - 1;
{'fraction_non_alphanumeric': 0.1612009650612099, 'fraction_numerical': 0.007863461710302923, 'mean_word_length': 2.692510722533817, 'pattern_counts': {'":': 0, '<': 11, '<?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': '1878940', 'n_tokens_mistral': 4692, 'n_tokens_neox': 3607, 'n_words': 701}