<commit_before>/*
	Name: autoComplete
	Authors:
		<NAME>: @commadelimited
		<NAME>: @cfjedimaster

	Website: http://andyMatthews.net
	Version: 1.5.1
*/
(function($) {

	"use strict";

	var defaults = {
		method: 'GET',
		icon: 'arrow-r',
		cancelRequests: false,
		target: $(),
		source: null,
		callback: null,
		link: null,
		minLength: 0,
		transition: 'fade',
		matchFromStart: true,
		labelHTML: function(value) { return value; },
		onNoResults: function() { return; },
		onLoading: function() { return; },
		onLoadingFinished: function() { return; },
		termParam : 'term',
		loadingHtml : '<li data-icon="none"><a href="#">Searching...</a></li>',
		interval : 0,
		builder : null
	},
	openXHR = {},
	buildItems = function($this, data, settings) {
		var str;
		if (settings.builder) {
			str = settings.builder.apply($this.eq(0), [data, settings]);
		} else {
			str = [];
			if (data) {
				$.each(data, function(index, value) {
					// are we working with objects or strings?
					if ($.isPlainObject(value)) {
						str.push('<li data-icon=' + settings.icon + '><a href="' + settings.link + encodeURIComponent(value.value) + '" data-transition="' + settings.transition + '" data-autocomplete=\'' + JSON.stringify(value) + '\'>' + settings.labelHTML(value.label) + '</a></li>');
					} else {
						str.push('<li data-icon=' + settings.icon + '><a href="' + settings.link + encodeURIComponent(value) + '" data-transition="' + settings.transition + '">' + settings.labelHTML(value) + '</a></li>');
					}
				});
			}
		}
		if ($.isArray(str)) {
			str = str.join('');
		}
		$(settings.target).html(str).listview("refresh");<commit_msg>When an option was for an object, and that object had a property with a ' in it, the html that is written out is invalid. In the callback function when $(e.currentTarget).data("autocomplete") is used, some of the properties would end up undefined. Encode ' as &#39; when writing out the json value of an object.<commit_after>/*
	Name: autoComplete
	Authors:
		<NAME>: @commadelimited
		<NAME>: @cfjedimaster

	Website: http://andyMatthews.net
	Version: 1.5.1
*/
(function($) {

	"use strict";

	var defaults = {
		method: 'GET',
		icon: 'arrow-r',
		cancelRequests: false,
		target: $(),
		source: null,
		callback: null,
		link: null,
		minLength: 0,
		transition: 'fade',
		matchFromStart: true,
		labelHTML: function(value) { return value; },
		onNoResults: function() { return; },
		onLoading: function() { return; },
		onLoadingFinished: function() { return; },
		termParam : 'term',
		loadingHtml : '<li data-icon="none"><a href="#">Searching...</a></li>',
		interval : 0,
		builder : null
	},
	openXHR = {},
	buildItems = function($this, data, settings) {
		var str;
		if (settings.builder) {
			str = settings.builder.apply($this.eq(0), [data, settings]);
		} else {
			str = [];
			if (data) {
				$.each(data, function(index, value) {
					// are we working with objects or strings?
					if ($.isPlainObject(value)) {
						str.push('<li data-icon=' + settings.icon + '><a href="' + settings.link + encodeURIComponent(value.value) + '" data-transition="' + settings.transition + '" data-autocomplete=\'' + JSON.stringify(value).replace(/'/g, "&#39;") + '\'>' + settings.labelHTML(value.label) + '</a></li>');
					} else {
						str.push('<li data-icon=' + settings.icon + '><a href="' + settings.link + encodeURIComponent(value) + '" data-transition="' + settings.transition + '">' + settings.labelHTML(value) + '</a></li>');
					}
				});
			}
		}
		if ($.isArray(str)) {
			str = str.join('');
		}
		$(settings.target).html(str).listview("refresh");
{'fraction_non_alphanumeric': 0.19472954230235784, 'fraction_numerical': 0.004438280166435506, 'mean_word_length': 3.6589147286821704, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, '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': '5077376', 'n_tokens_mistral': 1359, 'n_tokens_neox': 1200, 'n_words': 288}