<commit_before>
var randomGif = {

	storageID: 'randomGifCategory',
	gifCategory: 'adventure+time',

	init: function() {

		var gifCat = this.getStorage();
		if (gifCat !== null) {
			this.setNewGif(gifCat);
		}
		this.loadGif();
		this.actions();
	},

	loadGif: function() {
		$('#js-randomGif img').addClass('hidden');
		$('#js-randomGif').addClass('is-spinning');
		$.get('http://api.giphy.com/v1/gifs/random?api_key=dc6zaTOxFJmzC&tag='+ this.gifCategory)
			.done(function(data) {
				if (data.data.id) {
					$('#js-randomGif img').attr('src', data.data.image_url).on('load', function() {
						if($('#js-randomGif').length) {
							$('#error-log').remove();
						}
						$(this).parent().removeClass('is-spinning');
						$(this).removeClass('hidden');
					});
				} else {
					$('#js-randomGif').removeClass('is-spinning');
					$('#js-randomGif').append('<p id="error-log">No gif found, please try something else</p>');
				}
			})
			.fail(function(error) {
				console.log(error);
			});
	},

	getStorage: function() {
		if (window.localStorage.getItem(this.storageID)) {
			return window.localStorage.getItem(this.storageID);
		} else {
			return null;
		}
	},

	saveChoice: function() {
		var value = $('#gifModal input[type=radio]:checked').val();
		if (value === 'custom') {
			if ($('#customGifString').val() !== '') {
				value = $('#customGifString').val();
				value = value.replace(/\s/g, '+');
			} else {
				value = this.gifCategory;
			}
		}
		this.setNewGif(value);
		this.loadGif();
		$('#gifCloseModal').click();
	},

	setNewGif: function(value) {
		window.localStorage.setItem(this.storageID, value);
		this.gifCategory = value;
	},

	actions: function() {
		$('#gifOpt5').on('focus', function() {<commit_msg>improve randomgif before extracting it, closes #264<commit_after>
var randomGif = {

	storageID: 'randomGifCategory',
	gifCategory: 'adventure+time',

	init: function() {

		var gifCat = this.getStorage();
		if (gifCat !== null) {
			this.setNewGif(gifCat);
		}
		this.loadGif();
		this.actions();
	},

	loadGif: function() {
		var cleanCategory = this.gifCategory.replace(/\s/g, '-');
		cleanCategory = encodeURI(cleanCategory);
		$('#js-randomGif img').addClass('hidden');
		$('#js-randomGif').addClass('is-spinning');
		$.get('http://api.giphy.com/v1/gifs/random?api_key=dc6zaTOxFJmzC&tag='+ cleanCategory)
			.done(function(data) {
				if (data.data.id) {
					$('#js-randomGif img').attr('src', data.data.image_url).on('load', function() {
						if($('#js-randomGif').length) {
							$('#error-log').remove();
						}
						$(this).parent().removeClass('is-spinning');
						$(this).removeClass('hidden');
					});
				} else {
					$('#js-randomGif').removeClass('is-spinning');
					$('#js-randomGif').append('<p id="error-log">No gif found, please try something else</p>');
				}
			})
			.fail(function(error) {
				console.log(error);
			});
	},

	getStorage: function() {
		if (window.localStorage.getItem(this.storageID)) {
			return window.localStorage.getItem(this.storageID);
		} else {
			return null;
		}
	},

	saveChoice: function() {
		var value = $('#gifModal input[type=radio]:checked').val();
		if (value === 'custom') {
			if ($('#customGifString').val() !== '') {
				value = $('#customGifString').val();
			} else {
				value = this.gifCategory;
			}
		}
		this.setNewGif(value);
		this.loadGif();
		$('#gifCloseModal').click();
	},

	setNewGif: function(value) {
		window.localStorage.setItem(this.storageID, value);
		this.gifCategory = value;
	},

	actions: function() {
		$('#gifOpt5').on('focus', function() {
{'fraction_non_alphanumeric': 0.21620111731843575, 'fraction_numerical': 0.0025139664804469273, 'mean_word_length': 3.749336870026525, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3727864', 'n_tokens_mistral': 1480, 'n_tokens_neox': 1277, 'n_words': 185}